Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Heiko Carstens <hca@linux.ibm.com>,
	Sasha Levin <sashal@kernel.org>,
	pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
	nathan@kernel.org, gor@linux.ibm.com, ardb@kernel.org,
	samitolvanen@google.com, linux-riscv@lists.infradead.org,
	llvm@lists.linux.dev
Subject: [PATCH AUTOSEL 6.19-5.10] s390/purgatory: Add -Wno-default-const-init-unsafe to KBUILD_CFLAGS
Date: Wed, 11 Feb 2026 07:30:14 -0500	[thread overview]
Message-ID: <20260211123112.1330287-4-sashal@kernel.org> (raw)
In-Reply-To: <20260211123112.1330287-1-sashal@kernel.org>

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit b4780fe4ddf04b51127a33d705f4a2e224df00fa ]

Add -Wno-default-const-init-unsafe to purgatory KBUILD_CFLAGS, similar
to scripts/Makefile.extrawarn, since clang generates warnings for the
dummy variable in typecheck():

    CC      arch/s390/purgatory/purgatory.o
      arch/s390/include/asm/ptrace.h:221:9: warning: default initialization of an object of type 'typeof (regs->psw)' (aka 'const psw_t') leaves the object uninitialized [-Wdefault-const-init-var-unsafe]
        221 |         return psw_bits(regs->psw).pstate;
            |                ^
      arch/s390/include/asm/ptrace.h:98:2: note: expanded from macro 'psw_bits'
         98 |         typecheck(psw_t, __psw);                \
            |         ^
      include/linux/typecheck.h:11:12: note: expanded from macro 'typecheck'
         11 |         typeof(x) __dummy2; \
            |                   ^

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

Now I have a thorough understanding. Let me compile my analysis.

## Analysis: s390/purgatory: Add -Wno-default-const-init-unsafe to
KBUILD_CFLAGS

### 1. Commit Message Analysis

The commit adds the `-Wno-default-const-init-unsafe` compiler flag to
the s390 purgatory's `KBUILD_CFLAGS`. The commit message clearly
explains the problem: **clang 21+** introduced a new on-by-default
warning (`-Wdefault-const-init-var-unsafe`) that triggers on the
`typecheck()` macro's dummy variable. The warning fires in
`arch/s390/include/asm/ptrace.h:221` via `psw_bits()` -> `typecheck()`
-> `__dummy2` (line 11 of `include/linux/typecheck.h`).

The commit author is Heiko Carstens, the s390 subsystem maintainer.

### 2. Code Change Analysis

The change is exactly **one line** added to
`arch/s390/purgatory/Makefile`:

```
+KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe)
```

This is wrapped in `$(call cc-option, ...)`, which means it's only
applied when the compiler supports the flag, providing backward
compatibility.

### 3. Root Cause: Why s390 Purgatory Needs Its Own Fix

This is the critical technical detail. The s390 purgatory Makefile
**completely replaces** `KBUILD_CFLAGS` from scratch (line 16):

```16:16:arch/s390/purgatory/Makefile
KBUILD_CFLAGS := -std=gnu11 -fms-extensions -fno-strict-aliasing -Wall
-Wstrict-prototypes
```

Note the `:=` assignment operator — this discards ALL previously-set
global flags, including the `-Wno-default-const-init-unsafe` that was
already added to `scripts/Makefile.warn` (formerly
`scripts/Makefile.extrawarn`) by commit `d0afcfeb9e381` ("kbuild:
Disable -Wdefault-const-init-unsafe").

In contrast, other purgatory Makefiles (x86, riscv, powerpc) use
`filter-out` patterns like:
```
KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=%
...,$(KBUILD_CFLAGS))
```
which **preserve** the global flags (including the warning suppression).
Only s390's purgatory builds from scratch and needs this companion fix.

### 4. Is This a Build Fix?

**Yes, definitively.** With `CONFIG_WERROR=y` (enabled in many distro
configs and CI systems), the clang 21+ warning becomes a build error.
The commit message shows the exact warning output from `CC
arch/s390/purgatory/purgatory.o`. The trigger path is:

- `purgatory.o` includes `asm/ptrace.h`
- `ptrace.h:221` calls `psw_bits(regs->psw).pstate`
- `psw_bits` macro (line 98) calls `typecheck(psw_t, __psw)`
- `typecheck` macro (`include/linux/typecheck.h:11`) declares `typeof(x)
  __dummy2;` — an uninitialized const variable
- clang 21+ flags this with `-Wdefault-const-init-var-unsafe`

### 5. Relationship to Parent Commit

The parent commit `d0afcfeb9e381` ("kbuild: Disable -Wdefault-const-
init-unsafe") was explicitly tagged with `Cc: stable@vger.kernel.org`,
indicating the kernel community considers this warning fix important for
stable. That commit fixed the global build system, but the s390
purgatory was missed because it builds its own CFLAGS from scratch. This
commit is the necessary companion fix.

However, this commit is **self-contained** — it doesn't depend on
`d0afcfeb9e381` being present in stable. The s390 purgatory always
builds its own CFLAGS independently.

### 6. Risk Assessment

- **Lines changed**: 1
- **Files changed**: 1 Makefile
- **Runtime risk**: **Zero**. This is purely a compile-time flag that
  suppresses a spurious compiler warning. No runtime behavior change
  whatsoever.
- **Backward compatibility**: The `$(call cc-option, ...)` wrapper
  ensures the flag is silently ignored on compilers that don't support
  it (older clang, all gcc).
- **Side effects**: None. The warning being suppressed (`-Wdefault-
  const-init-var-unsafe`) is well-audited — the `typecheck()` macro's
  dummy variable is never used; it exists solely for compile-time type
  checking.

### 7. Stable Relevance

- The s390 purgatory (kexec code) exists in all stable kernel trees
  going back many years.
- The `psw_bits()` / `typecheck()` code path exists in all these trees.
- Users building stable kernels with newer clang + `CONFIG_WERROR=y`
  **will** get build failures.
- Build fixes are explicitly listed as appropriate for stable in
  `Documentation/process/stable-kernel-rules.rst`.

### 8. Dependency Check

The commit is fully self-contained. The only "dependency" is the s390
purgatory Makefile itself, which has existed unchanged (in terms of the
KBUILD_CFLAGS structure) for many kernel versions. The `$(call cc-
option, ...)` mechanism is available in all stable trees.

### Summary

This is a textbook build fix for stable:
- **One line**, zero risk, zero runtime impact
- Fixes a **real build failure** with newer clang + CONFIG_WERROR
- Self-contained, no dependencies
- Companion to a commit already tagged `Cc: stable@vger.kernel.org`
- Uses `cc-option` for backward compatibility
- Written by the s390 subsystem maintainer

**YES**

 arch/s390/purgatory/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile
index 0c196a5b194af..61d240a37633d 100644
--- a/arch/s390/purgatory/Makefile
+++ b/arch/s390/purgatory/Makefile
@@ -23,6 +23,7 @@ KBUILD_CFLAGS += -D__DISABLE_EXPORTS
 KBUILD_CFLAGS += $(CLANG_FLAGS)
 KBUILD_CFLAGS += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag)
 KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
+KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe)
 KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
 KBUILD_AFLAGS += -D__DISABLE_EXPORTS
 
-- 
2.51.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

       reply	other threads:[~2026-02-11 12:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260211123112.1330287-1-sashal@kernel.org>
2026-02-11 12:30 ` Sasha Levin [this message]
2026-02-11 12:30 ` [PATCH AUTOSEL 6.19] ACPI: scan: Use async schedule function in acpi_scan_clear_dep_fn() Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260211123112.1330287-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=ardb@kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-riscv@lists.infradead.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=patches@lists.linux.dev \
    --cc=pjw@kernel.org \
    --cc=samitolvanen@google.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox