aboutsummaryrefslogtreecommitdiff
path: root/accel
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki@daynix.com>2022-12-01 19:27:28 +0900
committerPaolo Bonzini <pbonzini@redhat.com>2023-09-29 09:33:10 +0200
commit7191f24c7fcfbc1216d09214122582f4f9d699db (patch)
treef247b2c1ca2f54b083217105f6af81c64263417f /accel
parent35ed01ba5448208695ada5fa20a13c0a4689a1c1 (diff)
downloadqemu-7191f24c7fcfbc1216d09214122582f4f9d699db.zip
qemu-7191f24c7fcfbc1216d09214122582f4f9d699db.tar.gz
qemu-7191f24c7fcfbc1216d09214122582f4f9d699db.tar.bz2
accel/kvm/kvm-all: Handle register access errors
A register access error typically means something seriously wrong happened so that anything bad can happen after that and recovery is impossible. Even failing one register access is catastorophic as architecture-specific code are not written so that it torelates such failures. Make sure the VM stop and nothing worse happens if such an error occurs. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-ID: <20221201102728.69751-1-akihiko.odaki@daynix.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'accel')
-rw-r--r--accel/kvm/kvm-all.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index ff1578b..72e1d11 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2851,7 +2851,13 @@ bool kvm_cpu_check_are_resettable(void)
static void do_kvm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
if (!cpu->vcpu_dirty) {
- kvm_arch_get_registers(cpu);
+ int ret = kvm_arch_get_registers(cpu);
+ if (ret) {
+ error_report("Failed to get registers: %s", strerror(-ret));
+ cpu_dump_state(cpu, stderr, CPU_DUMP_CODE);
+ vm_stop(RUN_STATE_INTERNAL_ERROR);
+ }
+
cpu->vcpu_dirty = true;
}
}
@@ -2865,7 +2871,13 @@ void kvm_cpu_synchronize_state(CPUState *cpu)
static void do_kvm_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_data arg)
{
- kvm_arch_put_registers(cpu, KVM_PUT_RESET_STATE);
+ int ret = kvm_arch_put_registers(cpu, KVM_PUT_RESET_STATE);
+ if (ret) {
+ error_report("Failed to put registers after reset: %s", strerror(-ret));
+ cpu_dump_state(cpu, stderr, CPU_DUMP_CODE);
+ vm_stop(RUN_STATE_INTERNAL_ERROR);
+ }
+
cpu->vcpu_dirty = false;
}
@@ -2876,7 +2888,12 @@ void kvm_cpu_synchronize_post_reset(CPUState *cpu)
static void do_kvm_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg)
{
- kvm_arch_put_registers(cpu, KVM_PUT_FULL_STATE);
+ int ret = kvm_arch_put_registers(cpu, KVM_PUT_FULL_STATE);
+ if (ret) {
+ error_report("Failed to put registers after init: %s", strerror(-ret));
+ exit(1);
+ }
+
cpu->vcpu_dirty = false;
}
@@ -2969,7 +2986,14 @@ int kvm_cpu_exec(CPUState *cpu)
MemTxAttrs attrs;
if (cpu->vcpu_dirty) {
- kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE);
+ ret = kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE);
+ if (ret) {
+ error_report("Failed to put registers after init: %s",
+ strerror(-ret));
+ ret = -1;
+ break;
+ }
+
cpu->vcpu_dirty = false;
}