- patches.arch/kvm-emulator-drop-rpl-check-from-linearize-function.patch:
[opensuse:kernel-source.git] / patches.arch / kvm-emulator-drop-rpl-check-from-linearize-function.patch
1 From: Gleb Natapov <gleb@redhat.com>
2 Date: Thu, 20 Dec 2012 16:57:42 +0200
3 Subject: [PATCH] KVM: emulator: drop RPL check from linearize() function
4 Git-commit: 3a78a4f46302bfc83602a53dfa4dcbe76a7a1f5f
5 Patch-mainline: v3.9-rc1
6 References: bnc#754583
7
8 According to Intel SDM Vol3 Section 5.5 "Privilege Levels" and 5.6
9 "Privilege Level Checking When Accessing Data Segments" RPL checking is
10 done during loading of a segment selector, not during data access. We
11 already do checking during segment selector loading, so drop the check
12 during data access. Checking RPL during data access triggers #GP if
13 after transition from real mode to protected mode RPL bits in a segment
14 selector are set.
15
16 Signed-off-by: Gleb Natapov <gleb@redhat.com>
17 Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
18 Acked-by: Bruce Rogers <brogers@suse.com>
19 ---
20  arch/x86/kvm/emulate.c |    4 +---
21  1 file changed, 1 insertion(+), 3 deletions(-)
22
23 Index: b/arch/x86/kvm/emulate.c
24 ===================================================================
25 --- a/arch/x86/kvm/emulate.c
26 +++ b/arch/x86/kvm/emulate.c
27 @@ -585,7 +585,7 @@ static int __linearize(struct x86_emulat
28         ulong la;
29         u32 lim;
30         u16 sel;
31 -       unsigned cpl, rpl;
32 +       unsigned cpl;
33  
34         la = seg_base(ctxt, ctxt->ops, addr.seg) + addr.ea;
35         switch (ctxt->mode) {
36 @@ -620,8 +620,6 @@ static int __linearize(struct x86_emulat
37                                 goto bad;
38                 }
39                 cpl = ctxt->ops->cpl(ctxt);
40 -               rpl = sel & 3;
41 -               cpl = max(cpl, rpl);
42                 if (!(desc.type & 8)) {
43                         /* data segment */
44                         if (cpl > desc.dpl)