On 11/7/2023 4:08 PM, Borislav Petkov wrote:
static int __init snp_rmptable_init(void) { - int family, model; - - if (!cpu_feature_enabled(X86_FEATURE_SEV_SNP)) + if (!amd_iommu_snp_en) return 0;
We will still need some method to tell the IOMMU driver if SNP support/feature is disabled by this function, for example, when CPU family and model is not supported by SNP and we jump to no_snp label.
The reliable way for this to work is to ensure snp_rmptable_init() is called before IOMMU initialization and then IOMMU initialization depends on SNP feature flag setup by snp_rmptable_init() to enable SNP support on IOMMU or not.
If snp_rmptable_init() is called after IOMMU initialization and it detects an issue with SNP support it will clear the SNP feature but the IOMMU driver does not get notified about it, therefore, snp_rmptable_init() should get called before IOMMU initialization or as part of IOMMU initialization, for example, amd_iommu_enable() calling snp_rmptable_init() before calling iommu_snp_enable().
Thanks, Ashish