Re: [PATCH v5 10/20] x86/decompressor: Call trampoline directly from C code

From: Ard Biesheuvel
Date: Thu Jun 08 2023 - 04:05:19 EST


On Wed, 7 Jun 2023 at 20:09, Yunhong Jiang
<yunhong.jiang@xxxxxxxxxxxxxxx> wrote:
>
> On Wed, Jun 07, 2023 at 09:23:32AM +0200, Ard Biesheuvel wrote:
> > Instead of returning to the asm calling code to invoke the trampoline,
> > call it straight from the C code that sets the scene. That way, the
> > struct return type is no longer needed for returning two values, and the
> > call can be made conditional more cleanly in a subsequent patch.
> >
> > Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
> > Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
> > ---
> > arch/x86/boot/compressed/head_64.S | 20 +++-----------
> > arch/x86/boot/compressed/pgtable_64.c | 28 ++++++++------------
> > 2 files changed, 15 insertions(+), 33 deletions(-)
> >
...
> > diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c
> > index d66639c961b8eeda..1d28ad95ea839531 100644
> > --- a/arch/x86/boot/compressed/pgtable_64.c
> > +++ b/arch/x86/boot/compressed/pgtable_64.c
> > @@ -16,11 +16,6 @@ unsigned int __section(".data") pgdir_shift = 39;
> > unsigned int __section(".data") ptrs_per_p4d = 1;
> > #endif
> >
> > -struct paging_config {
> > - unsigned long trampoline_start;
> > - unsigned long l5_required;
> > -};
> > -
> > /* Buffer to preserve trampoline memory */
> > static char trampoline_save[TRAMPOLINE_32BIT_SIZE];
> >
> > @@ -106,10 +101,10 @@ static unsigned long find_trampoline_placement(void)
> > return bios_start - TRAMPOLINE_32BIT_SIZE;
> > }
> >
> > -struct paging_config paging_prepare(void *rmode)
> > +asmlinkage void set_paging_levels(void *rmode)
>
> Can you please change the refer to paging_prepare() in the comments above also?

You mean the below, right?

--- a/arch/x86/boot/compressed/pgtable_64.c
+++ b/arch/x86/boot/compressed/pgtable_64.c
@@ -24,7 +24,7 @@ static char trampoline_save[TRAMPOLINE_32BIT_SIZE];
* purposes.
*
* Avoid putting the pointer into .bss as it will be cleared between
- * paging_prepare() and extract_kernel().
+ * set_paging_levels() and extract_kernel().
*/
unsigned long *trampoline_32bit __section(".data");