Re: [PATCHv2 13/13] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

From: Huang, Kai
Date: Tue Oct 24 2023 - 23:51:12 EST



> > + .text
> > + .align PAGE_SIZE
> > +SYM_FUNC_START(asm_acpi_mp_play_dead)
> > + /* Load address of reset vector into RCX to jump when kernel is ready */
> > + movq acpi_mp_reset_vector_paddr(%rip), %rcx
> > +
> > + /* Turn off global entries. Following CR3 write will flush them. */
> > + movq %cr4, %rdx
> > + andq $~(X86_CR4_PGE), %rdx
> > + movq %rdx, %cr4
> > +
> > + /* Switch to identity mapping */
> > + movq acpi_mp_pgd(%rip), %rax
> > + movq %rax, %cr3
>
> Do we need to switch back to kernel direct-map page table after CPU is wake up
> again? We do support normal CPU offline/online, but not limited to kexec,
> right?

Please ignore this. I found if I am reading right even for TDX guest the new
online cpu will start with trampoline_start64 assembly, so it will load kernel
page table anyway. Sorry for the noise.

[...]


> > + for (int i = 0; i < nr_pfn_mapped; i++) {
> > + unsigned long mstart, mend;
> > + mstart = pfn_mapped[i].start << PAGE_SHIFT;
> > + mend = pfn_mapped[i].end << PAGE_SHIFT;
> > + if (kernel_ident_mapping_init(&info, pgd, mstart, mend))
> > + return -ENOMEM;
> > + }
>
> This is for kexec() IIUC. Add a comment?
>
> If we consider normal CPU offline/online case, then I don't think we need the
> identity mapping for all memory?
>

Also this one. :-)

>