From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 764AF10792 for ; Mon, 7 Aug 2023 12:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691411823; 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=5CuphCgJIGsELzZCHyihudC7C9xErjXAeUjA0Czr5WA=; b=YDc7Gq44+y2Po7GVRpqxwPk71ndNg0601oVNz1+yCQC70ONzkcHrhcb7TaqlBMKyxtf9v8 cDnkDwRVkyN9+UXHRV9B8sfESBmAY+gtjVja5DOzHOkW4XWw+JTNmWRhRvLVUwPr20SnFt l/iUI6wmhPWmNTWvqb0W2ef+Hs1jcYY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-tFAqekpKOEu5hfmv8bj1iQ-1; Mon, 07 Aug 2023 08:37:00 -0400 X-MC-Unique: tFAqekpKOEu5hfmv8bj1iQ-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 327BD801CF3; Mon, 7 Aug 2023 12:36:58 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 033731121314; Mon, 7 Aug 2023 12:36:54 +0000 (UTC) From: Florian Weimer To: Marco Elver Cc: Andrew Morton , Kees Cook , Guenter Roeck , Peter Zijlstra , 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 References: <20230804090621.400-1-elver@google.com> <87il9rgjvw.fsf@oldenburg.str.redhat.com> Date: Mon, 07 Aug 2023 14:36:53 +0200 In-Reply-To: (Marco Elver's message of "Mon, 7 Aug 2023 14:24:26 +0200") Message-ID: <87pm3zf2qi.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 * Marco Elver: > Good idea. I had already created > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110899, and we need > better spec to proceed for GCC anyway. Thanks for the reference. >> 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. > > That's true, but is it a real problem? Isn't it known that trying to > make kernel modules built for a kernel with a different config (incl. > compiler) is not guaranteed to work? See IBT, CFI schemes, kernel > sanitizers, etc? > > If we were to start trying to introduce some kind of minimal kernel to > module ABI so that modules and kernels built with different toolchains > keep working together, we'd need a mechanism to guarantee this minimal > ABI or prohibit incompatible modules and kernels somehow. Is there a > precedence for this somewhere? I think the GCC vs Clang thing is expected to work today, isn't it? Using the Clang-based BPF tools with a GCC-compiled kernel requires a matching ABI. The other things you listed result in fairly obvious breakage, sometimes even module loading failures. Unconditional crashes are possible as well. With __preserve_most__, the issues are much more subtle and may only appear for some kernel/module compielr combinations and optimization settings. The impact of incorrectly clobbered registers tends to be like that. Thanks, Florian From mboxrd@z Thu Jan 1 00:00:00 1970 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 E3077C04A6A for ; Mon, 7 Aug 2023 12:37:30 +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:MIME-Version:Message-ID:In-Reply-To: Date:References:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=74CMzW8O/NmMvS9C+CW1ApDmisWmzNTZywRbKt0qNXE=; b=RCO3G59oB+6r/W 8em+Q2K+GIlN1q3DjHKseH7KKazoU3wBu4SLk0HoMSEpTZpr2+91AKii/Hbf3S1Xyq8adKGKvCwfi mIPMhqbNx+V+A+gFaGSx91PnoHkMK89fFxYSygGdd7e5I1KJIbEETCFOOvw2omRihpvDiX8VxQZZb t3BBQ1MolcnRj10ysfUDW/WUD8aJcyC/jpW9NCZ2nZGMYrvJPA260c2ejDyIAZEzW3ylXX4TXiplr oXtUuybwS7SC4MKb1q46oi1lL3rr3d1mvixw4RH2Ik0gEQxudQyk6W94wQwyxce3jxHmMhYHWhWOn +0tKTI+8MN5ueBNfFdtQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qSzTv-00HEhM-2h; Mon, 07 Aug 2023 12:37:07 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qSzTs-00HEgb-2d for linux-arm-kernel@lists.infradead.org; Mon, 07 Aug 2023 12:37:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691411823; 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=5CuphCgJIGsELzZCHyihudC7C9xErjXAeUjA0Czr5WA=; b=YDc7Gq44+y2Po7GVRpqxwPk71ndNg0601oVNz1+yCQC70ONzkcHrhcb7TaqlBMKyxtf9v8 cDnkDwRVkyN9+UXHRV9B8sfESBmAY+gtjVja5DOzHOkW4XWw+JTNmWRhRvLVUwPr20SnFt l/iUI6wmhPWmNTWvqb0W2ef+Hs1jcYY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-tFAqekpKOEu5hfmv8bj1iQ-1; Mon, 07 Aug 2023 08:37:00 -0400 X-MC-Unique: tFAqekpKOEu5hfmv8bj1iQ-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 327BD801CF3; Mon, 7 Aug 2023 12:36:58 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 033731121314; Mon, 7 Aug 2023 12:36:54 +0000 (UTC) From: Florian Weimer To: Marco Elver Cc: Andrew Morton , Kees Cook , Guenter Roeck , Peter Zijlstra , 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 References: <20230804090621.400-1-elver@google.com> <87il9rgjvw.fsf@oldenburg.str.redhat.com> Date: Mon, 07 Aug 2023 14:36:53 +0200 In-Reply-To: (Marco Elver's message of "Mon, 7 Aug 2023 14:24:26 +0200") Message-ID: <87pm3zf2qi.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230807_053704_929424_3DB67F18 X-CRM114-Status: GOOD ( 21.60 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org * Marco Elver: > Good idea. I had already created > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110899, and we need > better spec to proceed for GCC anyway. Thanks for the reference. >> 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. > > That's true, but is it a real problem? Isn't it known that trying to > make kernel modules built for a kernel with a different config (incl. > compiler) is not guaranteed to work? See IBT, CFI schemes, kernel > sanitizers, etc? > > If we were to start trying to introduce some kind of minimal kernel to > module ABI so that modules and kernels built with different toolchains > keep working together, we'd need a mechanism to guarantee this minimal > ABI or prohibit incompatible modules and kernels somehow. Is there a > precedence for this somewhere? I think the GCC vs Clang thing is expected to work today, isn't it? Using the Clang-based BPF tools with a GCC-compiled kernel requires a matching ABI. The other things you listed result in fairly obvious breakage, sometimes even module loading failures. Unconditional crashes are possible as well. With __preserve_most__, the issues are much more subtle and may only appear for some kernel/module compielr combinations and optimization settings. The impact of incorrectly clobbered registers tends to be like that. Thanks, Florian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel