* [PATCH V17 3/7] powerpc/jump_label: adjust inline asm to be consistent
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-07-08 8:24 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, daniel.almeida, tamird, acourbot, work, nathan,
ndesaulniers, morbo, justinstitt, fujita.tomonori, joelagnelf,
gregkh, prafulrai522, nsc, japo, mkchauras, lina+kernel, j,
airlied, linuxppc-dev, linux-kernel, rust-for-linux, llvm
In-Reply-To: <20260708082454.1254320-1-mkchauras@gmail.com>
Added support for a new macro ARCH_STATIC_BRANCH_ASM in powerpc
to avoid duplication of inline asm between C and Rust. This is
inline with 'commit aecaf181651c ("jump_label: adjust inline asm to be consistent")'
Co-developed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://github.com/Rust-for-Linux/linux/issues/105
Link: https://github.com/linuxppc/issues/issues/451
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
---
arch/powerpc/include/asm/jump_label.h | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
index d4eaba459a0e..3016e9c8d6bc 100644
--- a/arch/powerpc/include/asm/jump_label.h
+++ b/arch/powerpc/include/asm/jump_label.h
@@ -15,14 +15,20 @@
#define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG)
#define JUMP_LABEL_NOP_SIZE 4
+#define JUMP_TABLE_ENTRY(key, label) \
+ ".pushsection __jump_table, \"aw\" \n\t" \
+ ".long 1b - ., " label " - . \n\t" \
+ JUMP_ENTRY_TYPE key " - . \n\t" \
+ ".popsection \n\t"
+
+#define ARCH_STATIC_BRANCH_ASM(key, label) \
+ "1: nop \n\t" \
+ JUMP_TABLE_ENTRY(key, label)
+
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
{
- asm goto("1:\n\t"
- "nop # arch_static_branch\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
- ".long 1b - ., %l[l_yes] - .\n\t"
- JUMP_ENTRY_TYPE "%c0 - .\n\t"
- ".popsection \n\t"
+ asm goto(
+ ARCH_STATIC_BRANCH_ASM("%c0", "%l[l_yes]")
: : "i" (&((char *)key)[branch]) : : l_yes);
return false;
@@ -34,10 +40,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
{
asm goto("1:\n\t"
"b %l[l_yes] # arch_static_branch_jump\n\t"
- ".pushsection __jump_table, \"aw\"\n\t"
- ".long 1b - ., %l[l_yes] - .\n\t"
- JUMP_ENTRY_TYPE "%c0 - .\n\t"
- ".popsection \n\t"
+ JUMP_TABLE_ENTRY("%c0", "%l[l_yes]")
: : "i" (&((char *)key)[branch]) : : l_yes);
return false;
--
2.55.0
^ permalink raw reply related
* [PATCH V17 2/7] dma-resv: Fix undefined symbol when CONFIG_DMA_SHARED_BUFFER is disabled
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-07-08 8:24 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, daniel.almeida, tamird, acourbot, work, nathan,
ndesaulniers, morbo, justinstitt, fujita.tomonori, joelagnelf,
gregkh, prafulrai522, nsc, japo, mkchauras, lina+kernel, j,
airlied, linuxppc-dev, linux-kernel, rust-for-linux, llvm
Cc: Christian König
In-Reply-To: <20260708082454.1254320-1-mkchauras@gmail.com>
When building with LLVM=1 for architectures like powerpc where
CONFIG_DMA_SHARED_BUFFER is not enabled, the build fails with:
ld.lld: error: undefined symbol: dma_resv_reset_max_fences
>>> referenced by helpers.c
>>> rust/helpers/helpers.o:(rust_helper_dma_resv_unlock)
The issue occurs because:
1. CONFIG_DEBUG_MUTEXES=y is enabled
2. CONFIG_DMA_SHARED_BUFFER is not enabled
3. dma_resv_reset_max_fences() is declared in the header when
CONFIG_DEBUG_MUTEXES is set
4. But the function is only compiled in drivers/dma-buf/dma-resv.c,
which is only built when CONFIG_DMA_SHARED_BUFFER is enabled
5. Rust helpers call dma_resv_unlock() which calls
dma_resv_reset_max_fences(), causing an undefined symbol
Fix this by compiling `dma-resv.c` file only when CONFIG_DMA_SHARED_BUFFER
is enabled.
Fixes: 9b836641d3bf ("rust: helpers: Add bindings/wrappers for dma_resv_lock")
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
---
rust/helpers/helpers.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index 998e31052e66..4b90a1390ad5 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -58,7 +58,9 @@
#include "cred.c"
#include "device.c"
#include "dma.c"
+#ifdef CONFIG_DMA_SHARED_BUFFER
#include "dma-resv.c"
+#endif
#include "drm.c"
#include "drm_gpuvm.c"
#include "err.c"
--
2.55.0
^ permalink raw reply related
* [PATCH V17 1/7] rust: Fix "multiple candidates for rmeta dependency core" error
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-07-08 8:24 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, daniel.almeida, tamird, acourbot, work, nathan,
ndesaulniers, morbo, justinstitt, fujita.tomonori, joelagnelf,
gregkh, prafulrai522, nsc, japo, mkchauras, lina+kernel, j,
airlied, linuxppc-dev, linux-kernel, rust-for-linux, llvm
In-Reply-To: <20260708082454.1254320-1-mkchauras@gmail.com>
When building Rust code for powerpc64le with LLVM=1 and -j1, rustc
encounters an error: "multiple candidates for `rmeta` dependency `core`
found", with two candidates:
1. The host's standard library from the rustup toolchain
2. The kernel's custom libcore.rmeta in the rust/ directory
This occurs because the build system uses `-L$(objtree)/rust` for host
library builds (proc_macro2, quote, syn), which causes rustc to search
the rust/ directory. During this search, rustc finds both the kernel's
custom libcore.rmeta and gains access to the host's standard library,
creating a conflict.
The solution is to separate host libraries into a dedicated rust/host/
subdirectory and use `-L$(objtree)/rust/host` for host builds instead
of `-L$(objtree)/rust`. This ensures that:
1. Host library builds (proc_macro2, quote, syn) only search rust/host/
and never encounter the kernel's libcore.rmeta
2. Proc macro builds use `-L$(objtree)/rust/host` to find their
dependencies
Special handling is added for rustdoc-pin_init, which is a host build
(to access the alloc crate) but depends on proc macros from the main
rust/ directory. It uses explicit `--extern` paths to reference the
proc macros without adding `-L$(objtree)/rust`, which would reintroduce
the conflict.
The rust/host/ directory is added to clean-files to ensure it's removed
during `make clean`.
Link: https://github.com/Rust-for-Linux/linux/issues/105
Link: https://github.com/linuxppc/issues/issues/451
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
---
rust/Makefile | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/rust/Makefile b/rust/Makefile
index a870d1616c71..17b2f329c13d 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -3,6 +3,9 @@
# Where to place rustdoc generated documentation
rustdoc_output := $(objtree)/Documentation/output/rust/rustdoc
+# Clean generated host directory
+clean-files := host/
+
obj-$(CONFIG_RUST) += core.o compiler_builtins.o ffi.o
always-$(CONFIG_RUST) += exports_core_generated.h
@@ -33,7 +36,7 @@ endif
obj-$(CONFIG_RUST) += exports.o
-always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib
+always-$(CONFIG_RUST) += host/libproc_macro2.rlib host/libquote.rlib host/libsyn.rlib
always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
@@ -163,7 +166,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
$(rustc_target_envs) \
OBJTREE=$(abspath $(objtree)) \
$(RUSTDOC) $(filter-out $(skip_flags) --remap-path-scope=%,$(if $(rustdoc_host),$(rust_common_flags),$(rust_flags))) \
- $(rustc_target_flags) -L$(objtree)/$(obj) \
+ $(rustc_target_flags) -L$(objtree)/$(obj)$(if $(rustdoc_host),/host) \
-Zunstable-options --generate-link-to-definition \
--output $(rustdoc_output) \
--crate-name $(subst rustdoc-,,$@) \
@@ -261,6 +264,7 @@ rustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs \
rustdoc-pin_init: private rustdoc_host = yes
rustdoc-pin_init: private rustc_target_flags = $(pin_init-flags) \
+ --extern pin_init_internal=$(objtree)/$(obj)/$(libpin_init_internal_name) \
--extern alloc --cfg feature=\"alloc\"
rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \
rustdoc-macros FORCE
@@ -572,23 +576,23 @@ quiet_cmd_rustc_procmacrolibrary = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_Q
$(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
$(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \
--emit=dep-info=$(depfile) --emit=link=$@ --crate-type rlib -O \
- --out-dir $(objtree)/$(obj) -L$(objtree)/$(obj) \
+ --out-dir $(objtree)/$(obj)/host -L$(objtree)/$(obj)/host \
--crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $<
-$(obj)/libproc_macro2.rlib: private skip_clippy = 1
-$(obj)/libproc_macro2.rlib: private rustc_target_flags = $(proc_macro2-flags)
-$(obj)/libproc_macro2.rlib: $(src)/proc-macro2/lib.rs FORCE
+$(obj)/host/libproc_macro2.rlib: private skip_clippy = 1
+$(obj)/host/libproc_macro2.rlib: private rustc_target_flags = $(proc_macro2-flags)
+$(obj)/host/libproc_macro2.rlib: $(src)/proc-macro2/lib.rs FORCE
+$(call if_changed_dep,rustc_procmacrolibrary)
-$(obj)/libquote.rlib: private skip_clippy = 1
-$(obj)/libquote.rlib: private skip_flags = $(quote-skip_flags)
-$(obj)/libquote.rlib: private rustc_target_flags = $(quote-flags)
-$(obj)/libquote.rlib: $(src)/quote/lib.rs $(obj)/libproc_macro2.rlib FORCE
+$(obj)/host/libquote.rlib: private skip_clippy = 1
+$(obj)/host/libquote.rlib: private skip_flags = $(quote-skip_flags)
+$(obj)/host/libquote.rlib: private rustc_target_flags = $(quote-flags)
+$(obj)/host/libquote.rlib: $(src)/quote/lib.rs $(obj)/host/libproc_macro2.rlib FORCE
+$(call if_changed_dep,rustc_procmacrolibrary)
-$(obj)/libsyn.rlib: private skip_clippy = 1
-$(obj)/libsyn.rlib: private rustc_target_flags = $(syn-flags)
-$(obj)/libsyn.rlib: $(src)/syn/lib.rs $(obj)/libquote.rlib FORCE
+$(obj)/host/libsyn.rlib: private skip_clippy = 1
+$(obj)/host/libsyn.rlib: private rustc_target_flags = $(syn-flags)
+$(obj)/host/libsyn.rlib: $(src)/syn/lib.rs $(obj)/host/libquote.rlib FORCE
+$(call if_changed_dep,rustc_procmacrolibrary)
quiet_cmd_rustc_procmacro = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) P $@
@@ -598,26 +602,26 @@ quiet_cmd_rustc_procmacro = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET))
-Clinker-flavor=gcc -Clinker=$(HOSTCC) \
-Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \
--emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
- --crate-type proc-macro -L$(objtree)/$(obj) \
+ --crate-type proc-macro -L$(objtree)/$(obj)/host \
--crate-name $(patsubst lib%.$(procmacro-extension),%,$(notdir $@)) \
@$(objtree)/include/generated/rustc_cfg $<
# Procedural macros can only be used with the `rustc` that compiled it.
$(obj)/$(libzerocopy_derive_name): private skip_clippy = 1
$(obj)/$(libzerocopy_derive_name): private rustc_target_flags = $(zerocopy_derive-flags)
-$(obj)/$(libzerocopy_derive_name): $(src)/zerocopy-derive/lib.rs $(obj)/libproc_macro2.rlib \
- $(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE
+$(obj)/$(libzerocopy_derive_name): $(src)/zerocopy-derive/lib.rs $(obj)/host/libproc_macro2.rlib \
+ $(obj)/host/libquote.rlib $(obj)/host/libsyn.rlib FORCE
+$(call if_changed_dep,rustc_procmacro)
$(obj)/$(libmacros_name): private rustc_target_flags = \
--extern proc_macro2 --extern quote --extern syn
-$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/libproc_macro2.rlib \
- $(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE
+$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/host/libproc_macro2.rlib \
+ $(obj)/host/libquote.rlib $(obj)/host/libsyn.rlib FORCE
+$(call if_changed_dep,rustc_procmacro)
$(obj)/$(libpin_init_internal_name): private rustc_target_flags = $(pin_init_internal-flags)
$(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs \
- $(obj)/libproc_macro2.rlib $(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE
+ $(obj)/host/libproc_macro2.rlib $(obj)/host/libquote.rlib $(obj)/host/libsyn.rlib FORCE
+$(call if_changed_dep,rustc_procmacro)
# `rustc` requires `-Zunstable-options` to use custom target specifications
--
2.55.0
^ permalink raw reply related
* [PATCH V17 0/7] Rust Support for powerpc
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-07-08 8:24 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, dakr, daniel.almeida, tamird, acourbot, work, nathan,
ndesaulniers, morbo, justinstitt, fujita.tomonori, joelagnelf,
gregkh, prafulrai522, nsc, japo, mkchauras, lina+kernel, j,
airlied, linuxppc-dev, linux-kernel, rust-for-linux, llvm
Enable experimental rust support for ppc64le and ppc32be. The patch for
ppc32 has been provided by Link Mauve[1] and ppc64le support[2] has been
merged over it. ppc32 needs some toolchain fixes mentioned in the patch
`rust: Add PowerPC support` and the discussion for that is done here[1].
This has been tested on
- powernv9 hardware
- pseries P11 hardware
- pseries(9, 10) qemu
- powernv(9, 10) qemu
- rustdoc on x86 and powerpc64le
- rusttest on x86 and powerpc64le
We are actively working with our LLVM team to get the target for ppc,
ppc64 and ppc64le in the rust compiler.
[1] https://lore.kernel.org/all/20260204030507.8203-1-linkmauve@linkmauve.fr
[2] https://lore.kernel.org/all/20260204042417.83903-1-mkchauras@gmail.com
Changelog:
V16 -> V17:
- Rebased to latest v7.2-rc2
V15 -> V16:
- Rebased to latest v7.1-rc4
V15: https://lore.kernel.org/all/20260426105932.2270364-1-mkchauras@gmail.com/
V14 -> V15:
- Fix an issue with rustdoc build on ppc64le
V14: https://lore.kernel.org/all/20260426085725.2090827-1-mkchauras@gmail.com/
V13 -> V14:
- 2nd patch is rewritten (Christian)
- Fixed a small typo in rust/Makefile (Sashiko)
- Fixed commit message in Patch 4 (Sashiko)
V13: https://lore.kernel.org/all/20260424054742.45832-1-mkchauras@gmail.com/
V12 -> V13:
- Added a patch for fixing build issue on ppc32 by Link Mauve
- Added another patch to fix a build issue in dma-buf
- Added another patch to enforce minimum `rustc` version for powerpc
V12: https://lore.kernel.org/all/20260421120958.190430-1-mkchauras@gmail.com/
V11 -> V12:
- Rebased to mainline (rust/Makefile conflict resolved)
V11: https://lore.kernel.org/all/20260417152253.2312961-1-mkchauras@gmail.com/
V10 -> V11:
- Updated `rust/Makefile`
- Not all libraries are move to `rust/host` directory now. Only
proc_macro2, quote and syn are moved
- Special handling for pin init is added. Details in commit
- Removed mkdir for `rust/host`, this is now handled by toolchain.
V10: https://lore.kernel.org/all/20260406200149.3727922-1-mkchauras@gmail.com/
V9 -> V10:
- rust/Makefile updated with review comments from Miguel
- Patch 1/4 updated with commit message and subject
V9: https://lore.kernel.org/all/20260404121610.1956528-1-mkchauras@gmail.com/
V8 -> V9:
- rust/Makefile updated with a directory instead of abspath
V8: https://lore.kernel.org/all/20260403145308.1042622-1-mkchauras@gmail.com/
V7 -> V8:
- rust/Makefile updated to separate host libraries from target
V7: https://lore.kernel.org/all/20260329160254.2592207-1-mkchauras@gmail.com/
Changelog:
V6 -> V7:
- Documentation removed as powerpc is still under development
- Added a fix for race condition in rust/Makefile
V6: https://lore.kernel.org/all/20260210090023.2587534-1-mkchauras@gmail.com
V5 -> V6:
- Added a missing Tested by from Venkat which got missed since V3
- Support is marked as Maintained instead of experimental
V5: https://lore.kernel.org/all/20260210053756.2088302-1-mkchauras@gmail.com
V4 -> V5:
- Removed a nested ifdef from PPC64 for Little endian toolchain
V4: https://lore.kernel.org/all/20260209105456.1551677-1-mkchauras@gmail.com
V3 -> V4:
- Co-developed-by header added in patch 1
V3: https://lore.kernel.org/all/20260205180429.3280657-1-mkchauras@gmail.com
V2 -> V3:
- Splited HAVE_RUST in 2 lines
- BINDGEN_TARGET_powerpc initialized before assigning the same to
BINDGEN_TARGET
V2: https://lore.kernel.org/all/20260204210125.613350-1-mkchauras@gmail.com
V1 -> V2:
- jump label fix for rust has been moved to a separate patch
- PPC32 support has been taken
- rust support has been marked experimental
- target.json dependency has been removed
- HAVE_RUST now depends on CPU_LITTLE_ENDIAN for PPC64
V1: https://lore.kernel.org/all/20260204042417.83903-1-mkchauras@gmail.com
Link Mauve (2):
rust: Make __udivdi3() and __umoddi3() panic
rust: Add PowerPC support
Mukesh Kumar Chaurasiya (IBM) (5):
rust: Fix "multiple candidates for rmeta dependency core" error
dma-resv: Fix undefined symbol when CONFIG_DMA_SHARED_BUFFER is
disabled
powerpc/jump_label: adjust inline asm to be consistent
rust/powerpc: Set min rustc version for powerpc
powerpc: Enable Rust for ppc64le
arch/powerpc/Kconfig | 2 +
arch/powerpc/Makefile | 7 ++++
arch/powerpc/include/asm/jump_label.h | 23 ++++++-----
rust/Makefile | 56 +++++++++++++++++----------
rust/compiler_builtins.rs | 6 +++
rust/helpers/helpers.c | 2 +
scripts/min-tool-version.sh | 2 +
7 files changed, 68 insertions(+), 30 deletions(-)
--
2.55.0
^ permalink raw reply
* Re: [PATCH 04/12] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
From: Krzysztof Kozlowski @ 2026-07-08 8:20 UTC (permalink / raw)
To: Paul Louvel
Cc: Qiang Zhao, Christophe Leroy (CS GROUP), Thomas Gleixner,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij,
Bartosz Golaszewski, Madhavan Srinivasan, Michael Ellerman,
Nicholas Piggin, linuxppc-dev, linux-arm-kernel, linux-kernel,
devicetree, linux-gpio, Thomas Petazzoni
In-Reply-To: <DJRCWXDUGFY8.1AIUFSEBFTG94@bootlin.com>
On Mon, Jul 06, 2026 at 10:48:32AM +0200, Paul Louvel wrote:
> On Mon Jul 6, 2026 at 8:52 AM CEST, Krzysztof Kozlowski wrote:
> > On Fri, Jul 03, 2026 at 03:30:12PM +0200, Paul Louvel wrote:
> >> Some QE GPIO pins have an associated interrupt line in the QE PIC to
> >> signal state changes on the pin. Add the corresponding
> >> interrupt-controller / nexus properties to the QE GPIO binding.
> >>
> >> Because the GPIO controller does not perform any interrupt handling
> >> itself, a nexus node (interrupt-map) is used to map each GPIO line
> >> supporting IRQ to the parent QE PIC interrupt domain.
> >>
> >> As the QE PIC can be configured to generate an interrupt on either a
> >> high-to-low transition or any change in signal state, three
> >> interrupt-map entries are needed per GPIO pin that can yield an
> >> interrupt (falling, both, and the "none" case which defaults to both in
> >> QE PIC). This overhead is necessary because the interrupt-map-pass-thru
> >> property is not part of the DT specification.
> >>
> >> The interrupt-map property is optional: it is not required for GPIO
> >> banks that have no interrupt capable GPIO line (e.g. port D on MPC8323),
> >> or when interrupt functionality is not used.
> >>
> >> Update the example to show a scenario where each bank supports a
> >> different numbers of IRQs, or no IRQs at all.
> >>
> >> Signed-off-by: Paul Louvel <paul.louvel@bootlin.com>
> >> ---
> >> .../bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml | 69 +++++++++++++++++++++-
> >> 1 file changed, 66 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml b/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml
> >> index 1af99339ff40..0c849a5698f4 100644
> >> --- a/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml
> >> +++ b/Documentation/devicetree/bindings/gpio/fsl,mpc8323-qe-pario-bank.yaml
> >> @@ -27,6 +27,17 @@ properties:
> >> "#gpio-cells":
> >> const: 2
> >>
> >> + "#address-cells":
> >> + const: 0
> >> +
> >> + "#interrupt-cells":
> >> + const: 2
> >> +
> >
> > If this has interrupt-cells, then it is a nexus, thus why isn't this
> > also a "interrupt-controller"?
>
> Because these these banks are not interrupt controllers.
> Interrupts are handled by the QE PIC, and the GPIO controller does not do any
> interrupt handling itself.
> In this setup, does it really needs an "interrupt-controller" property?
So this is interrupt-nexus, but not an interrupt-controller. If that's
the case of hardware, then it is fine/correct.
Best regards,
Krzysztof
^ permalink raw reply
* Re: [PATCH V17 0/8] Rust Support for powerpc
From: Mukesh Kumar Chaurasiya @ 2026-07-08 8:18 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, oleg, ojeda, boqun, gary, bjorn3_gh, lossin,
a.hindborg, tmgross, dakr, daniel.almeida, tamird, acourbot, work,
nathan, ndesaulniers, morbo, justinstitt, msuchanek, sshegde,
mchauras, thuth, segher, ryan.roberts, fujita.tomonori,
joelagnelf, prafulrai522, gregkh, nsc, japo, lyude, lina+kernel,
linuxppc-dev, linux-kernel, rust-for-linux, llvm
In-Reply-To: <20260708081633.1248382-1-mkchauras@gmail.com>
On Wed, Jul 08, 2026 at 01:46:25PM +0530, Mukesh Kumar Chaurasiya (IBM) wrote:
> Enable experimental rust support for ppc64le and ppc32be. The patch for
> ppc32 has been provided by Link Mauve[1] and ppc64le support[2] has been
> merged over it. ppc32 needs some toolchain fixes mentioned in the patch
> `rust: Add PowerPC support` and the discussion for that is done here[1].
>
> This has been tested on
> - powernv9 hardware
> - pseries P11 hardware
> - pseries(9, 10) qemu
> - powernv(9, 10) qemu
> - rustdoc on x86 and powerpc64le
> - rusttest on x86 and powerpc64le
>
> We are actively working with our LLVM team to get the target for ppc,
> ppc64 and ppc64le in the rust compiler.
>
> [1] https://lore.kernel.org/all/20260204030507.8203-1-linkmauve@linkmauve.fr
> [2] https://lore.kernel.org/all/20260204042417.83903-1-mkchauras@gmail.com
>
> Changelog:
> V16 -> V17:
> - Rebased to latest v7.2-rc2
>
> V15 -> V16:
> - Rebased to latest v7.1-rc4
> V15: https://lore.kernel.org/all/20260426105932.2270364-1-mkchauras@gmail.com/
>
> V14 -> V15:
> - Fix an issue with rustdoc build on ppc64le
> V14: https://lore.kernel.org/all/20260426085725.2090827-1-mkchauras@gmail.com/
>
> V13 -> V14:
> - 2nd patch is rewritten (Christian)
> - Fixed a small typo in rust/Makefile (Sashiko)
> - Fixed commit message in Patch 4 (Sashiko)
> V13: https://lore.kernel.org/all/20260424054742.45832-1-mkchauras@gmail.com/
>
> V12 -> V13:
> - Added a patch for fixing build issue on ppc32 by Link Mauve
> - Added another patch to fix a build issue in dma-buf
> - Added another patch to enforce minimum `rustc` version for powerpc
> V12: https://lore.kernel.org/all/20260421120958.190430-1-mkchauras@gmail.com/
>
> V11 -> V12:
> - Rebased to mainline (rust/Makefile conflict resolved)
> V11: https://lore.kernel.org/all/20260417152253.2312961-1-mkchauras@gmail.com/
>
> V10 -> V11:
> - Updated `rust/Makefile`
> - Not all libraries are move to `rust/host` directory now. Only
> proc_macro2, quote and syn are moved
> - Special handling for pin init is added. Details in commit
> - Removed mkdir for `rust/host`, this is now handled by toolchain.
> V10: https://lore.kernel.org/all/20260406200149.3727922-1-mkchauras@gmail.com/
>
> V9 -> V10:
> - rust/Makefile updated with review comments from Miguel
> - Patch 1/4 updated with commit message and subject
> V9: https://lore.kernel.org/all/20260404121610.1956528-1-mkchauras@gmail.com/
>
> V8 -> V9:
> - rust/Makefile updated with a directory instead of abspath
> V8: https://lore.kernel.org/all/20260403145308.1042622-1-mkchauras@gmail.com/
>
> V7 -> V8:
> - rust/Makefile updated to separate host libraries from target
> V7: https://lore.kernel.org/all/20260329160254.2592207-1-mkchauras@gmail.com/
>
> Changelog:
> V6 -> V7:
> - Documentation removed as powerpc is still under development
> - Added a fix for race condition in rust/Makefile
> V6: https://lore.kernel.org/all/20260210090023.2587534-1-mkchauras@gmail.com
>
> V5 -> V6:
> - Added a missing Tested by from Venkat which got missed since V3
> - Support is marked as Maintained instead of experimental
> V5: https://lore.kernel.org/all/20260210053756.2088302-1-mkchauras@gmail.com
>
> V4 -> V5:
> - Removed a nested ifdef from PPC64 for Little endian toolchain
> V4: https://lore.kernel.org/all/20260209105456.1551677-1-mkchauras@gmail.com
>
> V3 -> V4:
> - Co-developed-by header added in patch 1
> V3: https://lore.kernel.org/all/20260205180429.3280657-1-mkchauras@gmail.com
>
> V2 -> V3:
> - Splited HAVE_RUST in 2 lines
> - BINDGEN_TARGET_powerpc initialized before assigning the same to
> BINDGEN_TARGET
> V2: https://lore.kernel.org/all/20260204210125.613350-1-mkchauras@gmail.com
>
> V1 -> V2:
> - jump label fix for rust has been moved to a separate patch
> - PPC32 support has been taken
> - rust support has been marked experimental
> - target.json dependency has been removed
> - HAVE_RUST now depends on CPU_LITTLE_ENDIAN for PPC64
> V1: https://lore.kernel.org/all/20260204042417.83903-1-mkchauras@gmail.com
>
> Link Mauve (2):
> rust: Make __udivdi3() and __umoddi3() panic
> rust: Add PowerPC support
>
> Mukesh Kumar Chaurasiya (IBM) (6):
> powerpc/syscall: Fix syscall skip handling for seccomp and ptrace
> rust: Fix "multiple candidates for rmeta dependency core" error
> dma-resv: Fix undefined symbol when CONFIG_DMA_SHARED_BUFFER is
> disabled
> powerpc/jump_label: adjust inline asm to be consistent
> rust/powerpc: Set min rustc version for powerpc
> powerpc: Enable Rust for ppc64le
>
> arch/powerpc/Kconfig | 2 +
> arch/powerpc/Makefile | 7 ++++
> arch/powerpc/include/asm/jump_label.h | 23 ++++++-----
> arch/powerpc/include/asm/ptrace.h | 22 +++++++++-
> arch/powerpc/include/asm/syscall.h | 6 +++
> arch/powerpc/include/uapi/asm/ptrace.h | 6 ++-
> arch/powerpc/kernel/ptrace/ptrace.c | 2 +
> arch/powerpc/kernel/syscall.c | 18 +++++++++
> rust/Makefile | 56 +++++++++++++++++---------
> rust/compiler_builtins.rs | 6 +++
> rust/helpers/helpers.c | 2 +
> scripts/min-tool-version.sh | 2 +
> 12 files changed, 119 insertions(+), 33 deletions(-)
>
> --
> 2.55.0
>
Please ignore this.
Regards,
Mukesh
^ permalink raw reply
* [PATCH V17 1/8] powerpc/syscall: Fix syscall skip handling for seccomp and ptrace
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-07-08 8:16 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, oleg, ojeda, boqun, gary, bjorn3_gh, lossin,
a.hindborg, tmgross, dakr, daniel.almeida, tamird, acourbot, work,
nathan, ndesaulniers, morbo, justinstitt, msuchanek, mkchauras,
sshegde, mchauras, thuth, segher, ryan.roberts, fujita.tomonori,
joelagnelf, prafulrai522, gregkh, nsc, japo, lyude, lina+kernel,
linuxppc-dev, linux-kernel, rust-for-linux, llvm
In-Reply-To: <20260708081633.1248382-1-mkchauras@gmail.com>
After enabling GENERIC_ENTRY on PowerPC, syscall_enter_from_user_mode()
returns -1 as a sentinel to signal that seccomp or ptrace has intercepted
the syscall and already set a return value via syscall_set_return_value().
system_call_exception() was not handling this sentinel, and since -1UL
is >= NR_syscalls, the code fell into the out-of-range path and returned
-ENOSYS, overwriting the errno already placed in regs->gpr[3].
The naive fix of checking r0 == -1L before the NR_syscalls bounds check
is ambiguous: a user legitimately calling syscall(-1) also produces r0 ==
-1L, and a tracer intercepting such a call would have its injected return
value silently discarded.
Fix this properly by introducing regs->entry_flags, a kernel-internal
field in struct pt_regs (consuming one slot of the existing __pt_regs_pad
so the ABI is preserved), with SYSCALL_ENTRY_RET_SET as an out-of-band
flag. syscall_set_return_value() sets this flag whenever seccomp or ptrace
injects a return value. system_call_exception() zeros entry_flags before
calling syscall_enter_from_user_mode(), then checks and clears the flag
afterwards: if set, it returns regs->gpr[3] directly regardless of what
syscall number the user originally requested.
This handles all seccomp actions correctly:
- SECCOMP_RET_ERRNO, SECCOMP_RET_TRACE (no tracer), SECCOMP_RET_USER_NOTIF:
all call syscall_set_return_value(), flag is set, injected value returned.
- SECCOMP_RET_TRAP, SECCOMP_RET_KILL: call syscall_rollback() and deliver
a signal; flag is not set, but the process is dying so the return value
is irrelevant.
The fix covers both ppc32 and ppc64 with no #ifdefs.
Fixes: bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature")
Reported-by: Michal Suchánek <msuchanek@suse.de>
Closes: https://lore.kernel.org/all/ajpp-_XnbF3UTM_E@kunlun.suse.cz/
Tested-by: Michal Suchánek <msuchanek@suse.de>
Reviewed-by: Michal Suchánek <msuchanek@suse.de>
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
---
arch/powerpc/include/asm/ptrace.h | 22 +++++++++++++++++++++-
arch/powerpc/include/asm/syscall.h | 6 ++++++
arch/powerpc/include/uapi/asm/ptrace.h | 6 ++++--
arch/powerpc/kernel/ptrace/ptrace.c | 2 ++
arch/powerpc/kernel/syscall.c | 18 ++++++++++++++++++
5 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index fdeb97421785..1a53d5cfa8db 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -54,8 +54,9 @@ struct pt_regs
};
unsigned long result;
unsigned long exit_flags;
+ unsigned long entry_flags;
/* Maintain 16 byte interrupt stack alignment */
- unsigned long __pt_regs_pad[3];
+ unsigned long __pt_regs_pad[2];
};
};
#if defined(CONFIG_PPC64) || defined(CONFIG_PPC_KUAP)
@@ -233,6 +234,25 @@ static inline unsigned long frame_pointer(struct pt_regs *regs)
#define current_pt_regs() \
((struct pt_regs *)((unsigned long)task_stack_page(current) + THREAD_SIZE) - 1)
+/*
+ * SYSCALL_ENTRY_RET_SET: seccomp or ptrace called syscall_set_return_value()
+ * and wants the syscall skipped; regs->gpr[3] already holds the return value.
+ */
+#define SYSCALL_ENTRY_RET_SET BIT(0)
+
+static inline void set_syscall_entry_ret(struct pt_regs *regs)
+{
+ regs->entry_flags |= SYSCALL_ENTRY_RET_SET;
+}
+
+static inline bool test_and_clear_syscall_entry_ret(struct pt_regs *regs)
+{
+ bool set = !!(regs->entry_flags & SYSCALL_ENTRY_RET_SET);
+
+ regs->entry_flags &= ~SYSCALL_ENTRY_RET_SET;
+ return set;
+}
+
/*
* The 4 low bits (0xf) are available as flags to overload the trap word,
* because interrupt vectors have minimum alignment of 0x10. TRAP_FLAGS_MASK
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
index 834fcc4f7b54..9ae79326abe3 100644
--- a/arch/powerpc/include/asm/syscall.h
+++ b/arch/powerpc/include/asm/syscall.h
@@ -98,6 +98,12 @@ static inline void syscall_set_return_value(struct task_struct *task,
regs->gpr[3] = val;
}
}
+ /*
+ * Mark that a return value has been explicitly set by seccomp or
+ * ptrace so that system_call_exception() can skip the syscall
+ * unconditionally, even when the user requested syscall(-1).
+ */
+ set_syscall_entry_ret(regs);
}
static inline void syscall_get_arguments(struct task_struct *task,
diff --git a/arch/powerpc/include/uapi/asm/ptrace.h b/arch/powerpc/include/uapi/asm/ptrace.h
index a393b7f2760a..2f2a43414fe6 100644
--- a/arch/powerpc/include/uapi/asm/ptrace.h
+++ b/arch/powerpc/include/uapi/asm/ptrace.h
@@ -56,7 +56,8 @@ struct pt_regs
unsigned long dsisr; /* on 4xx/Book-E used for ESR */
unsigned long result; /* Result of a system call */
unsigned long exit_flags; /* System call exit flags */
- unsigned long __pt_regs_pad[3]; /* Maintain 16 byte interrupt stack alignment */
+ unsigned long entry_flags; /* System call entry flags */
+ unsigned long __pt_regs_pad[2]; /* Maintain 16 byte interrupt stack alignment */
};
#endif /* __ASSEMBLER__ */
@@ -117,7 +118,8 @@ struct pt_regs
#define PT_DSISR 42
#define PT_RESULT 43
#define PT_EXIT_FLAGS 44
-#define PT_PAD 47 /* 3 times */
+#define PT_ENTRY_FLAGS 45
+#define PT_PAD 46 /* 2 times */
#define PT_DSCR 48
#define PT_REGS_COUNT 48
diff --git a/arch/powerpc/kernel/ptrace/ptrace.c b/arch/powerpc/kernel/ptrace/ptrace.c
index 316d4f5ead8e..440d00690cf2 100644
--- a/arch/powerpc/kernel/ptrace/ptrace.c
+++ b/arch/powerpc/kernel/ptrace/ptrace.c
@@ -235,6 +235,8 @@ void __init pt_regs_check(void)
offsetof(struct user_pt_regs, dsisr));
BUILD_BUG_ON(offsetof(struct pt_regs, result) !=
offsetof(struct user_pt_regs, result));
+ BUILD_BUG_ON(offsetof(struct pt_regs, entry_flags) !=
+ offsetof(struct user_pt_regs, entry_flags));
BUILD_BUG_ON(sizeof(struct user_pt_regs) > sizeof(struct pt_regs));
diff --git a/arch/powerpc/kernel/syscall.c b/arch/powerpc/kernel/syscall.c
index a9da2af6efa8..a43d3a9428cc 100644
--- a/arch/powerpc/kernel/syscall.c
+++ b/arch/powerpc/kernel/syscall.c
@@ -19,9 +19,27 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0)
long ret;
syscall_fn f;
+ /*
+ * Zero entry_flags before syscall_enter_from_user_mode() so that
+ * syscall_set_return_value() can set SYSCALL_ENTRY_RET_SET as an
+ * unambiguous out-of-band signal. The field is not initialised by
+ * the entry assembly.
+ */
+ regs->entry_flags = 0;
add_random_kstack_offset();
r0 = syscall_enter_from_user_mode(regs, r0);
+ /*
+ * Seccomp or ptrace may have set a return value and requested that
+ * the syscall be skipped. syscall_set_return_value() sets
+ * SYSCALL_ENTRY_RET_SET in regs->entry_flags as an
+ * unambiguous out-of-band signal. This avoids the ambiguity of
+ * using r0 == -1 as the skip sentinel when the user themselves
+ * called syscall(-1).
+ */
+ if (unlikely(test_and_clear_syscall_entry_ret(regs)))
+ return syscall_get_error(current, regs);
+
if (unlikely(r0 >= NR_syscalls)) {
if (unlikely(trap_is_unsupported_scv(regs))) {
/* Unsupported scv vector */
--
2.55.0
^ permalink raw reply related
* [PATCH V17 0/8] Rust Support for powerpc
From: Mukesh Kumar Chaurasiya (IBM) @ 2026-07-08 8:16 UTC (permalink / raw)
To: maddy, mpe, npiggin, chleroy, peterz, jpoimboe, jbaron, aliceryhl,
rostedt, ardb, oleg, ojeda, boqun, gary, bjorn3_gh, lossin,
a.hindborg, tmgross, dakr, daniel.almeida, tamird, acourbot, work,
nathan, ndesaulniers, morbo, justinstitt, msuchanek, mkchauras,
sshegde, mchauras, thuth, segher, ryan.roberts, fujita.tomonori,
joelagnelf, prafulrai522, gregkh, nsc, japo, lyude, lina+kernel,
linuxppc-dev, linux-kernel, rust-for-linux, llvm
Enable experimental rust support for ppc64le and ppc32be. The patch for
ppc32 has been provided by Link Mauve[1] and ppc64le support[2] has been
merged over it. ppc32 needs some toolchain fixes mentioned in the patch
`rust: Add PowerPC support` and the discussion for that is done here[1].
This has been tested on
- powernv9 hardware
- pseries P11 hardware
- pseries(9, 10) qemu
- powernv(9, 10) qemu
- rustdoc on x86 and powerpc64le
- rusttest on x86 and powerpc64le
We are actively working with our LLVM team to get the target for ppc,
ppc64 and ppc64le in the rust compiler.
[1] https://lore.kernel.org/all/20260204030507.8203-1-linkmauve@linkmauve.fr
[2] https://lore.kernel.org/all/20260204042417.83903-1-mkchauras@gmail.com
Changelog:
V16 -> V17:
- Rebased to latest v7.2-rc2
V15 -> V16:
- Rebased to latest v7.1-rc4
V15: https://lore.kernel.org/all/20260426105932.2270364-1-mkchauras@gmail.com/
V14 -> V15:
- Fix an issue with rustdoc build on ppc64le
V14: https://lore.kernel.org/all/20260426085725.2090827-1-mkchauras@gmail.com/
V13 -> V14:
- 2nd patch is rewritten (Christian)
- Fixed a small typo in rust/Makefile (Sashiko)
- Fixed commit message in Patch 4 (Sashiko)
V13: https://lore.kernel.org/all/20260424054742.45832-1-mkchauras@gmail.com/
V12 -> V13:
- Added a patch for fixing build issue on ppc32 by Link Mauve
- Added another patch to fix a build issue in dma-buf
- Added another patch to enforce minimum `rustc` version for powerpc
V12: https://lore.kernel.org/all/20260421120958.190430-1-mkchauras@gmail.com/
V11 -> V12:
- Rebased to mainline (rust/Makefile conflict resolved)
V11: https://lore.kernel.org/all/20260417152253.2312961-1-mkchauras@gmail.com/
V10 -> V11:
- Updated `rust/Makefile`
- Not all libraries are move to `rust/host` directory now. Only
proc_macro2, quote and syn are moved
- Special handling for pin init is added. Details in commit
- Removed mkdir for `rust/host`, this is now handled by toolchain.
V10: https://lore.kernel.org/all/20260406200149.3727922-1-mkchauras@gmail.com/
V9 -> V10:
- rust/Makefile updated with review comments from Miguel
- Patch 1/4 updated with commit message and subject
V9: https://lore.kernel.org/all/20260404121610.1956528-1-mkchauras@gmail.com/
V8 -> V9:
- rust/Makefile updated with a directory instead of abspath
V8: https://lore.kernel.org/all/20260403145308.1042622-1-mkchauras@gmail.com/
V7 -> V8:
- rust/Makefile updated to separate host libraries from target
V7: https://lore.kernel.org/all/20260329160254.2592207-1-mkchauras@gmail.com/
Changelog:
V6 -> V7:
- Documentation removed as powerpc is still under development
- Added a fix for race condition in rust/Makefile
V6: https://lore.kernel.org/all/20260210090023.2587534-1-mkchauras@gmail.com
V5 -> V6:
- Added a missing Tested by from Venkat which got missed since V3
- Support is marked as Maintained instead of experimental
V5: https://lore.kernel.org/all/20260210053756.2088302-1-mkchauras@gmail.com
V4 -> V5:
- Removed a nested ifdef from PPC64 for Little endian toolchain
V4: https://lore.kernel.org/all/20260209105456.1551677-1-mkchauras@gmail.com
V3 -> V4:
- Co-developed-by header added in patch 1
V3: https://lore.kernel.org/all/20260205180429.3280657-1-mkchauras@gmail.com
V2 -> V3:
- Splited HAVE_RUST in 2 lines
- BINDGEN_TARGET_powerpc initialized before assigning the same to
BINDGEN_TARGET
V2: https://lore.kernel.org/all/20260204210125.613350-1-mkchauras@gmail.com
V1 -> V2:
- jump label fix for rust has been moved to a separate patch
- PPC32 support has been taken
- rust support has been marked experimental
- target.json dependency has been removed
- HAVE_RUST now depends on CPU_LITTLE_ENDIAN for PPC64
V1: https://lore.kernel.org/all/20260204042417.83903-1-mkchauras@gmail.com
Link Mauve (2):
rust: Make __udivdi3() and __umoddi3() panic
rust: Add PowerPC support
Mukesh Kumar Chaurasiya (IBM) (6):
powerpc/syscall: Fix syscall skip handling for seccomp and ptrace
rust: Fix "multiple candidates for rmeta dependency core" error
dma-resv: Fix undefined symbol when CONFIG_DMA_SHARED_BUFFER is
disabled
powerpc/jump_label: adjust inline asm to be consistent
rust/powerpc: Set min rustc version for powerpc
powerpc: Enable Rust for ppc64le
arch/powerpc/Kconfig | 2 +
arch/powerpc/Makefile | 7 ++++
arch/powerpc/include/asm/jump_label.h | 23 ++++++-----
arch/powerpc/include/asm/ptrace.h | 22 +++++++++-
arch/powerpc/include/asm/syscall.h | 6 +++
arch/powerpc/include/uapi/asm/ptrace.h | 6 ++-
arch/powerpc/kernel/ptrace/ptrace.c | 2 +
arch/powerpc/kernel/syscall.c | 18 +++++++++
rust/Makefile | 56 +++++++++++++++++---------
rust/compiler_builtins.rs | 6 +++
rust/helpers/helpers.c | 2 +
scripts/min-tool-version.sh | 2 +
12 files changed, 119 insertions(+), 33 deletions(-)
--
2.55.0
^ permalink raw reply
* Re: [PATCH 02/12] dt-bindings: soc: fsl: qe: Set #interrupt-cells to 2 to support interrupt type encoding
From: Krzysztof Kozlowski @ 2026-07-08 8:16 UTC (permalink / raw)
To: Paul Louvel
Cc: Qiang Zhao, Christophe Leroy (CS GROUP), Thomas Gleixner,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Walleij,
Bartosz Golaszewski, Madhavan Srinivasan, Michael Ellerman,
Nicholas Piggin, linuxppc-dev, linux-arm-kernel, linux-kernel,
devicetree, linux-gpio, Thomas Petazzoni
In-Reply-To: <20260703-qe-pic-gpios-v1-2-6c3e706e27dc@bootlin.com>
On Fri, Jul 03, 2026 at 03:30:10PM +0200, Paul Louvel wrote:
> The QUICC Engine port interrupt controller can be configured to generate
> an interrupt on either a high-to-low transition or any change in the
> signal state on the related GPIOs.
>
> Update the #interrupt-cells property to 2 so consumers can encode
> interrupt level information.
>
> Signed-off-by: Paul Louvel <paul.louvel@bootlin.com>
> ---
> .../devicetree/bindings/interrupt-controller/fsl,qe-ports-ic.yaml | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Best regards,
Krzysztof
^ permalink raw reply
* Re: test_bitmap fails on ppc/ppc64 on kernels v7.1.3, v7.2-rc2
From: Christophe Leroy (CS GROUP) @ 2026-07-08 7:51 UTC (permalink / raw)
To: Andy Shevchenko, Erhard Furtner
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel
In-Reply-To: <ak3_sGAnFxbmxfe8@ashevche-desk.local>
Le 08/07/2026 à 09:43, Andy Shevchenko a écrit :
> On Wed, Jul 08, 2026 at 01:25:01AM +0200, Erhard Furtner wrote:
>
> ...
>
>>> So there is something with your config
>>
>> Interesting! As I get the same test failure on my Talos II too.
>>
>> Anyhow, I was able to bisect the issue. Offending commit is:
>>
>> # git bisect bad
>> 6b5a4b68736798df1031404a2fad06d031253ef7 is the first bad commit
>> commit 6b5a4b68736798df1031404a2fad06d031253ef7 (HEAD)
>> Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> Date: Thu Feb 26 12:16:44 2026 +0100
>>
>> bitmap: Add test for out-of-boundary modifications for scatter & gather
>>
>> Make sure that bitmap_scatter() and bitmap_gather() do not modify
>> the bits outside of the given nbits span.
>>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> Signed-off-by: Yury Norov <ynorov@nvidia.com>
>>
>> lib/test_bitmap.c | 10 +++++++---
>> 1 file changed, 7 insertions(+), 3 deletions(-)
>>
>>
>> Reverting this commit on top of v7.2-rc2 lets the test pass:
>>
>> test_bitmap: loaded.
>> test_bitmap: parselist('0-2047:128/256'): 888
>> test_bitmap: scnprintf("%*pbl", '0-32767'): 6074
>> test_bitmap: test_bitmap_read_perf: 1190938
>> test_bitmap: test_bitmap_write_perf: 1259471
>> test_bitmap: all 208655 tests passed
>>
>> Your hint about my config made me check a few options and I found the
>> offending one, which is INIT_STACK_ALL_PATTERN=y. On a kernel built with
>> INIT_STACK_ALL_ZERO=y the issue does not show up.
>
> Oh, this is nice. So, there are two (more?) options I see to mitigate
> the issue:
> - carefully copy the garbage from the stack to the expected values
> (effectively merge the whatever is on stack with the expected value)
> - allocate buffers on heap
>
> The latter seems the easiest and right thing to do (since we can't really
> predict if the stack pattern is the same or bitmap APIs scatters the bits
> just on top of the respective set or clear ones over that pattern).
>
> I will send a patch, thanks for the report and analysis!
>
>
The following change fixes the issue for me:
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 69813c10e6c0b..448c3eb48a4a8 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -392,6 +392,7 @@ static void __init test_bitmap_sg(void)
/* Scatter/gather relationship */
bitmap_zero(bmap_tmp, 100);
+ bitmap_zero(bmap_res, 100);
bitmap_gather(bmap_tmp, bmap_scatter, sg_mask, nbits);
bitmap_scatter(bmap_res, bmap_tmp, sg_mask, nbits);
expect_eq_bitmap(bmap_scatter, bmap_res, 100);
Christophe
^ permalink raw reply related
* Re: test_bitmap fails on ppc/ppc64 on kernels v7.1.3, v7.2-rc2
From: Andy Shevchenko @ 2026-07-08 7:43 UTC (permalink / raw)
To: Erhard Furtner
Cc: Christophe Leroy (CS GROUP), linuxppc-dev@lists.ozlabs.org,
linux-kernel
In-Reply-To: <b9b762d0-cfe1-4fdb-b668-b6ef4afb0059@mailbox.org>
On Wed, Jul 08, 2026 at 01:25:01AM +0200, Erhard Furtner wrote:
...
> > So there is something with your config
>
> Interesting! As I get the same test failure on my Talos II too.
>
> Anyhow, I was able to bisect the issue. Offending commit is:
>
> # git bisect bad
> 6b5a4b68736798df1031404a2fad06d031253ef7 is the first bad commit
> commit 6b5a4b68736798df1031404a2fad06d031253ef7 (HEAD)
> Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Date: Thu Feb 26 12:16:44 2026 +0100
>
> bitmap: Add test for out-of-boundary modifications for scatter & gather
>
> Make sure that bitmap_scatter() and bitmap_gather() do not modify
> the bits outside of the given nbits span.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
>
> lib/test_bitmap.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
>
> Reverting this commit on top of v7.2-rc2 lets the test pass:
>
> test_bitmap: loaded.
> test_bitmap: parselist('0-2047:128/256'): 888
> test_bitmap: scnprintf("%*pbl", '0-32767'): 6074
> test_bitmap: test_bitmap_read_perf: 1190938
> test_bitmap: test_bitmap_write_perf: 1259471
> test_bitmap: all 208655 tests passed
>
> Your hint about my config made me check a few options and I found the
> offending one, which is INIT_STACK_ALL_PATTERN=y. On a kernel built with
> INIT_STACK_ALL_ZERO=y the issue does not show up.
Oh, this is nice. So, there are two (more?) options I see to mitigate
the issue:
- carefully copy the garbage from the stack to the expected values
(effectively merge the whatever is on stack with the expected value)
- allocate buffers on heap
The latter seems the easiest and right thing to do (since we can't really
predict if the stack pattern is the same or bitmap APIs scatters the bits
just on top of the respective set or clear ones over that pattern).
I will send a patch, thanks for the report and analysis!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc()
From: Bartosz Golaszewski @ 2026-07-08 7:42 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Lee Jones, Mark Brown, Thierry Reding, Sebastian Hesselbarth,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Srinivas Kandagatla, Greg Kroah-Hartman, Vinod Koul,
Rafael J. Wysocki, Danilo Krummrich, Rob Herring, Saravana Kannan,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Andi Shyti, Joerg Roedel,
Will Deacon, Robin Murphy, Doug Berger, Florian Fainelli,
Broadcom internal kernel review list, Ulf Hansson, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Matthew Brost, Thomas Hellström, Rodrigo Vivi, David Airlie,
Simona Vetter, Peter Chen, Paul Cercueil, Bin Liu, Philipp Zabel,
Maximilian Luz, Hans de Goede, Ilpo Järvinen,
Krzysztof Kozlowski, Benjamin Herrenschmidt, brgl, linux-kernel,
netdev, linux-arm-msm, linux-sound, driver-core, devicetree,
linuxppc-dev, linux-i2c, iommu, linux-pm, imx, linux-arm-kernel,
intel-xe, dri-devel, linux-usb, linux-mips, platform-driver-x86,
mfd, Manuel Ebner, Bartosz Golaszewski
In-Reply-To: <ak0jyUbNonSRiP_g@ashevche-desk.local>
On Tue, 7 Jul 2026 18:05:29 +0200, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> said:
> On Mon, Jul 06, 2026 at 02:44:17PM +0200, Bartosz Golaszewski wrote:
>> Users of platform_device_alloc() + platform_device_add() must not modify
>> certain fields of the dynamically created platform device object. Update
>> the kernel doc to say which fields are affected and which functions to
>> use.
>
> Consider using __private checker attribute for them as well. It will make
> sparse scream.
>
Sure but let's leave it for another series.
Bart
^ permalink raw reply
* Re: [PATCH v3 1/3] selftests/mm: handle EINVAL when configuring gigantic hugepages
From: David Hildenbrand (Arm) @ 2026-07-08 7:38 UTC (permalink / raw)
To: Sayali Patil, Andrew Morton, Shuah Khan, linux-mm, linux-kernel,
linux-kselftest, Ritesh Harjani
Cc: Zi Yan, Michal Hocko, Oscar Salvador, Lorenzo Stoakes, Dev Jain,
Liam.Howlett, linuxppc-dev, Miaohe Lin, Venkat Rao Bagalkote
In-Reply-To: <2e3b585cbb30b2fc495dcd49d75de6f6da61861c.1783446924.git.sayalip@linux.ibm.com>
On 7/8/26 08:59, Sayali Patil wrote:
> Some MM selftests attempt to configure the amount of
> HugeTLB pages of different sizes by writing to nr_hugepages.
>
> PowerPC hash MMU pSeries systems advertise gigantic hugepage sizes
> but do not support runtime allocation of such pages, writes
> to the corresponding nr_hugepages file fail with -EINVAL.
> This causes the test to bail out even though the failure is due
> to a platform limitation rather than the
> functionality being tested.
>
> Ignore -EINVAL when configuring nr_hugepages so that tests continue to
> run on systems where gigantic hugepage allocation is unsupported.
>
> Before patch:
> -------------------------
> running ./hugetlb-madvise
> -------------------------
> TAP version 13
> 1..1
> [INFO] detected hugetlb page size: 16777216 KiB
> [INFO] detected hugetlb page size: 16384 KiB
> ok 1 MADV_DONTNEED and MADV_REMOVE on hugetlb
> Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> Bail out! /sys/kernel/mm/hugepages/hugepages-16777216kB/nr_hugepages
> write(0) failed: Invalid argument
> Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
> [FAIL]
>
> After patch:
> -------------------------
> running ./hugetlb-madvise
> -------------------------
> TAP version 13
> 1..1
> [INFO] detected hugetlb page size: 16777216 KiB
> [INFO] detected hugetlb page size: 16384 KiB
> ok 1 MADV_DONTNEED and MADV_REMOVE on hugetlb
> Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
> [PASS]
>
> Fixes: 27477b28b74f ("selftests/mm: hugepage_settings: add APIs to get and set nr_hugepages")
> Co-developed-by: David Hildenbrand (Arm) <david@kernel.org>
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
> Signed-off-by: Sayali Patil <sayalip@linux.ibm.com>
LGTM. Using proper flags would maybe be nicer, but no need for that for this
corner case for now.
--
Cheers,
David
^ permalink raw reply
* Re: [PATCH v3] powerpc/pseries/iommu: Add TCEs for 16GB pages when RAM is pre-mapped
From: Ritesh Harjani @ 2026-07-08 6:21 UTC (permalink / raw)
To: Gaurav Batra, maddy
Cc: linuxppc-dev, sbhat, vaibhav, donettom, harshpb, Gaurav Batra
In-Reply-To: <20260515155143.39050-1-gbatra@linux.ibm.com>
Thanks for the changes. Added minor comments and queries.
Gaurav Batra <gbatra@linux.ibm.com> writes:
> In powerPC, if Dynamic DMA Window is big enough, RAM is pre-mapped. To
> determine the size of RAM, a PAPR+ property "ibm,lrdr-capacity" is used.
> This OF property dictates what is the max size of RAM an LPAR can have,
> including DR added memory.
>
> In PowerPC, 16GB pages can be allocated at machine level and then
This will be mostly for Hash MMU correct? Which will be P9 then?
Is this also possible in case of P10?
Can this 16GB pages be added via HMC? How can one test this?
> assigned to LPARs. These 16GB pages are added to LPAR memory at the time
> of boot. The address range for these 16GB pages is above MAX RAM an LPAR
> can have (ibm,lrdr-capacity). In the current implementation, these 16GB
> pages are being excluded from pre-mapped TCEs. A driver can have DMA
> buffers allocated from 16GB pages. This results in platform to raise an
> EEH when DMA is attempted on buffers in 16GB memory range.
>
> commit 6aa989ab2bd0 ("powerpc/pseries/iommu: memory notifier incorrectly
> adds TCEs for pmemory")
>
> Prior to the above patch, memblock_end_of_DRAM() was being used to
> determine the MAX memory of an LPAR. This included 16GB pages as well.
> The issue with using memblock_end_of_DRAM() is that when pmemory is
> converted to RAM via daxctl command, the DDW engine will incorrectly try
> to add TCEs for pmemory as well.
>
> Below is the address distribution of RAM, 16GB pages and pmemory for an
> LPAR with max memory of 256GB, memory allocated 64GB, 2 16GB pages and
> assigned pmemory of 8GB.
>
> RANGE SIZE STATE REMOVABLE BLOCK
> 0x0000000000000000-0x0000000fffffffff 64G online yes 0-255
> 0x0000004000000000-0x00000047ffffffff 32G online yes 1024-1151
>
> cat /sys/bus/nd/devices/region0/resource
> 0x40100000000
> cat /sys/bus/nd/devices/region0/size
> 8589934592
>
cat /proc/iomem should show the output for pmemory as well correct?
> The approach to fix this problem is to revert back the code changes
> introduced by the above patch and to stash away the MAX memory of an
> LPAR, including 16GB pages, at the LPAR boot time. This value is then
> used whenever TCEs are needed to be pre-mapped - enable_DDW() or,
> iommu_mem_notifier()
>
Was this hit in an internal testing? Is it possible to have a test
around this please?
@Venkat, did we test this specific case with and w/o this patch as well?
Reason for my asks is - since we will be backporting this patch to older
stable kernels, it will be good to ensure this has been properly tested
and if possible we should even have a unit test to ensure this
doesn't break in future.
> Fixes: 6aa989ab2bd0 ("powerpc/pseries/iommu: memory notifier incorrectly adds TCEs for pmemory")
This patch was made in v6.15. Since we want this to be backported, I
would suggested add a CC stable tag as well.
> Signed-off-by: Gaurav Batra <gbatra@linux.ibm.com>
> ---
>
> Change log:
>
> V2 -> V3
>
> 1. Harsh: Remove R-b tags from the change log
>
> Response: Incorporated changes
>
> 2. Harsh: Change WARN_ON() to WARN_ONCE()
>
> Response: Incorporated changes
>
> 3. Harsh: Fix indendation
>
> Response: Incorporated changes
>
> 4. Harsh: Replace comment with a log if limit < arg->nr_pages ?
>
> Response: Doesn't seems to be needed since the WARN_ONCE() will log this
> scenario. I removed the comment instead.
>
> V1 -> V2
>
> 1. Harsh: Not only start_pfn, but end_pfn also needs to be within allowed
> range, which may require clamping arg->nr_pages if crossing the limits.
>
> Response: Incorporated changes.
>
> arch/powerpc/platforms/pseries/iommu.c | 58 ++++++++++++++++++--------
> 1 file changed, 41 insertions(+), 17 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> index 3e1f915fe4f6..7bbe070006fa 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -69,6 +69,8 @@ static struct iommu_table *iommu_pseries_alloc_table(int node)
> return tbl;
> }
>
> +static phys_addr_t pseries_ddw_max_ram;
> +
Since this is only set once during init and read afterwards.. Maybe we
should change this to __ro_after_init?
> #ifdef CONFIG_IOMMU_API
> static struct iommu_table_group_ops spapr_tce_table_group_ops;
> #endif
> @@ -1285,13 +1287,17 @@ static LIST_HEAD(failed_ddw_pdn_list);
>
> static phys_addr_t ddw_memory_hotplug_max(void)
After this change, this function only gets called from __init function.
So let's mark it as __init.
> {
> - resource_size_t max_addr;
> + resource_size_t max_addr = memory_hotplug_max();
> + struct device_node *memory;
>
> -#if defined(CONFIG_NUMA) && defined(CONFIG_MEMORY_HOTPLUG)
> - max_addr = hot_add_drconf_memory_max();
> -#else
> - max_addr = memblock_end_of_DRAM();
> -#endif
> + for_each_node_by_type(memory, "memory") {
> + struct resource res;
> +
> + if (of_address_to_resource(memory, 0, &res))
> + continue;
> +
> + max_addr = max_t(resource_size_t, max_addr, res.end + 1);
> + }
>
> return max_addr;
> }
> @@ -1446,7 +1452,7 @@ static struct property *ddw_property_create(const char *propname, u32 liobn, u64
> static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn, u64 dma_mask)
> {
> int len = 0, ret;
> - int max_ram_len = order_base_2(ddw_memory_hotplug_max());
> + int max_ram_len = order_base_2(pseries_ddw_max_ram);
> struct ddw_query_response query;
> struct ddw_create_response create;
> int page_shift;
> @@ -1668,7 +1674,7 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn, u64 dma_mas
>
> if (direct_mapping) {
Outside of this patch, but I see a case where:
- pmem is present and if ddw_sz is larger than MAX_PHYSMEM_BITS, in that
case we use the direct mapping (enable_ddw()).
So IMO - that path looks a bit buggy, because we say our ddw_sz is large enough
even with vpmem but we only create TCE entries for system ram and not for
vPMEM. So say when there is a DMA to the vpmem devdax region, then we
won't find any TCE entries and that may cause EEH too right?
> /* DDW maps the whole partition, so enable direct DMA mapping */
> - ret = walk_system_ram_range(0, ddw_memory_hotplug_max() >> PAGE_SHIFT,
> + ret = walk_system_ram_range(0, pseries_ddw_max_ram >> PAGE_SHIFT,
> win64->value, tce_setrange_multi_pSeriesLP_walk);
> if (ret) {
> dev_info(&dev->dev, "failed to map DMA window for %pOF: %d\n",
> @@ -2419,23 +2425,35 @@ static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action,
> {
> struct dma_win *window;
> struct memory_notify *arg = data;
> + unsigned long limit = arg->nr_pages;
> + unsigned long max_ram_pages = pseries_ddw_max_ram >> PAGE_SHIFT;
> int ret = 0;
>
> /* This notifier can get called when onlining persistent memory as well.
> * TCEs are not pre-mapped for persistent memory. Persistent memory will
> - * always be above ddw_memory_hotplug_max()
> + * always be above pseries_ddw_max_ram
> */
> + if (arg->start_pfn >= max_ram_pages)
> + return NOTIFY_OK;
This case is when we have pmem converted to system ram correct?
> +
> + /* RAM is being DLPAR'ed. The range should never exceed max ram.
> + * Just in case, clamp the range and throw a warning.
> + */
> + if (arg->start_pfn + limit > max_ram_pages) {
> + limit = max_ram_pages - arg->start_pfn;
> + WARN_ONCE(1, "Limiting Page Range %lx - %lx to Max Mem Pages: %lx\n",
> + arg->start_pfn, arg->start_pfn + arg->nr_pages,
> + max_ram_pages);
> + }
when would this condition hit if at all? Have we seen this happening in
past anytime?
>
> switch (action) {
> case MEM_GOING_ONLINE:
> spin_lock(&dma_win_list_lock);
> list_for_each_entry(window, &dma_win_list, list) {
> - if (window->direct && (arg->start_pfn << PAGE_SHIFT) <
> - ddw_memory_hotplug_max()) {
> + if (window->direct) {
> ret |= tce_setrange_multi_pSeriesLP(arg->start_pfn,
> - arg->nr_pages, window->prop);
> + limit, window->prop);
> }
> - /* XXX log error */
> }
> spin_unlock(&dma_win_list_lock);
> break;
> @@ -2443,12 +2461,10 @@ static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action,
> case MEM_OFFLINE:
> spin_lock(&dma_win_list_lock);
> list_for_each_entry(window, &dma_win_list, list) {
> - if (window->direct && (arg->start_pfn << PAGE_SHIFT) <
> - ddw_memory_hotplug_max()) {
> + if (window->direct) {
> ret |= tce_clearrange_multi_pSeriesLP(arg->start_pfn,
> - arg->nr_pages, window->prop);
> + limit, window->prop);
> }
> - /* XXX log error */
> }
> spin_unlock(&dma_win_list_lock);
> break;
> @@ -2532,6 +2548,14 @@ void __init iommu_init_early_pSeries(void)
> register_memory_notifier(&iommu_mem_nb);
>
> set_pci_dma_ops(&dma_iommu_ops);
> +
> + /* During init determine the max memory an LPAR can have and set it. This
> + * will be used for pre-mapping RAM in DDW. memblock_end_of_DRAM() can
> + * change during the running of LPAR - daxctl can add pmemory as
> + * "system-ram". This memory range should not be pre-mapped in DDW since
> + * the address of pmemory can be much higher than the DDW size.
> + */
> + pseries_ddw_max_ram = ddw_memory_hotplug_max();
> }
>
> static int __init disable_multitce(char *str)
>
> base-commit: 6d35786de28116ecf78797a62b84e6bf3c45aa5a
> --
> 2.39.3
-ritesh
^ permalink raw reply
* Re: [PATCH v2 1/3] selftests/mm: handle EINVAL when configuring gigantic hugepages
From: Sayali Patil @ 2026-07-08 7:01 UTC (permalink / raw)
To: David Hildenbrand (Arm), Andrew Morton, Shuah Khan, linux-mm,
linux-kernel, linux-kselftest, Ritesh Harjani
Cc: Zi Yan, Michal Hocko, Oscar Salvador, Lorenzo Stoakes, Dev Jain,
Liam.Howlett, linuxppc-dev, Miaohe Lin, Venkat Rao Bagalkote
In-Reply-To: <32a42e83-3e5e-4b00-b78c-d762094b9d76@kernel.org>
On 01/07/26 14:18, David Hildenbrand (Arm) wrote:
> On 6/30/26 22:20, Sayali Patil wrote:
>>
>>
>> On 30/06/26 16:15, David Hildenbrand (Arm) wrote:
>>> On 6/30/26 11:32, Sayali Patil wrote:
>>>> Some MM selftests attempt to configure the amount of
>>>> HugeTLB pages of different sizes by writing to nr_hugepages.
>>>>
>>>> PowerPC hash MMU pSeries systems advertise gigantic hugepage sizes
>>>> but do not support runtime allocation of such pages, writes
>>>> to the corresponding nr_hugepages file fail with -EINVAL.
>>>> This causes the test to bail out even though the failure is due
>>>> to a platform limitation rather than the
>>>> functionality being tested.
>>>>
>>>> Treat -EINVAL from the sysfs write as a skipped configuration request
>>>> and continue running the test instead of failing.
>>>>
>>>> Before patch:
>>>> -------------------------
>>>> running ./hugetlb-madvise
>>>> -------------------------
>>>> TAP version 13
>>>> 1..1
>>>> [INFO] detected hugetlb page size: 16777216 KiB
>>>> [INFO] detected hugetlb page size: 16384 KiB
>>>> ok 1 MADV_DONTNEED and MADV_REMOVE on hugetlb
>>>> Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
>>>> Bail out! /sys/kernel/mm/hugepages/hugepages-16777216kB/nr_hugepages
>>>> write(0) failed: Invalid argument
>>>> Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
>>>> [FAIL]
>>>>
>>>> After patch:
>>>> -------------------------
>>>> running ./hugetlb-madvise
>>>> -------------------------
>>>> TAP version 13
>>>> 1..1
>>>> [INFO] detected hugetlb page size: 16777216 KiB
>>>> [INFO] detected hugetlb page size: 16384 KiB
>>>> ok 1 MADV_DONTNEED and MADV_REMOVE on hugetlb
>>>> Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
>>>> /sys/kernel/mm/hugepages/hugepages-16777216kB/nr_hugepages
>>>> write(0) failed: Invalid argument
>>>> [PASS]
>>>>
>>>> Fixes: 27477b28b74f ("selftests/mm: hugepage_settings: add APIs to get and
>>>> set nr_hugepages")
>>>> Signed-off-by: Sayali Patil <sayalip@linux.ibm.com>
>>>> ---
>>>> .../testing/selftests/mm/hugepage_settings.c | 32 ++++++++++++++++++-
>>>> .../testing/selftests/mm/hugepage_settings.h | 1 +
>>>> 2 files changed, 32 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/tools/testing/selftests/mm/hugepage_settings.c b/tools/testing/
>>>> selftests/mm/hugepage_settings.c
>>>> index 2eab2110ac6a..ce38ae3da01a 100644
>>>> --- a/tools/testing/selftests/mm/hugepage_settings.c
>>>> +++ b/tools/testing/selftests/mm/hugepage_settings.c
>>>> @@ -422,6 +422,36 @@ static void hugetlb_sysfs_path(char *buf, size_t buflen,
>>>> size / 1024, attr);
>>>> }
>>>> +void hugetlb_write_num(const char *path, unsigned long num)
>>>> +{
>>>> + int fd, saved_errno;
>>>> + ssize_t numwritten;
>>>> + char buf[21];
>>>> +
>>>> + sprintf(buf, "%lu", num);
>>>> +
>>>> + fd = open(path, O_WRONLY);
>>>> + if (fd == -1)
>>>> + ksft_exit_fail_msg("%s open failed: %s\n", path, strerror(errno));
>>>> +
>>>> + numwritten = write(fd, buf, strlen(buf));
>>>> + saved_errno = errno;
>>>> + close(fd);
>>>> + errno = saved_errno;
>>>> +
>>>> + /* Treat EINVAL as a skipped configuration (e.g., unsupported gigantic
>>>> pages) */
>>>> + if (numwritten < 0 && errno == EINVAL) {
>>>> + ksft_print_msg("%s write(%s) failed: %s\n", path, buf,
>>>> strerror(errno));
>>>
>>> Should we even print anything here? Rather confusing. It's just like we cannot
>>> allocate anything (no memory).
>>>
>>> In general, you are copy-pasting a lot of write_num()+write_file() content,
>>> which is really suboptimal.
>>>
>>> All you want is an option for write_num -> write_file to skip on -EINVAL,
>>> correct?
>>>
>>> There are not that many write_num / write_file users ...
>>>
>>
>> Hi David,
>>
>> Yes, all I need is to ignore the expected -EINVAL when attempting to
>> configure gigantic hugepages via nr_hugepages.
>>
>> I looked at extending write_num()/write_file() for this as in v1
>> (https://lore.kernel.org/
>> all/8bfa921e30eb94072685103f6496784aa23bb166.1782365671.git.sayalip@linux.ibm.com/),
>> but these helpers are shared by several other selftests.
>> For example, write_file() is used by split_huge_page_test setup and by
>> khugepaged tests for drop_caches, and is also used for various THP and
>> khugepaged settings where -EINVAL would indicate a genuine setup
>> failure. This concern was also raised during the v1 review.
>>
>> Because the expected -EINVAL is specific to gigantic hugepage runtime
>> allocation, I kept the handling local to the hugetlb setup path rather
>> than changing the semantics of the common helpers.
>>
>> I also agree that printing a message is not particularly useful in this
>> case, and we can simply return without emitting any output.
>
> We can either convert the functions to use flags, or hide it in some internal helpers, like the following:
>
> From 1b1b8ad51f1f0be469cb191736300254b9521fe4 Mon Sep 17 00:00:00 2001
> From: "David Hildenbrand (Arm)" <david@kernel.org>
> Date: Wed, 1 Jul 2026 10:45:16 +0200
> Subject: [PATCH] tmp
>
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
> ---
> tools/testing/selftests/mm/vm_util.c | 28 ++++++++++++++++++++++++----
> tools/testing/selftests/mm/vm_util.h | 1 +
> 2 files changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c
> index 311fc5b4513eb..362070f817e9b 100644
> --- a/tools/testing/selftests/mm/vm_util.c
> +++ b/tools/testing/selftests/mm/vm_util.c
> @@ -719,7 +719,8 @@ int read_file(const char *path, char *buf, size_t buflen)
> return (unsigned int) numread;
> }
>
> -void write_file(const char *path, const char *buf, size_t buflen)
> +static int __write_file(const char *path, const char *buf, size_t buflen,
> + bool ignore_einval)
> {
> int fd, saved_errno;
> ssize_t numwritten;
> @@ -735,14 +736,23 @@ void write_file(const char *path, const char *buf, size_t buflen)
> saved_errno = errno;
> close(fd);
> errno = saved_errno;
> - if (numwritten < 0)
> +
> + if (numwritten < 0) {
> + if (ignore_einval && errno == EINVAL)
> + return;
> ksft_exit_fail_msg("%s write(%.*s) failed: %s\n", path, (int)(buflen - 1),
> buf, strerror(errno));
> + }
> if (numwritten != buflen - 1)
> ksft_exit_fail_msg("%s write(%.*s) is truncated, expected %zu bytes, got %zd bytes\n",
> path, (int)(buflen - 1), buf, buflen - 1, numwritten);
> }
>
> +static void write_file(const char *path, const char *buf, size_t buflen)
> +{
> + __write_file(path, bug, buflen, /* ignore_einval = */ false);
> +}
> +
> unsigned long read_num(const char *path)
> {
> char buf[21];
> @@ -753,12 +763,22 @@ unsigned long read_num(const char *path)
> return strtoul(buf, NULL, 10);
> }
>
> -void write_num(const char *path, unsigned long num)
> +static void __write_num(const char *path, unsigned long num, bool ignore_einval)
> {
> char buf[21];
>
> sprintf(buf, "%lu", num);
> - write_file(path, buf, strlen(buf) + 1);
> + write_file(path, buf, strlen(buf) + 1, ignore_einval);
> +}
> +
> +void write_num(const char *path, unsigned long num)
> +{
> + return __write_num(path, num, /* ignore_einval = */ false);
> +}
> +
> +void write_num_ignore_einval(const char *path, unsigned long num)
> +{
> + return __write_num(path, num, /* ignore_einval = */ true);
> }
>
> static unsigned long shmall, shmmax;
> diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h
> index ea8fc8fdf0eb0..7799154b67eed 100644
> --- a/tools/testing/selftests/mm/vm_util.h
> +++ b/tools/testing/selftests/mm/vm_util.h
> @@ -168,6 +168,7 @@ void write_file(const char *path, const char *buf, size_t buflen);
> int read_file(const char *path, char *buf, size_t buflen);
> unsigned long read_num(const char *path);
> void write_num(const char *path, unsigned long num);
> +void write_num_ignore_einval(const char *path, unsigned long num);
>
> void shm_limits_prepare(unsigned long length);
> void __shm_limits_restore(void);
Thanks, David. I've sent out v3 incorporating the suggested changes.
V3:https://lore.kernel.org/all/cover.1783446924.git.sayalip@linux.ibm.com/
^ permalink raw reply
* [PATCH v3 3/3] selftests/mm: fix ternary operator precedence in ksm_tests
From: Sayali Patil @ 2026-07-08 6:59 UTC (permalink / raw)
To: Andrew Morton, Shuah Khan, linux-mm, linux-kernel,
linux-kselftest, Ritesh Harjani
Cc: David Hildenbrand, Zi Yan, Michal Hocko, Oscar Salvador,
Lorenzo Stoakes, Dev Jain, Liam.Howlett, linuxppc-dev, Miaohe Lin,
Venkat Rao Bagalkote, Sayali Patil
In-Reply-To: <cover.1783446924.git.sayalip@linux.ibm.com>
The KSM selftest uses conditional expressions to skip accesses to
merge_across_nodes on systems without NUMA support. However, the
ternary operator is combined with logical OR without parentheses:
a || numa_available() ? 0 : b || c
Due to operator precedence rules, this is parsed as:
(a || numa_available()) ? 0 : (b || c)
instead of the intended:
a || (numa_available() ? 0 : b) || c
Add parentheses around the conditional expressions to ensure the
correct evaluation order.
Fixes: 9aa1af954db0 ("selftests: vm: check numa_available() before operating "merge_across_nodes" in ksm_tests")
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Sayali Patil <sayalip@linux.ibm.com>
---
tools/testing/selftests/mm/ksm_tests.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/mm/ksm_tests.c b/tools/testing/selftests/mm/ksm_tests.c
index 2ebbb544c671..5fd7792a0d47 100644
--- a/tools/testing/selftests/mm/ksm_tests.c
+++ b/tools/testing/selftests/mm/ksm_tests.c
@@ -288,8 +288,8 @@ static bool assert_ksm_pages_count(long dupl_page_count)
static int ksm_save_def(struct ksm_sysfs *ksm_sysfs)
{
if (ksm_read_sysfs(KSM_FP("max_page_sharing"), &ksm_sysfs->max_page_sharing) ||
- numa_available() ? 0 :
- ksm_read_sysfs(KSM_FP("merge_across_nodes"), &ksm_sysfs->merge_across_nodes) ||
+ (numa_available() ? 0 :
+ ksm_read_sysfs(KSM_FP("merge_across_nodes"), &ksm_sysfs->merge_across_nodes)) ||
ksm_read_sysfs(KSM_FP("sleep_millisecs"), &ksm_sysfs->sleep_millisecs) ||
ksm_read_sysfs(KSM_FP("pages_to_scan"), &ksm_sysfs->pages_to_scan) ||
ksm_read_sysfs(KSM_FP("run"), &ksm_sysfs->run) ||
@@ -304,8 +304,8 @@ static int ksm_save_def(struct ksm_sysfs *ksm_sysfs)
static int ksm_restore(struct ksm_sysfs *ksm_sysfs)
{
if (ksm_write_sysfs(KSM_FP("max_page_sharing"), ksm_sysfs->max_page_sharing) ||
- numa_available() ? 0 :
- ksm_write_sysfs(KSM_FP("merge_across_nodes"), ksm_sysfs->merge_across_nodes) ||
+ (numa_available() ? 0 :
+ ksm_write_sysfs(KSM_FP("merge_across_nodes"), ksm_sysfs->merge_across_nodes)) ||
ksm_write_sysfs(KSM_FP("pages_to_scan"), ksm_sysfs->pages_to_scan) ||
ksm_write_sysfs(KSM_FP("run"), ksm_sysfs->run) ||
ksm_write_sysfs(KSM_FP("sleep_millisecs"), ksm_sysfs->sleep_millisecs) ||
@@ -846,8 +846,8 @@ int main(int argc, char *argv[])
if (ksm_write_sysfs(KSM_FP("run"), 2) ||
ksm_write_sysfs(KSM_FP("sleep_millisecs"), 0) ||
- numa_available() ? 0 :
- ksm_write_sysfs(KSM_FP("merge_across_nodes"), 1) ||
+ (numa_available() ? 0 :
+ ksm_write_sysfs(KSM_FP("merge_across_nodes"), 1)) ||
ksm_write_sysfs(KSM_FP("pages_to_scan"), page_count))
ksft_exit_fail_msg("Cannot set up KSM tunables\n");
--
2.52.0
^ permalink raw reply related
* [PATCH v3 1/3] selftests/mm: handle EINVAL when configuring gigantic hugepages
From: Sayali Patil @ 2026-07-08 6:59 UTC (permalink / raw)
To: Andrew Morton, Shuah Khan, linux-mm, linux-kernel,
linux-kselftest, Ritesh Harjani
Cc: David Hildenbrand, Zi Yan, Michal Hocko, Oscar Salvador,
Lorenzo Stoakes, Dev Jain, Liam.Howlett, linuxppc-dev, Miaohe Lin,
Venkat Rao Bagalkote, Sayali Patil
In-Reply-To: <cover.1783446924.git.sayalip@linux.ibm.com>
Some MM selftests attempt to configure the amount of
HugeTLB pages of different sizes by writing to nr_hugepages.
PowerPC hash MMU pSeries systems advertise gigantic hugepage sizes
but do not support runtime allocation of such pages, writes
to the corresponding nr_hugepages file fail with -EINVAL.
This causes the test to bail out even though the failure is due
to a platform limitation rather than the
functionality being tested.
Ignore -EINVAL when configuring nr_hugepages so that tests continue to
run on systems where gigantic hugepage allocation is unsupported.
Before patch:
-------------------------
running ./hugetlb-madvise
-------------------------
TAP version 13
1..1
[INFO] detected hugetlb page size: 16777216 KiB
[INFO] detected hugetlb page size: 16384 KiB
ok 1 MADV_DONTNEED and MADV_REMOVE on hugetlb
Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
Bail out! /sys/kernel/mm/hugepages/hugepages-16777216kB/nr_hugepages
write(0) failed: Invalid argument
Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
[FAIL]
After patch:
-------------------------
running ./hugetlb-madvise
-------------------------
TAP version 13
1..1
[INFO] detected hugetlb page size: 16777216 KiB
[INFO] detected hugetlb page size: 16384 KiB
ok 1 MADV_DONTNEED and MADV_REMOVE on hugetlb
Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
[PASS]
Fixes: 27477b28b74f ("selftests/mm: hugepage_settings: add APIs to get and set nr_hugepages")
Co-developed-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Sayali Patil <sayalip@linux.ibm.com>
---
.../testing/selftests/mm/hugepage_settings.c | 2 +-
tools/testing/selftests/mm/vm_util.c | 26 ++++++++++++++++---
tools/testing/selftests/mm/vm_util.h | 1 +
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/mm/hugepage_settings.c b/tools/testing/selftests/mm/hugepage_settings.c
index 2eab2110ac6a..d7917dce3aba 100644
--- a/tools/testing/selftests/mm/hugepage_settings.c
+++ b/tools/testing/selftests/mm/hugepage_settings.c
@@ -437,7 +437,7 @@ void hugetlb_set_nr_pages(unsigned long size, unsigned long nr)
hugetlb_sysfs_path(path, sizeof(path), size, "nr_hugepages");
- write_num(path, nr);
+ write_num_ignore_einval(path, nr);
}
unsigned long hugetlb_free_pages(unsigned long size)
diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c
index 311fc5b4513e..ef1ea11981a7 100644
--- a/tools/testing/selftests/mm/vm_util.c
+++ b/tools/testing/selftests/mm/vm_util.c
@@ -719,7 +719,7 @@ int read_file(const char *path, char *buf, size_t buflen)
return (unsigned int) numread;
}
-void write_file(const char *path, const char *buf, size_t buflen)
+static void __write_file(const char *path, const char *buf, size_t buflen, bool ignore_einval)
{
int fd, saved_errno;
ssize_t numwritten;
@@ -735,14 +735,22 @@ void write_file(const char *path, const char *buf, size_t buflen)
saved_errno = errno;
close(fd);
errno = saved_errno;
- if (numwritten < 0)
+ if (numwritten < 0) {
+ if (ignore_einval && errno == EINVAL)
+ return;
ksft_exit_fail_msg("%s write(%.*s) failed: %s\n", path, (int)(buflen - 1),
buf, strerror(errno));
+ }
if (numwritten != buflen - 1)
ksft_exit_fail_msg("%s write(%.*s) is truncated, expected %zu bytes, got %zd bytes\n",
path, (int)(buflen - 1), buf, buflen - 1, numwritten);
}
+void write_file(const char *path, const char *buf, size_t buflen)
+{
+ __write_file(path, buf, buflen, /* ignore_einval = */ false);
+}
+
unsigned long read_num(const char *path)
{
char buf[21];
@@ -753,12 +761,22 @@ unsigned long read_num(const char *path)
return strtoul(buf, NULL, 10);
}
-void write_num(const char *path, unsigned long num)
+static void __write_num(const char *path, unsigned long num, bool ignore_einval)
{
char buf[21];
sprintf(buf, "%lu", num);
- write_file(path, buf, strlen(buf) + 1);
+ __write_file(path, buf, strlen(buf) + 1, ignore_einval);
+}
+
+void write_num(const char *path, unsigned long num)
+{
+ return __write_num(path, num, /* ignore_einval = */ false);
+}
+
+void write_num_ignore_einval(const char *path, unsigned long num)
+{
+ return __write_num(path, num, /* ignore_einval = */ true);
}
static unsigned long shmall, shmmax;
diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h
index ea8fc8fdf0eb..7799154b67ee 100644
--- a/tools/testing/selftests/mm/vm_util.h
+++ b/tools/testing/selftests/mm/vm_util.h
@@ -168,6 +168,7 @@ void write_file(const char *path, const char *buf, size_t buflen);
int read_file(const char *path, char *buf, size_t buflen);
unsigned long read_num(const char *path);
void write_num(const char *path, unsigned long num);
+void write_num_ignore_einval(const char *path, unsigned long num);
void shm_limits_prepare(unsigned long length);
void __shm_limits_restore(void);
--
2.52.0
^ permalink raw reply related
* [PATCH v3 2/3] selftests/mm: fix ksm NUMA merge test for systems with memoryless NUMA nodes
From: Sayali Patil @ 2026-07-08 6:59 UTC (permalink / raw)
To: Andrew Morton, Shuah Khan, linux-mm, linux-kernel,
linux-kselftest, Ritesh Harjani
Cc: David Hildenbrand, Zi Yan, Michal Hocko, Oscar Salvador,
Lorenzo Stoakes, Dev Jain, Liam.Howlett, linuxppc-dev, Miaohe Lin,
Venkat Rao Bagalkote, Sayali Patil
In-Reply-To: <cover.1783446924.git.sayalip@linux.ibm.com>
The KSM NUMA merge test allocates identical pages on different NUMA
nodes and verifies KSM behavior with merge_across_nodes enabled and
disabled.
On systems with memoryless NUMA nodes, for example:
#numactl -H
available: 2 nodes (0,4)
.....
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
node 0 size: 14825 MB
node 0 free: 1382 MB
node 4 cpus:
node 4 size: 0 MB
node 4 free: 0 MB
the test may attempt to allocate memory on a node without memory,
causing numa_alloc_onnode() to fail and resulting in a spurious test
failure.
The test currently checks numa_num_configured_nodes() to determine
whether sufficient NUMA nodes are available. However, configured nodes
do not necessarily have memory.
Reuse the existing get_first_mem_node() and get_next_mem_node()
helpers to locate NUMA nodes that actually contain memory, and skip
the test when fewer than two such nodes are available.
Before patch:
---------------------------
running ./ksm_tests -N -m 1
---------------------------
mbind: Invalid argument
ok 1 KSM NUMA merging
Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
[PASS]
ok 1 ksm_tests -N -m 1
---------------------------
running ./ksm_tests -N -m 0
---------------------------
mbind: Invalid argument
not ok 1 KSM NUMA merging
Totals: pass:0 fail:1 xfail:0 xpass:0 skip:0 error:0
[FAIL]
not ok 2 ksm_tests -N -m 0 # exit=1
After patch:
---------------------------
running ./ksm_tests -N -m 1
---------------------------
At least 2 NUMA nodes with memory must be available
ok 1
SKIP KSM NUMA merging
Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
[PASS]
ok 1 ksm_tests -N -m 1
---------------------------
running ./ksm_tests -N -m 0
---------------------------
At least 2 NUMA nodes with memory must be available
ok 1
SKIP KSM NUMA merging
Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
[PASS]
ok 2 ksm_tests -N -m 0
Fixes: e3820ab252dd ("selftest/vm: fix ksm selftest to run with different NUMA topologies")
Co-developed-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Sayali Patil <sayalip@linux.ibm.com>
---
tools/testing/selftests/mm/ksm_tests.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/mm/ksm_tests.c b/tools/testing/selftests/mm/ksm_tests.c
index a050f4840cfa..2ebbb544c671 100644
--- a/tools/testing/selftests/mm/ksm_tests.c
+++ b/tools/testing/selftests/mm/ksm_tests.c
@@ -440,9 +440,9 @@ static int get_next_mem_node(int node)
mem_node = i % (max_node + 1);
node_size = numa_node_size(mem_node, NULL);
if (node_size > 0)
- break;
+ return mem_node;
}
- return mem_node;
+ return -ENODEV;
}
static int get_first_mem_node(void)
@@ -455,8 +455,8 @@ static int check_ksm_numa_merge(int merge_type, int mapping, int prot, int timeo
{
void *numa1_map_ptr, *numa2_map_ptr;
struct timespec start_time;
+ int first_node, second_node;
int page_count = 2;
- int first_node;
if (clock_gettime(CLOCK_MONOTONIC_RAW, &start_time)) {
ksft_perror("clock_gettime");
@@ -467,17 +467,19 @@ static int check_ksm_numa_merge(int merge_type, int mapping, int prot, int timeo
ksft_print_msg("NUMA support not enabled\n");
return KSFT_SKIP;
}
- if (numa_num_configured_nodes() <= 1) {
- ksft_print_msg("At least 2 NUMA nodes must be available\n");
+ first_node = get_first_mem_node();
+ second_node = get_next_mem_node(first_node);
+
+ if (second_node < 0) {
+ ksft_print_msg("At least 2 NUMA nodes with memory must be available\n");
return KSFT_SKIP;
}
if (ksm_write_sysfs(KSM_FP("merge_across_nodes"), merge_across_nodes))
return KSFT_FAIL;
/* allocate 2 pages in 2 different NUMA nodes and fill them with the same data */
- first_node = get_first_mem_node();
numa1_map_ptr = numa_alloc_onnode(page_size, first_node);
- numa2_map_ptr = numa_alloc_onnode(page_size, get_next_mem_node(first_node));
+ numa2_map_ptr = numa_alloc_onnode(page_size, second_node);
if (!numa1_map_ptr || !numa2_map_ptr) {
ksft_perror("numa_alloc_onnode");
return KSFT_FAIL;
--
2.52.0
^ permalink raw reply related
* [PATCH v3 0/3] selftests/mm: avoid false failures in hugetlb and KSM tests
From: Sayali Patil @ 2026-07-08 6:59 UTC (permalink / raw)
To: Andrew Morton, Shuah Khan, linux-mm, linux-kernel,
linux-kselftest, Ritesh Harjani
Cc: David Hildenbrand, Zi Yan, Michal Hocko, Oscar Salvador,
Lorenzo Stoakes, Dev Jain, Liam.Howlett, linuxppc-dev, Miaohe Lin,
Venkat Rao Bagalkote, Sayali Patil
Hi all,
This series fixes issues in the hugetlb and KSM MM selftest categories
that can report failures when the prerequisites for the tests are not
satisfied.
Patch 1 updates the hugetlb selftest helpers to handle -EINVAL when
attempting to configure gigantic HugeTLB pages via nr_hugepages.
PowerPC hash MMU pSeries systems expose gigantic hugepage sizes
but do not allow runtime allocation of such pages,
causing the sysfs write to fail. Handle this case gracefully and
continue running the test instead of aborting.
Patch 2 fixes the KSM NUMA merge test on systems with memoryless NUMA
nodes. The test currently relies on the number of configured NUMA nodes
and may attempt allocations on nodes that have no memory, resulting in
spurious failures. Use the existing helpers to identify
NUMA nodes that contain memory and skip the test when fewer than two
such nodes are available.
Patch 3 fixes a pre-existing operator precedence issue in ksm_tests,
where a ternary expression combined with logical OR operators could be
evaluated differently than intended. Added parentheses to ensure the
correct evaluation order.
These changes improve handling of unsupported test configurations and
unmet test prerequisites, avoiding spurious failures.
Thanks,
Sayali
---
V2 -> V3:
- For "selftests/mm: handle EINVAL when configuring gigantic hugepages":
Reworked the implementation to use internal helper functions with an
ignore_einval flag, as suggested by David Hildenbrand.
Added __write_file() and __write_num() helpers to optionally ignore
-EINVAL from sysfs writes.
Added write_num_ignore_einval() wrapper for callers that need to tolerate
unsupported hugepage configurations.
V2: https://lore.kernel.org/all/cover.1782811071.git.sayalip@linux.ibm.com/
---
V1 -> V2:
- For "selftests/mm: handle EINVAL when configuring gigantic hugepages":
Added a dedicated hugetlb_write_num() helper to handle the expected EINVAL
returned by gigantic hugepage configuration, in the
hugepage setup code rather than modifying the generic write_file() helper.
- For "selftests/mm: fix ksm NUMA merge test for systems with memoryless NUMA nodes":
Updated implementation as per David's review comment to build upon
existing helpers get_next_mem_node().
- Added new patch "selftests/mm: fix ternary operator precedence in ksm_tests"
to address a pre-existing issue identified during Sahiko's review.
V1: https://lore.kernel.org/all/cover.1782365671.git.sayalip@linux.ibm.com/
---
Sayali Patil (3):
selftests/mm: handle EINVAL when configuring gigantic hugepages
selftests/mm: fix ksm NUMA merge test for systems with memoryless NUMA
nodes
selftests/mm: fix ternary operator precedence in ksm_tests
.../testing/selftests/mm/hugepage_settings.c | 2 +-
tools/testing/selftests/mm/ksm_tests.c | 28 ++++++++++---------
tools/testing/selftests/mm/vm_util.c | 26 ++++++++++++++---
tools/testing/selftests/mm/vm_util.h | 1 +
4 files changed, 39 insertions(+), 18 deletions(-)
--
2.52.0
^ permalink raw reply
* Re: [patch 07/18] s390/syscall: Use enter_from_user_mode_randomize_stack()
From: Sven Schnelle @ 2026-07-08 6:47 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Peter Zijlstra, linux-s390, Michael Ellerman,
Shrikanth Hegde, linuxppc-dev, Kees Cook, Huacai Chen, loongarch,
Paul Walmsley, Palmer Dabbelt, linux-riscv, x86, Mark Rutland,
Jinjie Ruan, Andy Lutomirski, Oleg Nesterov, Richard Henderson,
Russell King, Catalin Marinas, Guo Ren, Geert Uytterhoeven,
Thomas Bogendoerfer, Helge Deller, Yoshinori Sato,
Richard Weinberger, Chris Zankel, linux-arm-kernel, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Arnd Bergmann, Vineet Gupta, Will Deacon, Brian Cain,
Michal Simek, Dinh Nguyen, David S. Miller, Andreas Larsson,
linux-snps-arc, linux-hexagon, linux-openrisc, sparclinux,
linux-arch, Michal Suchánek, Jonathan Corbet, linux-doc
In-Reply-To: <20260707190254.030598804@kernel.org>
Thomas Gleixner <tglx@kernel.org> writes:
> enter_from_user_mode_randomize_stack() replaces enter_from_user_mode() and
> the subsequent invocation of add_random_kstack_offset_irqsoff().
>
> As a bonus this avoids the overhead of get/put_cpu_var() in
> add_random_kstack_offset().
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> Cc: linux-s390@vger.kernel.org
> ---
> arch/s390/kernel/syscall.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/arch/s390/kernel/syscall.c
> +++ b/arch/s390/kernel/syscall.c
> @@ -97,8 +97,8 @@ void noinstr __do_syscall(struct pt_regs
> {
> unsigned long nr;
>
> - enter_from_user_mode(regs);
> - add_random_kstack_offset();
> + enter_from_user_mode_randomize_stack(regs);
> +
> regs->psw = get_lowcore()->svc_old_psw;
> regs->int_code = get_lowcore()->svc_int_code;
> update_timer_sys();
Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
^ permalink raw reply
* [PATCH] usb: phy: fsl-usb: clear fsl_otg_dev after freeing it
From: Guangshuo Li @ 2026-07-08 6:45 UTC (permalink / raw)
To: Greg Kroah-Hartman, Kees Cook, Duoming Zhou, Guangshuo Li,
Li Yang, Anatolij Gustschin, linux-usb, linuxppc-dev,
linux-kernel
fsl_otg_dev is a file-scoped singleton pointer and is used by
fsl_otg_conf() to decide whether the OTG device has already been
initialized.
fsl_otg_remove() frees fsl_otg_dev but leaves the global pointer
unchanged. A later bind can therefore see a non-NULL dangling pointer,
skip initialization, and continue using freed memory through the global
fsl_otg_dev pointer.
Clear fsl_otg_dev after freeing it so that a later probe does not treat a
dangling pointer as an initialized device.
Fixes: 0807c500a1a6 ("USB: add Freescale USB OTG Transceiver driver")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/usb/phy/phy-fsl-usb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 35d79f11b03d..0b5e937633f4 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -997,6 +997,7 @@ static void fsl_otg_remove(struct platform_device *pdev)
fsl_otg_uninit_timers();
kfree(fsl_otg_dev->phy.otg);
kfree(fsl_otg_dev);
+ fsl_otg_dev = NULL;
if (pdata->exit)
pdata->exit(pdev);
--
2.43.0
^ permalink raw reply related
* Re: [PATCH] ASoC: fsl_sai: Fix spurious BCLK on resume by clearing BYP
From: Shengjiu Wang @ 2026-07-08 6:09 UTC (permalink / raw)
To: Chancel Liu
Cc: Xiubo.Lee, festevam, nicoleotsuka, lgirdwood, broonie, perex,
tiwai, linux-kernel, linuxppc-dev, linux-sound
In-Reply-To: <20260707084648.475743-1-chancel.liu@oss.nxp.com>
On Tue, Jul 7, 2026 at 4:47 PM Chancel Liu <chancel.liu@oss.nxp.com> wrote:
>
> From: Chancel Liu <chancel.liu@nxp.com>
>
> When the BCLK divider ratio is 1:1, fsl_sai_set_bclk() enables bypass
> mode by setting BYP, but never clears the bit. The BYP=1 value remains
> in the regcache, and is restored by regcache_sync() on the next runtime
> resume.
>
> Since BYP=1 combined with BCD=1 immediately outputs the ungated MCLK
> as BCLK without waiting for BCE/TE/RE to be enabled, the clock is
> driven prematurely before the stream is fully configured, causing
> noise on some codecs.
>
> Fix this by clearing BYP and BCI together in fsl_sai_config_disable().
> Also clear BCI, which is programmed together with the bypass case in
> synchronous mode, so the cached CR2 state is clean and regcache_sync()
> will not restore bypass mode prematurely on the next resume.
>
> Fixes: a50b7926d015 ("ASoC: fsl_sai: implement 1:1 bclk:mclk ratio support")
> Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Best regards
Shengjiu Wang
> ---
> sound/soc/fsl/fsl_sai.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
> index 9661602b53c5..4c0626d572a5 100644
> --- a/sound/soc/fsl/fsl_sai.c
> +++ b/sound/soc/fsl/fsl_sai.c
> @@ -847,6 +847,9 @@ static void fsl_sai_config_disable(struct fsl_sai *sai, int dir)
> regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx, ofs),
> FSL_SAI_CSR_FR, FSL_SAI_CSR_FR);
>
> + regmap_update_bits(sai->regmap, FSL_SAI_xCR2(tx, ofs),
> + FSL_SAI_CR2_BCI | FSL_SAI_CR2_BYP, 0);
> +
> /*
> * For sai master mode, after several open/close sai,
> * there will be no frame clock, and can't recover
> --
> 2.50.1
>
^ permalink raw reply
* Re: [PATCH] perf data convert json: Fix trace_seq memory leak in process_sample_event()
From: Namhyung Kim @ 2026-07-08 6:05 UTC (permalink / raw)
To: Tanushree Shah
Cc: Arnaldo Carvalho de Melo, jolsa, adrian.hunter, vmolnaro, mpetlan,
tmricht, maddy, irogers, linux-perf-users, linuxppc-dev, atrajeev,
hbathini, Tejas.Manhas1, Tanushree.Shah, Shivani.Nittor
In-Reply-To: <845be1b6-8e56-46fa-a258-5b0033fac474@linux.ibm.com>
On Tue, Jul 07, 2026 at 07:36:06PM +0530, Tanushree Shah wrote:
> Hi Namhyung,
> The only change I had planned for v2 was the fix for the pre-existing issue,
> which has now already been merged separately upstream.
>
> https://github.com/torvalds/linux/commit/2857a5dca750ea989c6fb70b4c14e801e4b7b4ad
>
> Please let me know if there is any additional change you would like me to
> include in v2.
Oh, nevermind then. I'll process this.
Thanks,
Namhyung
^ permalink raw reply
* Re: [PATCH] powerpc/970: fix nap return address corruption on async interrupt exit
From: Mukesh Kumar Chaurasiya @ 2026-07-08 5:34 UTC (permalink / raw)
To: Shrikanth Hegde
Cc: maddy, mpe, npiggin, chleroy, mchauras, ruanjinjie, thuth,
linuxppc-dev, linux-kernel, Andreas Schwab
In-Reply-To: <880eba74-6427-4fa3-941d-b67bbf98f3a4@linux.ibm.com>
On Wed, Jul 08, 2026 at 09:57:44AM +0530, Shrikanth Hegde wrote:
> Hi Mukesh.
>
> On 7/7/26 10:54 PM, Mukesh Kumar Chaurasiya (IBM) wrote:
<... snip ...>
> > /* Can avoid a test-and-clear because NMIs do not call this */
> > clear_thread_local_flags(_TLF_NAPPING);
> > @@ -286,14 +293,6 @@ static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
> > static inline void arch_interrupt_async_exit_prepare(struct pt_regs *regs)
> > {
> > - /*
> > - * Adjust at exit so the main handler sees the true NIA. This must
> > - * come before irq_exit() because irq_exit can enable interrupts, and
> > - * if another interrupt is taken before nap_adjust_return has run
> > - * here, then that interrupt would return directly to idle nap return.
> > - */
> > - nap_adjust_return(regs);
> > -
> > arch_interrupt_exit_prepare(regs);
> > }
>
> This makes arch_interrupt_async_exit_prepare same as arch_interrupt_exit_prepare.
> Maybe remove arch_interrupt_async_exit_prepare?
>
Hey,
`arch_interrupt_async_exit_prepare` and `arch_interrupt_exit_prepare`,
both are marked static inline. So the generated assembly will have no
impact. I kept it this way coz it was consistent with how we implemented
other macros like `DEFINE_INTERRUPT_HANDLER`.
Regards,
Mukesh
> > diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h
> > index fb42a664ae54..1b45a49e9bed 100644
> > --- a/arch/powerpc/include/asm/interrupt.h
> > +++ b/arch/powerpc/include/asm/interrupt.h
> > @@ -246,6 +246,7 @@ interrupt_handler void func(struct pt_regs *regs) \
> > instrumentation_begin(); \
> > irq_enter_rcu(); \
> > ____##func (regs); \
> > + nap_adjust_return(regs); \
> > irq_exit_rcu(); \
> > instrumentation_end(); \
> > arch_interrupt_async_exit_prepare(regs); \
>
^ permalink raw reply
* Re: [patch 18/18] entry, treewide: Make syscall_enter_from_user_mode[_work]() indicate syscall execution
From: Shrikanth Hegde @ 2026-07-08 5:21 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: Peter Zijlstra, Michal Suchánek, Jonathan Corbet,
Arnd Bergmann, Mark Rutland, Huacai Chen, Michael Ellerman,
Paul Walmsley, Palmer Dabbelt, Sven Schnelle, linux-doc,
loongarch, linuxppc-dev, linux-riscv, linux-s390, Kees Cook, x86,
Jinjie Ruan, Andy Lutomirski, Oleg Nesterov, Richard Henderson,
Russell King, Catalin Marinas, Guo Ren, Geert Uytterhoeven,
Thomas Bogendoerfer, Helge Deller, Yoshinori Sato,
Richard Weinberger, Chris Zankel, linux-arm-kernel, linux-alpha,
linux-csky, linux-m68k, linux-mips, linux-parisc, linux-sh,
linux-um, Vineet Gupta, Will Deacon, Brian Cain, Michal Simek,
Dinh Nguyen, David S. Miller, Andreas Larsson, linux-snps-arc,
linux-hexagon, linux-openrisc, sparclinux, linux-arch
In-Reply-To: <20260707190254.603111179@kernel.org>
Hi Thomas.
On 7/8/26 12:37 AM, Thomas Gleixner wrote:
> From: Michal Suchánek <msuchanek@suse.de>
>
> The return values of syscall_enter_from_user_mode[_work]() are
> non-intuitive. Both functions return the syscall number which should be
> invoked by the architecture specific syscall entry code. The returned
> number can be:
>
> - the unmodified syscall number which was handed in by the caller
>
> - a modified syscall number (ptrace, seccomp, trace/probe/bpf)
>
> That has an additional twist. If the return value is -1L then the caller is
> not allowed to modify the return value as that indicates that the modifying
> entity requests to abort the syscall and set the return value already. That
> can obviously not be differentiated from a syscall which handed in -1 as
> syscall number.
>
> The established way to deal with that is:
>
> set_return_value(regs, -ENOSYS);
> nr = syscall_enter_from_user_mode(regs, nr);
> if ((unsigned)nr < SYSCALLNR_MAX)
> handle_syscall(regs, nr);
> else if (nr != -1)
> set_return_value(regs, -ENOSYS);
>
> The latter is obviously redundant, but that's just a leftover of the
> historical evolution of this code. S390 has some special requirements here,
> which can be avoided when the return value is not ambiguous.
>
> Now that the functions which modify the syscall number and want to abort
> are converted to indicate that with a boolean return value, it's obvious to
> hand this through to the callers.
>
> Rework syscall_enter_from_user_mode[_work]) so they take a pointer to the
> syscall number and return a boolean, which indicates whether the syscall
> should be handled or not.
>
> That's not only more intuitive, it also results in slightly denser
> executable code on x86 at least, but perf results are neutral and within
> the noise.
>
> [ tglx: Adopted it to the changes in the generic entry code, fixed up the
> 32-bit fallout and rewrote change log ]
>
> Signed-off-by: Michal Suchánek <msuchanek@suse.de>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Shrikanth Hegde <sshegde@linux.ibm.com>
> Cc: Paul Walmsley <pjw@kernel.org>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> Cc: linux-doc@vger.kernel.org
> Cc: loongarch@lists.linux.dev
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-riscv@lists.infradead.org
> Cc: linux-s390@vger.kernel.org
> ---
> Documentation/core-api/entry.rst | 18 +++++++++++-------
> arch/loongarch/kernel/syscall.c | 14 +++++++-------
> arch/powerpc/kernel/syscall.c | 3 ++-
> arch/riscv/kernel/traps.c | 11 +++++------
> arch/s390/kernel/syscall.c | 7 +++++--
> arch/x86/entry/syscall_32.c | 25 ++++++++++++-------------
> arch/x86/entry/syscall_64.c | 12 ++++++------
> include/linux/entry-common.h | 12 +++++-------
> 8 files changed, 53 insertions(+), 49 deletions(-)
>
> --- a/Documentation/core-api/entry.rst
> +++ b/Documentation/core-api/entry.rst
> @@ -68,16 +68,20 @@ low-level C code must not be instrumente
> noinstr void syscall(struct pt_regs *regs, int nr)
> {
> arch_syscall_enter(regs);
> - nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
> -
> - instrumentation_begin();
> - if (!invoke_syscall(regs, nr) && nr != -1)
> - result_reg(regs) = __sys_ni_syscall(regs);
> - instrumentation_end();
> -
> + result_reg(regs) = -ENOSYS;
> + if (syscall_enter_from_user_mode_randomize_stack(regs, &nr)) {
> + instrumentation_begin();
> + if (!invoke_syscall(regs, nr))
> + result_reg(regs) = __sys_ni_syscall(regs);
> + instrumentation_end();
> + }
> syscall_exit_to_user_mode(regs);
> }
>
> +It is required that either the low level assembly code or the syscall
> +function sets the result register to -ENOSYS before invoking the generic
> +code.
> +
> syscall_enter_from_user_mode_randomize_stack() first invokes
> enter_from_user_mode_randomize_stack() which establishes state in the
> following order:
> --- a/arch/loongarch/kernel/syscall.c
> +++ b/arch/loongarch/kernel/syscall.c
> @@ -57,8 +57,8 @@ typedef long (*sys_call_fn)(unsigned lon
>
> void noinstr __no_stack_protector do_syscall(struct pt_regs *regs)
> {
> - unsigned long nr;
> sys_call_fn syscall_fn;
> + unsigned long nr;
>
> nr = regs->regs[11];
> /* Set for syscall restarting */
> @@ -69,12 +69,12 @@ void noinstr __no_stack_protector do_sys
> regs->orig_a0 = regs->regs[4];
> regs->regs[4] = -ENOSYS;
>
> - nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
> -
> - if (nr < NR_syscalls) {
> - syscall_fn = sys_call_table[array_index_nospec(nr, NR_syscalls)];
> - regs->regs[4] = syscall_fn(regs->orig_a0, regs->regs[5], regs->regs[6],
> - regs->regs[7], regs->regs[8], regs->regs[9]);
> + if (likely(syscall_enter_from_user_mode_randomize_stack(regs, &nr))) {
> + if (nr < NR_syscalls) {
> + syscall_fn = sys_call_table[array_index_nospec(nr, NR_syscalls)];
> + regs->regs[4] = syscall_fn(regs->orig_a0, regs->regs[5], regs->regs[6],
> + regs->regs[7], regs->regs[8], regs->regs[9]);
> + }
> }
>
> syscall_exit_to_user_mode(regs);
> --- a/arch/powerpc/kernel/syscall.c
> +++ b/arch/powerpc/kernel/syscall.c
> @@ -18,7 +18,8 @@ notrace long system_call_exception(struc
> long ret;
> syscall_fn f;
>
> - r0 = syscall_enter_from_user_mode_randomize_stack(regs, r0);
> + if (unlikely(!syscall_enter_from_user_mode_randomize_stack(regs, &r0))
> + return syscall_get_error(current, regs);
>
There is one missing )
diff --git a/arch/powerpc/kernel/syscall.c b/arch/powerpc/kernel/syscall.c
index d85894bdb6a2..1440dcabe052 100644
--- a/arch/powerpc/kernel/syscall.c
+++ b/arch/powerpc/kernel/syscall.c
@@ -18,7 +18,7 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0)
long ret;
syscall_fn f;
- if (unlikely(!syscall_enter_from_user_mode_randomize_stack(regs, &r0))
+ if (unlikely(!syscall_enter_from_user_mode_randomize_stack(regs, &r0)))
return syscall_get_error(current, regs);
if (unlikely(r0 >= NR_syscalls)) {
> if (unlikely(r0 >= NR_syscalls)) {
> if (unlikely(trap_is_unsupported_scv(regs))) {
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -332,13 +332,12 @@ void do_trap_ecall_u(struct pt_regs *reg
>
> riscv_v_vstate_discard(regs);
>
> - syscall = syscall_enter_from_user_mode_randomize_stack(regs, syscall);
> -
> - if (syscall >= 0 && syscall < NR_syscalls) {
> - syscall = array_index_nospec(syscall, NR_syscalls);
> - syscall_handler(regs, syscall);
> + if (syscall_enter_from_user_mode_randomize_stack(regs, &syscall)) {
> + if (syscall >= 0 && syscall < NR_syscalls) {
> + syscall = array_index_nospec(syscall, NR_syscalls);
> + syscall_handler(regs, syscall);
> + }
> }
> -
> syscall_exit_to_user_mode(regs);
> } else {
> irqentry_state_t state = irqentry_nmi_enter(regs);
> --- a/arch/s390/kernel/syscall.c
> +++ b/arch/s390/kernel/syscall.c
> @@ -96,6 +96,7 @@ SYSCALL_DEFINE0(ni_syscall)
> void noinstr __do_syscall(struct pt_regs *regs, int per_trap)
> {
> unsigned long nr;
> + bool permit;
>
> enter_from_user_mode_randomize_stack(regs);
>
> @@ -121,7 +122,9 @@ void noinstr __do_syscall(struct pt_regs
> regs->psw.addr = current->restart_block.arch_data;
> current->restart_block.arch_data = 1;
> }
> - nr = syscall_enter_from_user_mode_work(regs, nr);
> +
> + permit = syscall_enter_from_user_mode_work(regs, &nr);
> +
> /*
> * In the s390 ptrace ABI, both the syscall number and the return value
> * use gpr2. However, userspace puts the syscall number either in the
> @@ -129,7 +132,7 @@ void noinstr __do_syscall(struct pt_regs
> * work, the ptrace code sets PIF_SYSCALL_RET_SET, which is checked here
> * and if set, the syscall will be skipped.
> */
> - if (unlikely(test_and_clear_pt_regs_flag(regs, PIF_SYSCALL_RET_SET)))
> + if (unlikely(test_and_clear_pt_regs_flag(regs, PIF_SYSCALL_RET_SET) || !permit))
> goto out;
> regs->gprs[2] = -ENOSYS;
> if (likely(nr < NR_syscalls)) {
> --- a/arch/x86/entry/syscall_32.c
> +++ b/arch/x86/entry/syscall_32.c
> @@ -161,8 +161,9 @@ static __always_inline bool int80_is_ext
> nr = syscall_32_enter(regs);
>
> local_irq_enable();
> - nr = syscall_enter_from_user_mode_work(regs, nr);
> - do_syscall_32_irqs_on(regs, nr);
> +
> + if (likely(syscall_enter_from_user_mode_work(regs, &nr)))
> + do_syscall_32_irqs_on(regs, nr);
>
> instrumentation_end();
> syscall_exit_to_user_mode(regs);
> @@ -223,8 +224,8 @@ DEFINE_FREDENTRY_RAW(int80_emulation)
> nr = syscall_32_enter(regs);
>
> local_irq_enable();
> - nr = syscall_enter_from_user_mode_work(regs, nr);
> - do_syscall_32_irqs_on(regs, nr);
> + if (likely(syscall_enter_from_user_mode_work(regs, &nr)))
> + do_syscall_32_irqs_on(regs, nr);
>
> instrumentation_end();
> syscall_exit_to_user_mode(regs);
> @@ -243,13 +244,13 @@ DEFINE_FREDENTRY_RAW(int80_emulation)
> * orig_ax, the int return value truncates it. This matches
> * the semantics of syscall_get_nr().
> */
> - nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
> -
> - instrumentation_begin();
> + if (likely(syscall_enter_from_user_mode_randomize_stack(regs, &nr))) {
> + instrumentation_begin();
>
> - do_syscall_32_irqs_on(regs, nr);
> + do_syscall_32_irqs_on(regs, nr);
>
> - instrumentation_end();
> + instrumentation_end();
> + }
> syscall_exit_to_user_mode(regs);
> }
> #endif /* !CONFIG_IA32_EMULATION */
> @@ -286,10 +287,8 @@ static noinstr bool __do_fast_syscall_32
> return false;
> }
>
> - nr = syscall_enter_from_user_mode_work(regs, nr);
> -
> - /* Now this is just like a normal syscall. */
> - do_syscall_32_irqs_on(regs, nr);
> + if (likely(syscall_enter_from_user_mode_work(regs, &nr)))
> + do_syscall_32_irqs_on(regs, nr);
>
> instrumentation_end();
> syscall_exit_to_user_mode(regs);
> --- a/arch/x86/entry/syscall_64.c
> +++ b/arch/x86/entry/syscall_64.c
> @@ -78,14 +78,14 @@ static __always_inline void do_syscall_x
> /* Returns true to return using SYSRET, or false to use IRET */
> __visible noinstr bool do_syscall_64(struct pt_regs *regs, long nr)
> {
> - nr = syscall_enter_from_user_mode_randomize_stack(regs, nr);
> + if (likely(syscall_enter_from_user_mode_randomize_stack(regs, &nr))) {
> + instrumentation_begin();
>
> - instrumentation_begin();
> + if (!do_syscall_x64(regs, nr))
> + do_syscall_x32(regs, nr);
>
> - if (!do_syscall_x64(regs, nr))
> - do_syscall_x32(regs, nr);
> -
> - instrumentation_end();
> + instrumentation_end();
> + }
> syscall_exit_to_user_mode(regs);
>
> /*
> --- a/include/linux/entry-common.h
> +++ b/include/linux/entry-common.h
> @@ -71,7 +71,7 @@ static inline void syscall_enter_audit(s
> }
> }
>
> -static __always_inline bool syscall_trace_enter(struct pt_regs *regs, unsigned long work,
> +static __always_inline long syscall_trace_enter(struct pt_regs *regs, unsigned long work,
> long *syscall)
> {
> /*
> @@ -141,16 +141,14 @@ static __always_inline bool syscall_trac
> * ptrace_report_syscall_permit_entry(), __seccomp_permit_syscall(), trace_sys_enter()
> * 2) Invocation of audit_syscall_entry()
> */
> -static __always_inline long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall)
> +static __always_inline bool syscall_enter_from_user_mode_work(struct pt_regs *regs, long *syscall)
> {
> unsigned long work = READ_ONCE(current_thread_info()->syscall_work);
>
> - if (work & SYSCALL_WORK_ENTER) {
> - if (!syscall_trace_enter(regs, work, &syscall))
> - return -1L;
> - }
> + if (unlikely(work & SYSCALL_WORK_ENTER))
> + return syscall_trace_enter(regs, work, syscall);
>
> - return syscall;
> + return true;
> }
>
> /**
>
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox