Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2971825rwb; Mon, 7 Aug 2023 06:28:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaie8JVFigXHkff0dymqWl1mPnUj/UgjIGmaDQS2PDX8uQQIqZwSdrnKDaIm+GG4AuxH4w X-Received: by 2002:a05:6a00:2495:b0:66c:9e97:aece with SMTP id c21-20020a056a00249500b0066c9e97aecemr7760187pfv.10.1691414922570; Mon, 07 Aug 2023 06:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691414922; cv=none; d=google.com; s=arc-20160816; b=iRPCiu0WrEGMNOoqTC6jPhWD3PBC+/57APKOb0XEdoxnxsGcc0x7wNBZuMhZQX0UPr X38K6dye5n4DY175g8UvHYcN/acFhAXGOOhDT3Te+4nmewZK5624HBut5hojqNJXtO5q 5h/zVOXOCX6MAtNILnHGYyOt3CCTUjR0ZDF4t41EXPebR++l0UIDGpcxUTu71tyvaPeX 0fIa8b83fVlS33l24IoF4aZEl+vDwtZdlxFOp3EchJ8b9Mda8YYGL04J4hYQAX0bg4j9 Px9DJ6+0EU/QV2tbpI5WaqKOg2Gkzes5+90NN8Fl4So17UVbT4LEmNVXjA6/Evec9cEI Tl0w== 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=Y/4R25p4daYUTehiyP/H6NfDF6hC+5JyB6EXsqzz6/k=; fh=VfFMGhjO+6FaJXNGtdRcycTOiKXgCawKFW/Q7I8tcFQ=; b=xz8XE/VAja2kY3uvmS3fy3ZSWZQy2NQ3eoadLRSRrR/I+/1xCxHDK4UrAre+xEk8Ag 7c/fDmIhvmWgj6Pege0DYV35BhrTrNhoMxAJcA6R8RLY+B3mgp523Lz34ZbfrVwewFQp 4nEpPkmlSWDbdhtkkdMhSSGqG7nCExVhgqeYk9mB51yYh/uxvHr4i3XyUuDv3if+cJIS ICsoXh2pRIXdfCo03KWaOVoz81tBWLyuJz/aFfdEaoBbjrDirXNIYDJbRCyutBYcxqxk L8Pm4o0wkYYbXwH71QvOrAZpPiw0SydsLimHxLDWMTFA3ogado9FWFkS2Uq8O01Yg34z mMbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=CZsy0pok; 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 y39-20020a056a00182700b006825d2884acsi5770670pfa.72.2023.08.07.06.28.30; Mon, 07 Aug 2023 06:28:42 -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=CZsy0pok; 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 S233841AbjHGNIF (ORCPT + 99 others); Mon, 7 Aug 2023 09:08:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233837AbjHGNID (ORCPT ); Mon, 7 Aug 2023 09:08:03 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E541735 for ; Mon, 7 Aug 2023 06:07:59 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4fe28f92d8eso7065987e87.1 for ; Mon, 07 Aug 2023 06:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691413677; x=1692018477; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Y/4R25p4daYUTehiyP/H6NfDF6hC+5JyB6EXsqzz6/k=; b=CZsy0pok8t9/vlnLGm4O8VdNxEk0CcQX2MtFvzA2zSKcr8mMAe0DHTmVORe3TDmzNw NlF98o2pOwjM3gbhA2QBbnDzxhJUiV/U14l+nq8StfHXCTZfVHlYP9ZlKqXusZ0MlNLC SK3ueVaMMD7GEHVsMwmSnVoS7V8McfsYWRjgqBM+Dqysuzn0htMOI8pLZIeMOL9V8kOk GfsDu5bZ2tVfFVCrEahlI24fLYcd2yhZRD9SE6+P+EWGV2iJoZJ7auhrzdCqn5PTf3VO EflwubvyoVGschLEAI4Xekv7e/Ols84VsR0+dEphPPzqt92Kz0IAjzB3qzrSudUbP8jb 92KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691413677; x=1692018477; 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=Y/4R25p4daYUTehiyP/H6NfDF6hC+5JyB6EXsqzz6/k=; b=lt/ULVoyq0QxIsjdnGNpm66JZ1nVM5T0Dvr+eIwqMwPCllkanaFR6iwYP0DHmViSIP MwgfI7i0E/pZ7wS8oLmm5h20OmijXN4/Dm7Ls1ShvQ4qE4nxHP+q7joVj7Jfw+F4kviN lZR5SqLeTDQij2queRG6HM2HtPp2RK7vcopc8HhzEMNVsxNrnJBKqp6MCRA8lhYlujz1 lKr2ppBXXcStBLHfCBWV5HXWMNvmfOrdg+TfjQC2Fxxc6oL9Q0ogwNeTuWQgf4augWR8 a0K3T90AHHh7ykdZOlS+pkU0FEfUhUuSGCdWM8XN9buh22P4JbzLJEZtaDa2DR2bP5qB NgdA== X-Gm-Message-State: AOJu0YwskT1Rf9Gva2l5Xzo6h9tnI7wR8PGEwDJAj5EdTQTjl23rc9xd wuQrtCZDDJ+VuA8W1wM4YGbOZeCIC39AEX3RSJgYtJi91umrEf12Urk= X-Received: by 2002:a05:6512:358b:b0:4fd:d4b4:faba with SMTP id m11-20020a056512358b00b004fdd4b4fabamr5211620lfr.51.1691413677214; Mon, 07 Aug 2023 06:07:57 -0700 (PDT) MIME-Version: 1.0 References: <20230804090621.400-1-elver@google.com> <87il9rgjvw.fsf@oldenburg.str.redhat.com> <87pm3zf2qi.fsf@oldenburg.str.redhat.com> In-Reply-To: <87pm3zf2qi.fsf@oldenburg.str.redhat.com> From: Marco Elver Date: Mon, 7 Aug 2023 15:07:20 +0200 Message-ID: Subject: Re: [PATCH v2 1/3] compiler_types: Introduce the Clang __preserve_most function attribute To: Florian Weimer 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 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, 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 Mon, 7 Aug 2023 at 14:37, Florian Weimer wrote: > > * 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? I, personally, wouldn't bet on it. It very much depends on the kernel config used. > Using the Clang-based BPF tools with a GCC-compiled kernel requires a > matching ABI. BPF is a different story altogether, and falls more into the category of user space to kernel ABI, which the kernel has strong guarantees on. > 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. One way around this would be to make the availability of the attribute a Kconfig variable. Then externally compiled kernel modules should do the right thing, since they ought to use the right .config when being built. I can make that change for v3.