[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4ljfvg7c23g2wx4hcqz6x6tx7uvp6fffayqvu4ptsmfqajlujr@zngokbd2awma>
Date: Wed, 31 Jan 2024 10:20:28 +0200
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Kevin Loughlin <kevinloughlin@...gle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
Nick Desaulniers <ndesaulniers@...gle.com>, Justin Stitt <justinstitt@...gle.com>,
Tom Lendacky <thomas.lendacky@....com>, Pankaj Gupta <pankaj.gupta@....com>,
Hou Wenlong <houwenlong.hwl@...group.com>, Ard Biesheuvel <ardb@...nel.org>,
Dionna Glaze <dionnaglaze@...gle.com>, Brijesh Singh <brijesh.singh@....com>,
Michael Roth <michael.roth@....com>, linux-kernel@...r.kernel.org, llvm@...ts.linux.dev,
linux-coco@...ts.linux.dev, Ashish Kalra <ashish.kalra@....com>,
Andi Kleen <ak@...ux.intel.com>, Adam Dunlap <acdunlap@...gle.com>,
Peter Gonda <pgonda@...gle.com>, Jacob Xu <jacobhxu@...gle.com>,
Sidharth Telang <sidtelang@...gle.com>
Subject: Re: [PATCH v3 1/2] x86/sev: enforce RIP-relative accesses in early
SEV/SME code
On Tue, Jan 30, 2024 at 10:08:44PM +0000, Kevin Loughlin wrote:
> diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h
> index 359ada486fa9..b65e66ee79c4 100644
> --- a/arch/x86/include/asm/mem_encrypt.h
> +++ b/arch/x86/include/asm/mem_encrypt.h
> @@ -17,6 +17,20 @@
>
> #include <asm/bootparam.h>
>
> +/*
> + * Like the address operator "&", evaluates to the address of a LHS variable
> + * "var", but also enforces the use of RIP-relative logic. This macro can be
> + * used to safely access global data variables prior to kernel relocation.
> + */
> +#define RIP_RELATIVE_ADDR(var) \
> +({ \
> + void *rip_rel_ptr; \
> + asm ("lea "#var"(%%rip), %0" \
> + : "=r" (rip_rel_ptr) \
> + : "p" (&var)); \
> + rip_rel_ptr; \
> +})
> +
I don't think it is the right place for the macro. The next patch uses for
things unrelated to memory encryption.
> @@ -239,14 +244,14 @@ unsigned long __head __startup_64(unsigned long physaddr,
> */
>
> next_pgt_ptr = fixup_pointer(&next_early_pgt, physaddr);
> - pud = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr);
> - pmd = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr);
> + early_dynamic_pgts_ptr = fixup_pointer(early_dynamic_pgts, physaddr);
> + pud = (pudval_t *) early_dynamic_pgts_ptr[(*next_pgt_ptr)++];
> + pmd = (pmdval_t *) early_dynamic_pgts_ptr[(*next_pgt_ptr)++];
>
This change doesn't belong to this patch. Maybe move it into the next
patch and combine with removing fixup_pointer().
--
Kiryl Shutsemau / Kirill A. Shutemov
Powered by blists - more mailing lists