Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp710663pxb; Thu, 2 Sep 2021 13:14:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxQ4Y745U4fbMOHtGqYgjXOPK4mIaSPfxZMD2QWZ3YnFiK6CHaxpWpN2tXxU0fYDeitBLn X-Received: by 2002:a17:906:ae4f:: with SMTP id lf15mr5545105ejb.124.1630613645100; Thu, 02 Sep 2021 13:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630613645; cv=none; d=google.com; s=arc-20160816; b=U07ZLU2A6JRml/VyVdxvt+uh779DzvPI0Av2PLo1RZ7vRa7ChOr63VResqaG+MPrGv b+QUjC8ebAbbXxqQIMmeQ4VmsfPrwrj3Es1/QzedjDoCYWcj+nUMrxK2tF1Ih6ThfXUP BOdotC5w9VtEAiTEM+3D+NaijQKyGCbaUYv45IimAmof/4c1yDdTjVM9PbQUk1G/ps/D z09vSQ3s5bYihft/YlCP3GKOzv53MKxycbIAd9tbURFWpx/MHpj7ssSwY4/pVccQdsCz WmE5f8H4LnB9FDCBX9hzWm3kKe65BDWCejRULuttZZdvJb7PYdkiwwBLmtPqDyat8MVu VwxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DTKwLxJKBb29lTrloLnll/qYjKLGHBwxYT4LSAZlfkw=; b=R7ldyv9W+bPEizN2KTVZJn8S4aOGOw9FaqoOVpy5xQyqup6YemnVSAlyc1hpgJ0wmc MakU9S2flBLfIF9JJOWYJjIHsiovv7O5/KoSHPa3v2Gtemk3pjXbKYR1sn4jNAU5NsER xVrgt/gcmE7/ToJlzVwAWktCZbpjlTV6O9EEM2TK/fCgWWMFi8YdAp34iwndjUajHKN6 E4x4h71KIUpxysczJeiLt/O96xb3YTnrzKW5pUxl7doCBgm8YsbJpCCM/sc6O+UXYDWi I5e0ctz0Yw6Uv8C1z5kaUflFw810a7NPt6pnl1T5vm8XhUr8RiBLHq2Uz1bNsusuuMYR ygVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZP4gtQ+d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si2920332edq.331.2021.09.02.13.13.33; Thu, 02 Sep 2021 13:14:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZP4gtQ+d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346489AbhIBRGm (ORCPT + 99 others); Thu, 2 Sep 2021 13:06:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234528AbhIBRGl (ORCPT ); Thu, 2 Sep 2021 13:06:41 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9743C061757 for ; Thu, 2 Sep 2021 10:05:42 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id t19so5775588lfe.13 for ; Thu, 02 Sep 2021 10:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DTKwLxJKBb29lTrloLnll/qYjKLGHBwxYT4LSAZlfkw=; b=ZP4gtQ+dU1CBjTX+vGsXvPBuqGQi/TppHrDWDvUZ0BzMZa7gXlsJM5iEdJJiwKKK6e 76mzLH7hK9hzKbxLxJlicUTIsvsWhsPi3lZ7LWgDqGB7vvcBpbI/nElwYdnNGmUoLRBT o3802TKxg3Y1OZ3dniRTorfb02Z12jSGHCxcxKvX0kwvuX5wjJX3k7yRoU+Q5hGvpgu+ PWScLnnckyVRHBGV0vlxnq9qDB0cvu2QCGqCY+2gWpKbcqUVbAO+uu4kFcQSWEMZkYFz gIchFtt/vCHSn97H76Y7VTOI4Mrpge2GbeMgCmoARzIf1cx7cUgp6gjLQ25ue/geg1IO hIfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DTKwLxJKBb29lTrloLnll/qYjKLGHBwxYT4LSAZlfkw=; b=k6QlPTYzLntqaSgLnwHsrpd/SCjUwDZZ5arEZlpCtubn0X0SXk90zJnyiT775n/xwu h/6f2NJjGHAOCobK/xJou686URYhtXpvZBe9uY0TaIt4sMOfIICImnKv5TlX8PDriz+B wPNxSsdy0AFln+Pk/V7XlPHk5C+pQD1gxVYJop8DFv6bDOjjZpMe7R7sAHkPue0rQLPs 2xyIm67Om4an0NGUq/1RSJABr0AjuDqjxgJrTRIOpFzdHVMGrX0CpFooNRrXmJm57oGA fOMWFJiEfKEkNQtoEnCZW8p43K5K3YInYlOevFaxq7vsau85ap2Ct5Xi07cKHk09yU8h b+Ow== X-Gm-Message-State: AOAM533SER3rhG5cSTdDq6/5vKJd7Cu6OqSaCWfmcL7k2aFa5ItMQMNU 4THoQyz49uD+4zTBYQ9uji/8nUiicTl/wBAouvaHQQ== X-Received: by 2002:a05:6512:15a1:: with SMTP id bp33mr3286376lfb.122.1630602340963; Thu, 02 Sep 2021 10:05:40 -0700 (PDT) MIME-Version: 1.0 References: <20210831175025.27570-1-jiangshanlai@gmail.com> <20210831175025.27570-3-jiangshanlai@gmail.com> <1f327579-e62a-df65-0763-e88243829db3@linux.alibaba.com> <4c589fef-8c98-a6fc-693f-b205a7710e42@linux.alibaba.com> In-Reply-To: From: Nick Desaulniers Date: Thu, 2 Sep 2021 10:05:29 -0700 Message-ID: Subject: Re: [PATCH 02/24] x86/traps: Move arch/x86/kernel/traps.c to arch/x86/entry/ To: Peter Zijlstra , Miguel Ojeda , =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: Lai Jiangshan , Joerg Roedel , Lai Jiangshan , linux-kernel@vger.kernel.org, Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Daniel Bristot de Oliveira , Brijesh Singh , Andy Shevchenko , Arvind Sankar , Chester Lin , Juergen Gross , andrew.cooper3@citrix.com, linux-toolchains@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 2, 2021 at 6:36 AM Peter Zijlstra wrote: > > On Thu, Sep 02, 2021 at 02:05:41PM +0200, Peter Zijlstra wrote: > > On Thu, Sep 02, 2021 at 07:54:25PM +0800, Lai Jiangshan wrote: > > > For example, stack-protector is instrumenting many noninstr functions now > > > if the CONFIG is yes. It is normally Ok and gcc is adding per-function control > > > on it. > > > > IIRC the latest compiler have an attribute for this too, that really > > should be added to noinstr. Lemme go find. > > Something like so... Nick ? > > diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h > index 49b0ac8b6fd3..6a15c3d8df5c 100644 > --- a/include/linux/compiler-clang.h > +++ b/include/linux/compiler-clang.h > @@ -62,6 +62,12 @@ > #define __no_sanitize_coverage > #endif > > +#if defined(CONFIG_STACKPROTECTOR) > +#define __no_stack_protector __attribute__((no_stack_protector)) > +#else > +#define __no_stack_protector > +#endif > + > /* > * Not all versions of clang implement the type-generic versions > * of the builtin overflow checkers. Fortunately, clang implements > diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h > index cb9217fc60af..7ac0a3f11ba9 100644 > --- a/include/linux/compiler-gcc.h > +++ b/include/linux/compiler-gcc.h > @@ -128,6 +128,12 @@ > #define __no_sanitize_coverage > #endif > > +#if defined(CONFIG_STACKPROTECTOR) && __has_attribute__(__no_stack_protector__) > +#define __no_stack_protector __attribute__((no_stack_protector)) > +#else > +#define __no_stack_protector > +#endif > + The above 2 hunks should go in include/linux/compiler_attributes.h, but yes. I'd been meaning to send such a patch; it's nice to have finer grain function-level control over -fno-stack-protector which significantly hurts ergonomics for things like LTO. IIRC GCC only added the attribute recently in the 10.X release, so it might be too new to rely on quite yet. > #if GCC_VERSION >= 50100 > #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 > #endif > diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h > index e4ea86fc584d..5ae1c08dba8d 100644 > --- a/include/linux/compiler_types.h > +++ b/include/linux/compiler_types.h > @@ -210,7 +210,8 @@ struct ftrace_likely_data { > /* Section for code which can't be instrumented at all */ > #define noinstr \ > noinline notrace __attribute((__section__(".noinstr.text"))) \ > - __no_kcsan __no_sanitize_address __no_profile __no_sanitize_coverage > + __no_kcsan __no_sanitize_address __no_profile __no_sanitize_coverage \ > + __no_stack_protector > > #endif /* __KERNEL__ */ > -- Thanks, ~Nick Desaulniers