From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751724AbdKYQkG (ORCPT ); Sat, 25 Nov 2017 11:40:06 -0500 Received: from mail.skyhub.de ([5.9.137.197]:45038 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbdKYQkE (ORCPT ); Sat, 25 Nov 2017 11:40:04 -0500 Date: Sat, 25 Nov 2017 17:39:56 +0100 From: Borislav Petkov To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Dave Hansen , Andy Lutomirski , Thomas Gleixner , "H . Peter Anvin" , Peter Zijlstra , Linus Torvalds Subject: Re: [PATCH 20/43] x86/entry: Clean up SYSENTER_stack code Message-ID: <20171125163956.nrxpobf5xetnavo6@pd.tnic> References: <20171124172411.19476-1-mingo@kernel.org> <20171124172411.19476-21-mingo@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20171124172411.19476-21-mingo@kernel.org> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 24, 2017 at 06:23:48PM +0100, Ingo Molnar wrote: > From: Andy Lutomirski > > 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 > Signed-off-by: Thomas Gleixner > Cc: Borislav Petkov > Cc: Brian Gerst > Cc: Dave Hansen > Cc: Josh Poimboeuf > Cc: Linus Torvalds > Cc: Peter Zijlstra > Link: https://lkml.kernel.org/r/38ff640712c9b591b32de24a080daf13afaba234.1511497875.git.luto@kernel.org > Signed-off-by: Ingo Molnar > --- ... > 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.