Re: [PATCH] x86/sev: Apply RMP table fixups for kexec.
From: Kalra, Ashish
Date: Tue Apr 02 2024 - 15:34:02 EST
On 4/2/2024 1:50 PM, Borislav Petkov wrote:
On Tue, Apr 02, 2024 at 01:41:05PM -0500, Kalra, Ashish wrote:
But, that's what the e820 table fixup is doing,
And can it be doing it in snp_probe_rmptable_info() where all the RMP
table stuff is being done?
The e820 fixups has to be done on both e820_table_kexec and
e820_table_firmware (to handle both kexec variants) and this has to be
done when e820_table is used to populate both e820_table_kexec and
e820_table_firmware and this is done in e820__memory_setup().
But, snp_probe_rmptable_info() is called as part of early_cpu_init() ->
early_identify_cpu() which is called earlier than e820__memory_setup()
and e820 tables are setup much later e820__memory_setup().
And we can't do this in snp_rmptable_init() as e820_table_firmware can't
be fixed at that point and by that time this table has been mapped into
sysfs (/sys/firmware) which is used by kexec -c variant.
The function e820__memory_setup() has an optional platform quirk
available to override/pick up the firmware/bootloader e820 map, and
that's why i am using this platform specific quirk to override it with
the SNP specific RMP table e820 fixup function which internally calls
e820__memory_setup_default() to pass the firmware/bootloader e820 map
(set in e820_table) and then add RMP table fixups on top of it.
Thanks, Ashish