From: Paolo Bonzini Date: Fri, 29 Apr 2022 10:38:56 +0000 (-0400) Subject: Merge branch 'kvm-fixes-for-5.18-rc5' into HEAD X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=71d7c575a673d42ad7175ad5fc27c85c80330311;p=linux.git Merge branch 'kvm-fixes-for-5.18-rc5' into HEAD Fixes for (relatively) old bugs, to be merged in both the -rc and next development trees. The merge reconciles the ABI fixes for KVM_EXIT_SYSTEM_EVENT between 5.18 and commit c24a950ec7d6 ("KVM, SEV: Add KVM_EXIT_SHUTDOWN metadata for SEV-ES", 2022-04-13). --- 71d7c575a673d42ad7175ad5fc27c85c80330311 diff --cc Documentation/virt/kvm/api.rst index 72183ae628f7f,4a900cdbc62e9..0c1b9f139e4a6 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@@ -6088,11 -5985,8 +6088,9 @@@ should put the acknowledged interrupt v #define KVM_SYSTEM_EVENT_SHUTDOWN 1 #define KVM_SYSTEM_EVENT_RESET 2 #define KVM_SYSTEM_EVENT_CRASH 3 + #define KVM_SYSTEM_EVENT_SEV_TERM 4 - #define KVM_SYSTEM_EVENT_NDATA_VALID (1u << 31) __u32 type; __u32 ndata; - __u64 flags; __u64 data[16]; } system_event; @@@ -6116,17 -6009,21 +6113,23 @@@ Valid values for 'type' are has requested a crash condition maintenance. Userspace can choose to ignore the request, or to gather VM memory core dump and/or reset/shutdown of the VM. + - KVM_SYSTEM_EVENT_SEV_TERM -- an AMD SEV guest requested termination. + The guest physical address of the guest's GHCB is stored in `data[0]`. - Valid flags are: + If KVM_CAP_SYSTEM_EVENT_DATA is present, the 'data' field can contain + architecture specific information for the system-level event. Only + the first `ndata` items (possibly zero) of the data array are valid. - - KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 (arm64 only) -- the guest issued - a SYSTEM_RESET2 call according to v1.1 of the PSCI specification. + - for arm64, data[0] is set to KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 if + the guest issued a SYSTEM_RESET2 call according to v1.1 of the PSCI + specification. - Extra data for this event is stored in the `data[]` array, up to index - `ndata-1` included, if bit 31 is set in `type`. The data depends on the - `type` field. There is no extra data if bit 31 is clear or `ndata` is zero. + - for RISC-V, data[0] is set to the value of the second argument of the + ``sbi_system_reset`` call. + + Previous versions of Linux defined a `flags` member in this struct. The + field is now aliased to `data[0]`. Userspace can assume that it is only + written if ndata is greater than 0. :: diff --cc arch/x86/kvm/svm/sev.c index a93f0d01bb90f,537aaddc852fc..9ce162119b233 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@@ -2738,13 -2738,8 +2738,12 @@@ static int sev_handle_vmgexit_msr_proto pr_info("SEV-ES guest requested termination: %#llx:%#llx\n", reason_set, reason_code); - ret = -EINVAL; - break; + vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT; - vcpu->run->system_event.type = KVM_SYSTEM_EVENT_SEV_TERM | - KVM_SYSTEM_EVENT_NDATA_VALID; ++ vcpu->run->system_event.type = KVM_SYSTEM_EVENT_SEV_TERM; + vcpu->run->system_event.ndata = 1; - vcpu->run->system_event.data[1] = control->ghcb_gpa; ++ vcpu->run->system_event.data[0] = control->ghcb_gpa; + + return 0; } default: /* Error, keep GHCB MSR value as-is */ diff --cc include/uapi/linux/kvm.h index dd1d8167e71ff,6a184d260c7f2..e10d131edd805 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@@ -444,11 -444,14 +444,15 @@@ struct kvm_run #define KVM_SYSTEM_EVENT_SHUTDOWN 1 #define KVM_SYSTEM_EVENT_RESET 2 #define KVM_SYSTEM_EVENT_CRASH 3 +#define KVM_SYSTEM_EVENT_SEV_TERM 4 - #define KVM_SYSTEM_EVENT_NDATA_VALID (1u << 31) __u32 type; __u32 ndata; - __u64 data[16]; + union { + #ifndef __KERNEL__ + __u64 flags; + #endif + __u64 data[16]; + }; } system_event; /* KVM_EXIT_S390_STSI */ struct { @@@ -1147,7 -1150,8 +1151,8 @@@ struct kvm_ppc_resize_hpt #define KVM_CAP_S390_MEM_OP_EXTENSION 211 #define KVM_CAP_PMU_CAPABILITY 212 #define KVM_CAP_DISABLE_QUIRKS2 213 -/* #define KVM_CAP_VM_TSC_CONTROL 214 */ +#define KVM_CAP_VM_TSC_CONTROL 214 + #define KVM_CAP_SYSTEM_EVENT_DATA 215 #ifdef KVM_CAP_IRQ_ROUTING