mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
x86/sev: Create a function to clear/zero the RMP
In preparation for delayed SNP initialization and disablement on shutdown, create a function, clear_rmp(), that clears the RMP bookkeeping area and the RMP entries. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://patch.msgid.link/20260324161301.1353976-2-tycho@kernel.org
This commit is contained in:
parent
531397a803
commit
9c016c3f49
|
|
@ -242,6 +242,32 @@ void __init snp_fixup_e820_tables(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void clear_rmp(void)
|
||||
{
|
||||
unsigned int i;
|
||||
u64 val;
|
||||
|
||||
if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
|
||||
return;
|
||||
|
||||
/* Clearing the RMP while SNP is enabled will cause an exception */
|
||||
rdmsrq(MSR_AMD64_SYSCFG, val);
|
||||
if (WARN_ON_ONCE(val & MSR_AMD64_SYSCFG_SNP_EN))
|
||||
return;
|
||||
|
||||
memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
|
||||
|
||||
for (i = 0; i < rst_max_index; i++) {
|
||||
struct rmp_segment_desc *desc;
|
||||
|
||||
desc = rmp_segment_table[i];
|
||||
if (!desc)
|
||||
continue;
|
||||
|
||||
memset(desc->rmp_entry, 0, desc->size);
|
||||
}
|
||||
}
|
||||
|
||||
static bool __init alloc_rmp_segment_desc(u64 segment_pa, u64 segment_size, u64 pa)
|
||||
{
|
||||
u64 rst_index, rmp_segment_size_max;
|
||||
|
|
@ -484,7 +510,6 @@ static bool __init setup_rmptable(void)
|
|||
*/
|
||||
int __init snp_rmptable_init(void)
|
||||
{
|
||||
unsigned int i;
|
||||
u64 val;
|
||||
|
||||
if (WARN_ON_ONCE(!cc_platform_has(CC_ATTR_HOST_SEV_SNP)))
|
||||
|
|
@ -504,19 +529,7 @@ int __init snp_rmptable_init(void)
|
|||
if (val & MSR_AMD64_SYSCFG_SNP_EN)
|
||||
goto skip_enable;
|
||||
|
||||
/* Zero out the RMP bookkeeping area */
|
||||
memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
|
||||
|
||||
/* Zero out the RMP entries */
|
||||
for (i = 0; i < rst_max_index; i++) {
|
||||
struct rmp_segment_desc *desc;
|
||||
|
||||
desc = rmp_segment_table[i];
|
||||
if (!desc)
|
||||
continue;
|
||||
|
||||
memset(desc->rmp_entry, 0, desc->size);
|
||||
}
|
||||
clear_rmp();
|
||||
|
||||
/* MtrrFixDramModEn must be enabled on all the CPUs prior to enabling SNP. */
|
||||
on_each_cpu(mfd_enable, NULL, 1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user