On Fri, 2023-02-24 at 13:59 +0800, Yuan Yao wrote: > > > +        * Make sure only one CPU fiddles with the realmode stack > > +        */ > > +.Llock_rm: > > +       btl     $0, tr_lock > > +       jnc     2f > > +       pause > > +       jmp     .Llock_rm > > +2: > > +       lock > > +       btsl    $0, tr_lock > > +       jc      .Llock_rm > > + > > Looks these changes should be applied to trampoline_start64() > yet, which is used for boot up APs when apic->wakeup_secondary_cpu_64 > is available, e.g when ACPI_MADT_TYPE_MULTIPROC_WAKEUP is available. > > One case I know is the INTEL TD guest, which using the MADT wakeup > for AP wake up now. Yeah. I think we could probably pull that all out into a separate asm "load_realmode_esp" function which takes the lock and actually does the 'movl $rm_stack_end, %esp'. Then we call it from all the places which currently use $rm_stack_end, including sev_es_trampoline_start (even though we currently disable parallel startup there because CPUID doesn't work that early). Oh... except of course it can't be a function because we haven't got a stack, have we? It's a macro. Usama, are you happy using .macro in gas?