RE: [PATCH Part2 v6 02/49] iommu/amd: Introduce function to check SEV-SNP support

From: Kalra, Ashish
Date: Tue Jul 05 2022 - 10:07:47 EST


[AMD Official Use Only - General]

Hello Boris,

>> +bool iommu_sev_snp_supported(void)
>> +{
>> + struct amd_iommu *iommu;
>> +
>> + /*
>> + * The SEV-SNP support requires that IOMMU must be enabled, and is
>> + * not configured in the passthrough mode.
>> + */
>> + if (no_iommu || iommu_default_passthrough()) {
>> + pr_err("SEV-SNP: IOMMU is either disabled or configured in passthrough mode.\n");
>> + return false;
>> + }
>> +
>> + /*
>> + * Iterate through all the IOMMUs and verify the SNPSup feature is
>> + * enabled.
>> + */
>> + for_each_iommu(iommu) {
>> + if (!iommu_feature(iommu, FEATURE_SNP)) {
>> + pr_err("SNPSup is disabled (devid: %02x:%02x.%x)\n",
>> + PCI_BUS_NUM(iommu->devid), PCI_SLOT(iommu->devid),
>> + PCI_FUNC(iommu->devid));
>> + return false;
>> + }
>> + }
>> +
>> + return true;
>> +}
>> +EXPORT_SYMBOL_GPL(iommu_sev_snp_supported);

> Why is this function exported?

This function is required to ensure that IOMMU supports the SEV-SNP feature before enabling the SNP feature
and calling SNP_INIT. This IOMMU support check is done in the AMD IOMMU driver with the
iommu_sev_snp_supported() function so it is exported by the IOMMU driver and called by sev module
later for SNP initialization in snp_rmptable_init().

Thanks,
Ashish