mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-27 03:49:57 -04:00
iommu/amd: Clean up RMP entries for IOMMU pages during SNP shutdown
Add a new IOMMU API interface amd_iommu_snp_disable() to transition IOMMU pages to Hypervisor state from Reclaim state after SNP_SHUTDOWN_EX command. Invoke this API from the CCP driver after SNP_SHUTDOWN_EX command. Signed-off-by: Ashish Kalra <ashish.kalra@amd.com> Signed-off-by: Michael Roth <michael.roth@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20240126041126.1927228-20-michael.roth@amd.com
This commit is contained in:
committed by
Borislav Petkov (AMD)
parent
a867ad6b34
commit
f366a8dac1
@@ -26,6 +26,7 @@
|
||||
#include <linux/fs.h>
|
||||
#include <linux/fs_struct.h>
|
||||
#include <linux/psp.h>
|
||||
#include <linux/amd-iommu.h>
|
||||
|
||||
#include <asm/smp.h>
|
||||
#include <asm/cacheflush.h>
|
||||
@@ -1655,6 +1656,25 @@ static int __sev_snp_shutdown_locked(int *error)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* SNP_SHUTDOWN_EX with IOMMU_SNP_SHUTDOWN set to 1 disables SNP
|
||||
* enforcement by the IOMMU and also transitions all pages
|
||||
* associated with the IOMMU to the Reclaim state.
|
||||
* Firmware was transitioning the IOMMU pages to Hypervisor state
|
||||
* before version 1.53. But, accounting for the number of assigned
|
||||
* 4kB pages in a 2M page was done incorrectly by not transitioning
|
||||
* to the Reclaim state. This resulted in RMP #PF when later accessing
|
||||
* the 2M page containing those pages during kexec boot. Hence, the
|
||||
* firmware now transitions these pages to Reclaim state and hypervisor
|
||||
* needs to transition these pages to shared state. SNP Firmware
|
||||
* version 1.53 and above are needed for kexec boot.
|
||||
*/
|
||||
ret = amd_iommu_snp_disable();
|
||||
if (ret) {
|
||||
dev_err(sev->dev, "SNP IOMMU shutdown failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
sev->snp_initialized = false;
|
||||
dev_dbg(sev->dev, "SEV-SNP firmware shutdown\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user