Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2945199rwb; Mon, 7 Aug 2023 06:07:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdy0hY9J8lUYQg5kP9Am42DngDAbvr6jz2TlRZOVnUKnDgERWP8lVNGVExMjxrYdrUuuTi X-Received: by 2002:a2e:9819:0:b0:2b8:36d4:7b0a with SMTP id a25-20020a2e9819000000b002b836d47b0amr7174723ljj.29.1691413663068; Mon, 07 Aug 2023 06:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691413663; cv=none; d=google.com; s=arc-20160816; b=RNrmQIMiZdlmv22ZPf8ikVw/YBO2/R48Wm/gwLm0CRmu2v/pjLlJQ5WCqSlMXhKE39 khwUfhs5a/ae6viZNDd3vPeB/fjzi8F0I7tKhZXnQ51qnrUWvyII7wY90A70APqHf5PZ pjZlkCMMzXcQdT+QtTINtgxfMdf7+mlb0Ef8ZzNOl9NVQGyRgyE0H7nkba+zbiYkpNaj PzZ48HZ1pKgqpYNwGOa5qWdegC10RUKLB7v375dbeRLGRlFz5XpvqKr1onCBr1c7dGU4 VWqEJjo6a8b3e5fRA/3YwFEjE57ajnTYEyJha+eVGngvXU8awdvuuK9HMqSlAKLkTqhs n9lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MKVDKc7Pqd1qB2ritThbJyFE9EXb4dytHxurnka2dE0=; fh=3T48dBajmuzuZqkU7TBWQfXJzDUTzUOImv3KVSY0ZcY=; b=nJzFCrwH1clOPXyDMVtneJsWaoZmhrgNeMiKNdb1oQfo7aMey6SSdoofZaO2MyAWPp zJZ/sLtKn+8/mpyQLP9eSzQREdB8cCfX942MLH1U+d63g8oMcxswmRauH6jeNOFD2Cqy 5Bizuk7UJy+E3Mb+cn2c2h8zpochW4pMBlvX+jzjJ4lGpqN8ddnkz9+0tbnNJz7U9RX9 5e3SKcB1TfyMMGkBR8ZvUfxI9keTWzbPstf8EdHAGt3j15VuytZjLjUyPZlmFrHSPMII +ABjLEVZxDu/JXVRuDG71SfUi+hgik3imeVKbvmbPlPAt43BDNWtxS2+TFwsXWmosWQN oazA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=jnIrvved; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a1709064d8500b0099cb1e742e7si4004318eju.224.2023.08.07.06.07.09; Mon, 07 Aug 2023 06:07:43 -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=@infradead.org header.s=desiato.20200630 header.b=jnIrvved; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233122AbjHGMcW (ORCPT + 99 others); Mon, 7 Aug 2023 08:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233559AbjHGMcU (ORCPT ); Mon, 7 Aug 2023 08:32:20 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1FEB1710; Mon, 7 Aug 2023 05:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=MKVDKc7Pqd1qB2ritThbJyFE9EXb4dytHxurnka2dE0=; b=jnIrvvedq9C7QKCBFwOsCNIJX9 V9VbOWcczqLVKyrCHG7xIiLwhStLZWwvOyBMTcDULVt3KMgthpASODAmfS/B/IgNy5EzqCdCXA5JT 3ydHWZoh21co0+w9SFHvWFRvrIU+7Jwe4krDx5HY3VqDHBwyV/oj1920tmMyjQP0lWsgDY8rKX87I Nk92DPd9vqruI6mmUagufSoUxHNFk1MRzrdSDG2wKbYOCJIifwnXK62aBYiHXlkeH03CSBLBFaPHo imbMMtQakrBaAZsWI1Eo53wsGyWbcTlX11gI98n1fxtBPFD0tBrCeYBDVQJdavGh6hDsf4qe9rxPM NdFc0/Rg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qSzOd-003oMs-0g; Mon, 07 Aug 2023 12:31:39 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 7727E30014A; Mon, 7 Aug 2023 14:31:37 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 299ED203B463D; Mon, 7 Aug 2023 14:31:37 +0200 (CEST) Date: Mon, 7 Aug 2023 14:31:37 +0200 From: Peter Zijlstra To: Florian Weimer Cc: Marco Elver , Andrew Morton , Kees Cook , Guenter Roeck , Mark Rutland , Steven Rostedt , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Nathan Chancellor , Nick Desaulniers , Tom Rix , Miguel Ojeda , 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 Subject: Re: [PATCH v2 1/3] compiler_types: Introduce the Clang __preserve_most function attribute Message-ID: <20230807123137.GA564305@hirez.programming.kicks-ass.net> References: <20230804090621.400-1-elver@google.com> <87il9rgjvw.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87il9rgjvw.fsf@oldenburg.str.redhat.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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 Mon, Aug 07, 2023 at 01:41:07PM +0200, Florian Weimer wrote: > * Marco Elver: > > > [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 > > You dropped the interesting part: > > | If the arguments are passed in callee-saved registers, then they will > | be preserved by the callee across the call. This doesn’t apply for > | values returned in callee-saved registers. > | > | · On X86-64 the callee preserves all general purpose registers, except > | for R11. R11 can be used as a scratch register. Floating-point > | registers (XMMs/YMMs) are not preserved and need to be saved by the > | caller. > | > | · On AArch64 the callee preserve all general purpose registers, except > | X0-X8 and X16-X18. > > Ideally, this would be documented in the respective psABI supplement. > I filled in some gaps and filed: > > Document the ABI for __preserve_most__ function calls > > > Doesn't this change impact the kernel module ABI? > > I would really expect a check here > > > +#if __has_attribute(__preserve_most__) > > +# define __preserve_most notrace __attribute__((__preserve_most__)) > > +#else > > +# define __preserve_most > > +#endif > > that this is not a compilation for a module. Otherwise modules built > with a compiler with __preserve_most__ attribute support are > incompatible with kernels built with a compiler without that attribute. We have a metric ton of options that can break module ABI. If you're daft enough to not build with the exact same compiler and .config you get to keep the pieces.