From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDEDBC77B7C for ; Fri, 5 May 2023 03:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229697AbjEEDKP (ORCPT ); Thu, 4 May 2023 23:10:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjEEDKL (ORCPT ); Thu, 4 May 2023 23:10:11 -0400 Received: from out0-202.mail.aliyun.com (out0-202.mail.aliyun.com [140.205.0.202]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44D8111575; Thu, 4 May 2023 20:10:06 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R461e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047188;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=34;SR=0;TI=SMTPD_---.SYe4zj5_1683256196; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.SYe4zj5_1683256196) by smtp.aliyun-inc.com; Fri, 05 May 2023 11:09:57 +0800 Date: Fri, 05 May 2023 11:09:56 +0800 From: "Hou Wenlong" To: Juergen Gross Cc: , "Thomas Garnier" , "Lai Jiangshan" , "Kees Cook" , "Brian Gerst" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , "Andy Lutomirski" , "Boris Ostrovsky" , "Darren Hart" , "Andy Shevchenko" , "Nathan Chancellor" , "Nick Desaulniers" , "Tom Rix" , "Peter Zijlstra" , "=?UTF-8?B?TWlrZSBSYXBvcG9ydCAoSUJNKQ==?=" , "Ashok Raj" , "Rick Edgecombe" , "Catalin Marinas" , "Guo Ren" , "Greg Kroah-Hartman" , "Jason A. Donenfeld" , "Pawan Gupta" , "Kim Phillips" , "David Woodhouse" , "Josh Poimboeuf" , , , Subject: Re: [PATCH RFC 16/43] x86-64: Use per-cpu stack canary if supported by compiler Message-ID: <20230505030956.GA103506@k08j02272.eu95sqa> References: <7cee0c83225ffd8cf8fd0065bea9348f6db3b12a.1682673543.git.houwenlong.hwl@antgroup.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 04, 2023 at 12:31:59PM +0200, Juergen Gross wrote: > On 28.04.23 11:50, Hou Wenlong wrote: > >From: Brian Gerst > > > >From: Brian Gerst > > > >If the compiler supports it, use a standard per-cpu variable for the > >stack protector instead of the old fixed location. Keep the fixed > >location code for compatibility with older compilers. > > > >[Hou Wenlong: Disable it on Clang, adapt new code change and adapt > >missing GS set up path in pvh_start_xen()] > > > >Signed-off-by: Brian Gerst > >Co-developed-by: Hou Wenlong > >Signed-off-by: Hou Wenlong > >Cc: Thomas Garnier > >Cc: Lai Jiangshan > >Cc: Kees Cook > >--- > > arch/x86/Kconfig | 12 ++++++++++++ > > arch/x86/Makefile | 21 ++++++++++++++------- > > arch/x86/entry/entry_64.S | 6 +++++- > > arch/x86/include/asm/processor.h | 17 ++++++++++++----- > > arch/x86/include/asm/stackprotector.h | 16 +++++++--------- > > arch/x86/kernel/asm-offsets_64.c | 2 +- > > arch/x86/kernel/cpu/common.c | 15 +++++++-------- > > arch/x86/kernel/head_64.S | 16 ++++++++++------ > > arch/x86/kernel/vmlinux.lds.S | 4 +++- > > arch/x86/platform/pvh/head.S | 8 ++++++++ > > arch/x86/xen/xen-head.S | 14 +++++++++----- > > 11 files changed, 88 insertions(+), 43 deletions(-) > > > > ... > > >diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S > >index 643d02900fbb..09eaf59e8066 100644 > >--- a/arch/x86/xen/xen-head.S > >+++ b/arch/x86/xen/xen-head.S > >@@ -51,15 +51,19 @@ SYM_CODE_START(startup_xen) > > leaq (__end_init_task - PTREGS_SIZE)(%rip), %rsp > >- /* 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. > >+ /* > >+ * Set up GS base. > > * 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 > >+#if defined(CONFIG_STACKPROTECTOR_FIXED) > >+ leaq INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx > >+#elif defined(CONFIG_SMP) > >+ movabs $__per_cpu_load, %rdx > > Shouldn't above 2 targets be %rax? > Ah yes, my mistake. I didn't test it on XEN guest, sorry, I'll test XEN guest before the next submission. Thanks. > >+#else > >+ xorl %eax, %eax > >+#endif > > cdq > > wrmsr > > > Juergen > pub 2048R/28BF132F 2014-06-02 Juergen Gross > uid Juergen Gross > uid Juergen Gross > uid Juergen Gross > sub 2048R/16375B53 2014-06-02