Skip to content

Commit c8e9926

Browse files
tlendackymdroth
authored andcommitted
KVM: SEV: Publish supported SEV-SNP policy bits
Define the set of policy bits that KVM currently knows as not requiring any implementation support within KVM. Provide this value to userspace via the KVM_GET_DEVICE_ATTR ioctl. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Michael Roth <michael.roth@amd.com>
1 parent 799613d commit c8e9926

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎arch/x86/include/uapi/asm/kvm.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ struct kvm_sync_regs {
468468
/* vendor-specific groups and attributes for system fd */
469469
#define KVM_X86_GRP_SEV 1
470470
# define KVM_X86_SEV_VMSA_FEATURES 0
471+
# define KVM_X86_SNP_POLICY_BITS 1
471472

472473
struct kvm_vmx_nested_state_data {
473474
__u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];

‎arch/x86/kvm/svm/sev.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ module_param_named(ciphertext_hiding_asids, nr_ciphertext_hiding_asids, uint, 04
8181
SNP_POLICY_MASK_DEBUG | \
8282
SNP_POLICY_MASK_SINGLE_SOCKET)
8383

84+
static u64 snp_supported_policy_bits;
85+
8486
#define INITIAL_VMSA_GPA 0xFFFFFFFFF000
8587

8688
static u8 sev_enc_bit;
@@ -2088,6 +2090,10 @@ int sev_dev_get_attr(u32 group, u64 attr, u64 *val)
20882090
*val = sev_supported_vmsa_features;
20892091
return 0;
20902092

2093+
case KVM_X86_SNP_POLICY_BITS:
2094+
*val = snp_supported_policy_bits;
2095+
return 0;
2096+
20912097
default:
20922098
return -ENXIO;
20932099
}
@@ -2152,7 +2158,7 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
21522158
if (params.flags)
21532159
return -EINVAL;
21542160

2155-
if (params.policy & ~SNP_POLICY_MASK_VALID)
2161+
if (params.policy & ~snp_supported_policy_bits)
21562162
return -EINVAL;
21572163

21582164
/* Check for policy bits that must be set */
@@ -3045,8 +3051,10 @@ void __init sev_hardware_setup(void)
30453051
else if (sev_snp_supported)
30463052
sev_snp_supported = is_sev_snp_initialized();
30473053

3048-
if (sev_snp_supported)
3054+
if (sev_snp_supported) {
30493055
nr_ciphertext_hiding_asids = init_args.max_snp_asid;
3056+
snp_supported_policy_bits = SNP_POLICY_MASK_VALID;
3057+
}
30503058

30513059
/*
30523060
* If ciphertext hiding is enabled, the joint SEV-ES/SEV-SNP

0 commit comments

Comments
 (0)