Re: [PATCH v3 0/2] x86: enforce and cleanup RIP-relative accesses in early boot code

From: Ard Biesheuvel
Date: Sat Feb 03 2024 - 05:28:25 EST


On Sat, 3 Feb 2024 at 11:20, Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Fri, Feb 02, 2024 at 04:22:02PM -0800, Kevin Loughlin wrote:
> > True. I just think it would be better to have an upstream fix for
> > clang builds of SEV-SNP guests; I believe the first such SEV-SNP code
> > was merged in 5.19 if I'm not mistaken.
>
> SNP host support is not upstream yet. So we'd be supporting something
> which is out-of-tree. Lemme see how ugly it'll get...
>

The minimal fix doesn't look that bad IMHO. Note that this version is
based on your patch that removes
CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT, and we'd need to see whether
or not to backport that as well.

arch/x86/include/asm/asm.h | 13 +++++++++++++
arch/x86/include/asm/mem_encrypt.h | 13 ++++++++-----
arch/x86/kernel/sev-shared.c | 12 ++++++------
arch/x86/kernel/sev.c | 9 +++++++--
arch/x86/mm/mem_encrypt_identity.c | 27 ++++++++++++---------------
5 files changed, 46 insertions(+), 28 deletions(-)

https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?h=x86-pie-for-sev-v4a&id=65d0e5f4ed6ca807cdf28a1c5c0389af2c9f9bda