Version 2 of the GHCB specification introduced advertisement of features that are supported by the Hypervisor. Now that KVM supports the basic SEV-SNP, advertisement the support through the hypervisor feature request MSR protocol and NAE VMGEXITs. Signed-off-by: Brijesh Singh <brijesh.singh@xxxxxxx> --- arch/x86/kvm/svm/sev.c | 14 ++++++++++++++ arch/x86/kvm/svm/svm.h | 1 + 2 files changed, 15 insertions(+) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 7bf4c2354a5a..5f0034e0dacc 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2174,6 +2174,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm) case SVM_VMGEXIT_AP_HLT_LOOP: case SVM_VMGEXIT_AP_JUMP_TABLE: case SVM_VMGEXIT_UNSUPPORTED_EVENT: + case SVM_VMGEXIT_HYPERVISOR_FEATURES: break; default: goto vmgexit_err; @@ -2431,6 +2432,13 @@ static int sev_handle_vmgexit_msr_protocol(struct vcpu_svm *svm) GHCB_MSR_INFO_MASK, GHCB_MSR_INFO_POS); break; + case GHCB_MSR_HV_FEATURES_REQ: { + set_ghcb_msr_bits(svm, GHCB_HV_FEATURES_SUPPORTED, + GHCB_MSR_HV_FEATURES_MASK, GHCB_MSR_HV_FEATURES_POS); + set_ghcb_msr_bits(svm, GHCB_MSR_HV_FEATURES_RESP, + GHCB_MSR_INFO_MASK, GHCB_MSR_INFO_POS); + break; + } case GHCB_MSR_TERM_REQ: { u64 reason_set, reason_code; @@ -2546,6 +2554,12 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) ret = 1; break; } + case SVM_VMGEXIT_HYPERVISOR_FEATURES: { + ghcb_set_sw_exit_info_2(ghcb, GHCB_HV_FEATURES_SUPPORTED); + + ret = 1; + break; + } case SVM_VMGEXIT_UNSUPPORTED_EVENT: vcpu_unimpl(vcpu, "vmgexit: unsupported event - exit_info_1=%#llx, exit_info_2=%#llx\n", diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index dad528d9f08f..2b0083753812 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -530,6 +530,7 @@ void svm_vcpu_unblocking(struct kvm_vcpu *vcpu); #define GHCB_VERSION_MAX 1ULL #define GHCB_VERSION_MIN 1ULL +#define GHCB_HV_FEATURES_SUPPORTED 0 extern unsigned int max_sev_asid; -- 2.17.1