From a7532c505f7f77e14bcc530cb452c73ff1d0272b Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Mon, 4 May 2026 20:13:20 +0200 Subject: [PATCH 01/11] sparc: vio: use sysfs_emit in sysfs show functions Replace sprintf() and scnprintf() with sysfs_emit() in sysfs show functions. sysfs_emit() is preferred to format sysfs output as it provides better bounds checking. Signed-off-by: Thorsten Blum Reviewed-by: Andreas Larsson Tested-by: Andreas Larsson Signed-off-by: Andreas Larsson --- arch/sparc/kernel/vio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c index 8b4f55047716..b7b06752a038 100644 --- a/arch/sparc/kernel/vio.c +++ b/arch/sparc/kernel/vio.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -121,7 +122,7 @@ static ssize_t devspec_show(struct device *dev, else if (!strcmp(vdev->type, "vdc-port")) str = "vdisk"; - return sprintf(buf, "%s\n", str); + return sysfs_emit(buf, "%s\n", str); } static DEVICE_ATTR_RO(devspec); @@ -129,7 +130,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct vio_dev *vdev = to_vio_dev(dev); - return sprintf(buf, "%s\n", vdev->type); + return sysfs_emit(buf, "%s\n", vdev->type); } static DEVICE_ATTR_RO(type); @@ -138,7 +139,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, { const struct vio_dev *vdev = to_vio_dev(dev); - return sprintf(buf, "vio:T%sS%s\n", vdev->type, vdev->compat); + return sysfs_emit(buf, "vio:T%sS%s\n", vdev->type, vdev->compat); } static DEVICE_ATTR_RO(modalias); @@ -192,7 +193,7 @@ show_pciobppath_attr(struct device *dev, struct device_attribute *attr, vdev = to_vio_dev(dev); dp = vdev->dp; - return scnprintf(buf, PAGE_SIZE, "%pOF\n", dp); + return sysfs_emit(buf, "%pOF\n", dp); } static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH, From 84e8d9c34b3d4d59e5fedfd49df8a2617aa09db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sat, 14 Mar 2026 13:17:49 +0100 Subject: [PATCH 02/11] sparc: uapi: Add ucontext.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On SPARC the standard ucontext.h UAPI header is named 'uctx.h'. Add an alias for the standard name. Signed-off-by: Thomas Weißschuh Reviewed-by: Andreas Larsson Signed-off-by: Andreas Larsson --- arch/sparc/include/uapi/asm/ucontext.h | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 arch/sparc/include/uapi/asm/ucontext.h diff --git a/arch/sparc/include/uapi/asm/ucontext.h b/arch/sparc/include/uapi/asm/ucontext.h new file mode 100644 index 000000000000..e9b5dbbedefb --- /dev/null +++ b/arch/sparc/include/uapi/asm/ucontext.h @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ + +#include From 2cdd477261a989278fea3e1127cea472b6eca52a Mon Sep 17 00:00:00 2001 From: Kexin Sun Date: Sat, 21 Mar 2026 18:59:35 +0800 Subject: [PATCH 03/11] sparc32: remove deadwood swift_flush_tlb_page() debug code Remove an #if 0 block that has been dead since at least Linux 2.6.12. The block was marked "P3: deadwood to debug precise flushes on Swift" and contained a never-compiled alternative implementation of swift_flush_tlb_page(). It also referenced the since-removed srmmu_flush_tlb_page(), dropped in commit 3d5f7d37c8b4 ("sparc32: drop unused functions in pgtsrmmu.h"). Assisted-by: unnamed:deepseek-v3.2 coccinelle Signed-off-by: Kexin Sun Reviewed-by: Andreas Larsson Signed-off-by: Andreas Larsson --- arch/sparc/mm/srmmu.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index 1b24c5e8d73d..9a74902ad181 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c @@ -581,35 +581,6 @@ extern void swift_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end); extern void swift_flush_tlb_page(struct vm_area_struct *vma, unsigned long page); -#if 0 /* P3: deadwood to debug precise flushes on Swift. */ -void swift_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) -{ - int cctx, ctx1; - - page &= PAGE_MASK; - if ((ctx1 = vma->vm_mm->context) != -1) { - cctx = srmmu_get_context(); -/* Is context # ever different from current context? P3 */ - if (cctx != ctx1) { - printk("flush ctx %02x curr %02x\n", ctx1, cctx); - srmmu_set_context(ctx1); - swift_flush_page(page); - __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : - "r" (page), "i" (ASI_M_FLUSH_PROBE)); - srmmu_set_context(cctx); - } else { - /* Rm. prot. bits from virt. c. */ - /* swift_flush_cache_all(); */ - /* swift_flush_cache_page(vma, page); */ - swift_flush_page(page); - - __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : - "r" (page), "i" (ASI_M_FLUSH_PROBE)); - /* same as above: srmmu_flush_tlb_page() */ - } - } -} -#endif /* * The following are all MBUS based SRMMU modules, and therefore could From 3774fd535fc2e54cdc4e915050f787a8b0bc6f8c Mon Sep 17 00:00:00 2001 From: Ethan Nelson-Moore Date: Mon, 4 May 2026 17:09:12 -0700 Subject: [PATCH 04/11] sparc: remove unused SERIAL_CONSOLE config option There are no references to this option in SPARC or architecture-independent code. Remove it to simplify the configuration process. Signed-off-by: Ethan Nelson-Moore Reviewed-by: Andreas Larsson Signed-off-by: Andreas Larsson --- arch/sparc/Kconfig | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index a6b787efc2c4..fb53b21a8696 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -327,30 +327,6 @@ config SPARC_LED by reading /proc/led and its blinking mode can be changed via writes to /proc/led -config SERIAL_CONSOLE - bool - depends on SPARC32 - default y - help - If you say Y here, it will be possible to use a serial port as the - system console (the system console is the device which receives all - kernel messages and warnings and which allows logins in single user - mode). This could be useful if some terminal or printer is connected - to that serial port. - - Even if you say Y here, the currently visible virtual console - (/dev/tty0) will still be used as the system console by default, but - you can alter that using a kernel command line option such as - "console=ttyS1". (Try "man bootparam" or see the documentation of - your boot loader (silo) about how to pass options to the kernel at - boot time.) - - If you don't have a graphics card installed and you say Y here, the - kernel will automatically use the first serial line, /dev/ttyS0, as - system console. - - If unsure, say N. - config SPARC_LEON bool "Sparc Leon processor family" depends on SPARC32 From 5b0eee4cd812bd6547eea393cb9b5c0322f26c88 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 5 May 2026 20:18:15 -0700 Subject: [PATCH 05/11] sparc64: uprobes: add missing break Missing fallthrough causes failure with newer compilers: arch/sparc/kernel/uprobes.c:284:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] 284 | default: | ^ arch/sparc/kernel/uprobes.c:284:2: note: insert 'break;' to avoid fall-through 284 | default: | ^ | break; Signed-off-by: Rosen Penev Reviewed-by: Masami Hiramatsu (Google) Reviewed-by: Andreas Larsson Signed-off-by: Andreas Larsson --- arch/sparc/kernel/uprobes.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/sparc/kernel/uprobes.c b/arch/sparc/kernel/uprobes.c index 305017bec164..c8cac64e9988 100644 --- a/arch/sparc/kernel/uprobes.c +++ b/arch/sparc/kernel/uprobes.c @@ -280,6 +280,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, case DIE_SSTEP: if (uprobe_post_sstep_notifier(args->regs)) ret = NOTIFY_STOP; + break; default: break; From 1919c0e50000e9afb76dbbf4a1261ec3238e3ae4 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 22 May 2026 21:20:26 -0700 Subject: [PATCH 06/11] sparc: add _mcount() prototype sparc64 defconfig told me WARNING: modpost: EXPORT symbol "_mcount" [vmlinux] version generation failed, symbol will not be versioned. Is "_mcount" prototyped in ? so I added it. Cc: David S. Miller Cc: Andreas Larsson Signed-off-by: Andrew Morton Reviewed-by: Andreas Larsson Tested-by: Andreas Larsson Signed-off-by: Andreas Larsson --- arch/sparc/include/asm/asm-prototypes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/sparc/include/asm/asm-prototypes.h b/arch/sparc/include/asm/asm-prototypes.h index bbd1a8afaabf..270c51017212 100644 --- a/arch/sparc/include/asm/asm-prototypes.h +++ b/arch/sparc/include/asm/asm-prototypes.h @@ -25,6 +25,7 @@ void *memcpy(void *dest, const void *src, size_t n); void *memset(void *s, int c, size_t n); typedef int TItype __attribute__((mode(TI))); TItype __multi3(TItype a, TItype b); +void _mcount(void); s64 __ashldi3(s64, int); s64 __lshrdi3(s64, int); From 9bc0bd9617964804dc02e6ee2413af42c4a50d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 25 May 2026 10:36:21 +0200 Subject: [PATCH 07/11] sparc: Avoid -Wunused-but-set-parameter in clear_user_page() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The loop in clear_user_pages() iterates over all pages and calls clear_user_page() for each of them. During the loop "vaddr" is modified. However on sparc clear_user() is a macro which does not use "vaddr". The compiler sees a variable which is modified but never used and emits a warning for that: include/linux/highmem.h: In function 'clear_user_pages': include/linux/highmem.h:234:63: warning: parameter 'vaddr' set but not used [-Wunused-but-set-parameter=] static inline void clear_user_pages(void *addr, unsigned long vaddr, Other architectures use an inline function for clear_user_page() which avoids the warning. This is not possible on sparc, as sparc_flush_page_to_ram() is not yet declared where clear_user_page() is defined. Including cacheflush_32.h will trigger recursive and lots of other issues. So hide the warning with a cast to (void) instead. While we are here, do the same for copy_user_page(). Fixes: 62a9f5a85b98 ("mm: introduce clear_pages() and clear_user_pages()") Signed-off-by: Thomas Weißschuh Reviewed-by: Andreas Larsson Signed-off-by: Andreas Larsson --- arch/sparc/include/asm/page_32.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/sparc/include/asm/page_32.h b/arch/sparc/include/asm/page_32.h index c1bccbedf567..9f0b54f70908 100644 --- a/arch/sparc/include/asm/page_32.h +++ b/arch/sparc/include/asm/page_32.h @@ -20,10 +20,12 @@ #define clear_user_page(addr, vaddr, page) \ do { clear_page(addr); \ sparc_flush_page_to_ram(page); \ + (void)(vaddr); \ } while (0) #define copy_user_page(to, from, vaddr, page) \ do { copy_page(to, from); \ sparc_flush_page_to_ram(page); \ + (void)(vaddr); \ } while (0) /* The following structure is used to hold the physical From 852fed2e8bfe195351fb0078ba7245d41154e7a5 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 7 May 2026 17:08:34 -0700 Subject: [PATCH 08/11] sparc: Disable compat support with LLD An LLVM=1 sparc64 allmodconfig enables COMPAT and then tries to build the 32-bit vDSO. That path cannot be linked with ld.lld: ld.lld: error: unknown emulation: elf32_sparc ld.lld does not support the 32-bit SPARC ELF emulation used for the compat vDSO, so keep COMPAT disabled when LLD is the linker. This avoids selecting an unsupported build path while leaving the existing GNU ld configuration unchanged. Assisted-by: Codex:GPT-5.5 Signed-off-by: Rosen Penev Acked-by: Nathan Chancellor Reviewed-by: Andreas Larsson Link: https://lore.kernel.org/r/20260508000834.834824-1-rosenp@gmail.com Signed-off-by: Andreas Larsson --- arch/sparc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index fb53b21a8696..c3d72b433bcd 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -450,6 +450,7 @@ endmenu config COMPAT bool depends on SPARC64 + depends on !LD_IS_LLD default y select HAVE_UID16 select ARCH_WANT_OLD_COMPAT_IPC From 2416b30ec23fd23126b4747994c00d926d438d6f Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 12 Jun 2026 11:15:03 -0700 Subject: [PATCH 09/11] sparc: Export mcount for Clang-built modules Clang emits calls to mcount for -pg on sparc64, while the existing ftrace support only exports the _mcount name. With FUNCTION_TRACER enabled, modules can therefore keep relocations against mcount and fail during modpost: ERROR: modpost: "mcount" [arch/sparc/kernel/chmc.ko] undefined! _mcount and mcount are aliases in arch/sparc/lib/mcount.S. Export the plain mcount alias as well so Clang-built modules can resolve their profiling call target. Assisted-by: Codex:GPT-5 Signed-off-by: Rosen Penev Reviewed-by: Andreas Larsson Signed-off-by: Andreas Larsson --- arch/sparc/include/asm/asm-prototypes.h | 1 + arch/sparc/lib/mcount.S | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/sparc/include/asm/asm-prototypes.h b/arch/sparc/include/asm/asm-prototypes.h index 270c51017212..a39a24c53216 100644 --- a/arch/sparc/include/asm/asm-prototypes.h +++ b/arch/sparc/include/asm/asm-prototypes.h @@ -26,6 +26,7 @@ void *memset(void *s, int c, size_t n); typedef int TItype __attribute__((mode(TI))); TItype __multi3(TItype a, TItype b); void _mcount(void); +void mcount(void); s64 __ashldi3(s64, int); s64 __lshrdi3(s64, int); diff --git a/arch/sparc/lib/mcount.S b/arch/sparc/lib/mcount.S index f7f7910eb41e..0309ba2c4712 100644 --- a/arch/sparc/lib/mcount.S +++ b/arch/sparc/lib/mcount.S @@ -21,6 +21,7 @@ EXPORT_SYMBOL(_mcount) .globl mcount .type mcount,#function + EXPORT_SYMBOL(mcount) _mcount: mcount: #ifdef CONFIG_FUNCTION_TRACER From 7eb475e8a738ee6fd1260aa59ddccb610fdd4300 Mon Sep 17 00:00:00 2001 From: Pengpeng Hou Date: Mon, 15 Jun 2026 13:58:50 +0800 Subject: [PATCH 10/11] sparc: led: avoid trimming a newline from empty writes led_proc_write() duplicates up to LED_MAX_LENGTH bytes with memdup_user_nul() and then unconditionally inspects buf[count - 1] to strip a trailing newline. A zero-length write therefore reads one byte before the duplicated buffer. The previous version rejected empty writes, but empty input already falls through to the existing default case and turns the LED off like any other unrecognized string. Preserve that behavior and only skip the newline trim when there is no input byte to inspect. Fixes: ee1858d3122d ("[SPARC]: Add sun4m LED driver.") Suggested-by: Andreas Larsson Signed-off-by: Pengpeng Hou Signed-off-by: Andreas Larsson --- arch/sparc/kernel/led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sparc/kernel/led.c b/arch/sparc/kernel/led.c index f4fb82b019bb..9b53ac1fe533 100644 --- a/arch/sparc/kernel/led.c +++ b/arch/sparc/kernel/led.c @@ -78,7 +78,7 @@ static ssize_t led_proc_write(struct file *file, const char __user *buffer, return PTR_ERR(buf); /* work around \n when echo'ing into proc */ - if (buf[count - 1] == '\n') + if (count > 0 && buf[count - 1] == '\n') buf[count - 1] = '\0'; /* before we change anything we want to stop any running timers, From 5b2a3b1a98fb47c593144c2770e012d463952b70 Mon Sep 17 00:00:00 2001 From: Catalin Iacob Date: Mon, 8 Jun 2026 17:29:20 +0300 Subject: [PATCH 11/11] sparc: Remove remaining defconfig references to the pktcdvd driver Commit 1cea5180f2f8 ("block: remove pktcdvd driver") left behind some CONFIG_CONFIG_CDROM_PKTCDVD* references in defconfigs. Remove them. Signed-off-by: Catalin Iacob Reviewed-by: Andreas Larsson Signed-off-by: Andreas Larsson --- arch/sparc/configs/sparc64_defconfig | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/sparc/configs/sparc64_defconfig b/arch/sparc/configs/sparc64_defconfig index 632081a262ba..4abea39281cd 100644 --- a/arch/sparc/configs/sparc64_defconfig +++ b/arch/sparc/configs/sparc64_defconfig @@ -60,8 +60,6 @@ CONFIG_CONNECTOR=m CONFIG_BLK_DEV_LOOP=m CONFIG_BLK_DEV_CRYPTOLOOP=m CONFIG_BLK_DEV_NBD=m -CONFIG_CDROM_PKTCDVD=m -CONFIG_CDROM_PKTCDVD_WCACHE=y CONFIG_ATA_OVER_ETH=m CONFIG_SUNVDC=m CONFIG_ATA=y