177 lines
5.8 KiB
Diff
177 lines
5.8 KiB
Diff
|
From 6bae9faff44415edf51bb7f919fc816f8fe3cd12 Mon Sep 17 00:00:00 2001
|
||
|
From: Julia Suvorova <jusual@redhat.com>
|
||
|
Date: Fri, 27 Sep 2024 12:47:41 +0200
|
||
|
Subject: [PATCH 29/38] target/i386/kvm: Report which action failed in
|
||
|
kvm_arch_put/get_registers
|
||
|
|
||
|
RH-Author: Julia Suvorova <None>
|
||
|
RH-MergeRequest: 287: kvm: Allow kvm_arch_get/put_registers to accept Error**
|
||
|
RH-Jira: RHEL-20574
|
||
|
RH-Acked-by: Juraj Marcin <None>
|
||
|
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
||
|
RH-Commit: [2/2] 1e430500be009393846a19451472b3d1031c1283
|
||
|
|
||
|
To help debug and triage future failure reports (akin to [1,2]) that
|
||
|
may occur during kvm_arch_put/get_registers, the error path of each
|
||
|
action is accompanied by unique error message.
|
||
|
|
||
|
[1] https://issues.redhat.com/browse/RHEL-7558
|
||
|
[2] https://issues.redhat.com/browse/RHEL-21761
|
||
|
|
||
|
Signed-off-by: Julia Suvorova <jusual@redhat.com>
|
||
|
Reviewed-by: Peter Xu <peterx@redhat.com>
|
||
|
Link: https://lore.kernel.org/r/20240927104743.218468-3-jusual@redhat.com
|
||
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||
|
(cherry picked from commit fc058618d1596d29e89016750a1aaf64c9fe8832)
|
||
|
---
|
||
|
target/i386/kvm/kvm.c | 23 +++++++++++++++++++++++
|
||
|
1 file changed, 23 insertions(+)
|
||
|
|
||
|
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
|
||
|
index 423e6922d8..814f93da19 100644
|
||
|
--- a/target/i386/kvm/kvm.c
|
||
|
+++ b/target/i386/kvm/kvm.c
|
||
|
@@ -5136,6 +5136,7 @@ int kvm_arch_put_registers(CPUState *cpu, int level, Error **errp)
|
||
|
if (level >= KVM_PUT_RESET_STATE) {
|
||
|
ret = kvm_put_msr_feature_control(x86_cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set feature control MSR");
|
||
|
return ret;
|
||
|
}
|
||
|
}
|
||
|
@@ -5143,12 +5144,14 @@ int kvm_arch_put_registers(CPUState *cpu, int level, Error **errp)
|
||
|
/* must be before kvm_put_nested_state so that EFER.SVME is set */
|
||
|
ret = has_sregs2 ? kvm_put_sregs2(x86_cpu) : kvm_put_sregs(x86_cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set special registers");
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
if (level >= KVM_PUT_RESET_STATE) {
|
||
|
ret = kvm_put_nested_state(x86_cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set nested state");
|
||
|
return ret;
|
||
|
}
|
||
|
}
|
||
|
@@ -5166,6 +5169,7 @@ int kvm_arch_put_registers(CPUState *cpu, int level, Error **errp)
|
||
|
if (xen_mode == XEN_EMULATE && level == KVM_PUT_FULL_STATE) {
|
||
|
ret = kvm_put_xen_state(cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set Xen state");
|
||
|
return ret;
|
||
|
}
|
||
|
}
|
||
|
@@ -5173,37 +5177,45 @@ int kvm_arch_put_registers(CPUState *cpu, int level, Error **errp)
|
||
|
|
||
|
ret = kvm_getput_regs(x86_cpu, 1);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set general purpose registers");
|
||
|
return ret;
|
||
|
}
|
||
|
ret = kvm_put_xsave(x86_cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set XSAVE");
|
||
|
return ret;
|
||
|
}
|
||
|
ret = kvm_put_xcrs(x86_cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set XCRs");
|
||
|
return ret;
|
||
|
}
|
||
|
ret = kvm_put_msrs(x86_cpu, level);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set MSRs");
|
||
|
return ret;
|
||
|
}
|
||
|
ret = kvm_put_vcpu_events(x86_cpu, level);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set vCPU events");
|
||
|
return ret;
|
||
|
}
|
||
|
if (level >= KVM_PUT_RESET_STATE) {
|
||
|
ret = kvm_put_mp_state(x86_cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set MP state");
|
||
|
return ret;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ret = kvm_put_tscdeadline_msr(x86_cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set TSC deadline MSR");
|
||
|
return ret;
|
||
|
}
|
||
|
ret = kvm_put_debugregs(x86_cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to set debug registers");
|
||
|
return ret;
|
||
|
}
|
||
|
return 0;
|
||
|
@@ -5218,6 +5230,7 @@ int kvm_arch_get_registers(CPUState *cs, Error **errp)
|
||
|
|
||
|
ret = kvm_get_vcpu_events(cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get vCPU events");
|
||
|
goto out;
|
||
|
}
|
||
|
/*
|
||
|
@@ -5226,44 +5239,54 @@ int kvm_arch_get_registers(CPUState *cs, Error **errp)
|
||
|
*/
|
||
|
ret = kvm_get_mp_state(cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get MP state");
|
||
|
goto out;
|
||
|
}
|
||
|
ret = kvm_getput_regs(cpu, 0);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get general purpose registers");
|
||
|
goto out;
|
||
|
}
|
||
|
ret = kvm_get_xsave(cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get XSAVE");
|
||
|
goto out;
|
||
|
}
|
||
|
ret = kvm_get_xcrs(cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get XCRs");
|
||
|
goto out;
|
||
|
}
|
||
|
ret = has_sregs2 ? kvm_get_sregs2(cpu) : kvm_get_sregs(cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get special registers");
|
||
|
goto out;
|
||
|
}
|
||
|
ret = kvm_get_msrs(cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get MSRs");
|
||
|
goto out;
|
||
|
}
|
||
|
ret = kvm_get_apic(cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get APIC");
|
||
|
goto out;
|
||
|
}
|
||
|
ret = kvm_get_debugregs(cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get debug registers");
|
||
|
goto out;
|
||
|
}
|
||
|
ret = kvm_get_nested_state(cpu);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get nested state");
|
||
|
goto out;
|
||
|
}
|
||
|
#ifdef CONFIG_XEN_EMU
|
||
|
if (xen_mode == XEN_EMULATE) {
|
||
|
ret = kvm_get_xen_state(cs);
|
||
|
if (ret < 0) {
|
||
|
+ error_setg_errno(errp, -ret, "Failed to get Xen state");
|
||
|
goto out;
|
||
|
}
|
||
|
}
|
||
|
--
|
||
|
2.39.3
|
||
|
|