Re: [PATCH v3 2/2] x86/head64: Replace pointer fixups with RIP_RELATIVE_ADDR()

From: Kevin Loughlin
Date: Thu Feb 01 2024 - 11:38:44 EST


On Wed, Jan 31, 2024 at 12:24 AM Kirill A. Shutemov
<kirill.shutemov@xxxxxxxxxxxxxxx> wrote:
>
> On Tue, Jan 30, 2024 at 10:08:45PM +0000, Kevin Loughlin wrote:
> > @@ -594,15 +579,15 @@ static void set_bringup_idt_handler(gate_desc *idt, int n, void *handler)
> > /* This runs while still in the direct mapping */
> > static void __head startup_64_load_idt(unsigned long physbase)
> > {
> > - struct desc_ptr *desc = fixup_pointer(&bringup_idt_descr, physbase);
> > - gate_desc *idt = fixup_pointer(bringup_idt_table, physbase);
> > + struct desc_ptr *desc = RIP_RELATIVE_ADDR(bringup_idt_descr);
> > + gate_desc *idt = RIP_RELATIVE_ADDR(bringup_idt_table);
> >
> >
> > if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT)) {
> > void *handler;
> >
> > /* VMM Communication Exception */
> > - handler = fixup_pointer(vc_no_ghcb, physbase);
> > + handler = RIP_RELATIVE_ADDR(vc_no_ghcb);
> > set_bringup_idt_handler(idt, X86_TRAP_VC, handler);
> > }
> >
>
> Looks like you removed all physbase users in the function. No need to pass
> it to it.

Thanks, will fix.

>
> > @@ -629,7 +614,7 @@ void early_setup_idt(void)
> > void __head startup_64_setup_env(unsigned long physbase)
> > {
> > /* Load GDT */
> > - startup_gdt_descr.address = (unsigned long)fixup_pointer(startup_gdt, physbase);
> > + startup_gdt_descr.address = (unsigned long)RIP_RELATIVE_ADDR(startup_gdt);
> > native_load_gdt(&startup_gdt_descr);
> >
> > /* New GDT is live - reload data segment registers */
>
> With startup_64_load_idt() fixed, no users for physbase in this function
> either.

Ditto.