An SEV-ES guest does not allow register state to be altered once it has
been measured. When an SEV-ES guest issues a reboot command, Qemu will
reset the vCPU state and resume the guest. This will cause failures under
SEV-ES. Prevent that from occuring by introducing an arch-specific
callback that returns a boolean indicating whether vCPUs are resettable.
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: David Hildenbrand <david@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Venu Busireddy <venu.busireddy@oracle.com>
Message-Id: <
1ac39c441b9a3e970e9556e1cc29d0a0814de6fd.
1611682609.git.thomas.lendacky@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
s->coalesced_flush_in_progress = false;
}
+bool kvm_cpu_check_are_resettable(void)
+{
+ return kvm_arch_cpu_check_are_resettable();
+}
+
static void do_kvm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
if (!cpu->vcpu_dirty) {
/* Unblock cpu */
void qemu_cpu_kick_self(void);
+bool cpus_are_resettable(void);
+
void cpu_synchronize_all_states(void);
void cpu_synchronize_all_post_reset(void);
void cpu_synchronize_all_post_init(void);
void cpu_synchronize_post_init(CPUState *cpu);
void cpu_synchronize_pre_loadvm(CPUState *cpu);
+static inline bool cpu_check_are_resettable(void)
+{
+ return kvm_enabled() ? kvm_cpu_check_are_resettable() : true;
+}
+
#endif /* QEMU_HW_ACCEL_H */
/* Notify resamplefd for EOI of specific interrupts. */
void kvm_resample_fd_notify(int gsi);
+/**
+ * kvm_cpu_check_are_resettable - return whether CPUs can be reset
+ *
+ * Returns: true: CPUs are resettable
+ * false: CPUs are not resettable
+ */
+bool kvm_cpu_check_are_resettable(void);
+
+bool kvm_arch_cpu_check_are_resettable(void);
+
#endif
}
}
+bool cpus_are_resettable(void)
+{
+ return cpu_check_are_resettable();
+}
+
int64_t cpus_get_virtual_clock(void)
{
/*
if (reboot_action == REBOOT_ACTION_SHUTDOWN &&
reason != SHUTDOWN_CAUSE_SUBSYSTEM_RESET) {
shutdown_requested = reason;
+ } else if (!cpus_are_resettable()) {
+ error_report("cpus are not resettable, terminating");
+ shutdown_requested = reason;
} else {
reset_requested = reason;
}
{
return (data - 32) & 0xffff;
}
+
+bool kvm_arch_cpu_check_are_resettable(void)
+{
+ return true;
+}
#include "sysemu/kvm_int.h"
#include "sysemu/runstate.h"
#include "kvm_i386.h"
+#include "sev_i386.h"
#include "hyperv.h"
#include "hyperv-proto.h"
{
return has_msr_umwait;
}
+
+bool kvm_arch_cpu_check_are_resettable(void)
+{
+ return !sev_es_enabled();
+}
return -1;
}
+
+bool kvm_arch_cpu_check_are_resettable(void)
+{
+ return true;
+}
kvm_set_one_reg(cs, KVM_REG_PPC_TB_OFFSET, &tb_offset);
}
}
+
+bool kvm_arch_cpu_check_are_resettable(void)
+{
+ return true;
+}
kvm_s390_vcpu_interrupt(cpu, &irq);
}
+
+bool kvm_arch_cpu_check_are_resettable(void)
+{
+ return true;
+}