Re: [PATCH v2] x86/mm/kaiser: Prepare the x86/entry assembly code for entry/exit CR3 switching

From: Thomas Gleixner
Date: Mon Nov 27 2017 - 08:37:02 EST


On Mon, 27 Nov 2017, Josh Poimboeuf wrote:
> On Sun, Nov 26, 2017 at 03:55:53PM +0100, Ingo Molnar wrote:
> > @@ -198,6 +201,14 @@ ENTRY(entry_SYSCALL_64)
> >
> > swapgs
> > movq %rsp, PER_CPU_VAR(rsp_scratch)
> > +
> > + /*
> > + * The kernel CR3 is needed to map the process stack, but we
> > + * need a scratch register to be able to load CR3. %rsp is
> > + * clobberable right now, so use it as a scratch register.
> > + * %rsp will look crazy here for a couple instructions.
> > + */
> > + SWITCH_TO_KERNEL_CR3 scratch_reg=%rsp
> > movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
>
> I think it doesn't make sense to have a SWITCH_TO_KERNEL_CR3 here. This
> code is the (future) kaiser-disabled path, where SWITCH_TO_KERNEL_CR3 is
> a no-op anyway.

Yes, Borislav noticed that as well. That's a left over from the early
versions where the trampoline did not exist.

Thanks,

tglx