From patchwork Wed Aug 2 15:06:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 13338321 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E05DCC001DF for ; Wed, 2 Aug 2023 15:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=+KXSxnfmERwd6WLvX2C4M+z2H0hLuvDcxrlHosxeIWQ=; b=E/z A/zPDEs41jM6nZkhKNNWutNDbvHgXEi91pv741224QUlHSEoVoTTUGAyVleF1jzX/qSlsJ91UFQjQ iKgcbSUH+DSXtF1To++fwow4AhCfi/Gcdp+dBGTOTEzD4eyj0xodXZvSAvPES6FQYnZAxsySsLk5X izr5RGMNQ8rck07FdGchiS3eEcC0FzpxXXTCn8XF3BzV+Tm0S2H2RZoi2WCDfamrV8BINmN2luY1l Bx5UbYLNWtly6cMBW2l6TlLW270IaVE69Bkgni9y3eEvFhiSxvcu6TksWDx/GKbqKIv43V8XRpFiD qB+BQd7s1q4bhiJekQKHBw7UDTndUuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRDRn-005BEN-0p; Wed, 02 Aug 2023 15:07:35 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRDRk-005BD5-0s for linux-arm-kernel@lists.infradead.org; Wed, 02 Aug 2023 15:07:33 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d0d27cd9db9so1857478276.0 for ; Wed, 02 Aug 2023 08:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690988848; x=1691593648; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=ODlQqQRL7j+ioqTq3MDMk7BwHCUeRlM+arLr48y6tNA=; b=SlPCrS1xmbnWErc1CKgkJPNCNs7mvtB7anzE5xNQkivhTRzEbUhgWQnPMVMtb3VXh+ ZBtkHFgVBWyYK9aJXUFag88OyruHvsTDz0sROofPxloDejTDL0u7WLbUzdd0bjeB+jSN oTfyPlrZyq9uO50GbK472SiCDM3EoN7lghNrsmGgmy5MZ0QBWWSW/G3ysfDRPCvjzTil jIk0DCPgZI/Khn3fRGwbxbnH3v6fhL+esA/xOgDvjtUUcvHxo0iNIh9aXl4CxUkdcmD8 fJBSw5TBqO8FHGk7VqWk7U50HciveTvD2sCx9Bd9M88m/E0/TJ8dDqT/2Fi+tjLdynkA hc8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690988848; x=1691593648; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ODlQqQRL7j+ioqTq3MDMk7BwHCUeRlM+arLr48y6tNA=; b=WWS35Aw+tuahtxcwzT8I8LE/BPOCxydTukNF9laUjHdLMhHC2zUKq85D80PntgLb/N BNTYvBoUO6EXpgauTOh73WAzQvJJduzFeL1Zvxr0uF4tV+iT/0ngjYks4FGf5Ku2qbgK SjqyjOtRuCXyrhHalkxQlg/6KF2kPt7zItgFHukM8/ko7Jx3VgUBbfJX8WxoP35MIrjJ pHrmMA4N7r3uMv6uRG2WPfRrV85/+quB/kQptshl1DR5dA0xrjLCFBQXxgNROo8IKMmB HjavciP+gSKg0O9CuAdMAigLpZEA0sYntUzcKAV7UvEyyP0+XriMJkIkXJy2Mr60ZN2T lS/Q== X-Gm-Message-State: ABy/qLYUO7S+3mJX4gpCo3zZnS9VFcscWtrbEz+kUnnNuPq37geQpCxg JnhgGe79PVDrks9ggt91blZVm7Yaaw== X-Google-Smtp-Source: APBJJlG54cyvOOilnqyHEvE3EGA71yo6JZSxh2bIK8O8x7AqakXp9rNt0p+eKxoE0w7ySnwaeqPwqs6mJg== X-Received: from elver.muc.corp.google.com ([2a00:79e0:9c:201:5f73:1fc0:c9fd:f203]) (user=elver job=sendgmr) by 2002:a25:dfc3:0:b0:d15:53b5:509f with SMTP id w186-20020a25dfc3000000b00d1553b5509fmr197192ybg.2.1690988848424; Wed, 02 Aug 2023 08:07:28 -0700 (PDT) Date: Wed, 2 Aug 2023 17:06:37 +0200 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog Message-ID: <20230802150712.3583252-1-elver@google.com> Subject: [PATCH 1/3] Compiler attributes: Introduce the __preserve_most function attribute From: Marco Elver 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230802_080732_309848_C0829018 X-CRM114-Status: GOOD ( 12.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org [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 + /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute */