[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch v3 34/36] x86/smpboot: Implement a bit spinlock to protect the realmode stack
- To: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
- From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
- Date: Tue, 9 May 2023 15:13:40 +0200
- Cc: LKML <linux-kernel@xxxxxxxxxxxxxxx>, x86@xxxxxxxxxx, David Woodhouse <dwmw2@xxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Brian Gerst <brgerst@xxxxxxxxx>, Arjan van de Veen <arjan@xxxxxxxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Paul McKenney <paulmck@xxxxxxxxxx>, Tom Lendacky <thomas.lendacky@xxxxxxx>, Sean Christopherson <seanjc@xxxxxxxxxx>, Oleksandr Natalenko <oleksandr@xxxxxxxxxxxxxx>, Paul Menzel <pmenzel@xxxxxxxxxxxxx>, "Guilherme G. Piccoli" <gpiccoli@xxxxxxxxxx>, Piotr Gorski <lucjan.lucjanov@xxxxxxxxx>, Usama Arif <usama.arif@xxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Russell King <linux@xxxxxxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, Catalin Marinas <catalin.marinas@xxxxxxx>, Will Deacon <will@xxxxxxxxxx>, Guo Ren <guoren@xxxxxxxxxx>, linux-csky@xxxxxxxxxxxxxxx, Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>, linux-mips@xxxxxxxxxxxxxxx, "James E.J. Bottomley" <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>, Helge Deller <deller@xxxxxx>, linux-parisc@xxxxxxxxxxxxxxx, Paul Walmsley <paul.walmsley@xxxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, linux-riscv@xxxxxxxxxxxxxxxxxxx, Mark Rutland <mark.rutland@xxxxxxx>, Sabin Rapan <sabrapan@xxxxxxxxxx>, "Michael Kelley (LINUX)" <mikelley@xxxxxxxxxxxxx>, David Woodhouse <dwmw@xxxxxxxxxxxx>
- Delivery-date: Tue, 09 May 2023 13:15:36 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Mon, May 08, 2023 at 09:44:22PM +0200, Thomas Gleixner wrote:
> @@ -252,6 +252,17 @@ SYM_INNER_LABEL(secondary_startup_64_no_
> movq TASK_threadsp(%rax), %rsp
>
> /*
> + * Now that this CPU is running on its own stack, drop the realmode
> + * protection. For the boot CPU the pointer is NULL!
> + */
> + movq trampoline_lock(%rip), %rax
movl $0, (%rax)
> +.Lsetup_gdt:
> + /*
> * We must switch to a new descriptor in kernel space for the GDT
> * because soon the kernel won't have access anymore to the userspace
> * addresses where we're currently running on. We have to do that here
> --- a/arch/x86/realmode/rm/trampoline_64.S
> +++ b/arch/x86/realmode/rm/trampoline_64.S
> @@ -37,6 +37,24 @@
> .text
> .code16
>
> +.macro LOAD_REALMODE_ESP
> + /*
> + * 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\@
Do we really care about performance here; or should we pick the simpler
form? Also, 'lock' is a prefix, not an instruction.
.Llock_rm\@:
lock btsl $0, tr_lock;
jnc 2f
pause
jmp .Llock_rm\@
2:
> +
> + # Setup stack
> + movl $rm_stack_end, %esp
> +.endm
> +
> .balign PAGE_SIZE
|