Skip to content

Commit ae01818

Browse files
codomaniabonzini
authored andcommitted
KVM: SEV: Add GHCB handling for Hypervisor Feature Support requests
Version 2 of the GHCB specification introduced advertisement of features that are supported by the Hypervisor. Now that KVM supports version 2 of the GHCB specification, bump the maximum supported protocol version. Signed-off-by: Brijesh Singh <[email protected]> Signed-off-by: Ashish Kalra <[email protected]> Signed-off-by: Michael Roth <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent d916f00 commit ae01818

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

arch/x86/include/asm/sev-common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ enum psc_op {
101101
/* GHCB Hypervisor Feature Request/Response */
102102
#define GHCB_MSR_HV_FT_REQ 0x080
103103
#define GHCB_MSR_HV_FT_RESP 0x081
104+
#define GHCB_MSR_HV_FT_POS 12
105+
#define GHCB_MSR_HV_FT_MASK GENMASK_ULL(51, 0)
104106
#define GHCB_MSR_HV_FT_RESP_VAL(v) \
105107
/* GHCBData[63:12] */ \
106108
(((u64)(v) & GENMASK_ULL(63, 12)) >> 12)

arch/x86/kvm/svm/sev.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#define GHCB_VERSION_MAX 1ULL
3737
#define GHCB_VERSION_MIN 1ULL
3838

39+
#define GHCB_HV_FT_SUPPORTED GHCB_HV_FT_SNP
40+
3941
/* enable/disable SEV support */
4042
static bool sev_enabled = true;
4143
module_param_named(sev, sev_enabled, bool, 0444);
@@ -2701,6 +2703,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm)
27012703
case SVM_VMGEXIT_AP_HLT_LOOP:
27022704
case SVM_VMGEXIT_AP_JUMP_TABLE:
27032705
case SVM_VMGEXIT_UNSUPPORTED_EVENT:
2706+
case SVM_VMGEXIT_HV_FEATURES:
27042707
break;
27052708
default:
27062709
reason = GHCB_ERR_INVALID_EVENT;
@@ -2961,6 +2964,12 @@ static int sev_handle_vmgexit_msr_protocol(struct vcpu_svm *svm)
29612964
GHCB_MSR_INFO_MASK,
29622965
GHCB_MSR_INFO_POS);
29632966
break;
2967+
case GHCB_MSR_HV_FT_REQ:
2968+
set_ghcb_msr_bits(svm, GHCB_HV_FT_SUPPORTED,
2969+
GHCB_MSR_HV_FT_MASK, GHCB_MSR_HV_FT_POS);
2970+
set_ghcb_msr_bits(svm, GHCB_MSR_HV_FT_RESP,
2971+
GHCB_MSR_INFO_MASK, GHCB_MSR_INFO_POS);
2972+
break;
29642973
case GHCB_MSR_TERM_REQ: {
29652974
u64 reason_set, reason_code;
29662975

@@ -3085,6 +3094,11 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
30853094
ret = 1;
30863095
break;
30873096
}
3097+
case SVM_VMGEXIT_HV_FEATURES:
3098+
ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, GHCB_HV_FT_SUPPORTED);
3099+
3100+
ret = 1;
3101+
break;
30883102
case SVM_VMGEXIT_UNSUPPORTED_EVENT:
30893103
vcpu_unimpl(vcpu,
30903104
"vmgexit: unsupported event - exit_info_1=%#llx, exit_info_2=%#llx\n",

0 commit comments

Comments
 (0)