Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'parisc-for-6.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux

Pull parisc updates from Helge Deller:
"There is one noteable patch, which allows the parisc kernel to use the
same MADV_xxx constants as the other architectures going forward. With
that change only alpha has one entry left (MADV_DONTNEED is 6 vs 4 on
others) which is different. To prevent an ABI breakage, a wrapper is
included which translates old MADV values to the new ones, so existing
userspace isn't affected. Reason for that patch is, that some
applications wrongly used the standard MADV_xxx values even on some
non-x86 platforms and as such those programs failed to run correctly
on parisc (examples are qemu-user, tor browser and boringssl).

Then the kgdb console and the LED code received some fixes, and some
0-day warnings are now gone. Finally, the very last compile warning
which was visible during a kernel build is now fixed too (in the vDSO
code).

The majority of the patches are tagged for stable series and in
summary this patchset is quite small and drops more code than it adds:

Fixes:
- Fix potential null-ptr-deref in start_task()
- Fix kgdb console on serial port
- Add missing FORCE prerequisites in Makefile
- Drop PMD_SHIFT from calculation in pgtable.h

Enhancements:
- Implement a wrapper to align madvise() MADV_* constants with other
architectures
- If machine supports running MPE/XL, show the MPE model string

Cleanups:
- Drop duplicate kgdb console code
- Indenting fixes in setup_cmdline()"

* tag 'parisc-for-6.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
parisc: Show MPE/iX model string at bootup
parisc: Add missing FORCE prerequisites in Makefile
parisc: Move pdc_result struct to firmware.c
parisc: Drop locking in pdc console code
parisc: Drop duplicate kgdb_pdc console
parisc: Fix locking in pdc_iodc_print() firmware call
parisc: Drop PMD_SHIFT from calculation in pgtable.h
parisc: Align parisc MADV_XXX constants with all other architectures
parisc: led: Fix potential null-ptr-deref in start_task()
parisc: Fix inconsistent indenting in setup_cmdline()

+100 -120
+1 -1
arch/parisc/include/asm/pdc.h
··· 37 37 int pdc_system_map_find_addrs(struct pdc_system_map_addr_info *pdc_addr_info, 38 38 long mod_index, long addr_index); 39 39 int pdc_model_info(struct pdc_model *model); 40 - int pdc_model_sysmodel(char *name); 40 + int pdc_model_sysmodel(unsigned int os_id, char *name); 41 41 int pdc_model_cpuid(unsigned long *cpu_id); 42 42 int pdc_model_versions(unsigned long *versions, int id); 43 43 int pdc_model_capabilities(unsigned long *capabilities);
+2 -2
arch/parisc/include/asm/pgtable.h
··· 151 151 152 152 /* This calculates the number of initial pages we need for the initial 153 153 * page tables */ 154 - #if (KERNEL_INITIAL_ORDER) >= (PMD_SHIFT) 155 - # define PT_INITIAL (1 << (KERNEL_INITIAL_ORDER - PMD_SHIFT)) 154 + #if (KERNEL_INITIAL_ORDER) >= (PLD_SHIFT + BITS_PER_PTE) 155 + # define PT_INITIAL (1 << (KERNEL_INITIAL_ORDER - PLD_SHIFT - BITS_PER_PTE)) 156 156 #else 157 157 # define PT_INITIAL (1) /* all initial PTEs fit into one page */ 158 158 #endif
+14 -15
arch/parisc/include/uapi/asm/mman.h
··· 49 49 #define MADV_DONTFORK 10 /* don't inherit across fork */ 50 50 #define MADV_DOFORK 11 /* do inherit across fork */ 51 51 52 + #define MADV_MERGEABLE 12 /* KSM may merge identical pages */ 53 + #define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages */ 54 + 55 + #define MADV_HUGEPAGE 14 /* Worth backing with hugepages */ 56 + #define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */ 57 + 58 + #define MADV_DONTDUMP 16 /* Explicity exclude from the core dump, 59 + overrides the coredump filter bits */ 60 + #define MADV_DODUMP 17 /* Clear the MADV_NODUMP flag */ 61 + 62 + #define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */ 63 + #define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ 64 + 52 65 #define MADV_COLD 20 /* deactivate these pages */ 53 66 #define MADV_PAGEOUT 21 /* reclaim these pages */ 54 67 ··· 70 57 71 58 #define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */ 72 59 73 - #define MADV_MERGEABLE 65 /* KSM may merge identical pages */ 74 - #define MADV_UNMERGEABLE 66 /* KSM may not merge identical pages */ 75 - 76 - #define MADV_HUGEPAGE 67 /* Worth backing with hugepages */ 77 - #define MADV_NOHUGEPAGE 68 /* Not worth backing with hugepages */ 78 - 79 - #define MADV_DONTDUMP 69 /* Explicity exclude from the core dump, 80 - overrides the coredump filter bits */ 81 - #define MADV_DODUMP 70 /* Clear the MADV_NODUMP flag */ 82 - 83 - #define MADV_WIPEONFORK 71 /* Zero memory on fork, child only */ 84 - #define MADV_KEEPONFORK 72 /* Undo MADV_WIPEONFORK */ 85 - 86 - #define MADV_COLLAPSE 73 /* Synchronous hugepage collapse */ 60 + #define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */ 87 61 88 62 #define MADV_HWPOISON 100 /* poison a page for testing */ 89 63 #define MADV_SOFT_OFFLINE 101 /* soft offline page for testing */ 90 64 91 65 /* compatibility flags */ 92 66 #define MAP_FILE 0 93 - #define MAP_VARIABLE 0 94 67 95 68 #define PKEY_DISABLE_ACCESS 0x1 96 69 #define PKEY_DISABLE_WRITE 0x2
+17 -15
arch/parisc/kernel/firmware.c
··· 74 74 static DEFINE_SPINLOCK(pdc_lock); 75 75 #endif 76 76 77 - extern unsigned long pdc_result[NUM_PDC_RESULT]; 78 - extern unsigned long pdc_result2[NUM_PDC_RESULT]; 77 + unsigned long pdc_result[NUM_PDC_RESULT] __aligned(8); 78 + unsigned long pdc_result2[NUM_PDC_RESULT] __aligned(8); 79 79 80 80 #ifdef CONFIG_64BIT 81 81 #define WIDE_FIRMWARE 0x1 ··· 527 527 * Using OS_ID_HPUX will return the equivalent of the 'modelname' command 528 528 * on HP/UX. 529 529 */ 530 - int pdc_model_sysmodel(char *name) 530 + int pdc_model_sysmodel(unsigned int os_id, char *name) 531 531 { 532 532 int retval; 533 533 unsigned long flags; 534 534 535 535 spin_lock_irqsave(&pdc_lock, flags); 536 536 retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_SYSMODEL, __pa(pdc_result), 537 - OS_ID_HPUX, __pa(name)); 537 + os_id, __pa(name)); 538 538 convert_to_wide(pdc_result); 539 539 540 540 if (retval == PDC_OK) { ··· 1288 1288 1289 1289 #endif /* defined(BOOTLOADER) */ 1290 1290 1291 - /* locked by pdc_console_lock */ 1292 - static int __attribute__((aligned(8))) iodc_retbuf[32]; 1293 - static char __attribute__((aligned(64))) iodc_dbuf[4096]; 1291 + /* locked by pdc_lock */ 1292 + static char iodc_dbuf[4096] __page_aligned_bss; 1294 1293 1295 1294 /** 1296 1295 * pdc_iodc_print - Console print using IODC. ··· 1306 1307 unsigned int i; 1307 1308 unsigned long flags; 1308 1309 1310 + count = min_t(unsigned int, count, sizeof(iodc_dbuf)); 1311 + 1312 + spin_lock_irqsave(&pdc_lock, flags); 1309 1313 for (i = 0; i < count;) { 1310 1314 switch(str[i]) { 1311 1315 case '\n': ··· 1324 1322 } 1325 1323 1326 1324 print: 1327 - spin_lock_irqsave(&pdc_lock, flags); 1328 - real32_call(PAGE0->mem_cons.iodc_io, 1329 - (unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT, 1330 - PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers), 1331 - __pa(iodc_retbuf), 0, __pa(iodc_dbuf), i, 0); 1332 - spin_unlock_irqrestore(&pdc_lock, flags); 1325 + real32_call(PAGE0->mem_cons.iodc_io, 1326 + (unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT, 1327 + PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers), 1328 + __pa(pdc_result), 0, __pa(iodc_dbuf), i, 0); 1329 + spin_unlock_irqrestore(&pdc_lock, flags); 1333 1330 1334 1331 return i; 1335 1332 } ··· 1355 1354 real32_call(PAGE0->mem_kbd.iodc_io, 1356 1355 (unsigned long)PAGE0->mem_kbd.hpa, ENTRY_IO_CIN, 1357 1356 PAGE0->mem_kbd.spa, __pa(PAGE0->mem_kbd.dp.layers), 1358 - __pa(iodc_retbuf), 0, __pa(iodc_dbuf), 1, 0); 1357 + __pa(pdc_result), 0, __pa(iodc_dbuf), 1, 0); 1359 1358 1360 1359 ch = *iodc_dbuf; 1361 - status = *iodc_retbuf; 1360 + /* like convert_to_wide() but for first return value only: */ 1361 + status = *(int *)&pdc_result; 1362 1362 spin_unlock_irqrestore(&pdc_lock, flags); 1363 1363 1364 1364 if (status == 0)
-20
arch/parisc/kernel/kgdb.c
··· 208 208 } 209 209 return -1; 210 210 } 211 - 212 - /* KGDB console driver which uses PDC to read chars from keyboard */ 213 - 214 - static void kgdb_pdc_write_char(u8 chr) 215 - { 216 - /* no need to print char. kgdb will do it. */ 217 - } 218 - 219 - static struct kgdb_io kgdb_pdc_io_ops = { 220 - .name = "kgdb_pdc", 221 - .read_char = pdc_iodc_getc, 222 - .write_char = kgdb_pdc_write_char, 223 - }; 224 - 225 - static int __init kgdb_pdc_init(void) 226 - { 227 - kgdb_register_io_module(&kgdb_pdc_io_ops); 228 - return 0; 229 - } 230 - early_initcall(kgdb_pdc_init);
+3 -13
arch/parisc/kernel/pdc_cons.c
··· 12 12 #include <asm/page.h> /* for PAGE0 */ 13 13 #include <asm/pdc.h> /* for iodc_call() proto and friends */ 14 14 15 - static DEFINE_SPINLOCK(pdc_console_lock); 16 - 17 15 static void pdc_console_write(struct console *co, const char *s, unsigned count) 18 16 { 19 17 int i = 0; 20 - unsigned long flags; 21 18 22 - spin_lock_irqsave(&pdc_console_lock, flags); 23 19 do { 24 20 i += pdc_iodc_print(s + i, count - i); 25 21 } while (i < count); 26 - spin_unlock_irqrestore(&pdc_console_lock, flags); 27 22 } 28 23 29 24 #ifdef CONFIG_KGDB 30 25 static int kgdb_pdc_read_char(void) 31 26 { 32 - int c; 33 - unsigned long flags; 34 - 35 - spin_lock_irqsave(&pdc_console_lock, flags); 36 - c = pdc_iodc_getc(); 37 - spin_unlock_irqrestore(&pdc_console_lock, flags); 27 + int c = pdc_iodc_getc(); 38 28 39 29 return (c <= 0) ? NO_POLL_CHAR : c; 40 30 } 41 31 42 32 static void kgdb_pdc_write_char(u8 chr) 43 33 { 44 - if (PAGE0->mem_cons.cl_class != CL_DUPLEX) 45 - pdc_console_write(NULL, &chr, 1); 34 + /* no need to print char as it's shown on standard console */ 35 + /* pdc_iodc_print(&chr, 1); */ 46 36 } 47 37 48 38 static struct kgdb_io kgdb_pdc_io_ops = {
+7 -2
arch/parisc/kernel/processor.c
··· 272 272 printk(KERN_INFO "capabilities 0x%lx\n", 273 273 boot_cpu_data.pdc.capabilities); 274 274 275 - if (pdc_model_sysmodel(boot_cpu_data.pdc.sys_model_name) == PDC_OK) 276 - printk(KERN_INFO "model %s\n", 275 + if (pdc_model_sysmodel(OS_ID_HPUX, boot_cpu_data.pdc.sys_model_name) == PDC_OK) 276 + pr_info("HP-UX model name: %s\n", 277 277 boot_cpu_data.pdc.sys_model_name); 278 + 279 + serial_no[0] = 0; 280 + if (pdc_model_sysmodel(OS_ID_MPEXL, serial_no) == PDC_OK && 281 + serial_no[0]) 282 + pr_info("MPE/iX model name: %s\n", serial_no); 278 283 279 284 dump_stack_set_arch_desc("%s", boot_cpu_data.pdc.sys_model_name); 280 285
+2 -15
arch/parisc/kernel/real2.S
··· 15 15 16 16 #include <linux/linkage.h> 17 17 18 - 19 - .section .bss 20 - 21 - .export pdc_result 22 - .export pdc_result2 23 - .align 8 24 - pdc_result: 25 - .block ASM_PDC_RESULT_SIZE 26 - pdc_result2: 27 - .block ASM_PDC_RESULT_SIZE 28 - 29 18 .export real_stack 30 - .export real32_stack 31 19 .export real64_stack 32 - .align 64 20 + __PAGE_ALIGNED_BSS 33 21 real_stack: 34 - real32_stack: 35 22 real64_stack: 36 23 .block 8192 37 24 38 25 #define N_SAVED_REGS 9 39 - 26 + .section .bss 40 27 save_cr_space: 41 28 .block REG_SZ * N_SAVED_REGS 42 29 save_cr_end:
+12 -14
arch/parisc/kernel/setup.c
··· 50 50 extern unsigned int boot_args[]; 51 51 char *p; 52 52 53 - /* Collect stuff passed in from the boot loader */ 53 + *cmdline_p = command_line; 54 54 55 55 /* boot_args[0] is free-mem start, boot_args[1] is ptr to command line */ 56 - if (boot_args[0] < 64) { 57 - /* called from hpux boot loader */ 58 - boot_command_line[0] = '\0'; 59 - } else { 60 - strscpy(boot_command_line, (char *)__va(boot_args[1]), 61 - COMMAND_LINE_SIZE); 56 + if (boot_args[0] < 64) 57 + return; /* return if called from hpux boot loader */ 58 + 59 + /* Collect stuff passed in from the boot loader */ 60 + strscpy(boot_command_line, (char *)__va(boot_args[1]), 61 + COMMAND_LINE_SIZE); 62 62 63 63 /* autodetect console type (if not done by palo yet) */ 64 64 p = boot_command_line; ··· 75 75 strlcat(p, " earlycon=pdc", COMMAND_LINE_SIZE); 76 76 77 77 #ifdef CONFIG_BLK_DEV_INITRD 78 - if (boot_args[2] != 0) /* did palo pass us a ramdisk? */ 79 - { 80 - initrd_start = (unsigned long)__va(boot_args[2]); 81 - initrd_end = (unsigned long)__va(boot_args[3]); 82 - } 83 - #endif 78 + /* did palo pass us a ramdisk? */ 79 + if (boot_args[2] != 0) { 80 + initrd_start = (unsigned long)__va(boot_args[2]); 81 + initrd_end = (unsigned long)__va(boot_args[3]); 84 82 } 83 + #endif 85 84 86 85 strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE); 87 - *cmdline_p = command_line; 88 86 } 89 87 90 88 #ifdef CONFIG_PA11
+28
arch/parisc/kernel/sys_parisc.c
··· 465 465 flags = FIX_O_NONBLOCK(flags); 466 466 return sys_inotify_init1(flags); 467 467 } 468 + 469 + /* 470 + * madvise() wrapper 471 + * 472 + * Up to kernel v6.1 parisc has different values than all other 473 + * platforms for the MADV_xxx flags listed below. 474 + * To keep binary compatibility with existing userspace programs 475 + * translate the former values to the new values. 476 + * 477 + * XXX: Remove this wrapper in year 2025 (or later) 478 + */ 479 + 480 + asmlinkage notrace long parisc_madvise(unsigned long start, size_t len_in, int behavior) 481 + { 482 + switch (behavior) { 483 + case 65: behavior = MADV_MERGEABLE; break; 484 + case 66: behavior = MADV_UNMERGEABLE; break; 485 + case 67: behavior = MADV_HUGEPAGE; break; 486 + case 68: behavior = MADV_NOHUGEPAGE; break; 487 + case 69: behavior = MADV_DONTDUMP; break; 488 + case 70: behavior = MADV_DODUMP; break; 489 + case 71: behavior = MADV_WIPEONFORK; break; 490 + case 72: behavior = MADV_KEEPONFORK; break; 491 + case 73: behavior = MADV_COLLAPSE; break; 492 + } 493 + 494 + return sys_madvise(start, len_in, behavior); 495 + }
+1 -1
arch/parisc/kernel/syscalls/syscall.tbl
··· 131 131 116 common sysinfo sys_sysinfo compat_sys_sysinfo 132 132 117 common shutdown sys_shutdown 133 133 118 common fsync sys_fsync 134 - 119 common madvise sys_madvise 134 + 119 common madvise parisc_madvise 135 135 120 common clone sys_clone_wrapper 136 136 121 common setdomainname sys_setdomainname 137 137 122 common sendfile sys_sendfile compat_sys_sendfile
+2 -2
arch/parisc/kernel/vdso32/Makefile
··· 26 26 27 27 # Force dependency (incbin is bad) 28 28 # link rule for the .so file, .lds has to be first 29 - $(obj)/vdso32.so: $(src)/vdso32.lds $(obj-vdso32) $(obj-cvdso32) $(VDSO_LIBGCC) 29 + $(obj)/vdso32.so: $(src)/vdso32.lds $(obj-vdso32) $(obj-cvdso32) $(VDSO_LIBGCC) FORCE 30 30 $(call if_changed,vdso32ld) 31 31 32 32 # assembly rules for the .S files ··· 38 38 39 39 # actual build commands 40 40 quiet_cmd_vdso32ld = VDSO32L $@ 41 - cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $^ -o $@ 41 + cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $(filter-out FORCE, $^) -o $@ 42 42 quiet_cmd_vdso32as = VDSO32A $@ 43 43 cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $< 44 44 quiet_cmd_vdso32cc = VDSO32C $@
+2 -2
arch/parisc/kernel/vdso64/Makefile
··· 26 26 27 27 # Force dependency (incbin is bad) 28 28 # link rule for the .so file, .lds has to be first 29 - $(obj)/vdso64.so: $(src)/vdso64.lds $(obj-vdso64) $(VDSO_LIBGCC) 29 + $(obj)/vdso64.so: $(src)/vdso64.lds $(obj-vdso64) $(VDSO_LIBGCC) FORCE 30 30 $(call if_changed,vdso64ld) 31 31 32 32 # assembly rules for the .S files ··· 35 35 36 36 # actual build commands 37 37 quiet_cmd_vdso64ld = VDSO64L $@ 38 - cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@ 38 + cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $(filter-out FORCE, $^) -o $@ 39 39 quiet_cmd_vdso64as = VDSO64A $@ 40 40 cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $< 41 41
+3
drivers/parisc/led.c
··· 137 137 138 138 /* Create the work queue and queue the LED task */ 139 139 led_wq = create_singlethread_workqueue("led_wq"); 140 + if (!led_wq) 141 + return -ENOMEM; 142 + 140 143 queue_delayed_work(led_wq, &led_task, 0); 141 144 142 145 return 0;
+6 -6
tools/arch/parisc/include/uapi/asm/mman.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 2 #ifndef TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H 3 3 #define TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H 4 - #define MADV_DODUMP 70 4 + #define MADV_DODUMP 17 5 5 #define MADV_DOFORK 11 6 - #define MADV_DONTDUMP 69 6 + #define MADV_DONTDUMP 16 7 7 #define MADV_DONTFORK 10 8 8 #define MADV_DONTNEED 4 9 9 #define MADV_FREE 8 10 - #define MADV_HUGEPAGE 67 11 - #define MADV_MERGEABLE 65 12 - #define MADV_NOHUGEPAGE 68 10 + #define MADV_HUGEPAGE 14 11 + #define MADV_MERGEABLE 12 12 + #define MADV_NOHUGEPAGE 15 13 13 #define MADV_NORMAL 0 14 14 #define MADV_RANDOM 1 15 15 #define MADV_REMOVE 9 16 16 #define MADV_SEQUENTIAL 2 17 - #define MADV_UNMERGEABLE 66 17 + #define MADV_UNMERGEABLE 13 18 18 #define MADV_WILLNEED 3 19 19 #define MAP_ANONYMOUS 0x10 20 20 #define MAP_DENYWRITE 0x0800
-12
tools/perf/bench/bench.h
··· 10 10 * The madvise transparent hugepage constants were added in glibc 11 11 * 2.13. For compatibility with older versions of glibc, define these 12 12 * tokens if they are not already defined. 13 - * 14 - * PA-RISC uses different madvise values from other architectures and 15 - * needs to be special-cased. 16 13 */ 17 - #ifdef __hppa__ 18 - # ifndef MADV_HUGEPAGE 19 - # define MADV_HUGEPAGE 67 20 - # endif 21 - # ifndef MADV_NOHUGEPAGE 22 - # define MADV_NOHUGEPAGE 68 23 - # endif 24 - #else 25 14 # ifndef MADV_HUGEPAGE 26 15 # define MADV_HUGEPAGE 14 27 16 # endif 28 17 # ifndef MADV_NOHUGEPAGE 29 18 # define MADV_NOHUGEPAGE 15 30 19 # endif 31 - #endif 32 20 33 21 int bench_numa(int argc, const char **argv); 34 22 int bench_sched_messaging(int argc, const char **argv);