@@ -72,6 +72,8 @@ module_param_named(ciphertext_hiding_asids, nr_ciphertext_hiding_asids, uint, 04
7272 SNP_POLICY_MASK_DEBUG | \
7373 SNP_POLICY_MASK_SINGLE_SOCKET)
7474
75+ static u64 snp_supported_policy_bits __ro_after_init ;
76+
7577#define INITIAL_VMSA_GPA 0xFFFFFFFFF000
7678
7779static u8 sev_enc_bit ;
@@ -2135,6 +2137,10 @@ int sev_dev_get_attr(u32 group, u64 attr, u64 *val)
21352137 * val = sev_supported_vmsa_features ;
21362138 return 0 ;
21372139
2140+ case KVM_X86_SNP_POLICY_BITS :
2141+ * val = snp_supported_policy_bits ;
2142+ return 0 ;
2143+
21382144 default :
21392145 return - ENXIO ;
21402146 }
@@ -2199,7 +2205,7 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
21992205 if (params .flags )
22002206 return - EINVAL ;
22012207
2202- if (params .policy & ~KVM_SNP_POLICY_MASK_VALID )
2208+ if (params .policy & ~snp_supported_policy_bits )
22032209 return - EINVAL ;
22042210
22052211 /* Check for policy bits that must be set */
@@ -3092,8 +3098,11 @@ void __init sev_hardware_setup(void)
30923098 else if (sev_snp_supported )
30933099 sev_snp_supported = is_sev_snp_initialized ();
30943100
3095- if (sev_snp_supported )
3101+ if (sev_snp_supported ) {
3102+ snp_supported_policy_bits = sev_get_snp_policy_bits () &
3103+ KVM_SNP_POLICY_MASK_VALID ;
30963104 nr_ciphertext_hiding_asids = init_args .max_snp_asid ;
3105+ }
30973106
30983107 /*
30993108 * If ciphertext hiding is enabled, the joint SEV-ES/SEV-SNP
0 commit comments