Skip to contentSkip to conversation

iommu/amd: remove amd_iommu_snp_enable

PATCH In review Christoph Hellwig 4 participants 6 messages Aug 31, 2023 – Sep 7, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/amd: remove amd_iommu_snp_enable

amd_iommu_snp_enable is unused and has been since it was added in commit fb2accadaa94 ("iommu/amd: Introduce function to check and enable SNP").

---
 drivers/iommu/amd/init.c  | 38 --------------------------------------
 include/linux/amd-iommu.h |  4 ----
 2 files changed, 42 deletions(-)
drivers/iommu/amd/init.c +0 -38
index ea0f1ab9417837..9f22e469da973b 100644
@@ -3744,41 +3744,3 @@ int amd_iommu_pc_set_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, u8 fxn, u64
 
 	return iommu_pc_get_set_reg(iommu, bank, cntr, fxn, value, true);
 }
-
-#ifdef CONFIG_AMD_MEM_ENCRYPT
-int amd_iommu_snp_enable(void)
-{
-	/*
-	 * The SNP support requires that IOMMU must be enabled, and is
-	 * not configured in the passthrough mode.
-	 */
-	if (no_iommu || iommu_default_passthrough()) {
-		pr_err("SNP: IOMMU is disabled or configured in passthrough mode, SNP cannot be supported");
-		return -EINVAL;
-	}
-
-	/*
-	 * Prevent enabling SNP after IOMMU_ENABLED state because this process
-	 * affect how IOMMU driver sets up data structures and configures
-	 * IOMMU hardware.
-	 */
-	if (init_state > IOMMU_ENABLED) {
-		pr_err("SNP: Too late to enable SNP for IOMMU.\n");
-		return -EINVAL;
-	}
-
-	amd_iommu_snp_en = check_feature_on_all_iommus(FEATURE_SNP);
-	if (!amd_iommu_snp_en)
-		return -EINVAL;
-
-	pr_info("SNP enabled\n");
-
-	/* Enforce IOMMU v1 pagetable when SNP is enabled. */
-	if (amd_iommu_pgtable != AMD_IOMMU_V1) {
-		pr_warn("Force to using AMD IOMMU v1 page table due to SNP\n");
-		amd_iommu_pgtable = AMD_IOMMU_V1;
-	}
-
-	return 0;
-}
-#endif
include/linux/amd-iommu.h +0 -4
index 953e6f12fa1c30..58e6c3806c09d4 100644
@@ -206,8 +206,4 @@ int amd_iommu_pc_get_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, u8 fxn,
 		u64 *value);
 struct amd_iommu *get_amd_iommu(unsigned int idx);
 
-#ifdef CONFIG_AMD_MEM_ENCRYPT
-int amd_iommu_snp_enable(void);
-#endif
-
 #endif /* _ASM_X86_AMD_IOMMU_H */
Signature · 1 line
2.39.2
#2 lore raw
Quoted 6 lines · Kim Phillips

+Mike Roth, Ashish

Quoted 3 lines · Christoph Hellwig

amd_iommu_snp_enable is unused and has been since it was added in commit fb2accadaa94 ("iommu/amd: Introduce function to check and enable SNP").

Quoted 6 lines
Quoted 2 lines

---

It is used by the forthcoming host SNP support:

https://lore.kernel.org/lkml/[email protected]/

Then resend it with that support, but don't waste resources and everyones time now.

Reviewed-by
#3 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Kim Phillips

+Mike Roth, Ashish

Quoted 5 lines · Christoph Hellwig

amd_iommu_snp_enable is unused and has been since it was added in commit fb2accadaa94 ("iommu/amd: Introduce function to check and enable SNP").

---

Quoted 6 lines
Quoted 3 lines

It is used by the forthcoming host SNP support:

https://lore.kernel.org/lkml/[email protected]/

Then resend it with that support, but don't waste resources and everyones time now.

+1

I've said this many times lately. There are other things in this driver that have no upstream justification too, like nesting "support".

Please organize this SNP support into series that makes sense and are self complete :( I'm not sure a 51 patch series is a productive way to approach this..

Jason

reviewer Reviewed-by
#4 lore raw
Quoted 13 lines · Jason Gunthorpe
Quoted 12 lines · Christoph Hellwig
Quoted 11 lines · Kim Phillips

+Mike Roth, Ashish

Quoted 5 lines · Christoph Hellwig

amd_iommu_snp_enable is unused and has been since it was added in commit fb2accadaa94 ("iommu/amd: Introduce function to check and enable SNP").

---

It is used by the forthcoming host SNP support:

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

https://lore.kernel.org/lkml/[email protected]/

Then resend it with that support, but don't waste resources and everyones time now.

+1

Duly noted :)

The reason we introduced this change separately from the SNP series was because it is part of a different subsystem, which normally get pulled in separately. Unfortunately the main series takes a long time to get into upstream Linux kernel. So, this code appears as unused, which I can see how it can be confusing to other developers.

FYI: This is just removing a function to enable SNP support in AMD IOMMU driver. The underlying logic to enable the hardware still exist, which is part of the SNP feature enablement of the AMD IOMMU driver.

Quoted 3 lines

I've said this many times lately. There are other things in this driver that have no upstream justification too, like nesting "support".

Jason, there is no need to keep repeating and polluting this thread. I am happy to discuss and clarify any points of your concern on the "nesting support" in a separate discussion thread :)

Quoted 3 lines

Please organize this SNP support into series that makes sense and are self complete :( I'm not sure a 51 patch series is a productive way to approach this..

We have discussed with Michael Roth (the author of the series "Add AMD Secure Nested Paging (SEV-SNP) Hypervisor Support"​), and he will start including the removed function in the next revision of his series.

Regards,
Suravee

#5 lore raw
Quoted 7 lines · Suravee
Quoted 3 lines

I've said this many times lately. There are other things in this driver that have no upstream justification too, like nesting "support".

Jason, there is no need to keep repeating and polluting this thread. I am happy to discuss and clarify any points of your concern on the "nesting support" in a separate discussion thread :)

It is not polluting this thread. We are, again, asking AMD to follow the rules please.

None of the other threads about the nesting has resulted in acceptance that code needs to be removed as well. Go respond in one of those if you have something to add.

Jason