Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1226675rwo; Wed, 2 Aug 2023 10:30:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnfW3PHf5KCoS+7EIxAAdR4tcMOfZSN17a9N4SWiME2bakK8HbDfc5AfJWxt3yydPn7JwI X-Received: by 2002:a05:6870:ac21:b0:1bf:5d1a:f218 with SMTP id kw33-20020a056870ac2100b001bf5d1af218mr1207670oab.28.1690997415715; Wed, 02 Aug 2023 10:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690997415; cv=none; d=google.com; s=arc-20160816; b=iZvycdggIjO9BHVAA7lkm7DSM4p4Rl8o6RtuFUqUjnidbuVsjRtyw+RyXTkrQ6DfPi uIxjQN1+fuxRrBEbn1KV4WoDOAEEG/PDgVAyMT3/rFCe15aVctYEKroKa3Ubf8dQO9y2 7W6XTHhF4FLwLGFqaa+ZAPY3XW+Ge7DvqOQv1xKLIn2xNGdYs6bNgLdBJuD/cdE45UUf fui7zbNVIAIQVWEFUQQ/iltmvHu9KAk4beCD6fi5zFbtyyK4n6PlN3ealNDZWGOGvG2p bkUmxt01dIt2j+IYSAGPUg+sEC5XnC3FeIr+8ToyQ+aZ0ZG2wdZaMxlh9ZgFE4OxcICV Rq/Q== 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=LrJLBG38n+Wiyfmv9S4MGg4xgt3i7BNwPWJDTs2HMj8=; fh=LclYWhdTYCCnc+/U+KSui7VEiIFUuheOLAb4/BmiW44=; b=etPot0Tv930O+NzwA/iTxhG9XBuw1dqyjcPjQLnSZHDcjqj3J5a70ZKKHpPlFrAZOj KGi3yFQyPxXV0nlsz0U4PCRk0glmY8gdkEjFMb++A3D7BbdYrWfbMIV4iTOxYoY11oM5 pDb5AkNHiA5A91pj1HNv1LL4PZwayB3evk7CfAZXkM6PlmwrhTOpdjwYq/wYm983dng9 DRt3zv51GIyseiH2jRNNZdbyc7rfHcp9eUfku7gC1TE8LqS9wfkILr0rDgih6MX9yKid aIy1YsJ4seoybV8hcceXhdoPItbq3Uf0MW1rbg5sbbLdcneG8E39mC/pqjLOBgPV8pjR bBJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Yr2vtAOi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a17090a64c600b002509d96227esi1492287pjm.173.2023.08.02.10.29.51; Wed, 02 Aug 2023 10:30:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Yr2vtAOi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232700AbjHBQwT (ORCPT + 99 others); Wed, 2 Aug 2023 12:52:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232398AbjHBQwA (ORCPT ); Wed, 2 Aug 2023 12:52:00 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FBC33AA7 for ; Wed, 2 Aug 2023 09:51:19 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31751d7d96eso21955f8f.1 for ; Wed, 02 Aug 2023 09:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690995077; x=1691599877; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LrJLBG38n+Wiyfmv9S4MGg4xgt3i7BNwPWJDTs2HMj8=; b=Yr2vtAOieZy3/74CDEAGC2Gnt8sgnypV0sH1nFYDYE+Z9U73wi72vRoBj9mOPgJwjv 99wZ+YY4Rl0iV4S7hY5jTJtBu9E+Wq+0WPHsLe7dYzPVxIQ7tL3K9N9EEAXWyXptkr4R ias3QXAFYMwvc666cOayPBqLwNU+Kv7rga8bPxnBbLZRg9CrOcJ+FBK+rP2suecmhpuK 73IMHyBKaqHCKBxo5PMwGaIBZKNj+nCrhhmAYIbNw5hpKlBf+9T+TnMkonjeqbOS1kee h/worVBInk2I1mObvjC5ogsA2iH6t0VXQGFlLd+k2vwihb2JKETOekCztRRPYmPBl9O/ EQ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690995077; x=1691599877; h=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=LrJLBG38n+Wiyfmv9S4MGg4xgt3i7BNwPWJDTs2HMj8=; b=NE7TL5/iM8nvEe3ONnhVkwjMq3ugIpuZpwyHVNbHf4dYPSnLYP0S9Hkw+pNNckekIx 7hN3d0oh2e7q9+JIMFkm9Z1FdoYDutcelWwZuzOx3nSW7oKD9ViY2tHuGiYbjIUdpuXA 96tfVHNKmjGiXkaTfahmQcn0IftiQ1eZjU3IFrmBO0ymKbFYgcrr6VEglVEDGoGE7EJ4 /mrFrULeVpf/ILR78JDcItktuh9/Ra0o9OY4V76DQw7qwzfvwegGuJqUIwHVu70fvs79 ZoDWSMYzaFHUI+dBddoPnl36OnhNoytuC6P95fqJJoPhewuPccQ2tkX5aRk9mfzilsID kh8g== X-Gm-Message-State: ABy/qLYv0rEE+UV7B8rvKsMWUcaVAIc5qd4XmAal5HAwi3j0gQ6kEm3T VflPfcGlOld+qqEDy6Ngt2H2a/pNX+9HHnMUOGrxfQ== X-Received: by 2002:adf:facc:0:b0:317:49a2:1f89 with SMTP id a12-20020adffacc000000b0031749a21f89mr5196369wrs.1.1690995076610; Wed, 02 Aug 2023 09:51:16 -0700 (PDT) MIME-Version: 1.0 References: <20230802150712.3583252-1-elver@google.com> In-Reply-To: <20230802150712.3583252-1-elver@google.com> From: Marco Elver Date: Wed, 2 Aug 2023 18:50:39 +0200 Message-ID: Subject: Re: [PATCH 1/3] Compiler attributes: Introduce the __preserve_most function attribute To: elver@google.com, Andrew Morton , Kees Cook Cc: Guenter Roeck , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Miguel Ojeda , Nick Desaulniers , Nathan Chancellor , Tom Rix , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Dmitry Vyukov , Alexander Potapenko , kasan-dev@googlegroups.com, linux-toolchains@vger.kernel.org, Mark Rutland , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2 Aug 2023 at 17:07, Marco Elver wrote: > > [1]: "On X86-64 and AArch64 targets, this attribute changes the calling > convention of a function. The preserve_most calling convention attempts > to make the code in the caller as unintrusive as possible. This > convention behaves identically to the C calling convention on how > arguments and return values are passed, but it uses a different set of > caller/callee-saved registers. This alleviates the burden of saving and > recovering a large register set before and after the call in the > caller." > > [1] https://clang.llvm.org/docs/AttributeReference.html#preserve-most > > Use of this attribute results in better code generation for calls to > very rarely called functions, such as error-reporting functions, or > rarely executed slow paths. > > Introduce the attribute to compiler_attributes.h. > > Signed-off-by: Marco Elver > --- > include/linux/compiler_attributes.h | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h > index 00efa35c350f..615a63ecfcf6 100644 > --- a/include/linux/compiler_attributes.h > +++ b/include/linux/compiler_attributes.h > @@ -321,6 +321,17 @@ > # define __pass_object_size(type) > #endif > > +/* > + * Optional: not supported by gcc. > + * > + * clang: https://clang.llvm.org/docs/AttributeReference.html#preserve-most > + */ > +#if __has_attribute(__preserve_most__) > +# define __preserve_most __attribute__((__preserve_most__)) > +#else > +# define __preserve_most > +#endif Mark says that there may be an issue with using this in combination with ftrace because arm64 tracing relies on AAPCS. Probably not just arm64, but also other architectures (x86?). To make this safe, I'm going to move __preserve_most to compiler_types.h and always pair it with notrace and some comments in v2.