[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171125163956.nrxpobf5xetnavo6@pd.tnic>
Date: Sat, 25 Nov 2017 17:39:56 +0100
From: Borislav Petkov <bp@...en8.de>
To: Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org,
Dave Hansen <dave.hansen@...ux.intel.com>,
Andy Lutomirski <luto@...capital.net>,
Thomas Gleixner <tglx@...utronix.de>,
"H . Peter Anvin" <hpa@...or.com>,
Peter Zijlstra <peterz@...radead.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH 20/43] x86/entry: Clean up SYSENTER_stack code
On Fri, Nov 24, 2017 at 06:23:48PM +0100, Ingo Molnar wrote:
> From: Andy Lutomirski <luto@...nel.org>
>
> The existing code was a mess, mainly because C arrays are nasty.
> Turn SYSENTER_stack into a struct, add a helper to find it, and do
> all the obvious cleanups this enables.
>
> Signed-off-by: Andy Lutomirski <luto@...nel.org>
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> Cc: Borislav Petkov <bpetkov@...e.de>
> Cc: Brian Gerst <brgerst@...il.com>
> Cc: Dave Hansen <dave.hansen@...el.com>
> Cc: Josh Poimboeuf <jpoimboe@...hat.com>
> Cc: Linus Torvalds <torvalds@...ux-foundation.org>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Link: https://lkml.kernel.org/r/38ff640712c9b591b32de24a080daf13afaba234.1511497875.git.luto@kernel.org
> Signed-off-by: Ingo Molnar <mingo@...nel.org>
> ---
...
> diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
> index 61b1af88ac07..46c0995344aa 100644
> --- a/arch/x86/kernel/asm-offsets.c
> +++ b/arch/x86/kernel/asm-offsets.c
> @@ -94,10 +94,8 @@ void common(void) {
> BLANK();
> DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
>
> - /* Offset from cpu_tss to SYSENTER_stack */
> - OFFSET(CPU_TSS_SYSENTER_stack, tss_struct, SYSENTER_stack);
> - /* Size of SYSENTER_stack */
> - DEFINE(SIZEOF_SYSENTER_stack, sizeof(((struct tss_struct *)0)->SYSENTER_stack));
> + OFFSET(TSS_STRUCT_SYSENTER_stack, tss_struct, SYSENTER_stack);
> + DEFINE(SIZEOF_SYSENTER_stack, sizeof(struct SYSENTER_stack));
>
> /* Layout info for cpu_entry_area */
> OFFSET(CPU_ENTRY_AREA_tss, cpu_entry_area, tss);
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index 6b949e6ea0f9..f9c7e6852874 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -1332,12 +1332,7 @@ void enable_sep_cpu(void)
>
> tss->x86_tss.ss1 = __KERNEL_CS;
> wrmsr(MSR_IA32_SYSENTER_CS, tss->x86_tss.ss1, 0);
> -
> - wrmsr(MSR_IA32_SYSENTER_ESP,
> - (unsigned long)&get_cpu_entry_area(cpu)->tss +
> - offsetofend(struct tss_struct, SYSENTER_stack),
> - 0);
> -
> + wrmsr(MSR_IA32_SYSENTER_ESP, (unsigned long)(cpu_SYSENTER_stack(cpu) + 1), 0);
> wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long)entry_SYSENTER_32, 0);
Right, so we have now two TSS thingies, AFAICT:
tss = &per_cpu(cpu_tss, cpu);
which is cpu_tss and then indirectly, we have also:
&get_cpu_entry_area((cpu))->tss
And those are two different things in my guest here:
[ 0.044002] tss: 0xf5747000
[ 0.044706] entry area tss: 0xffef1000
What is the logic here? We carry two TSSs per CPU - one which is RO
for the entry area and the other is the actual cpu_tss thing? Or am I
misreading it?
Thx.
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
Powered by blists - more mailing lists