KVM: x86: #PF error-code on R/W operations is wrong
[firefly-linux-kernel-4.4.55.git] / arch / x86 / kvm / emulate.c
index d949287ed01033dc5e1ff09fbc91c07cead58a2a..ef23c1e5fa9fb42442e6e2a53c7567594789fbb8 100644 (file)
@@ -4909,8 +4909,12 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
                /* optimisation - avoid slow emulated read if Mov */
                rc = segmented_read(ctxt, ctxt->dst.addr.mem,
                                   &ctxt->dst.val, ctxt->dst.bytes);
-               if (rc != X86EMUL_CONTINUE)
+               if (rc != X86EMUL_CONTINUE) {
+                       if (rc == X86EMUL_PROPAGATE_FAULT &&
+                           ctxt->exception.vector == PF_VECTOR)
+                               ctxt->exception.error_code |= PFERR_WRITE_MASK;
                        goto done;
+               }
        }
        ctxt->dst.orig_val = ctxt->dst.val;