From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f72.google.com (mail-dl1-f72.google.com [74.125.82.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9122F563280 for ; Tue, 13 Oct 2026 22:40:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791931221; cv=none; b=baUAK2L4q8bZObtmhH7Ngx7t2hrm8hn2wE5yD2MxMIQyKGYoSg8fDWtj4c7qBHUZ8ID+tn4KmBSDeotaM/Fi8lVIBpNJkhIT2FO4idUMXquSUGJQ94vnxEdnhMXkRmfhPu2i5iuwdjFeGPg6qMpSXKrJW4tnaZniK+qV/xz/590= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791931221; c=relaxed/simple; bh=Em27O2OyO7l+P8tBXhGlDjdSvn4vy+iPZ8ia1MGPgrk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=N3I3CHS8Ruh3t/BX+Bl+uH8cdSOqtIn/0fMLg+LTS8zTWSb2LkKhzF1eLr5+53UsA3nOhPjlCKB2KjbTGVsNqQockp57Mx+GMyzMfRV80X21tAlhW3BFhaegFDxMfymN3G5HS082uWogIcTDtmeH+ZwJqQIUhCxS9AhWG+hbKac= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NSpjLAcq; arc=none smtp.client-ip=74.125.82.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NSpjLAcq" Received: by mail-dl1-f72.google.com with SMTP id a92af1059eb24-1663fb7e005so4564606c88.0 for ; Tue, 13 Oct 2026 15:40:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1791931216; x=1792536016; darn=lists.linux.dev; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=zS2ZTWNtYHltA9QytinDsw+p3+JtthDKSkNq3q9AYXg=; b=NSpjLAcql4u2opZH52bq7zUsaGqgIvpP7NwNW1bepTidM542tt9Wwxp52u2nSzic2+ /5Kv26dz6eXPefpA5RCd45eLgPy5n3aLEiHdnQ7By44j3Uk9gUHqticpZhKAE/ZYkRWd tr5VX23dzzoaSkzkD5sMj4SaNQfBagOwJC5uyU4GmFuWcQ7wdC3DtsPXAMGhyn3uW2uL KU0kbtqswrYlf2PdgZUn/AOwtbQ5Lstn3p2Lft7nw05pKPG2g1OMDeppZl3ZZfy1HwUw ATDOUfaQl7oLvl5bFoVGU46+APUfTsP+mQSsWN6ZH5Z6w95z5LSRdIq3PpqbK5L4QIOp WNEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791931216; x=1792536016; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=zS2ZTWNtYHltA9QytinDsw+p3+JtthDKSkNq3q9AYXg=; b=GUMvG94RS6kBWXg31jrLaowDSi1kqhaa0xrmYL5kMunz/WEGS63nZJRbICcc1mkQo2 ooclLWCLe8cSF7whhfZkafAqzPtWr7ekf8DM4ka43iu5mcKB5C07pmk7kcqDJNB6nlok jM45/nK+jcRs8JnIFmQaqkxZV0Scjm5wIiFdeWSby6WaYUj6d4M53kcAbAmPf6PINriG kfK1xniVmJQ0XP+WGXz+0PPkuOxg+Z/nP0oELMxIDndpNifpjs6tB+ZQuqjuZ3f9fIiw pt5IBsDkAX2e2s3FzxfOG5s/kVPFNPehlsYJWWCM81DRAPpW7fE0vJLV5p1MYxxVT6r4 E8xw== X-Forwarded-Encrypted: i=1; AKwUvByqUhuXkNwgo4RxMflXzh2mee/mL3PKLv/jvgUToRA0jvLL8fqOwr7+0SP2OjOMwYCdHodBQpE3YtmhSw==@lists.linux.dev X-Gm-Message-State: AFq9FYLKXF1UEEE22SIUr9+PjCwJ8N2OUV9CvFidCXItV9htFsvecI5Y JO4251EiM8UosqJUB261VYyM3Dgf7JXgbNTzec/hOkSd0Zwy9gvxVCvUuCkKI562LZXl6d1tn2A r8qfgdgKMnw== X-Received: from dlbvs3.prod.google.com ([2002:a05:7022:3f03:b0:16a:e18b:92ba]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:4553:20b0:166:9e0d:3b56 with SMTP id a92af1059eb24-16a6384d0c8mr17137930c88.38.1791931214565; Tue, 13 Oct 2026 15:40:14 -0700 (PDT) Date: Tue, 13 Oct 2026 15:39:36 -0700 In-Reply-To: <20261013223946.1836757-1-irogers@google.com> Precedence: bulk X-Mailing-List: driver-core@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20261013223946.1836757-1-irogers@google.com> X-Mailer: git-send-email 2.56.0.385.gd3acb90ef8-goog Message-ID: <20261013223946.1836757-2-irogers@google.com> Subject: [PATCH 01/11] Compiler Attributes: Add __require_explicit_initialization macro From: Ian Rogers To: Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Miguel Ojeda , Kees Cook , Nathan Chancellor Cc: Nick Desaulniers , Bill Wendling , Justin Stitt , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Nayna Jain , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Viresh Kumar , David Teigland , Alexander Aring , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Richard Weinberger , Zhihao Cheng , Felix Kuehling , Alex Deucher , "=?UTF-8?q?Christian=20K=C3=B6nig?=" , driver-core@lists.linux.dev, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, gfs2@lists.linux.dev, xen-devel@lists.xenproject.org, linux-s390@vger.kernel.org, linux-mtd@lists.infradead.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Ian Rogers Content-Type: text/plain; charset="UTF-8" Clang supports the 'require_explicit_initialization' attribute on struct fields to indicate that a field must be initialized explicitly by the user when the object is constructed. When an aggregate initializer or uninitialized variable omits an annotated field, Clang emits a -Wuninitialized-explicit-init warning (enabled by default). Add the __require_explicit_initialization macro to include/linux/compiler_attributes.h (which is included by include/linux/compiler_types.h and include/linux/compiler.h) so kernel structs with error-prone initialization (such as mandatory callbacks or cleanup handlers) can enforce explicit initialization at compile time, as discussed at the Linux Plumbers Conference. Also teach Sphinx (Documentation/conf.py), kernel-doc (tools/lib/python/kdoc/xforms_lists.py), and checkpatch.pl about the new attribute macro. Link: https://lpc.events/event/20/contributions/2392/ Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers --- Documentation/conf.py | 1 + include/linux/compiler_attributes.h | 11 +++++++++++ scripts/checkpatch.pl | 1 + tools/lib/python/kdoc/xforms_lists.py | 1 + 4 files changed, 14 insertions(+) diff --git a/Documentation/conf.py b/Documentation/conf.py index 5ab26ce89daf..3e5cb9ca0970 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -203,6 +203,7 @@ c_id_attributes = [ "__noreturn", "__packed", "__pure", + "__require_explicit_initialization", "__section", "__always_unused", "__maybe_unused", diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index 476c4c560d17..60522ab80c5a 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -322,6 +322,17 @@ */ #define __pure __attribute__((__pure__)) +/* + * Optional: not supported by gcc + * + * clang: https://clang.llvm.org/docs/AttributeReference.html#require-explicit-initialization + */ +#if __has_attribute(__require_explicit_initialization__) +# define __require_explicit_initialization __attribute__((__require_explicit_initialization__)) +#else +# define __require_explicit_initialization +#endif + /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-section-function-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-section-variable-attribute diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 8a7787d228a6..4a3ae6b0100a 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6871,6 +6871,7 @@ sub process { "noreturn" => "__noreturn", "packed" => "__packed", "pure" => "__pure", + "require_explicit_initialization" => "__require_explicit_initialization", "section" => "__section", "used" => "__used", "weak" => "__weak" diff --git a/tools/lib/python/kdoc/xforms_lists.py b/tools/lib/python/kdoc/xforms_lists.py index e3dda2fe8a53..32066fbbe763 100644 --- a/tools/lib/python/kdoc/xforms_lists.py +++ b/tools/lib/python/kdoc/xforms_lists.py @@ -36,6 +36,7 @@ class CTransforms: (CMatch("CRYPTO_MINALIGN_ATTR"), ""), (CMatch("__private"), ""), (CMatch("__rcu"), ""), + (CMatch("__require_explicit_initialization"), ""), (CMatch("____cacheline_aligned_in_smp"), ""), (CMatch("____cacheline_aligned"), ""), (CMatch("__cacheline_group_(?:begin|end)"), ""), -- 2.56.0.385.gd3acb90ef8-goog