summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-02-09 10:02:05 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2015-02-09 13:36:01 +0100
commitd44e1212230a68f9dccd1a95b5c8ca5217c62094 (patch)
tree8f3e4007c2bd4126422b4efe7e85b6f0d5333b26 /arch/x86/kvm/emulate.c
parentMerge tag 'kvm-s390-next-20150209' of git://git.kernel.org/pub/scm/linux/kern... (diff)
downloadlinux-d44e1212230a68f9dccd1a95b5c8ca5217c62094.tar.xz
linux-d44e1212230a68f9dccd1a95b5c8ca5217c62094.zip
KVM: x86: emulate: correct page fault error code for NoWrite instructions
NoWrite instructions (e.g. cmp or test) never set the "write access" bit in the error code, even if one of the operands is treated as a destination. Fixes: c205fb7d7d4f81e46fc577b707ceb9e356af1456 Cc: Nadav Amit <namit@cs.technion.ac.il> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r--arch/x86/kvm/emulate.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 81dcf7964701..a943bf0c06d0 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -4954,7 +4954,8 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
rc = segmented_read(ctxt, ctxt->dst.addr.mem,
&ctxt->dst.val, ctxt->dst.bytes);
if (rc != X86EMUL_CONTINUE) {
- if (rc == X86EMUL_PROPAGATE_FAULT &&
+ if (!(ctxt->d & NoWrite) &&
+ rc == X86EMUL_PROPAGATE_FAULT &&
ctxt->exception.vector == PF_VECTOR)
ctxt->exception.error_code |= PFERR_WRITE_MASK;
goto done;