Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4765545rwb; Tue, 8 Aug 2023 13:31:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMdQAFH+bCLBNNSLMS+TnbZDFA9nMjHhlc2parXv77X1kcxkjzN9omk0b/BMjjY7NjoCMt X-Received: by 2002:a2e:330e:0:b0:2b9:dfd0:c3d5 with SMTP id d14-20020a2e330e000000b002b9dfd0c3d5mr389523ljc.46.1691526714776; Tue, 08 Aug 2023 13:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691526714; cv=none; d=google.com; s=arc-20160816; b=NEo6TArLnR3MtqO9p7ibkBCms7eFa7/wvsmDnOH7CeDEA0x5I5xNUsLVESNfNsYb57 CSQFcWNLHGxnN/NfFUk8eXy8wQiTPUiE8EgHL2PmsdY94Ih7e2RtvWJX9xJRGZr+l98H REa/A1k0hjmaksmaVpGhJ8rF/IxO+CnxXklTy8uoneixHdeYVgKKo3Dgonj1ffnMN8ze spSBqI2qpFBp2+m62jTDUTY37Eq3iywKqsyFTgLhVbfiowaIVL0rfu9alcOCn4Je/u6Z vhrvG3oCFZ6bpayFLEPawPfsHQzwc8gHc0Q89guLaMWvQKg3Ag9vGSDGFg1E1mjgY6lE pICw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=LpOwTgxUQueKTTwOJlS9a4DMbQJlgeLRkDEjrIokCAc=; fh=shlGGbApy7qGdDHB+lq6z5bM4NEXnY9gUBYcpu2vW9U=; b=Tqt/vrdQvvBMvau/6cMSE1bwT5XFiezBAoT25edH+UxKnscnr11U6UKuHBZcGGpdkR ixKBhZlibkejqBJoBrZsiQ2TQdJ9e+15X0F9pxCtSsxukNMupd3rp9deNvp7wd0CyaDv 3Z9E9S/j5HFvnktH978PmjOKl4o8/kueOJrJt9zWdTA1GimO6PjjnVmallS9X+J0i/FK EyKxfMd/OS4mcrNIVD2s0BSCwNmDpO95IuagVdgtGARMnhUJ0Y9DgkXKdCmeN9iz1ssC vPkrZsNcAsod9ioeP1BEJLVr+NraW1bZuXnMb1XkAnscHQWz49chZKdge9brAubG5STT /l7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eVTfxbC3; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ox3-20020a170907100300b0099caf27e61fsi7114850ejb.244.2023.08.08.13.31.28; Tue, 08 Aug 2023 13:31:54 -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=@redhat.com header.s=mimecast20190719 header.b=eVTfxbC3; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236552AbjHHToE (ORCPT + 99 others); Tue, 8 Aug 2023 15:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230410AbjHHTnv (ORCPT ); Tue, 8 Aug 2023 15:43:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5637943CF2 for ; Tue, 8 Aug 2023 09:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691513079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LpOwTgxUQueKTTwOJlS9a4DMbQJlgeLRkDEjrIokCAc=; b=eVTfxbC36g32xFf3z0JE5AxSimNq+ut3q0sj4Ojop7ygXT6gQ3cifGcjTozEH+7343o/lx 8azq8J47sPuhTwERCV3mt5b6achj44QVKGQYzo63vVIiOiPg58pupq2dH8fXmBn05TyXk6 98ElaNHurB1CF6r91PdTNSRFyYh/UJM= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-678-x_BVl-L4N6OBZSXsqfsgqg-1; Tue, 08 Aug 2023 07:41:11 -0400 X-MC-Unique: x_BVl-L4N6OBZSXsqfsgqg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CFA37381AE42; Tue, 8 Aug 2023 11:41:09 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 462E41121314; Tue, 8 Aug 2023 11:41:06 +0000 (UTC) From: Florian Weimer To: Peter Zijlstra 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, Josh Poimboeuf Subject: Re: [PATCH v2 1/3] compiler_types: Introduce the Clang __preserve_most function attribute References: <20230804090621.400-1-elver@google.com> <87il9rgjvw.fsf@oldenburg.str.redhat.com> <20230808105705.GB212435@hirez.programming.kicks-ass.net> Date: Tue, 08 Aug 2023 13:41:05 +0200 In-Reply-To: <20230808105705.GB212435@hirez.programming.kicks-ass.net> (Peter Zijlstra's message of "Tue, 8 Aug 2023 12:57:05 +0200") Message-ID: <87pm3xhicu.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 * Peter Zijlstra: > Now, the problem with __preserve_most is that it makes it really easy to > deviate from this pattern, you can trivially write a function that is > not a trivial wrapper and then does not show up on unwind. This might > indeed be a problem. Backtrace generation shouldn't be impacted by a compiler implementation of __preserve_most__. If unwinding implies restoring register contents, the question becomes whether the unwinder can be taught to do this natively. For .eh_frame/PT_GNU_EH_FRAME-based unwinders and __preserve_most__, I think that's true because they already support custom ABIs (and GCC uses them for local functions). In other cases, if the unwinder does not support the extra registers, then it might still be possible to compensate for that via code generation (e.g., setjmp won't be __preserve_most__, so the compiler would have to preserve register contents by other means, also accounting for the returns-twice nature, likewise for exception handling landing pads). But __preserve_all__ is a completely different beast. I *think* it is possible to do this with helpers (state size, state save, state restore) and strategically placed restores after returns-twice functions and the like, but people disagree. This has come up before in the context of the s390x vector ABI and the desire to add new callee-saved registers. We just couldn't make that work at the time. On the other hand, __preserve_all__ goes into the other direction (opt-in of extra saves), so it may be conceptually easier. Thanks, Florian