> Then you don't need a comment here, only a big fat comment in the code > that configures the min/max ASIDs, which is going to be a gnarly comment no matter > what we do. Oh, and this should be done before the > > if (min_asid > max_asid) > return -ENOTTY; > > sanity check. > > And then drop the mix of ternary operators and if statements, and just do: > > unsigned int min_asid, max_asid, asid; > bool retry = true; > int ret; > > if (vm_type == KVM_X86_SNP_VM) { > min_asid = min_snp_asid; > max_asid = max_snp_asid; > } else if (sev->es_active) { > min_asid = min_sev_es_asid; > max_asid = max_sev_es_asid; > } else { > min_asid = min_sev_asid; > max_asid = max_sev_asid; > } > > /* > * The min ASID can end up larger than the max if basic SEV support is > * effectively disabled by disallowing use of ASIDs for SEV guests. > * Ditto for SEV-ES guests when CipherTextHiding is enabled. > */ Ok, makes sense. > if (min_asid > max_asid) > return -ENOTTY; > >> @@ -3040,14 +3074,18 @@ void __init sev_hardware_setup(void) >> "unusable" : >> "disabled", >> min_sev_asid, max_sev_asid); >> - if (boot_cpu_has(X86_FEATURE_SEV_ES)) >> + if (boot_cpu_has(X86_FEATURE_SEV_ES)) { >> + if (snp_max_snp_asid >= (min_sev_asid - 1)) >> + sev_es_supported = false; >> pr_info("SEV-ES %s (ASIDs %u - %u)\n", >> str_enabled_disabled(sev_es_supported), >> - min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1); >> + min_sev_asid > 1 ? snp_max_snp_asid ? snp_max_snp_asid + 1 : 1 : >> + 0, min_sev_asid - 1); >> + } >> if (boot_cpu_has(X86_FEATURE_SEV_SNP)) >> pr_info("SEV-SNP %s (ASIDs %u - %u)\n", >> str_enabled_disabled(sev_snp_supported), >> - min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1); >> + min_sev_asid > 1 ? 1 : 0, snp_max_snp_asid ? : min_sev_asid - 1); > > Mixing in snp_max_snp_asid pretty much makes this is unreadable. Please rework > this code to generate {min,max}_{sev,sev_es,snp,}_asid (add prep patches if > necessary). I don't care terribly if ternary operators are used, but please > don't chain them. > Ok. Thanks, Ashish >> >> sev_enabled = sev_supported; >> sev_es_enabled = sev_es_supported; >> @@ -3068,6 +3106,8 @@ void __init sev_hardware_setup(void) >> * Do both SNP and SEV initialization at KVM module load. >> */ >> init_args.probe = true; >> + init_args.cipher_text_hiding_en = snp_cipher_text_hiding; >> + init_args.snp_max_snp_asid = snp_max_snp_asid; >> sev_platform_init(&init_args); >> } >> >> -- >> 2.34.1 >>