qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
ret = EXCP_INTERRUPT;
break;
+ case KVM_SYSTEM_EVENT_SEV_TERM:
case KVM_SYSTEM_EVENT_CRASH:
kvm_cpu_synchronize_state(cpu);
bql_lock();
#
# @tdx: tdx guest panic information type (Since: 10.1)
#
+# @sev: AMD SEV-ES guest termination information type (Since: 11.0)
+#
# Since: 2.9
##
{ 'enum': 'GuestPanicInformationType',
- 'data': [ 'hyper-v', 's390', 'tdx' ] }
+ 'data': [ 'hyper-v', 's390', 'tdx', 'sev' ] }
##
# @GuestPanicInformation:
'discriminator': 'type',
'data': {'hyper-v': 'GuestPanicInformationHyperV',
's390': 'GuestPanicInformationS390',
- 'tdx' : 'GuestPanicInformationTdx'}}
+ 'tdx': 'GuestPanicInformationTdx',
+ 'sev': 'GuestPanicInformationSev' }}
##
# @GuestPanicInformationHyperV:
'message': 'str',
'*gpa': 'uint64'}}
+##
+# @GuestPanicInformationSev:
+#
+# Information for AMD SEV-specific termination request (GHCB MSR
+# contents)
+#
+# @set: The reason code set provided by the guest
+#
+# @code: The reason code provided by the guest
+#
+# Since: 11.0
+##
+{'struct': 'GuestPanicInformationSev',
+ 'data': {'set': 'uint32',
+ 'code': 'uint32'}}
+
##
# @MEMORY_FAILURE:
#
"can be found at gpa page: 0x%" PRIx64 "\n",
info->u.tdx.gpa);
}
+ } else if (info->type == GUEST_PANIC_INFORMATION_TYPE_SEV) {
+ qemu_log_mask(LOG_GUEST_ERROR, "SEV termination (reason set: %d code: %d)",
+ info->u.sev.set,
+ info->u.sev.code);
}
qapi_free_GuestPanicInformation(info);
*/
#include "qemu/osdep.h"
+#include "qemu/error-report.h"
+#include "system/kvm.h"
#include "cpu.h"
#include "qapi/error.h"
#include "qapi/qapi-visit-run-state.h"
CPUX86State *env = &cpu->env;
GuestPanicInformation *panic_info = NULL;
+#ifdef CONFIG_KVM
+ if (kvm_enabled()) {
+ struct kvm_run *run = cs->kvm_run;
+
+ if (run->exit_reason == KVM_EXIT_SYSTEM_EVENT &&
+ run->system_event.type == KVM_SYSTEM_EVENT_SEV_TERM) {
+ panic_info = g_new0(GuestPanicInformation, 1);
+
+ panic_info->type = GUEST_PANIC_INFORMATION_TYPE_SEV;
+ /* There should always be one data item, otherwise use zeroes. */
+ if (run->system_event.ndata > 0) {
+ panic_info->u.sev.set = (run->system_event.data[0] >> 12) & 0xf;
+ panic_info->u.sev.code = (run->system_event.data[0] >> 16) & 0xff;
+ } else {
+ warn_report("Hypervisor did not provide any data for SEV-ES termination");
+ }
+ }
+ } else
+#endif
+
if (hyperv_feat_enabled(cpu, HYPERV_FEAT_CRASH)) {
panic_info = g_new0(GuestPanicInformation, 1);