Skip to content

Commit 35f79d0

Browse files
committed
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()
2 parents 70b07be + 4934fbf commit 35f79d0

File tree

16 files changed

+100
-120
lines changed

16 files changed

+100
-120
lines changed

arch/parisc/include/asm/pdc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int pdc_system_map_find_mods(struct pdc_system_map_mod_info *pdc_mod_info,
3737
int pdc_system_map_find_addrs(struct pdc_system_map_addr_info *pdc_addr_info,
3838
long mod_index, long addr_index);
3939
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);
4141
int pdc_model_cpuid(unsigned long *cpu_id);
4242
int pdc_model_versions(unsigned long *versions, int id);
4343
int pdc_model_capabilities(unsigned long *capabilities);

arch/parisc/include/asm/pgtable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ extern void __update_cache(pte_t pte);
151151

152152
/* This calculates the number of initial pages we need for the initial
153153
* 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))
156156
#else
157157
# define PT_INITIAL (1) /* all initial PTEs fit into one page */
158158
#endif

arch/parisc/include/uapi/asm/mman.h

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@
4949
#define MADV_DONTFORK 10 /* don't inherit across fork */
5050
#define MADV_DOFORK 11 /* do inherit across fork */
5151

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+
5265
#define MADV_COLD 20 /* deactivate these pages */
5366
#define MADV_PAGEOUT 21 /* reclaim these pages */
5467

@@ -57,27 +70,13 @@
5770

5871
#define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */
5972

60-
#define MADV_MERGEABLE 65 /* KSM may merge identical pages */
61-
#define MADV_UNMERGEABLE 66 /* KSM may not merge identical pages */
62-
63-
#define MADV_HUGEPAGE 67 /* Worth backing with hugepages */
64-
#define MADV_NOHUGEPAGE 68 /* Not worth backing with hugepages */
65-
66-
#define MADV_DONTDUMP 69 /* Explicity exclude from the core dump,
67-
overrides the coredump filter bits */
68-
#define MADV_DODUMP 70 /* Clear the MADV_NODUMP flag */
69-
70-
#define MADV_WIPEONFORK 71 /* Zero memory on fork, child only */
71-
#define MADV_KEEPONFORK 72 /* Undo MADV_WIPEONFORK */
72-
73-
#define MADV_COLLAPSE 73 /* Synchronous hugepage collapse */
73+
#define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */
7474

7575
#define MADV_HWPOISON 100 /* poison a page for testing */
7676
#define MADV_SOFT_OFFLINE 101 /* soft offline page for testing */
7777

7878
/* compatibility flags */
7979
#define MAP_FILE 0
80-
#define MAP_VARIABLE 0
8180

8281
#define PKEY_DISABLE_ACCESS 0x1
8382
#define PKEY_DISABLE_WRITE 0x2

arch/parisc/kernel/firmware.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@
7474
static DEFINE_SPINLOCK(pdc_lock);
7575
#endif
7676

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);
7979

8080
#ifdef CONFIG_64BIT
8181
#define WIDE_FIRMWARE 0x1
@@ -527,14 +527,14 @@ int pdc_model_info(struct pdc_model *model)
527527
* Using OS_ID_HPUX will return the equivalent of the 'modelname' command
528528
* on HP/UX.
529529
*/
530-
int pdc_model_sysmodel(char *name)
530+
int pdc_model_sysmodel(unsigned int os_id, char *name)
531531
{
532532
int retval;
533533
unsigned long flags;
534534

535535
spin_lock_irqsave(&pdc_lock, flags);
536536
retval = mem_pdc_call(PDC_MODEL, PDC_MODEL_SYSMODEL, __pa(pdc_result),
537-
OS_ID_HPUX, __pa(name));
537+
os_id, __pa(name));
538538
convert_to_wide(pdc_result);
539539

540540
if (retval == PDC_OK) {
@@ -1288,9 +1288,8 @@ void pdc_io_reset_devices(void)
12881288

12891289
#endif /* defined(BOOTLOADER) */
12901290

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;
12941293

12951294
/**
12961295
* pdc_iodc_print - Console print using IODC.
@@ -1307,6 +1306,9 @@ int pdc_iodc_print(const unsigned char *str, unsigned count)
13071306
unsigned int i;
13081307
unsigned long flags;
13091308

1309+
count = min_t(unsigned int, count, sizeof(iodc_dbuf));
1310+
1311+
spin_lock_irqsave(&pdc_lock, flags);
13101312
for (i = 0; i < count;) {
13111313
switch(str[i]) {
13121314
case '\n':
@@ -1322,12 +1324,11 @@ int pdc_iodc_print(const unsigned char *str, unsigned count)
13221324
}
13231325

13241326
print:
1325-
spin_lock_irqsave(&pdc_lock, flags);
1326-
real32_call(PAGE0->mem_cons.iodc_io,
1327-
(unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT,
1328-
PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers),
1329-
__pa(iodc_retbuf), 0, __pa(iodc_dbuf), i, 0);
1330-
spin_unlock_irqrestore(&pdc_lock, flags);
1327+
real32_call(PAGE0->mem_cons.iodc_io,
1328+
(unsigned long)PAGE0->mem_cons.hpa, ENTRY_IO_COUT,
1329+
PAGE0->mem_cons.spa, __pa(PAGE0->mem_cons.dp.layers),
1330+
__pa(pdc_result), 0, __pa(iodc_dbuf), i, 0);
1331+
spin_unlock_irqrestore(&pdc_lock, flags);
13311332

13321333
return i;
13331334
}
@@ -1354,10 +1355,11 @@ int pdc_iodc_getc(void)
13541355
real32_call(PAGE0->mem_kbd.iodc_io,
13551356
(unsigned long)PAGE0->mem_kbd.hpa, ENTRY_IO_CIN,
13561357
PAGE0->mem_kbd.spa, __pa(PAGE0->mem_kbd.dp.layers),
1357-
__pa(iodc_retbuf), 0, __pa(iodc_dbuf), 1, 0);
1358+
__pa(pdc_result), 0, __pa(iodc_dbuf), 1, 0);
13581359

13591360
ch = *iodc_dbuf;
1360-
status = *iodc_retbuf;
1361+
/* like convert_to_wide() but for first return value only: */
1362+
status = *(int *)&pdc_result;
13611363
spin_unlock_irqrestore(&pdc_lock, flags);
13621364

13631365
if (status == 0)

arch/parisc/kernel/kgdb.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,23 +208,3 @@ int kgdb_arch_handle_exception(int trap, int signo,
208208
}
209209
return -1;
210210
}
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);

arch/parisc/kernel/pdc_cons.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,27 @@
1212
#include <asm/page.h> /* for PAGE0 */
1313
#include <asm/pdc.h> /* for iodc_call() proto and friends */
1414

15-
static DEFINE_SPINLOCK(pdc_console_lock);
16-
1715
static void pdc_console_write(struct console *co, const char *s, unsigned count)
1816
{
1917
int i = 0;
20-
unsigned long flags;
2118

22-
spin_lock_irqsave(&pdc_console_lock, flags);
2319
do {
2420
i += pdc_iodc_print(s + i, count - i);
2521
} while (i < count);
26-
spin_unlock_irqrestore(&pdc_console_lock, flags);
2722
}
2823

2924
#ifdef CONFIG_KGDB
3025
static int kgdb_pdc_read_char(void)
3126
{
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();
3828

3929
return (c <= 0) ? NO_POLL_CHAR : c;
4030
}
4131

4232
static void kgdb_pdc_write_char(u8 chr)
4333
{
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); */
4636
}
4737

4838
static struct kgdb_io kgdb_pdc_io_ops = {

arch/parisc/kernel/processor.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,15 @@ void __init collect_boot_cpu_data(void)
272272
printk(KERN_INFO "capabilities 0x%lx\n",
273273
boot_cpu_data.pdc.capabilities);
274274

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",
277277
boot_cpu_data.pdc.sys_model_name);
278278

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);
283+
279284
dump_stack_set_arch_desc("%s", boot_cpu_data.pdc.sys_model_name);
280285

281286
boot_cpu_data.hversion = boot_cpu_data.pdc.model.hversion;

arch/parisc/kernel/real2.S

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,15 @@
1515

1616
#include <linux/linkage.h>
1717

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-
2918
.export real_stack
30-
.export real32_stack
3119
.export real64_stack
32-
.align 64
20+
__PAGE_ALIGNED_BSS
3321
real_stack:
34-
real32_stack:
3522
real64_stack:
3623
.block 8192
3724

3825
#define N_SAVED_REGS 9
39-
26+
.section .bss
4027
save_cr_space:
4128
.block REG_SZ * N_SAVED_REGS
4229
save_cr_end:

arch/parisc/kernel/setup.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ void __init setup_cmdline(char **cmdline_p)
5050
extern unsigned int boot_args[];
5151
char *p;
5252

53-
/* Collect stuff passed in from the boot loader */
53+
*cmdline_p = command_line;
5454

5555
/* 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);
6262

6363
/* autodetect console type (if not done by palo yet) */
6464
p = boot_command_line;
@@ -75,16 +75,14 @@ void __init setup_cmdline(char **cmdline_p)
7575
strlcat(p, " earlycon=pdc", COMMAND_LINE_SIZE);
7676

7777
#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]);
8482
}
83+
#endif
8584

8685
strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
87-
*cmdline_p = command_line;
8886
}
8987

9088
#ifdef CONFIG_PA11

arch/parisc/kernel/sys_parisc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,3 +465,31 @@ asmlinkage long parisc_inotify_init1(int flags)
465465
flags = FIX_O_NONBLOCK(flags);
466466
return sys_inotify_init1(flags);
467467
}
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+
}

0 commit comments

Comments
 (0)