[<prev] [next>] [day] [month] [year] [list]
Message-Id: <48B3D680-626C-4CF8-B4F3-214D0282B0A5@gmail.com>
Date: Sun, 22 Jan 2012 13:01:14 +0200
From: Nadav Amit <nadav.amit@...il.com>
To: Avi Kivity <avi@...hat.com>
Cc: Nadav Amit <namit@...technion.ac.il>,
Marcelo Tosatti <mtosatti@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
Gleb Natapov <gleb@...hat.com>
Subject: [PATCH v2 1/2] KVM: Exception during emulation decode should propagate
An exception might occur during decode (e.g., #PF during fetch).
Currently, the exception is ignored and emulation is performed.
Instead, emulation should be skipped and the fault should be injected.
Skipping instruction should report a failure in this case.
Signed-off-by: Nadav Amit <nadav.amit@...il.com>
---
arch/x86/kvm/emulate.c | 5 +++++
arch/x86/kvm/x86.c | 8 ++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 05a562b..9a07dcd 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3869,6 +3869,11 @@ done:
if (ctxt->memopp && ctxt->memopp->type == OP_MEM && ctxt->rip_relative)
ctxt->memopp->addr.mem.ea += ctxt->_eip;
+ if (rc == X86EMUL_PROPAGATE_FAULT) {
+ ctxt->have_exception = true;
+ return EMULATION_OK;
+ }
+
return (rc != X86EMUL_CONTINUE) ? EMULATION_FAILED : EMULATION_OK;
}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1171def..05fd3d7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4443,10 +4443,17 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,
}
if (emulation_type & EMULTYPE_SKIP) {
+ if (ctxt->have_exception)
+ return EMULATE_FAIL;
kvm_rip_write(vcpu, ctxt->_eip);
return EMULATE_DONE;
}
+ if (ctxt->have_exception) {
+ writeback = false;
+ goto post;
+ }
+
if (retry_instruction(ctxt, cr2, emulation_type))
return EMULATE_DONE;
@@ -4470,6 +4477,7 @@ restart:
return handle_emulation_failure(vcpu);
}
+post:
if (ctxt->have_exception) {
inject_emulated_exception(vcpu);
r = EMULATE_DONE;
--
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists