[PATCH v2 0/2] Apply RMP table fixups for kexec.

Ashish Kalra posted 2 patches 1 year, 9 months ago
There is a newer version of this series
arch/x86/include/asm/e820/api.h |  3 +++
arch/x86/include/asm/sev.h      |  2 ++
arch/x86/kernel/e820.c          |  7 +++++-
arch/x86/mm/mem_encrypt.c       |  3 +++
arch/x86/virt/svm/sev.c         | 44 +++++++++++++++++++++++++++++++++
5 files changed, 58 insertions(+), 1 deletion(-)
[PATCH v2 0/2] Apply RMP table fixups for kexec.
Posted by Ashish Kalra 1 year, 9 months ago
From: Ashish Kalra <ashish.kalra@amd.com>

Handle cases where the RMP table placement in the BIOS is
not 2M aligned and then the kexec kernel could try to allocate
from within that chunk and that causes a fatal RMP fault.
Check if RMP table start & end physical range in e820_table
is not aligned to 2MB and in that case use e820__range_update()
to map this range to reserved.

The callback to apply these RMP table fixups needs to be called
after the e820 tables are setup/populated and before the e820 map
has been converted to the standard Linux memory resources and e820 map
is no longer used and modifying it has no effect.

v2:
- Remove overriding e820__memory_setup_default() to invoke
  snp_rmptable_e820_fixup() to apply the RMP table fixups.
- This callback snp_rmptable_e820_fixup() is now invoked
  after e820__memory_setup() and before e820__reserve_resources().
- Expose e820 API interfaces to update e820_table_kexec and
  e820_table_firmware externally.
- snp_rmptable_e820_fixup() now calls these new external API
  interfaces to update e820_table_kexec and e820_table_firmware.


Ashish Kalra (2):
  x86/e820: Expose API to update e820 kexec and firmware tables
    externally.
  x86/sev: Add callback to apply RMP table fixups for kexec.

 arch/x86/include/asm/e820/api.h |  3 +++
 arch/x86/include/asm/sev.h      |  2 ++
 arch/x86/kernel/e820.c          |  7 +++++-
 arch/x86/mm/mem_encrypt.c       |  3 +++
 arch/x86/virt/svm/sev.c         | 44 +++++++++++++++++++++++++++++++++
 5 files changed, 58 insertions(+), 1 deletion(-)

-- 
2.34.1
Re: [PATCH v2 0/2] Apply RMP table fixups for kexec.
Posted by Borislav Petkov 1 year, 9 months ago
Drop linux-tip-commits@vger.kernel.org from Cc.

On Mon, Apr 15, 2024 at 09:08:56PM +0000, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@amd.com>
> 
> Handle cases where the RMP table placement in the BIOS is
> not 2M aligned and then the kexec kernel could try to allocate
> from within that chunk and that causes a fatal RMP fault.

Is this something that happens on existing systems currently so that it
needs to be fixed upstream?

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Re: [PATCH v2 0/2] Apply RMP table fixups for kexec.
Posted by Kalra, Ashish 1 year, 9 months ago
Hello Boris,

On 4/20/2024 6:08 AM, Borislav Petkov wrote:
> Drop linux-tip-commits@vger.kernel.org from Cc.
>
> On Mon, Apr 15, 2024 at 09:08:56PM +0000, Ashish Kalra wrote:
>> From: Ashish Kalra <ashish.kalra@amd.com>
>>
>> Handle cases where the RMP table placement in the BIOS is
>> not 2M aligned and then the kexec kernel could try to allocate
>> from within that chunk and that causes a fatal RMP fault.
> Is this something that happens on existing systems currently so that it
> needs to be fixed upstream?

Patch 2/2 - includes the following Fixes tag, do i need to include the 
Fixes tag in the cover letter too ?

Fixes: c3b86e61b756 ("x86/cpufeatures: Enable/unmask SEV-SNP CPU feature")

Thanks,
Ashish
Re: [PATCH v2 0/2] Apply RMP table fixups for kexec.
Posted by Borislav Petkov 1 year, 9 months ago
On Wed, Apr 24, 2024 at 02:10:03PM -0500, Kalra, Ashish wrote:
> Patch 2/2 - includes the following Fixes tag, do i need to include the Fixes
> tag in the cover letter too ?
> 
> Fixes: c3b86e61b756 ("x86/cpufeatures: Enable/unmask SEV-SNP CPU feature")

People slap Fixes tags on pretty much every patch nowadays. I'd prefer
it if you spell it out in the future what the problem is you're
encountering so that I can make a decision where to route the patches
through.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette