浏览代码

KVM: x86: Emulator performs code segment checks on read access

When read access is performed using a readable code segment, the "conforming"
and "non-conforming" checks should not be done.  As a result, read using
non-conforming readable code segment fails.

This is according to Intel SDM 5.6.1 ("Accessing Data in Code Segments").

The fix is not to perform the "non-conforming" checks if the access is not a
fetch; the relevant checks are already done when loading the segment.

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Nadav Amit 11 年之前
父节点
当前提交
c49c759f7a
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      arch/x86/kvm/emulate.c

+ 2 - 2
arch/x86/kvm/emulate.c

@@ -703,8 +703,8 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
 		if (size > *max_size)
 		if (size > *max_size)
 			goto bad;
 			goto bad;
 		cpl = ctxt->ops->cpl(ctxt);
 		cpl = ctxt->ops->cpl(ctxt);
-		if (!(desc.type & 8)) {
-			/* data segment */
+		if (!fetch) {
+			/* data segment or readable code segment */
 			if (cpl > desc.dpl)
 			if (cpl > desc.dpl)
 				goto bad;
 				goto bad;
 		} else if ((desc.type & 8) && !(desc.type & 4)) {
 		} else if ((desc.type & 8) && !(desc.type & 4)) {