Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1852922rda; Tue, 24 Oct 2023 05:33:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7aOeLQXvZ4MTnFXSkBYVkp9YrtkE+F2bw54cA9Hqgu8jv6KK0G6mpL7UryL1EIsaM7bv9 X-Received: by 2002:a17:903:6d0:b0:1ca:de41:753f with SMTP id kj16-20020a17090306d000b001cade41753fmr4893960plb.15.1698150820236; Tue, 24 Oct 2023 05:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698150820; cv=none; d=google.com; s=arc-20160816; b=EgdVQdUsZgrCb46QRdBUrcK/QNMicCME9TOnalyIFCy15Ye9Esv2kmrmSFppiJ+gD6 BtieT+3xU5KDxsYj2B4e1SpVkl8DBCEaFaCBJSB5KHZdJ25hX0FQC5AL1sC9xMR8sJon m1bSPCLlepXVh1ozNsaiOAwnwHuFeJuB/wigGuEHbzBuzwWsu5KR3XIUG5tS9Ou+xcBo qKuZNRuhHc9/jNbl7d8JOmQcpNd65gaMYLkQOKdFikEJPqqDeGGNxxYzp35Gv/ArOOrw vdP1lzb3i9+j4UFU8bxVxWCSNwa4A/ABzePMWoYkSU9bF669n44DZ58wYspY2C/WC3EN Nc8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PHQr1DjZxvInvZ0D3s16y341VBd8U9kidRKMaeuvJ30=; fh=OeqABZGhkWuMQua3HfO6T/DfmgPwdiEhScz9hFdobNs=; b=IkCj+I1QV/dmAhv3g2DtB+V6CUS1Pxpps7PmhBEtHb7MsmDahcGo2BEuc8Wi3EjUNJ DTWoYCMKte9AW1hJ27CG+Ks51rOOS+Ecnj1KOF+aq5hSFpBbzhcvEY/LNVNJOGhbirT/ p4SZJTOWBDX2mHyKzjP76XLVhLRkr3Txn4/RpMjjSH1RIxLZnVArq7BP+2h1egArE4Ob 6sNMhNHeuCwMGT/aYtJ7zFQ6xG88Sf4YyBNtSSEWlvkl2FKyOlUW6JVMmac1gwF7PCVb UjDYd8rxQQGNEtVJDzXyYEK7TNdN4x+F/9KBMz1mtPkFE/0DUjnbRj51WfuqI8Trr91d Z+7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="A/Sx1kzA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id y6-20020a170902864600b001c3da86939csi8028640plt.546.2023.10.24.05.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 05:33:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="A/Sx1kzA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 56ADA80C7756; Tue, 24 Oct 2023 05:33:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232323AbjJXMd0 (ORCPT + 99 others); Tue, 24 Oct 2023 08:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbjJXMdY (ORCPT ); Tue, 24 Oct 2023 08:33:24 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9062EA2 for ; Tue, 24 Oct 2023 05:33:22 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-53e751aeb3cso6799754a12.2 for ; Tue, 24 Oct 2023 05:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698150801; x=1698755601; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PHQr1DjZxvInvZ0D3s16y341VBd8U9kidRKMaeuvJ30=; b=A/Sx1kzAXa9X1HqsuC6GNtNsXNSq5CqtUPBBo58u2HD055W5nqoYDOJakAafxRN87k RUr70kGfO85YdZgFcNjWf53dBjtXsmzmzZ6mY/HNx06mq2Tn35KtACXBCjhMtWezt7lr YQn5TFYmHQSy53ln00lkqfsh/N4jp5ZfQxVmbkDa4B9lIpJCtF2oGWqLng1PMLd3Xp1c hND3n3uHcOZSfH1qZFgj3P0OD4bTKIj4iVUPybGfT6odVpH333MrPJsnbBhXEchxbK9x OXwHOq+usMSet7jJ7Etc2DydeQfkPdNPYT4BFwy88JRCc1Bqx1qQty6RhROjR362MkV7 BplQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698150801; x=1698755601; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PHQr1DjZxvInvZ0D3s16y341VBd8U9kidRKMaeuvJ30=; b=hcuCBdG9QUhzVAyouu8cWIQ3DMgFY88PuBdyIZR1A7ZaL6PsF7msaNhilpL+H/vTxa Ae/L+4eAJrwmEx1Z9NuCzXg0oVIJG3P+R/wOQ891U3sO+rNS5kVKxWHRlY6QZZ0hJmWO nJv5pcQCCmPP/pjpjoHse7JQhbfTagP0g1zeJM8YRzxU4eBPxdwSsVuI+LbG5/8jiKMm tukzFrEcX0f7ke5H27aVL5RPDKUcx7hRxq0wKY9O/n0DGxZVlSL4RP4aeuKAgA0roMO4 xpdG98gAIBgVZxVD9U2cGD06B0J5H0q3XnfeGCP3M0gBkarZB3cJut8BrQx1Gxl5BJ5t DiSg== X-Gm-Message-State: AOJu0YyzomEQ38sBcZ2lLOVJSSoR3JGiMq/50p9YrX6ELpeu5kVb/59f BCRLc7zY8b5cYcKcYC6E2lL0+uZ2yVeSpO7gSX4= X-Received: by 2002:a05:6402:3484:b0:53f:25c4:357f with SMTP id v4-20020a056402348400b0053f25c4357fmr8597341edc.34.1698150800722; Tue, 24 Oct 2023 05:33:20 -0700 (PDT) MIME-Version: 1.0 References: <20231023211730.40566-1-brgerst@gmail.com> <20231023211730.40566-5-brgerst@gmail.com> In-Reply-To: <20231023211730.40566-5-brgerst@gmail.com> From: Uros Bizjak Date: Tue, 24 Oct 2023 14:33:08 +0200 Message-ID: Subject: Re: [PATCH 4/9] x86/percpu/64: Remove fixed_percpu_data To: Brian Gerst Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Ingo Molnar , Thomas Gleixner , Borislav Petkov , "H . Peter Anvin" , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 05:33:35 -0700 (PDT) On Mon, Oct 23, 2023 at 11:17=E2=80=AFPM Brian Gerst wr= ote: > > Now that the stack protector canary value is a normal percpu variable, > fixed_percpu_data is unused and can be removed. > > Signed-off-by: Brian Gerst > --- > arch/x86/include/asm/processor.h | 13 +++++-------- > arch/x86/kernel/cpu/common.c | 4 ---- > arch/x86/kernel/head_64.S | 12 ++++++------ > arch/x86/kernel/vmlinux.lds.S | 6 ------ > arch/x86/tools/relocs.c | 1 - > arch/x86/xen/xen-head.S | 12 ++++++++---- > 6 files changed, 19 insertions(+), 29 deletions(-) > > diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/proc= essor.h > index 04371f60e3c6..48c31b8e3e72 100644 > --- a/arch/x86/include/asm/processor.h > +++ b/arch/x86/include/asm/processor.h > @@ -393,16 +393,13 @@ struct irq_stack { > } __aligned(IRQ_STACK_SIZE); > > #ifdef CONFIG_X86_64 > -struct fixed_percpu_data { > - char gs_base[40]; > -}; > - > -DECLARE_PER_CPU_FIRST(struct fixed_percpu_data, fixed_percpu_data) __vis= ible; > -DECLARE_INIT_PER_CPU(fixed_percpu_data); > - > static inline unsigned long cpu_kernelmode_gs_base(int cpu) > { > - return (unsigned long)per_cpu(fixed_percpu_data.gs_base, cpu); > +#ifdef CONFIG_SMP > + return per_cpu_offset(cpu); > +#else > + return 0; > +#endif > } > > extern asmlinkage void entry_SYSCALL32_ignore(void); > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c > index f9c8bd27b642..a44fd3ad460e 100644 > --- a/arch/x86/kernel/cpu/common.c > +++ b/arch/x86/kernel/cpu/common.c > @@ -2051,10 +2051,6 @@ DEFINE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot) = =3D { > EXPORT_PER_CPU_SYMBOL(pcpu_hot); > > #ifdef CONFIG_X86_64 > -DEFINE_PER_CPU_FIRST(struct fixed_percpu_data, > - fixed_percpu_data) __aligned(PAGE_SIZE) __visible; > -EXPORT_PER_CPU_SYMBOL_GPL(fixed_percpu_data); > - > static void wrmsrl_cstar(unsigned long val) > { > /* > diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S > index 3dcabbc49149..f2453eb38417 100644 > --- a/arch/x86/kernel/head_64.S > +++ b/arch/x86/kernel/head_64.S > @@ -72,9 +72,14 @@ SYM_CODE_START_NOALIGN(startup_64) > > /* Setup GSBASE to allow stack canary access for C code */ > movl $MSR_GS_BASE, %ecx > - leaq INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx > +#ifdef CONFIG_SMP > + leaq __per_cpu_load(%rip), %rdx > movl %edx, %eax > shrq $32, %rdx > +#else > + xorl %eax, %eax > + xorl %edx, %edx > +#endif > wrmsr > > call startup_64_setup_env > @@ -345,15 +350,10 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM= _L_GLOBAL) > > /* Set up %gs. > * > - * The base of %gs always points to fixed_percpu_data. If the > - * stack protector canary is enabled, it is located at %gs:40. > * Note that, on SMP, the boot cpu uses init data section until > * the per cpu areas are set up. > */ > movl $MSR_GS_BASE,%ecx > -#ifndef CONFIG_SMP > - leaq INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx > -#endif > movl %edx, %eax > shrq $32, %rdx > wrmsr > diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.= S > index 54a5596adaa6..c87dc8de2084 100644 > --- a/arch/x86/kernel/vmlinux.lds.S > +++ b/arch/x86/kernel/vmlinux.lds.S > @@ -509,14 +509,8 @@ SECTIONS > */ > #define INIT_PER_CPU(x) init_per_cpu__##x =3D ABSOLUTE(x) + __per_cpu_lo= ad > INIT_PER_CPU(gdt_page); > -INIT_PER_CPU(fixed_percpu_data); > INIT_PER_CPU(irq_stack_backing_store); > > -#ifdef CONFIG_SMP > -. =3D ASSERT((fixed_percpu_data =3D=3D 0), > - "fixed_percpu_data is not at start of per-cpu area"); > -#endif > - > #ifdef CONFIG_CPU_UNRET_ENTRY > . =3D ASSERT((retbleed_return_thunk & 0x3f) =3D=3D 0, "retbleed_return_t= hunk not cacheline-aligned"); > #endif > diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c > index d30949e25ebd..3ccd9d4fcf9c 100644 > --- a/arch/x86/tools/relocs.c > +++ b/arch/x86/tools/relocs.c > @@ -811,7 +811,6 @@ static void percpu_init(void) > * __per_cpu_load > * > * The "gold" linker incorrectly associates: > - * init_per_cpu__fixed_percpu_data > * init_per_cpu__gdt_page > */ > static int is_percpu_sym(ElfW(Sym) *sym, const char *symname) > diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S > index a0ea285878db..9ce0d9d268bb 100644 > --- a/arch/x86/xen/xen-head.S > +++ b/arch/x86/xen/xen-head.S > @@ -53,14 +53,18 @@ SYM_CODE_START(startup_xen) > > /* Set up %gs. > * > - * The base of %gs always points to fixed_percpu_data. If the > - * stack protector canary is enabled, it is located at %gs:40. > * Note that, on SMP, the boot cpu uses init data section until > * the per cpu areas are set up. > */ > movl $MSR_GS_BASE,%ecx > - movq $INIT_PER_CPU_VAR(fixed_percpu_data),%rax > - cdq > +#ifdef CONFIG_SMP > + leaq __per_cpu_load(%rip), %rdx > + movl %edx, %eax > + shrq $32, %rdx > +#else > + xorl %eax, %eax > + xorl %edx, %edx > +#endif > wrmsr > > mov %rsi, %rdi Please note there is another access to $MSR_GS_BASE in /arch/x86/platform/pvh/head.S around line 98. Should this be fixed, too? Uros.