浏览代码

KVM: emulator: drop RPL check from linearize() function

According to Intel SDM Vol3 Section 5.5 "Privilege Levels" and 5.6
"Privilege Level Checking When Accessing Data Segments" RPL checking is
done during loading of a segment selector, not during data access. We
already do checking during segment selector loading, so drop the check
during data access. Checking RPL during data access triggers #GP if
after transition from real mode to protected mode RPL bits in a segment
selector are set.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Gleb Natapov 12 年之前
父节点
当前提交
3a78a4f463
共有 1 个文件被更改,包括 1 次插入6 次删除
  1. 1 6
      arch/x86/kvm/emulate.c

+ 1 - 6
arch/x86/kvm/emulate.c

@@ -665,7 +665,7 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,
 	ulong la;
 	ulong la;
 	u32 lim;
 	u32 lim;
 	u16 sel;
 	u16 sel;
-	unsigned cpl, rpl;
+	unsigned cpl;
 
 
 	la = seg_base(ctxt, addr.seg) + addr.ea;
 	la = seg_base(ctxt, addr.seg) + addr.ea;
 	switch (ctxt->mode) {
 	switch (ctxt->mode) {
@@ -699,11 +699,6 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,
 				goto bad;
 				goto bad;
 		}
 		}
 		cpl = ctxt->ops->cpl(ctxt);
 		cpl = ctxt->ops->cpl(ctxt);
-		if (ctxt->mode == X86EMUL_MODE_REAL)
-			rpl = 0;
-		else
-			rpl = sel & 3;
-		cpl = max(cpl, rpl);
 		if (!(desc.type & 8)) {
 		if (!(desc.type & 8)) {
 			/* data segment */
 			/* data segment */
 			if (cpl > desc.dpl)
 			if (cpl > desc.dpl)