[Devel] [PATCH RHEL8 COMMIT] kvm/x86: extend info on emualation failure
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Jun 10 13:32:10 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.39
------>
commit bdc21a00eacaae53e20ac1fa9e431a9f32a5ae22
Author: Denis Plotnikov <dplotnikov at virtuozzo.com>
Date: Thu Jun 10 13:32:10 2021 +0300
kvm/x86: extend info on emualation failure
Patch makes handle emulation failure report the phase where
the failure occur: on decoding or on emulation.
This is for bugs debugging like
https://jira.sw.ru/browse/PSBM-99553
Signed-off-by: Denis Plotnikov <dplotnikov at virtuozzo.com>
(cherry-picked from vz7 commit c4f456a14a56 ("kvm/x86: extend info on emualation
failure"))
https://jira.sw.ru/browse/PSBM-127849
Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
---
arch/x86/kvm/x86.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8415bd3d04f5..8a25cd9130cb 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6504,10 +6504,11 @@ void kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip)
}
EXPORT_SYMBOL_GPL(kvm_inject_realmode_interrupt);
-static void printk_emulation_data(struct kvm_vcpu *vcpu, int emulation_type)
+static void printk_emulation_data(struct kvm_vcpu *vcpu, int emulation_type,
+ bool decoding)
{
struct x86_emulate_ctxt *ctx = vcpu->arch.emulate_ctxt;
- int i;
+ uint64_t i;
vcpu_err(vcpu, "=== emulation failure ===\n");
@@ -6515,6 +6516,8 @@ static void printk_emulation_data(struct kvm_vcpu *vcpu, int emulation_type)
vcpu_err(vcpu, "emulation context data (emulation_type: 0x%x)\n",
emulation_type);
+ vcpu_err(vcpu, "failed phase: %s\n",
+ decoding ? "decoding" : "emulation");
vcpu_err(vcpu, "eflags: 0x%lx start_eip: 0x%lx mode: %d\n",
ctx->eflags, ctx->eip, ctx->mode);
vcpu_err(vcpu, "opcode_len: %u b: 0x%x op_bytes: %u ad_bytes: %u\n",
@@ -6522,17 +6525,21 @@ static void printk_emulation_data(struct kvm_vcpu *vcpu, int emulation_type)
vcpu_err(vcpu, "d: 0x%llx current_eip: 0x%lx\n ", ctx->d, ctx->_eip);
vcpu_err(vcpu, "fetch data: data: %p ptr %p pos %p\n",
ctx->fetch.data, ctx->fetch.ptr, ctx->fetch.end);
+ vcpu_err(vcpu, "have excpetion: %s\n",
+ ctx->have_exception ? "yes" : "no");
+
vcpu_err(vcpu, "fetch data content: ");
for (i = 0; i < ARRAY_SIZE(ctx->fetch.data); i++) {
printk("0x%02x ", ctx->fetch.data[i]);
}
- printk("\n");
+ vcpu_err(vcpu, "\n");
vcpu_err(vcpu, "=== end of emulation failure ===\n");
}
-static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type)
+static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type,
+ bool decoding)
{
++vcpu->stat.insn_emulation_fail;
trace_kvm_emulate_insn_failed(vcpu);
@@ -6546,7 +6553,7 @@ static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type)
vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
vcpu->run->internal.ndata = 0;
- printk_emulation_data(vcpu, emulation_type);
+ printk_emulation_data(vcpu, emulation_type, decoding);
return 0;
}
@@ -6883,7 +6890,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
inject_emulated_exception(vcpu);
return 1;
}
- return handle_emulation_failure(vcpu, emulation_type);
+ return handle_emulation_failure(vcpu, emulation_type,
+ true);
}
}
@@ -6940,7 +6948,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
emulation_type))
return 1;
- return handle_emulation_failure(vcpu, emulation_type);
+ return handle_emulation_failure(vcpu, emulation_type, false);
}
if (ctxt->have_exception) {
More information about the Devel
mailing list