]> git.ipfire.org Git - thirdparty/linux.git/log
thirdparty/linux.git
3 months agos390/ptrace: Avoid KASAN false positives in regs_get_kernel_stack_nth()
Vasily Gorbik [Thu, 6 Mar 2025 18:12:54 +0000 (19:12 +0100)] 
s390/ptrace: Avoid KASAN false positives in regs_get_kernel_stack_nth()

With recent ftrace changes, argument tracing has been added to the
function tracer. As a result, ftrace opportunistically reads the first
FTRACE_REGS_MAX_ARGS (i.e., 6) registers. On s390, only five arguments are
passed in registers, and the 6-th is read from the stack. If a function
has fewer than 6 arguments, the following KASAN report may be observed:

 BUG: KASAN: stack-out-of-bounds in regs_get_kernel_stack_nth+0xa8/0xb0
 Read of size 8 at addr 00007f7fe066fdb8 by task swapper/31/0

 CPU: 31 UID: 0 PID: 0 Comm: swapper/31 Not tainted 6.14.0-rc4-00006-g76fe0337c219 #16
 Hardware name: IBM 3931 A01 704 (KVM/Linux)
 Call Trace:
  [<00007fffe0147224>] dump_stack_lvl+0x104/0x168
  [<00007fffe011381c>] print_address_description.constprop.0+0x34/0x338
  [<00007fffe0113b64>] print_report+0x44/0x138
  [<00007fffe0ad9422>] kasan_report+0xc2/0x180
  [<00007fffe0159ff8>] regs_get_kernel_stack_nth+0xa8/0xb0
  [<00007fffe05ebeda>] trace_function+0x23a/0x4d0
  [<00007fffe0615d32>] irqsoff_tracer_call+0xd2/0x110
  [<00007fffe2b4e34c>] ftrace_common+0x1c/0x40
  [<00007fffe0150826>] arch_cpu_idle_enter+0x6/0x10
  [<00007fffe035a1c8>] do_idle+0x168/0x2e0
  [<00007fffe035a9d0>] cpu_startup_entry+0x90/0xb0
  [<00007fffe017d25a>] smp_start_secondary+0x3da/0x4e0
  [<00007fffe2b4e20a>] restart_int_handler+0x72/0x88
 no locks held by swapper/31/0.

 The buggy address belongs to stack of task swapper/31/0
  and is located at offset 0 in frame:
  do_idle+0x0/0x2e0

 This frame has 1 object:
  [32, 40) '__mask'

 The buggy address belongs to the virtual mapping at
  [00007f7fe066000000007f7fe0671000) created by:
  dup_task_struct+0x66/0x4e0

 The buggy address belongs to the physical page:
 page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x80f23
 flags: 0x3ffff00000000000(node=0|zone=1|lastcpupid=0x1ffff)
 raw: 3ffff00000000000 0000000000000000 0000000000000122 0000000000000000
 raw: 0000000000000000 0000000000000000 ffffffff00000001 0000000000000000
 page dumped because: kasan: bad access detected

 Memory state around the buggy address:
  00007f7fe066fc80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00007f7fe066fd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 >00007f7fe066fd80: 00 00 00 00 00 00 00 f1 f1 f1 f1 00 f3 f3 f3 00
                                         ^
  00007f7fe066fe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00007f7fe066fe80: 00 f1 f1 f1 f1 00 f2 f2 f2 00 00 f3 f3 00 00 00

The function regs_get_kernel_stack_nth() verifies that the requested
argument is located on the stack, making it safe to read even if it is
not actually present. Make use of READ_ONCE_NOCHECK() helper to silence
KASAN reports in this case.

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/boot: Ignore vmlinux.map
WangYuli [Tue, 11 Mar 2025 03:08:24 +0000 (11:08 +0800)] 
s390/boot: Ignore vmlinux.map

When building with CONFIG_VMLINUX_MAP=y, a decompressor vmlinux.map file
is generated in the boot directory.

Add this file to .gitignore to ensure Git does not track it.

Signed-off-by: WangYuli <wangyuli@uniontech.com>
Link: https://lore.kernel.org/r/F884C733016D6715+20250311030824.675683-1-wangyuli@uniontech.com
Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/sysctl: Remove "vm/allocate_pgste" sysctl
Heiko Carstens [Mon, 10 Mar 2025 11:43:01 +0000 (12:43 +0100)] 
s390/sysctl: Remove "vm/allocate_pgste" sysctl

Remove the not needed "vm/allocate_pgste" sysctl. It has no effect
anymore. However this is a user space visible change. It shouldn't cause
any problems, however if it does this needs to be partially reverted.

Note that some distributions set
vm/allocate_pgste=1

in one of the various sysctl configuration files. Besides a warning about
the (now) non-existent procfs file this doesn't cause any problems.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390: Remove 2k vs 4k page table leftovers
Heiko Carstens [Mon, 10 Mar 2025 11:43:00 +0000 (12:43 +0100)] 
s390: Remove 2k vs 4k page table leftovers

Since commit d08d4e7cd6bf ("s390/mm: use full 4KB page for 2KB PTE") always
4k page tables are allocated, however there is still some (now) obsolete
code left which deals with switching from 2k to 4k page tables for qemu/kvm
processes.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Remove the not needed code.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/tlb: Use mm_has_pgste() instead of mm_alloc_pgste()
Heiko Carstens [Mon, 10 Mar 2025 11:42:59 +0000 (12:42 +0100)] 
s390/tlb: Use mm_has_pgste() instead of mm_alloc_pgste()

An mm has pgstes only after s390_enable_sie() has been called, while
mm_alloc_pgste() may be always true (e.g. via sysctl setting).

Limit the calls to gmap_unlink() in pte_free_tlb() to those cases
where there might be something to unlink.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/lowcore: Use lghi instead llilh to clear register
Heiko Carstens [Mon, 10 Mar 2025 09:33:43 +0000 (10:33 +0100)] 
s390/lowcore: Use lghi instead llilh to clear register

lghi is the fastest way to clear a register. Use that intead of llilh.

Suggested-by: Juergen Christ <jchrist@linux.ibm.com>
Reviewed-by: Juergen Christ <jchrist@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/syscall: Merge __do_syscall() and do_syscall()
Heiko Carstens [Mon, 10 Mar 2025 09:33:42 +0000 (10:33 +0100)] 
s390/syscall: Merge __do_syscall() and do_syscall()

The compiler inlines do_syscall() into __do_syscall(). Therefore do this in
C code as well, since this makes the code easier to understand.

Also adjust and add various unlikely() and likely() annotations.

Furthermore this allows to replace the separate exit_to_user_mode() and
syscall_exit_to_user_mode_work() calls with a combined
syscall_exit_to_user_mode() call which results in slightly better code.

Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/spinlock: Implement SPINLOCK_LOCKVAL with inline assembly
Heiko Carstens [Mon, 10 Mar 2025 09:33:41 +0000 (10:33 +0100)] 
s390/spinlock: Implement SPINLOCK_LOCKVAL with inline assembly

Implement SPINLOCK_LOCKVAL with an inline assembly, which makes use of the
ALTERNATIVE macro, to read spinlock_lockval from lowcore. Provide an
alternative instruction with a different offset in case lowcore is
relocated.

This replaces sequences of two instructions with one instruction.

Before:
  10602a:       a7 78 00 00             lhi     %r7,0
  10602e:       a5 8e 00 00             llilh   %r8,0
  106032:       58 d0 83 ac             l       %r13,940(%r8)
  106036:       ba 7d b5 80             cs      %r7,%r13,1408(%r11)

After:
  10602a:       a7 88 00 00             lhi     %r8,0
  10602e:       e3 70 03 ac 00 58       ly      %r7,940
  106034:       ba 87 b5 80             cs      %r8,%r7,1408(%r11)

Kernel image size change:
add/remove: 756/750 grow/shrink: 646/3435 up/down: 30778/-46326 (-15548)

Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/smp: Implement raw_smp_processor_id() with inline assembly
Heiko Carstens [Mon, 10 Mar 2025 09:33:40 +0000 (10:33 +0100)] 
s390/smp: Implement raw_smp_processor_id() with inline assembly

Implement raw_smp_processor_id() with an inline assembly, which makes
use of the ALTERNATIVE macro, to read cpu_nr from lowcore. Provide an
alternative instruction with a different offset in case lowcore is
relocated.

This replaces sequences of two instructions with one instruction.

Before:
  1000b6:       a5 1e 00 00             llilh   %r1,0
  1000ba:       58 20 13 a0             l       %r2,928(%r1)

After:
  1000b6:       e3 20 03 a0 00 58       ly      %r2,928

Kernel image size change:
add/remove: 753/755 grow/shrink: 230/1510 up/down: 30538/-35832 (-5294)

Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/current: Implement current with inline assembly
Heiko Carstens [Mon, 10 Mar 2025 09:33:39 +0000 (10:33 +0100)] 
s390/current: Implement current with inline assembly

Implement current with an inline assembly, which makes use of the
ALTERNATIVE macro, to read current from lowcore. Provide an alternative
instruction with a different offset in case lowcore is relocated.

This replaces sequences of two instructions with one instruction.

Before:
 100076:       a5 1e 00 00             llilh   %r1,0
 10007a:       e3 40 13 40 00 04       lg      %r4,832(%r1)

After:
 100076:       e3 10 03 40 00 04       lg      %r1,832

Kernel image size change:
add/remove: 3/17 grow/shrink: 166/2204 up/down: 7122/-24594 (-17472)

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/lowcore: Use inline qualifier for get_lowcore() inline assembly
Heiko Carstens [Mon, 10 Mar 2025 09:33:38 +0000 (10:33 +0100)] 
s390/lowcore: Use inline qualifier for get_lowcore() inline assembly

Use asm_inline to let the compiler know that the get_lowcore() inline
assembly has the smallest possible size. The ALTERNATIVE construct is used
to generate a single instruction, however the macro expands to multiple
lines. GCC uses the number of lines of an inline assembly to count the
number of instructions within an inline assembly, which then has an effect
on inlining decisions.

In order to avoid incorrect assumptions use asm_inline. The result is that
more functions are inlined, which results in a small growth of the kernel
image:

add/remove: 59/480 grow/shrink: 854/647 up/down: 168780/-162394 (6386)

Reviewed-by: Juergen Christ <jchrist@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390: Move s390 sysctls into their own file under arch/s390
joel granados [Thu, 6 Mar 2025 11:29:46 +0000 (12:29 +0100)] 
s390: Move s390 sysctls into their own file under arch/s390

Move s390 sysctls (spin_retry and userprocess_debug) into their own
files under arch/s390. Create two new sysctl tables
(2390_{fault,spin}_sysctl_table) which will be initialized with
arch_initcall placing them after their original place in proc_root_init.

This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.

Signed-off-by: joel granados <joel.granados@kernel.org>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Link: https://lore.kernel.org/r/20250306-jag-mv_ctltables-v2-6-71b243c8d3f8@kernel.org
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agoMerge branch 'strict-mm-typechecks-support' into features
Vasily Gorbik [Tue, 11 Mar 2025 14:29:44 +0000 (15:29 +0100)] 
Merge branch 'strict-mm-typechecks-support' into features

Heiko writes:

"The recent large kernel Rust thread where Linus commented about that
structures may be returned in registers [1] made me again aware that this
is not true for s390 where the ABI defines that structures are returned in
a return value buffer allocated by the caller. This was also mentioned by
Alexander Gordeev a couple of weeks ago.

In theory the -freg-struct-return compiler flag would allow to return small
structures in registers, however that has not been implemented for
s390. Juergen Christ did an experimental gcc implementation which shows the
benefit of such a change (bloat-o-meter):

add/remove: 3/2 grow/shrink: 12/441 up/down: 740/-7182 (-6442)

This result is not very impressive, and doesn't seem to justify a new ABI
for the kernel.

However there is still the existing STRICT_MM_TYPECHECKS which can be used
to change some mm types from structures to simple scalar types. Changing
the mm types results in:

add/remove: 2/8 grow/shrink: 25/116 up/down: 3902/-6204 (-2302)

Which is already a third of the possible savings which would be the result
of the described ABI change.

Therefore add support for a configurable STRICT_MM_TYPECHECKS which allows
to generate better code, but also allows to have type checking for debug
builds."

[1] https://lore.kernel.org/all/CAHk-=wgb1g9VVHRaAnJjrfRFWAOVT2ouNOMqt0js8h3D6zvHDw@mail.gmail.com/

* strict-mm-typechecks-support:
  s390/mm: Add configurable STRICT_MM_TYPECHECKS
  s390/mm: Convert pgste_val() into function
  s390/mm: Convert pgprot_val() into function
  s390/mm: Use pgprot_val() instead of open coding

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/syscall: Simplify syscall_get_arguments()
Sven Schnelle [Thu, 27 Feb 2025 07:22:07 +0000 (08:22 +0100)] 
s390/syscall: Simplify syscall_get_arguments()

Replace the while loop and if statement with a simple for loop
to make the code easier to understand.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/vfio-ap: Notify userspace that guest's AP config changed when mdev removed
Rorie Reyes [Tue, 4 Mar 2025 20:08:12 +0000 (15:08 -0500)] 
s390/vfio-ap: Notify userspace that guest's AP config changed when mdev removed

The guest's AP configuration is cleared when the mdev is removed, so
userspace must be notified that the AP configuration has changed. To this
end, this patch:

* Removes call to 'signal_guest_ap_cfg_changed()' function from the
  'vfio_ap_mdev_unset_kvm()' function because it has no affect given it is
  called after the mdev fd is closed.

* Adds call to 'signal_guest_ap_cfg_changed()' function to the
  'vfio_ap_mdev_request()' function to notify userspace that the guest's
  AP configuration has changed before signaling the request to remove the
  mdev.

Minor change - Fixed an indentation issue in function
'signal_guest_ap_cfg_changed()'

Fixes: 07d89045bffe ("s390/vfio-ap: Signal eventfd when guest AP configuration is changed")
Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com>
Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Link: https://lore.kernel.org/r/20250304200812.54556-1-rreyes@linux.ibm.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390: Remove ioremap_wt() and pgprot_writethrough()
Niklas Schnelle [Fri, 21 Feb 2025 11:51:48 +0000 (12:51 +0100)] 
s390: Remove ioremap_wt() and pgprot_writethrough()

It turns out that while s390 architecture calls its memory-I/O mapping
variants write-through and write-back the implementation of ioremap_wt()
and pgprot_writethrough() does not match Linux notion of ioremap_wt().

In particular Linux expects ioremap_wt() to be weaker still than
ioremap_wc(), allowing not just gathering and re-ordering but also reads
to be served from cache. Instead s390's implementation is equivalent to
normal ioremap() while its ioremap_wc() allows re-ordering.

Note that there are no known users of ioremap_wt() on s390 and the
resulting behavior is in line with asm-generic defining ioremap_wt() as
ioremap(), if undefined, so no breakage is expected.

As s390 does not have a mapping type matching the Linux notion of
ioremap_wt() and pgprot_writethrough(), simply drop them and rely on the
asm-generic fallbacks instead.

Fixes: b02002cc4c0f ("s390/pci: Implement ioremap_wc/prot() with MIO")
Fixes: b43b3fff042d ("s390: mm: convert to GENERIC_IOREMAP")
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/mm: Add configurable STRICT_MM_TYPECHECKS
Heiko Carstens [Tue, 4 Mar 2025 08:14:33 +0000 (09:14 +0100)] 
s390/mm: Add configurable STRICT_MM_TYPECHECKS

Add support for configurable STRICT_MM_TYPECHECKS. The s390 ABI defines
that return values with complex types like structures and unions are
returned in a return value buffer allocated by the caller. This is also
true for small structures and unions which would fit into a register.  On
the other hand when such types are passed as arguments to functions they
are passed in registers, if they are small enough.
This leads to inefficient code when such a return value of a function call
is then passed as argument to a subsequent function call.

This is especially true for all mm types, like pte_t and others, which are
only for type checking reasons defined as a structure. This however can be
bypassed with the STRICT_MM_TYPECHECKS feature, which is used by a few
other architectures, which seem to have the same problem.

Add CONFIG_STRICT_MM_TYPECHECKS which can be used to change the type of
pte_t and other structures. If the config option is not enabled the types
are defined to unsigned long, allowing for better code generation, however
there is no type checking anymore. If it is enabled the types are
structures like before so that type checking is performed, but less
efficient code is generated.

The option is always enabled in debug_defconfig, and for convenience an
mmtypes.config topic target is added, which allows to easily enable it, in
case memory management code is changed.

CONFIG_STRICT_MM_TYPECHECKS and STRICT_MM_TYPECHECKS are kept separate,
since STRICT_MM_TYPECHECKS is common across architectures and common
code. Therefore use the same define also for s390 code.

Add CONFIG_STRICT_MM_TYPECHECKS to make it build time configurable.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/mm: Convert pgste_val() into function
Heiko Carstens [Tue, 4 Mar 2025 08:14:32 +0000 (09:14 +0100)] 
s390/mm: Convert pgste_val() into function

Similar to all other *_val() functions convert the last remaining
architecture specific mm primitive pgste_val() into a function.

Add set_pgste_bit() and clear_pgste_bit() helper functions which allow to
clear and set pgste bits. This is also similar to e.g. set_pte_bit() and
other helper functions.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/mm: Convert pgprot_val() into function
Heiko Carstens [Tue, 4 Mar 2025 08:14:31 +0000 (09:14 +0100)] 
s390/mm: Convert pgprot_val() into function

Convert pgprot_val() into a function similar to other mm primitives like
e.g. pte_val(). This disallows usage as an lvalue; however there aren't any
such users left, except for some architecture specific ones.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
3 months agos390/mm: Use pgprot_val() instead of open coding
Heiko Carstens [Tue, 4 Mar 2025 08:14:30 +0000 (09:14 +0100)] 
s390/mm: Use pgprot_val() instead of open coding

Use pgprot_val() to get the page protection value, instead of accessing the
structure member directly. The type of pgprot_t is supposed to be hidden
from all users so that it can be changed; e.g. for STRICT_MM_TYPECHECKS.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/atomic_ops: Let __atomic_add_const() variants always return void
Heiko Carstens [Fri, 28 Feb 2025 14:11:03 +0000 (15:11 +0100)] 
s390/atomic_ops: Let __atomic_add_const() variants always return void

Depending on MARCH_HAS_Z196_FEATURES __atomic_add_const() returns void or
the previous value before the atomic variant. Make sure that for both cases
void is returned so potential incorrect usage results in both cases in a
compile error.

Reviewed-by: Juergen Christ <jchrist@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/traps: Change stack overflow message
Sven Schnelle [Thu, 27 Feb 2025 06:49:48 +0000 (07:49 +0100)] 
s390/traps: Change stack overflow message

When the kernel stack pointer is pointing to invalid memory,
a 'Kernel stack overflow' message is printed, which is misleading.
Change the message to actually say that the stack pointer is invalid
instead.

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/traps: Cleanup coding style
Heiko Carstens [Wed, 26 Feb 2025 10:03:07 +0000 (11:03 +0100)] 
s390/traps: Cleanup coding style

Just some trivial whitespace and coding style changes.

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/traps: Get rid of superfluous cpu_has_vx() check
Heiko Carstens [Wed, 26 Feb 2025 10:03:06 +0000 (11:03 +0100)] 
s390/traps: Get rid of superfluous cpu_has_vx() check

If the vector facility is installed cpu_has_vx() is always true, if it is
not installed the result is always false, and no vector exception can
happen. Therefore remove the superfluous check.

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/traps: Use pr_emerg() instead of printk()
Heiko Carstens [Wed, 26 Feb 2025 10:03:05 +0000 (11:03 +0100)] 
s390/traps: Use pr_emerg() instead of printk()

Use pr_emerg() instead of printk() in case of a stack overflow,
providing the emergency printk level. Also slightly adjust the
printed text for pr_emerg() and panic().

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/traps: Cleanup get_user() handling in illegal_op()
Heiko Carstens [Wed, 26 Feb 2025 10:03:04 +0000 (11:03 +0100)] 
s390/traps: Cleanup get_user() handling in illegal_op()

The usage of get_user() in illegal_op() is quite unusual. Make the code
more readable and get rid of unnecessary casts. The generated code is
identical before/after this change.

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/boot: Convert __diag308() to extable
Heiko Carstens [Mon, 24 Feb 2025 14:59:11 +0000 (15:59 +0100)] 
s390/boot: Convert __diag308() to extable

Shorten __diag308() and use regular EX_TABLE program check handling.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/boot: Convert detect_diag9c() to extable
Heiko Carstens [Mon, 24 Feb 2025 14:59:10 +0000 (15:59 +0100)] 
s390/boot: Convert detect_diag9c() to extable

Shorten detect_diag9c() and use regular EX_TABLE program check handling.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/boot: Convert diag500_storage_limit() to extable
Heiko Carstens [Mon, 24 Feb 2025 14:59:09 +0000 (15:59 +0100)] 
s390/boot: Convert diag500_storage_limit() to extable

Shorten diag500_storage_limit() and use regular EX_TABLE program check
handling.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/boot: Convert tprot() to extable
Heiko Carstens [Mon, 24 Feb 2025 14:59:08 +0000 (15:59 +0100)] 
s390/boot: Convert tprot() to extable

Shorten tprot() and use regular EX_TABLE program check handling.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/boot: Convert __diag260() to extable
Heiko Carstens [Mon, 24 Feb 2025 14:59:07 +0000 (15:59 +0100)] 
s390/boot: Convert __diag260() to extable

Shorten __diag260() and use regular EX_TABLE program check handling.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/boot: Convert cmma_test_essa() to extable
Heiko Carstens [Mon, 24 Feb 2025 14:59:06 +0000 (15:59 +0100)] 
s390/boot: Convert cmma_test_essa() to extable

Shorten cmma_test_essa() and use regular EX_TABLE program check handling.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/boot: Add exception table support
Heiko Carstens [Mon, 24 Feb 2025 14:59:05 +0000 (15:59 +0100)] 
s390/boot: Add exception table support

The early boot code contains various open-coded inline assemblies with
exception handling. In order to handle possible exceptions each of them
changes the program check new psw, and restores it.

In order to simplify the various inline assemblies add simple exception
table support: the program check handler is called with a fully populated
pt_regs on the stack and may change the psw and register members. When the
program check handler returns the psw and registers from pt_regs will be
used to continue execution.

The program check handler searches the exception table for an entry which
matches the address of the program check. If such an entry is found the psw
address within pt_regs on the stack is replaced with a fixup address, and
execution continues at the new address.

If no entry is found the psw is changed to a disabled wait psw and
execution stops.

Before entering the C part of the program check handler the address of the
program check new psw is replaced to a minimalistic handler.
This is supposed to help against program check loops. If an exception
happens while in program check processing the register contents of the
original exception are restored and a disabled wait psw is loaded.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/boot: Pass pt_regs to program check handler
Heiko Carstens [Mon, 24 Feb 2025 14:59:04 +0000 (15:59 +0100)] 
s390/boot: Pass pt_regs to program check handler

Setup a pt_regs structure on the stack, poplulate it in low level assembler
code, and pass it to print_pgm_check_info(). This way there is no need to
access then lowcore from print_pgm_check_info() anymore, and the function
looks like a normal program check handler function.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/asm-offsets: Rename __LC_PGM_INT_CODE
Heiko Carstens [Mon, 24 Feb 2025 14:59:03 +0000 (15:59 +0100)] 
s390/asm-offsets: Rename __LC_PGM_INT_CODE

Avoid confusion and rename __LC_PGM_INT_CODE since it correlates to the
pgm_code member of struct lowcore, and not the pgm_int_code member.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390: Use system header file variant of include directive
Heiko Carstens [Tue, 25 Feb 2025 08:47:34 +0000 (09:47 +0100)] 
s390: Use system header file variant of include directive

A few include directives use the local search variant even though the files
to be included aren't local. Therefore use the normal system header file
variant of the include directive.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/mm: Simplify gap clamping in mmap_base() using clamp()
Qasim Ijaz [Tue, 4 Feb 2025 16:25:08 +0000 (16:25 +0000)] 
s390/mm: Simplify gap clamping in mmap_base() using clamp()

mmap_base() has logic to ensure that the variable "gap" stays within the
range defined by "gap_min" and "gap_max". Replace this with the clamp()
macro to shorten and simplify code.

Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
Link: https://lore.kernel.org/r/20250204162508.12335-1-qasdev00@gmail.com
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
[gor@linux.ibm.com: also remove the gap_min and gap_max variables]
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/tty: Fix a potential memory leak bug
Haoxiang Li [Tue, 18 Feb 2025 03:41:04 +0000 (11:41 +0800)] 
s390/tty: Fix a potential memory leak bug

The check for get_zeroed_page() leads to a direct return
and overlooked the memory leak caused by loop allocation.
Add a free helper to free spaces allocated by get_zeroed_page().

Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Link: https://lore.kernel.org/r/20250218034104.2436469-1-haoxiang_li2024@163.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/sclp: Add check for get_zeroed_page()
Haoxiang Li [Tue, 18 Feb 2025 02:52:16 +0000 (10:52 +0800)] 
s390/sclp: Add check for get_zeroed_page()

Add check for the return value of get_zeroed_page() in
sclp_console_init() to prevent null pointer dereference.
Furthermore, to solve the memory leak caused by the loop
allocation, add a free helper to do the free job.

Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Link: https://lore.kernel.org/r/20250218025216.2421548-1-haoxiang_li2024@163.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/alternatives: Add debug functionality
Heiko Carstens [Fri, 7 Feb 2025 14:49:11 +0000 (15:49 +0100)] 
s390/alternatives: Add debug functionality

Similar to x86 and loongarch add a "debug-alternative" command line
parameter, which allows for alternative debugging. The parameter
itself comes with architecture specific semantics:

"debug-alternative"
 -> print debug message for every single alternative

"debug-alternative=0;2"
-> print debug message for all alternatives with type 0 and 2

"debug-alternative=0:0-7"
-> print debug message for all alternatives with type 0 which have a
   facility number within the range of 0-7

"debug-alternative=0:!8;1"
-> print debug message for all alternatives with type 0, for all
   facility numbers, except facility 8, and in addition print all
   alternatives with type 1

A defconfig build currently results in a kernel with more than 20.000
alternatives, where the majority is for the niai alternative (spinlocks),
and the relocated lowcore alternative. The following kernel command like
options limit alternative debug output, and enable dynamic debug messages:

debug-alternative=0:!49;1:!0
earlyprintk
bootdebug
ignore_loglevel
loglevel=8
dyndbg="file alternative.c +p"

This results in output like this:

 alt: [0/ 11] 0000021b9ce8680cc0f400000089 -> c00400000000
 alt: [0/ 64] 0000021b9ce87e60c0f400000043 -> c00400000000
 alt: [0/133] 0000021b9ce88c56c0f400000027 -> c00400000000
 alt: [0/ 74] 0000021b9ce89410c0f40000002a -> c00400000000
 alt: [0/ 40] 0000021b9dc3720a47000000 -> b280d398
 alt: [0/193] 0000021b9dc3730647000000 -> b201d2b0
 alt: [0/193] 0000021b9dc37354c00400000000 -> d20720c0d2b0
 alt: [1/  5] 0000038d720d7bf2c0f400000016 -> c00400000000

With

[<alternative type>/<alternative data>] <address> oldcode -> newcode

Alternative data depends on the alternative type: for type 0
(ALT_TYPE_FACILITY) data is the facility. For type 1 (ALT_TYPE_FEATURE)
data is the corresponding machine feature.

Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/setup: Add decompressor_handled_param() wrapper
Heiko Carstens [Fri, 7 Feb 2025 14:49:10 +0000 (15:49 +0100)] 
s390/setup: Add decompressor_handled_param() wrapper

Make decompressor_handled_param() a wrapper for
__decompressor_handled_param(). __decompressor_handled_param() now
takes two parameters: a function name and a parameter name, which do
not necessarily match.

This allows to use characters like "-", which are not allowed in
function names, for command line parameters which are handled by the
decompressor and should be ignored by the kernel.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/bear: Convert cpu_has_bear() to cpu feature function
Heiko Carstens [Fri, 7 Feb 2025 14:49:09 +0000 (15:49 +0100)] 
s390/bear: Convert cpu_has_bear() to cpu feature function

Get rid of the cpu_has_bear jump label and convert cpu_has_bear() to a cpu
feature function using test_facility() and with that use a static branch.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/vx: Convert cpu_has_vx() to cpu feature function
Heiko Carstens [Fri, 7 Feb 2025 14:49:08 +0000 (15:49 +0100)] 
s390/vx: Convert cpu_has_vx() to cpu feature function

Instead of having a private cpu_has_vx() implementation use the new common
cpu feature method. Move the facility detection to the decompressor so it
matches all other cpu features.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390: Convert MACHINE_IS_[LPAR|VM|KVM], etc, machine_is_[lpar|vm|kvm]()
Heiko Carstens [Fri, 7 Feb 2025 14:49:07 +0000 (15:49 +0100)] 
s390: Convert MACHINE_IS_[LPAR|VM|KVM], etc, machine_is_[lpar|vm|kvm]()

Move machine type detection to the decompressor and use static branches
to implement and use machine_is_[lpar|vm|kvm]() instead of a runtime check
via MACHINE_IS_[LPAR|VM|KVM].

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/sysinfo: Move stsi() to header file
Heiko Carstens [Fri, 7 Feb 2025 14:49:06 +0000 (15:49 +0100)] 
s390/sysinfo: Move stsi() to header file

Move stsi() inline assembly to header file so it is possible to use it
also for the decompressor.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/sysinfo: Cleanup stsi() inline assembly
Heiko Carstens [Fri, 7 Feb 2025 14:49:05 +0000 (15:49 +0100)] 
s390/sysinfo: Cleanup stsi() inline assembly

Merge stsi() and __stsi() and cleanup the inline assembly. This involves
making use of the flag output constraint. Semantically the result is
identical to before.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/sysinfo: Remove exception handling from __stsi()
Heiko Carstens [Fri, 7 Feb 2025 14:49:04 +0000 (15:49 +0100)] 
s390/sysinfo: Remove exception handling from __stsi()

The exception handling for __stsi() was added in 2001 when it still was
possible to run Linux on systems without LPAR hypervisor, and therefore
without an stsi instruction. Given that this is not supported anymore
remove the exception handling from the __stsi() inline assembly.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/diag: Convert MACHINE_HAS_DIAG9C to machine_has_diag9c()
Heiko Carstens [Fri, 7 Feb 2025 14:49:03 +0000 (15:49 +0100)] 
s390/diag: Convert MACHINE_HAS_DIAG9C to machine_has_diag9c()

Use static branch(es) to implement and use machine_has_diag9c() instead of
a runtime check via MACHINE_HAS_DIAG9C.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/kvm: Convert MACHINE_HAS_ESOP to machine_has_esop()
Heiko Carstens [Fri, 7 Feb 2025 14:49:02 +0000 (15:49 +0100)] 
s390/kvm: Convert MACHINE_HAS_ESOP to machine_has_esop()

Use static branch(es) to implement and use machine_has_esop() instead
of a runtime check via MACHINE_HAS_ESOP.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/tx: Convert MACHINE_HAS_TE to machine_has_tx()
Heiko Carstens [Fri, 7 Feb 2025 14:49:01 +0000 (15:49 +0100)] 
s390/tx: Convert MACHINE_HAS_TE to machine_has_tx()

Use static branch(es) to implement and use machine_has_tx() instead of
a runtime check with MACHINE_HAS_TE.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/tlb: Convert MACHINE_HAS_TLB_GUEST to machine_has_tlb_guest()
Heiko Carstens [Fri, 7 Feb 2025 14:49:00 +0000 (15:49 +0100)] 
s390/tlb: Convert MACHINE_HAS_TLB_GUEST to machine_has_tlb_guest()

Use static branch(es) to implement and use machine_has_tlb_guest()
instead of a runtime check via MACHINE_HAS_TLB_GUEST.

Also add sclp_early_detect_machine_features() in order to allow for
feature detection from the decompressor.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/time: Convert MACHINE_HAS_SCC to machine_has_scc()
Heiko Carstens [Fri, 7 Feb 2025 14:48:59 +0000 (15:48 +0100)] 
s390/time: Convert MACHINE_HAS_SCC to machine_has_scc()

Use static branch(es) to implement and use machine_has_scc() instead
of a runtime check via MACHINE_HAS_SCC.

This comes with a cleanup of early time initialization: the initial
tod_clock_base value is now passed via the bootdata mechanism, instead
of using absolute lowcore as transport vehicle from the decompressor
to the kernel.

Also the early tod clock initialization is moved to the decompressor
which allows to use a static branch with machine_has_scc() within the
kernel.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/pci: Get rid of MACHINE_HAS_PCI_MIO
Heiko Carstens [Fri, 7 Feb 2025 14:48:58 +0000 (15:48 +0100)] 
s390/pci: Get rid of MACHINE_HAS_PCI_MIO

Remove MACHINE_FLAG_PCI_MIO/MACHINE_HAS_PCI_MIO and implement the identical
functionality with set_machine_feature(), clear_machine_feature() and
test_machine_feature().

Acked-by: Niklas Schnelle <schnelle@linux.ibm.com>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/lowcore: Convert relocated lowcore alternative to machine feature
Heiko Carstens [Fri, 7 Feb 2025 14:48:57 +0000 (15:48 +0100)] 
s390/lowcore: Convert relocated lowcore alternative to machine feature

Convert the explicit relocated lowcore alternative type to a more
generic machine feature. This only reduces the number of alternative
types, but has no impact on code generation.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390: Static branches for machine features infrastructure
Heiko Carstens [Fri, 7 Feb 2025 14:48:56 +0000 (15:48 +0100)] 
s390: Static branches for machine features infrastructure

Provide infrastructure which allows to generate machine_has_<feature>()
functions, which are replacing the existing MACHINE_HAS_<feature> macros.
Such function usages generate a static branch depending on <feature>. The
static branch is patched using an alternative.

Each <feature> correlates with a bit set in the machine_features bit
field. If the corresponding bit is set, the branch will be patched. In
order to have any effect on branch patching feature bits must be set with
set_machine_features() in the decompressor before alternatives patching of
the kernel image.

It is possible to use clear_machine_feature() and test_machine_feature()
for machine features which cannot be completely detected within the
decompressor, e.g. if common code command line parameters allow to enable
or disable certain features. In such cases test_machine_feature() instead
of machine_has_feature() must be used within the kernel. This results in a
runtime check and not a static branch.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/cpufeature: Convert MACHINE_HAS_IDTE to cpu_has_idte()
Heiko Carstens [Fri, 7 Feb 2025 14:48:55 +0000 (15:48 +0100)] 
s390/cpufeature: Convert MACHINE_HAS_IDTE to cpu_has_idte()

Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/cpufeature: Convert MACHINE_HAS_EDAT2 to cpu_has_edat2()
Heiko Carstens [Fri, 7 Feb 2025 14:48:54 +0000 (15:48 +0100)] 
s390/cpufeature: Convert MACHINE_HAS_EDAT2 to cpu_has_edat2()

Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/cpufeature: Convert MACHINE_HAS_EDAT1 to cpu_has_edat1()
Heiko Carstens [Fri, 7 Feb 2025 14:48:53 +0000 (15:48 +0100)] 
s390/cpufeature: Convert MACHINE_HAS_EDAT1 to cpu_has_edat1()

Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/cpufeature: Convert MACHINE_HAS_TOPOLOGY to cpu_has_topology()
Heiko Carstens [Fri, 7 Feb 2025 14:48:52 +0000 (15:48 +0100)] 
s390/cpufeature: Convert MACHINE_HAS_TOPOLOGY to cpu_has_topology()

Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/cpufeature: Convert MACHINE_HAS_TLB_LC to cpu_has_tlb_lc()
Heiko Carstens [Fri, 7 Feb 2025 14:48:51 +0000 (15:48 +0100)] 
s390/cpufeature: Convert MACHINE_HAS_TLB_LC to cpu_has_tlb_lc()

Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/cpufeature: Convert MACHINE_HAS_NX to cpu_has_nx()
Heiko Carstens [Fri, 7 Feb 2025 14:48:50 +0000 (15:48 +0100)] 
s390/cpufeature: Convert MACHINE_HAS_NX to cpu_has_nx()

Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/cpufeature: Convert MACHINE_HAS_GS to cpu_has_gs()
Heiko Carstens [Fri, 7 Feb 2025 14:48:49 +0000 (15:48 +0100)] 
s390/cpufeature: Convert MACHINE_HAS_GS to cpu_has_gs()

Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/cpufeature: Convert MACHINE_HAS_RDP to cpu_has_rdp()
Heiko Carstens [Fri, 7 Feb 2025 14:48:48 +0000 (15:48 +0100)] 
s390/cpufeature: Convert MACHINE_HAS_RDP to cpu_has_rdp()

Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/cpufeature: Convert MACHINE_HAS_SEQ_INSN to cpu_has_seq_insn()
Heiko Carstens [Fri, 7 Feb 2025 14:48:47 +0000 (15:48 +0100)] 
s390/cpufeature: Convert MACHINE_HAS_SEQ_INSN to cpu_has_seq_insn()

Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/zfcp: Remove outdated email address
Heiko Carstens [Tue, 4 Feb 2025 07:42:02 +0000 (08:42 +0100)] 
s390/zfcp: Remove outdated email address

The linux390@de.ibm.com email address is outdated. It has been removed from
the MAINTAINERS file nearly 10 years ago with commit 64776820b4ff ("s390:
remove generic email address from maintainers file").

Change MODULE_AUTHOR() accordingly and also use the more common
IBM Corporation company name.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/uaccess: Inline __clear_user()
Heiko Carstens [Tue, 11 Feb 2025 19:19:30 +0000 (20:19 +0100)] 
s390/uaccess: Inline __clear_user()

Rework __clear_user() similar to raw_copy_from_user() / raw_copy_to_user()
and inline the function saving the overhead of branches.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/uaccess: Optimize raw_copy_from_user() / raw_copy_to_user() for constant sizes
Heiko Carstens [Tue, 11 Feb 2025 19:19:29 +0000 (20:19 +0100)] 
s390/uaccess: Optimize raw_copy_from_user() / raw_copy_to_user() for constant sizes

Avoid that the compiler generates an mvcos loop for constant sizes
smaller than 4096 bytes. The mvcos instruction copies between zero and
4096 bytes (effective length) with one operation. Therefore it is not
necessary to implement a loop for sizes smaller or equal to 4096
bytes.

This reduces the kernel text size by ~50kb (defconfig, gcc 14.2.0):
add/remove: 4/5 grow/shrink: 6/471 up/down: 2294/-51700 (-49406)

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/uaccess: Define INLINE_COPY_FROM_USER and INLINE_COPY_TO_USER
Heiko Carstens [Tue, 11 Feb 2025 19:19:28 +0000 (20:19 +0100)] 
s390/uaccess: Define INLINE_COPY_FROM_USER and INLINE_COPY_TO_USER

Inline copy_from_user() and copy_to_user(). With the shortened inline
assemblies of raw_copy_to_user() and raw_copy_from_user() the additional
kernel text size is acceptable, considering that this avoids function
calls on hot paths.

This increases the kernel text size by ~90kb (defconfig, gcc 14.2.0):

add/remove: 13/4 grow/shrink: 650/14 up/down: 93484/-3254 (90230)

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/uaccess: Separate key uaccess functions
Heiko Carstens [Tue, 11 Feb 2025 19:19:27 +0000 (20:19 +0100)] 
s390/uaccess: Separate key uaccess functions

Implement separate raw_copy_to_user_key() and raw_copy_from_user_key()
functions, which allows to remove the open-coded operand access control
handling from the normal raw_copy_to_user() / raw_copy_from_user()
functions - they are simplified to use immediate instructions to load
hard-coded operand access control values into register zero, which saves
one instruction.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/uaccess: Shorten raw_copy_from_user() / raw_copy_to_user() inline assemblies
Heiko Carstens [Tue, 11 Feb 2025 19:19:26 +0000 (20:19 +0100)] 
s390/uaccess: Shorten raw_copy_from_user() / raw_copy_to_user() inline assemblies

Add specific exception handler for copy_to_user() / copy_from_user()
mvcos fault handling, which allows to shorten the inline assemblies to
three instructions.

On fault the exception handler adjusts the length used by the mvcos
instruction in a way that the instruction completes with condition code
zero, indicating the number of bytes copied with the input/output operand
'size'. This allows to calculate and return the number of bytes not copied,
if any, like required.

Loop and return value handling is changed to C so that the compiler may
optimize the code.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/mm: Remove have_store_indication static key
Heiko Carstens [Fri, 31 Jan 2025 15:11:38 +0000 (16:11 +0100)] 
s390/mm: Remove have_store_indication static key

Whenever test_facility() is used with a constant facility
number the generated code is identical to a static branch.

Remove the extra initcall and static_branch_enable() handling for
have_store_indication, and use test_facility() directly.

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390: Sort mcount locations at build time
Heiko Carstens [Thu, 13 Feb 2025 12:57:33 +0000 (13:57 +0100)] 
s390: Sort mcount locations at build time

For s390 the mcount_loc section of the kernel image contains the addresses
of the mcount locations. All addresses will be adjusted with the same
offset by the decompressor before the kernel is started.

Therefore select HAVE_BUILDTIME_MCOUNT_SORT so that the entries of this
section are sorted at build time. Given that the same offset is applied to
all entries the section will be sorted in any case.

Note that this was not possible before commit 778666df60f0 ("s390: compile
relocatable kernel without -fPIE"). Since this commit all R_390_64 absolute
relocations are handled in a special way: only the address of the to be
changed location is put into a special section. For all those locations the
same offset is applied as described above.

Without that change it would have been necessary to also adjust the addend
of all relocations which correspond to the mcount_loc section, when sorting
the mcount_loc section.

Reported-by: Steven Rostedt <rostedt@goodmis.org>
Closes: https://lore.kernel.org/r/20250210142647.083ff456@gandalf.local.home/
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/vfio-ap: Signal eventfd when guest AP configuration is changed
Rorie Reyes [Tue, 7 Jan 2025 18:36:45 +0000 (13:36 -0500)] 
s390/vfio-ap: Signal eventfd when guest AP configuration is changed

In this patch, an eventfd object is created by the vfio_ap device driver
and used to notify userspace when a guests's AP configuration is
dynamically changed. Such changes may occur whenever:

* An adapter, domain or control domain is assigned to or unassigned from a
  mediated device that is attached to the guest.
* A queue assigned to the mediated device that is attached to a guest is
  bound to or unbound from the vfio_ap device driver. This can occur
  either by manually binding/unbinding the queue via the vfio_ap driver's
  sysfs bind/unbind attribute interfaces, or because an adapter, domain or
  control domain assigned to the mediated device is added to or removed
  from the host's AP configuration via an SE/HMC

The purpose of this patch is to provide immediate notification of changes
made to a guest's AP configuration by the vfio_ap driver. This will enable
the guest to take immediate action rather than relying on polling or some
other inefficient mechanism to detect changes to its AP configuration.

Note that there are corresponding QEMU patches that will be shipped along
with this patch (see vfio-ap: Report vfio-ap configuration changes) that
will pick up the eventfd signal.

Signed-off-by: Rorie Reyes <rreyes@linux.ibm.com>
Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Tested-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Link: https://lore.kernel.org/r/20250107183645.90082-1-rreyes@linux.ibm.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/vfio-ccw: Make mdev_types not look like a fake flex array
Halil Pasic [Mon, 17 Feb 2025 10:06:14 +0000 (11:06 +0100)] 
s390/vfio-ccw: Make mdev_types not look like a fake flex array

The vfio-ccw driver and the vfio parent device provided by it (parent)
support just a single mdev_type, and this is not likely to change any
time soon. To match the mdev interfaces nicely initially the choice was
made that mdev_types (which gets passed into mdev_register_parent())
shall be an array of pointers to struct mdev_type with a single element,
and to make things worse it ended up being the last member.

Now the problem with that is that before C99 the usual way to get
something similar to a flexible array member was to use a trailing array
of size 0 or 1. This is what I called fake flex array. For a while now
the community is trying to get rid of fake flex arrays. And while
mdev_types was not a fake flex array but an array of size one, because
it can easily be and probably was mistaken for a fake flex array it got
converted into a real C99 flex array with a compile time known constant
size of one.

As per [1] it was established that "only fake flexible arrays should be
transformed into C99 flex-array members". Since IMHO the entire point of
flex arrays is being flexible about the array size at run time, a C99
flex array is a poor fit for mdev_types.  But an array of a size one is
a poor fit as well for the reason stated above, let us try to get rid of
the flex array without introducing back the one sized array.

So, lets make mdev_types a pointer to struct mdev_type and pass in the
address of that pointer as the 4th formal parameter of
mdev_register_parent().

[1] https://lore.kernel.org/lkml/85863d7a-2d8b-4c1b-b76a-e2f40834a7a8@embeddedor.com/

Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Tested-by: Eric Farman <farman@linux.ibm.com>
Link: https://lore.kernel.org/r/20250217100614.3043620-3-pasic@linux.ibm.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/vfio-ap: Make mdev_types not look like a fake flex array
Halil Pasic [Mon, 17 Feb 2025 10:06:13 +0000 (11:06 +0100)] 
s390/vfio-ap: Make mdev_types not look like a fake flex array

The vfio-ap driver and the vfio parent device provided by it
(matrix_dev) support just a single mdev_type, and this is not likely to
change any time soon.  Despite that matrix_dev->mdev_types started out
as a C99 flexible array presumably as a typo, and since the typo messed
up the allocation, commit e2c8cee9f489 ("s390/vfio-ap: Fix memory
allocation for mdev_types array") changed it to an array of size 1. And
to make things worse mdev_types happens to be the last member of struct
ap_matrix_dev.

Now the problem with that is that before C99 the usual way to get
something similar to a flexible array member was to use a trailing array of
size 0 or 1. This is what I called fake flex array. For a while now the
community is trying to get rid of fake flex arrays. And while mdev_types
is not a fake flex array but an array of size one (to match the mdev
interfaces nicer), it can easily be and was mistaken for a fake flex
array.

So, let us make mdev_types a pointer to struct mdev_type and pass in the
address of that pointer as the 4th formal parameter of
mdev_register_parent().

Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Tested-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Link: https://lore.kernel.org/r/20250217100614.3043620-2-pasic@linux.ibm.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/cio: Remove outdated email address
Heiko Carstens [Fri, 31 Jan 2025 15:57:02 +0000 (16:57 +0100)] 
s390/cio: Remove outdated email address

The linux390@de.ibm.com email address is outdated. It has been removed
from the MAINTAINERS file nearly 10 years ago with commit 64776820b4ff
("s390: remove generic email address from maintainers file"); remove
one of the last remaining occurrences.

Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agos390/vfio-ap: Fix indentation in vfio_ap_mdev_ioctl()
Thorsten Blum [Thu, 16 Jan 2025 13:11:47 +0000 (14:11 +0100)] 
s390/vfio-ap: Fix indentation in vfio_ap_mdev_ioctl()

Remove any extra indentation to improve the code's readability.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Link: https://lore.kernel.org/r/20250116131146.105439-2-thorsten.blum@linux.dev
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
4 months agoLinux 6.14-rc2 v6.14-rc2
Linus Torvalds [Sun, 9 Feb 2025 20:45:03 +0000 (12:45 -0800)] 
Linux 6.14-rc2

4 months agoMerge tag 'kbuild-fixes-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/masah...
Linus Torvalds [Sun, 9 Feb 2025 18:05:32 +0000 (10:05 -0800)] 
Merge tag 'kbuild-fixes-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - Suppress false-positive -Wformat-{overflow,truncation}-non-kprintf
   warnings regardless of the W= option

 - Avoid CONFIG_TRIM_UNUSED_KSYMS dropping symbols passed to symbol_get()

 - Fix a build regression of the Debian linux-headers package

* tag 'kbuild-fixes-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: install-extmod-build: add missing quotation marks for CC variable
  kbuild: fix misspelling in scripts/Makefile.lib
  kbuild: keep symbols for symbol_get() even with CONFIG_TRIM_UNUSED_KSYMS
  scripts/Makefile.extrawarn: Do not show clang's non-kprintf warnings at W=1

4 months agoMerge tag 'pm-6.14-rc2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
Linus Torvalds [Sun, 9 Feb 2025 17:47:06 +0000 (09:47 -0800)] 
Merge tag 'pm-6.14-rc2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fix from Rafael Wysocki:
 "Fix a recently introduced kernel crash due to a NULL pointer
  dereference during system-wide suspend (Rafael Wysocki)"

* tag 'pm-6.14-rc2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  PM: sleep: core: Restrict power.set_active propagation

4 months agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Linus Torvalds [Sun, 9 Feb 2025 17:41:38 +0000 (09:41 -0800)] 
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm fixes from Paolo Bonzini:
 "ARM:

   - Correctly clean the BSS to the PoC before allowing EL2 to access it
     on nVHE/hVHE/protected configurations

   - Propagate ownership of debug registers in protected mode after the
     rework that landed in 6.14-rc1

   - Stop pretending that we can run the protected mode without a GICv3
     being present on the host

   - Fix a use-after-free situation that can occur if a vcpu fails to
     initialise the NV shadow S2 MMU contexts

   - Always evaluate the need to arm a background timer for fully
     emulated guest timers

   - Fix the emulation of EL1 timers in the absence of FEAT_ECV

   - Correctly handle the EL2 virtual timer, specially when HCR_EL2.E2H==0

  s390:

   - move some of the guest page table (gmap) logic into KVM itself,
     inching towards the final goal of completely removing gmap from the
     non-kvm memory management code.

     As an initial set of cleanups, move some code from mm/gmap into kvm
     and start using __kvm_faultin_pfn() to fault-in pages as needed;
     but especially stop abusing page->index and page->lru to aid in the
     pgdesc conversion.

  x86:

   - Add missing check in the fix to defer starting the huge page
     recovery vhost_task

   - SRSO_USER_KERNEL_NO does not need SYNTHESIZED_F"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (31 commits)
  KVM: x86/mmu: Ensure NX huge page recovery thread is alive before waking
  KVM: remove kvm_arch_post_init_vm
  KVM: selftests: Fix spelling mistake "initally" -> "initially"
  kvm: x86: SRSO_USER_KERNEL_NO is not synthesized
  KVM: arm64: timer: Don't adjust the EL2 virtual timer offset
  KVM: arm64: timer: Correctly handle EL1 timer emulation when !FEAT_ECV
  KVM: arm64: timer: Always evaluate the need for a soft timer
  KVM: arm64: Fix nested S2 MMU structures reallocation
  KVM: arm64: Fail protected mode init if no vgic hardware is present
  KVM: arm64: Flush/sync debug state in protected mode
  KVM: s390: selftests: Streamline uc_skey test to issue iske after sske
  KVM: s390: remove the last user of page->index
  KVM: s390: move PGSTE softbits
  KVM: s390: remove useless page->index usage
  KVM: s390: move gmap_shadow_pgt_lookup() into kvm
  KVM: s390: stop using lists to keep track of used dat tables
  KVM: s390: stop using page->index for non-shadow gmaps
  KVM: s390: move some gmap shadowing functions away from mm/gmap.c
  KVM: s390: get rid of gmap_translate()
  KVM: s390: get rid of gmap_fault()
  ...

4 months agoPM: sleep: core: Restrict power.set_active propagation
Rafael J. Wysocki [Sat, 8 Feb 2025 17:54:28 +0000 (18:54 +0100)] 
PM: sleep: core: Restrict power.set_active propagation

Commit 3775fc538f53 ("PM: sleep: core: Synchronize runtime PM status of
parents and children") exposed an issue related to simple_pm_bus_pm_ops
that uses pm_runtime_force_suspend() and pm_runtime_force_resume() as
bus type PM callbacks for the noirq phases of system-wide suspend and
resume.

The problem is that pm_runtime_force_suspend() does not distinguish
runtime-suspended devices from devices for which runtime PM has never
been enabled, so if it sees a device with runtime PM status set to
RPM_ACTIVE, it will assume that runtime PM is enabled for that device
and so it will attempt to suspend it with the help of its runtime PM
callbacks which may not be ready for that.  As it turns out, this
causes simple_pm_bus_runtime_suspend() to crash due to a NULL pointer
dereference.

Another problem related to the above commit and simple_pm_bus_pm_ops is
that setting runtime PM status of a device handled by the latter to
RPM_ACTIVE will actually prevent it from being resumed because
pm_runtime_force_resume() only resumes devices with runtime PM status
set to RPM_SUSPENDED.

To mitigate these issues, do not allow power.set_active to propagate
beyond the parent of the device with DPM_FLAG_SMART_SUSPEND set that
will need to be resumed, which should be a sufficient stop-gap for the
time being, but they will need to be properly addressed in the future
because in general during system-wide resume it is necessary to resume
all devices in a dependency chain in which at least one device is going
to be resumed.

Fixes: 3775fc538f53 ("PM: sleep: core: Synchronize runtime PM status of parents and children")
Closes: https://lore.kernel.org/linux-pm/1c2433d4-7e0f-4395-b841-b8eac7c25651@nvidia.com/
Reported-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/6137505.lOV4Wx5bFT@rjwysocki.net
4 months agoMerge tag 'hardening-v6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sat, 8 Feb 2025 22:12:17 +0000 (14:12 -0800)] 
Merge tag 'hardening-v6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull hardening fixes from Kees Cook:
 "Address a KUnit stack initialization regression that got tickled on
  m68k, and solve a Clang(v14 and earlier) bug found by 0day:

   - Fix stackinit KUnit regression on m68k

   - Use ARRAY_SIZE() for memtostr*()/strtomem*()"

* tag 'hardening-v6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  string.h: Use ARRAY_SIZE() for memtostr*()/strtomem*()
  compiler.h: Introduce __must_be_byte_array()
  compiler.h: Move C string helpers into C-only kernel section
  stackinit: Fix comment for test_small_end
  stackinit: Keep selftest union size small on m68k

4 months agoMerge tag 'seccomp-v6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
Linus Torvalds [Sat, 8 Feb 2025 22:04:21 +0000 (14:04 -0800)] 
Merge tag 'seccomp-v6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull seccomp fix from Kees Cook:
 "This is really a work-around for x86_64 having grown a syscall to
  implement uretprobe, which has caused problems since v6.11.

  This may change in the future, but for now, this fixes the unintended
  seccomp filtering when uretprobe switched away from traps, and does so
  with something that should be easy to backport.

   - Allow uretprobe on x86_64 to avoid behavioral complications (Eyal
     Birger)"

* tag 'seccomp-v6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  selftests/seccomp: validate uretprobe syscall passes through seccomp
  seccomp: passthrough uretprobe systemcall without filtering

4 months agoMerge tag 'execve-v6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
Linus Torvalds [Sat, 8 Feb 2025 21:59:24 +0000 (13:59 -0800)] 
Merge tag 'execve-v6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull execve fix from Kees Cook:
 "This is an alpha-specific fix, but since it touched ELF I was asked to
  carry it.

   - alpha/elf: Fix misc/setarch test of util-linux by removing 32bit
     support (Eric W. Biederman)"

* tag 'execve-v6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  alpha/elf: Fix misc/setarch test of util-linux by removing 32bit support

4 months agoMerge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Linus Torvalds [Sat, 8 Feb 2025 21:45:34 +0000 (13:45 -0800)] 
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "A number of fairly small fixes, mostly in drivers but two in the core
  to change a retry for depopulation (a trendy new hdd thing that
  reorganizes blocks away from failing elements) and one to fix a GFP_
  annotation to avoid a lock dependency (the third core patch is all in
  testing)"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: qla1280: Fix kernel oops when debug level > 2
  scsi: ufs: core: Fix error return with query response
  scsi: storvsc: Set correct data length for sending SCSI command without payload
  scsi: ufs: core: Fix use-after free in init error and remove paths
  scsi: core: Do not retry I/Os during depopulation
  scsi: core: Use GFP_NOIO to avoid circular locking dependency
  scsi: ufs: Fix toggling of clk_gating.state when clock gating is not allowed
  scsi: ufs: core: Ensure clk_gating.lock is used only after initialization
  scsi: ufs: core: Simplify temperature exception event handling
  scsi: target: core: Add line break to status show
  scsi: ufs: core: Fix the HIGH/LOW_TEMP Bit Definitions
  scsi: core: Add passthrough tests for success and no failure definitions

4 months agoMerge tag 'i2c-for-6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
Linus Torvalds [Sat, 8 Feb 2025 21:35:17 +0000 (13:35 -0800)] 
Merge tag 'i2c-for-6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c reverts from Wolfram Sang:
 "It turned out the new mechanism for handling created devices does not
  handle all muxing cases.

  Revert the changes to give a proper solution more time"

* tag 'i2c-for-6.14-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  Revert "i2c: Replace list-based mechanism for handling auto-detected clients"
  Revert "i2c: Replace list-based mechanism for handling userspace-created clients"

4 months agoMerge tag 'rust-fixes-6.14' of https://github.com/Rust-for-Linux/linux
Linus Torvalds [Sat, 8 Feb 2025 20:22:21 +0000 (12:22 -0800)] 
Merge tag 'rust-fixes-6.14' of https://github.com/Rust-for-Linux/linux

Pull rust fixes from Miguel Ojeda:

 - Do not export KASAN ODR symbols to avoid gendwarfksyms warnings

 - Fix future Rust 1.86.0 (to be released 2025-04-03) x86_64 builds

 - Clean future Rust 1.86.0 (to be released 2025-04-03) warning

 - Fix future GCC 15 (to be released in a few months) builds

 - Fix `rusttest` target in macOS

* tag 'rust-fixes-6.14' of https://github.com/Rust-for-Linux/linux:
  x86: rust: set rustc-abi=x86-softfloat on rustc>=1.86.0
  rust: kbuild: do not export generated KASAN ODR symbols
  rust: kbuild: add -fzero-init-padding-bits to bindgen_skip_cflags
  rust: init: use explicit ABI to clean warning in future compilers
  rust: kbuild: use host dylib naming in rusttestlib-kernel

4 months agoMerge tag 'ftrace-v6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
Linus Torvalds [Sat, 8 Feb 2025 20:18:02 +0000 (12:18 -0800)] 
Merge tag 'ftrace-v6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull ftrace fix from Steven Rostedt:
 "Function graph fix of notrace functions.

  When the function graph tracer was restructured to use the global
  section of the meta data in the shadow stack, the bit logic was
  changed. There's a TRACE_GRAPH_NOTRACE_BIT that is the bit number in
  the mask that tells if the function graph tracer is currently in the
  "notrace" mode. The TRACE_GRAPH_NOTRACE is the mask with that bit set.

  But when the code we restructured, the TRACE_GRAPH_NOTRACE_BIT was
  used when it should have been the TRACE_GRAPH_NOTRACE mask. This made
  notrace not work properly"

* tag 'ftrace-v6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  fgraph: Fix set_graph_notrace with setting TRACE_GRAPH_NOTRACE_BIT

4 months agoMerge tag 'x86-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sat, 8 Feb 2025 20:04:00 +0000 (12:04 -0800)] 
Merge tag 'x86-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fix from Ingo Molnar:
 "Fix a build regression on GCC 15 builds, caused by GCC changing the
  default C version that is overriden in the main Makefile but not in
  the x86 boot code Makefile"

* tag 'x86-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/boot: Use '-std=gnu11' to fix build with GCC 15

4 months agoMerge tag 'timers-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 8 Feb 2025 19:55:03 +0000 (11:55 -0800)] 
Merge tag 'timers-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer fixes from Ingo Molnar:
 "Fix a PREEMPT_RT bug in the clocksource verification code that caused
  false positive warnings.

  Also fix a timer migration setup bug when new CPUs are added"

* tag 'timers-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  timers/migration: Fix off-by-one root mis-connection
  clocksource: Use migrate_disable() to avoid calling get_random_u32() in atomic context

4 months agoMerge tag 'sched-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 8 Feb 2025 19:16:22 +0000 (11:16 -0800)] 
Merge tag 'sched-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull scheduler fixes from Ingo Molnar:
 "Fix a cfs_rq->h_nr_runnable accounting bug that trips up a defensive
  SCHED_WARN_ON() on certain workloads. The bug is believed to be
  (accidentally) self-correcting, hence no behavioral side effects are
  expected.

  Also print se.slice in debug output, since this value can now be set
  via the syscall ABI and can be useful to track"

* tag 'sched-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/debug: Provide slice length for fair tasks
  sched/fair: Fix inaccurate h_nr_runnable accounting with delayed dequeue

4 months agoMerge tag 'irq-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sat, 8 Feb 2025 19:05:54 +0000 (11:05 -0800)] 
Merge tag 'irq-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull irq fix from Ingo Molnar:
 "Another followup fix for the procps genirq output formatting
  regression caused by an optimization"

* tag 'irq-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  genirq: Remove leading space from irq_chip::irq_print_chip() callbacks

4 months agoMerge tag 'locking-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 8 Feb 2025 18:54:11 +0000 (10:54 -0800)] 
Merge tag 'locking-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking fix from Ingo Molnar:
 "Fix a dangling pointer bug in the futex code used by the uring code.

  It isn't causing problems at the moment due to uring ABI limitations
  leaving it essentially unused in current usages, but is a good idea to
  fix nevertheless"

* tag 'locking-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  futex: Pass in task to futex_queue()

4 months agofgraph: Fix set_graph_notrace with setting TRACE_GRAPH_NOTRACE_BIT
Steven Rostedt [Sat, 8 Feb 2025 05:15:11 +0000 (00:15 -0500)] 
fgraph: Fix set_graph_notrace with setting TRACE_GRAPH_NOTRACE_BIT

The code was restructured where the function graph notrace code, that
would not trace a function and all its children is done by setting a
NOTRACE flag when the function that is not to be traced is hit.

There's a TRACE_GRAPH_NOTRACE_BIT which defines the bit in the flags and a
TRACE_GRAPH_NOTRACE which is the mask with that bit set. But the
restructuring used TRACE_GRAPH_NOTRACE_BIT when it should have used
TRACE_GRAPH_NOTRACE.

For example:

 # cd /sys/kernel/tracing
 # echo set_track_prepare stack_trace_save  > set_graph_notrace
 # echo function_graph > current_tracer
 # cat trace
[..]
 0)               |                          __slab_free() {
 0)               |                            free_to_partial_list() {
 0)               |                                  arch_stack_walk() {
 0)               |                                    __unwind_start() {
 0)   0.501 us    |                                      get_stack_info();

Where a non filter trace looks like:

 # echo > set_graph_notrace
 # cat trace
 0)               |                            free_to_partial_list() {
 0)               |                              set_track_prepare() {
 0)               |                                stack_trace_save() {
 0)               |                                  arch_stack_walk() {
 0)               |                                    __unwind_start() {

Where the filter should look like:

 # cat trace
 0)               |                            free_to_partial_list() {
 0)               |                              _raw_spin_lock_irqsave() {
 0)   0.350 us    |                                preempt_count_add();
 0)   0.351 us    |                                do_raw_spin_lock();
 0)   2.440 us    |                              }

Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/20250208001511.535be150@batman.local.home
Fixes: b84214890a9bc ("function_graph: Move graph notrace bit to shadow stack global var")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
4 months agokbuild: Move -Wenum-enum-conversion to W=2
Nathan Chancellor [Thu, 17 Oct 2024 17:09:22 +0000 (10:09 -0700)] 
kbuild: Move -Wenum-enum-conversion to W=2

-Wenum-enum-conversion was strengthened in clang-19 to warn for C, which
caused the kernel to move it to W=1 in commit 75b5ab134bb5 ("kbuild:
Move -Wenum-{compare-conditional,enum-conversion} into W=1") because
there were numerous instances that would break builds with -Werror.
Unfortunately, this is not a full solution, as more and more developers,
subsystems, and distributors are building with W=1 as well, so they
continue to see the numerous instances of this warning.

Since the move to W=1, there have not been many new instances that have
appeared through various build reports and the ones that have appeared
seem to be following similar existing patterns, suggesting that most
instances of this warning will not be real issues. The only alternatives
for silencing this warning are adding casts (which is generally seen as
an ugly practice) or refactoring the enums to macro defines or a unified
enum (which may be undesirable because of type safety in other parts of
the code).

Move the warning to W=2, where warnings that occur frequently but may be
relevant should reside.

Cc: stable@vger.kernel.org
Fixes: 75b5ab134bb5 ("kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1")
Link: https://lore.kernel.org/ZwRA9SOcOjjLJcpi@google.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 months agoMerge tag 'v6.14rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Sat, 8 Feb 2025 03:23:06 +0000 (19:23 -0800)] 
Merge tag 'v6.14rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull smb client fixes from Steve French:

 - Three DFS fixes: DFS mount fix, fix for noisy log msg and one to
   remove some unused code

 - SMB3 Lease fix

* tag 'v6.14rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  smb: client: change lease epoch type from unsigned int to __u16
  smb: client: get rid of kstrdup() in get_ses_refpath()
  smb: client: fix noisy when tree connecting to DFS interlink targets
  smb: client: don't trust DFSREF_STORAGE_SERVER bit

4 months agoMerge tag 'drm-fixes-2025-02-08' of https://gitlab.freedesktop.org/drm/kernel
Linus Torvalds [Fri, 7 Feb 2025 20:21:54 +0000 (12:21 -0800)] 
Merge tag 'drm-fixes-2025-02-08' of https://gitlab.freedesktop.org/drm/kernel

Pull drm fixes from Dave Airlie:
 "Just regular drm fixes, amdgpu, xe and i915 mostly, but a few
  scattered fixes. I think one of the i915 fixes fixes some build combos
  that Guenter was seeing.

  amdgpu:
   - Add new tiling flag for DCC write compress disable
   - Add BO metadata flag for DCC
   - Fix potential out of bounds access in display
   - Seamless boot fix
   - CONFIG_FRAME_WARN fix
   - PSR1 fix

  xe:
   - OA uAPI related fixes
   - Fix SRIOV migration initialization
   - Restore devcoredump to a sane state

  i915:
   - Fix the build error with clamp after WARN_ON on gcc 13.x+
   - HDCP related fixes
   - PMU fix zero delta busyness issue
   - Fix page cleanup on DMA remap failure
   - Drop 64bpp YUV formats from ICL+ SDR planes
   - GuC log related fix
   - DisplayPort related fixes

  ivpu:
   - Fix error handling

  komeda:
   - add return check

  zynqmp:
   - fix locking in DP code

  ast:
   - fix AST DP timeout

  cec:
   - fix broken CEC adapter check"

* tag 'drm-fixes-2025-02-08' of https://gitlab.freedesktop.org/drm/kernel: (29 commits)
  drm/i915/dp: Fix potential infinite loop in 128b/132b SST
  Revert "drm/amd/display: Use HW lock mgr for PSR1"
  drm/amd/display: Respect user's CONFIG_FRAME_WARN more for dml files
  accel/amdxdna: Add MODULE_FIRMWARE() declarations
  drm/i915/dp: Iterate DSC BPP from high to low on all platforms
  drm/xe: Fix and re-enable xe_print_blob_ascii85()
  drm/xe/devcoredump: Move exec queue snapshot to Contexts section
  drm/xe/oa: Set stream->pollin in xe_oa_buffer_check_unlocked
  drm/xe/pf: Fix migration initialization
  drm/xe/oa: Preserve oa_ctrl unused bits
  drm/amd/display: Fix seamless boot sequence
  drm/amd/display: Fix out-of-bound accesses
  drm/amdgpu: add a BO metadata flag to disable write compression for Vulkan
  drm/i915/backlight: Return immediately when scale() finds invalid parameters
  drm/i915/dp: Return min bpc supported by source instead of 0
  drm/i915/dp: fix the Adaptive sync Operation mode for SDP
  drm/i915/guc: Debug print LRC state entries only if the context is pinned
  drm/i915: Drop 64bpp YUV formats from ICL+ SDR planes
  drm/i915: Fix page cleanup on DMA remap failure
  drm/i915/pmu: Fix zero delta busyness issue
  ...

4 months agoMerge tag 'stable/for-linus-6.14-rc1-tag' of git://git.kernel.org/pub/scm/linux/kerne...
Linus Torvalds [Fri, 7 Feb 2025 19:05:50 +0000 (11:05 -0800)] 
Merge tag 'stable/for-linus-6.14-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/ibft

Pull ibft fixes from Konrad Rzeszutek Wilk:
 "Two tiny fixes to IBFT code: one for Kconfig and another for IPv6"

* tag 'stable/for-linus-6.14-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/ibft:
  iscsi_ibft: Fix UBSAN shift-out-of-bounds warning in ibft_attr_show_nic()
  firmware: iscsi_ibft: fix ISCSI_IBFT Kconfig entry

4 months agoMerge tag 'block-6.14-20250207' of git://git.kernel.dk/linux
Linus Torvalds [Fri, 7 Feb 2025 19:00:33 +0000 (11:00 -0800)] 
Merge tag 'block-6.14-20250207' of git://git.kernel.dk/linux

Pull block fixes from Jens Axboe:

 - MD pull request via Song:
      - fix an error handling path for md-linear

 - NVMe pull request via Keith:
      - Connection fixes for fibre channel transport (Daniel)
      - Endian fixes (Keith, Christoph)
      - Cleanup fix for host memory buffer (Francis)
      - Platform specific power quirks (Georg)
      - Target memory leak (Sagi)
      - Use appropriate controller state accessor (Daniel)

 - Fixup for a regression introduced last week, where sunvdc wasn't
   updated for an API change, causing compilation failures on sparc64.

* tag 'block-6.14-20250207' of git://git.kernel.dk/linux:
  drivers/block/sunvdc.c: update the correct AIP call
  md: Fix linear_set_limits()
  nvme-fc: use ctrl state getter
  nvme: make nvme_tls_attrs_group static
  nvmet: add a missing endianess conversion in nvmet_execute_admin_connect
  nvmet: the result field in nvmet_alloc_ctrl_args is little endian
  nvmet: fix a memory leak in controller identify
  nvme-fc: do not ignore connectivity loss during connecting
  nvme: handle connectivity loss in nvme_set_queue_count
  nvme-fc: go straight to connecting state when initializing
  nvme-pci: Add TUXEDO IBP Gen9 to Samsung sleep quirk
  nvme-pci: Add TUXEDO InfinityFlex to Samsung sleep quirk
  nvme-pci: remove redundant dma frees in hmb
  nvmet: fix rw control endian access