Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+2 -1
+2 -1
arch/x86/kvm/emulate.c
··· 4954 4954 rc = segmented_read(ctxt, ctxt->dst.addr.mem, 4955 4955 &ctxt->dst.val, ctxt->dst.bytes); 4956 4956 if (rc != X86EMUL_CONTINUE) { 4957 - if (rc == X86EMUL_PROPAGATE_FAULT && 4957 + if (!(ctxt->d & NoWrite) && 4958 + rc == X86EMUL_PROPAGATE_FAULT && 4958 4959 ctxt->exception.vector == PF_VECTOR) 4959 4960 ctxt->exception.error_code |= PFERR_WRITE_MASK; 4960 4961 goto done;