parisc: Use irq_enter_rcu() to fix warning at kernel/context_tracking.c:367
PATCH 1/7 parisc: Use irq_enter_rcu() to fix warning at kernel/context_tracking.c:367
From: Helge Deller <[email protected]>
Use irq*_rcu() functions to fix this kernel warning:
WARNING: CPU: 0 PID: 0 at kernel/context_tracking.c:367 ct_irq_enter+0xa0/0xd0 Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.7.0-rc3-64bit+ #1037 Hardware name: 9000/785/C3700
IASQ: 0000000000000000 0000000000000000 IAOQ: 00000000412cd758 00000000412cd75c
IIR: 03ffe01f ISR: 0000000000000000 IOR: 0000000043c20c20
CPU: 0 CR30: 0000000041caa000 CR31: 0000000000000000
ORIG_R28: 0000000000000005
IAOQ[0]: ct_irq_enter+0xa0/0xd0
IAOQ[1]: ct_irq_enter+0xa4/0xd0
RP(r2): irq_enter+0x34/0x68
Backtrace: [<000000004034a3ec>] irq_enter+0x34/0x68 [<000000004030dc48>] do_cpu_irq_mask+0xc0/0x450 [<0000000040303070>] intr_return+0x0/0xc
--- arch/parisc/kernel/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/parisc/kernel/irq.c +2 -2
@@ -498,7 +498,7 @@ asmlinkage void do_cpu_irq_mask(struct pt_regs *regs) old_regs =set_irq_regs (regs);local_irq_disable (); -irq_enter (); +irq_enter_rcu (); eirr_val =mfctl (23 ) & cpu_eiem &per_cpu (local_ack_eiem, cpu);if (!eirr_val)
@@ -533,7 +533,7 @@ asmlinkage void do_cpu_irq_mask(struct pt_regs *regs)#endif /* CONFIG_IRQSTACKS */ out: -irq_exit (); +irq_exit_rcu ();set_irq_regs (old_regs);return ;
Signature · 1 line
2.43.0
PATCH 2/7 parisc: Make RO_DATA page aligned in vmlinux.lds.S
From: Helge Deller <[email protected]>
The rodata_test program for CONFIG_DEBUG_RODATA_TEST=y complains if read-only data does not start at page boundary.
--- arch/parisc/kernel/vmlinux.lds.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/kernel/vmlinux.lds.S +1 -1
@@ -127,7 +127,7 @@ SECTIONS } #endif - RO_DATA(8) + RO_DATA(PAGE_SIZE) /* unwind info */ . = ALIGN(4);
Signature · 1 line
2.43.0
PATCH 3/7 parisc: Check for valid stride size for cache flushes
In reply to [email protected]From: Helge Deller <[email protected]>
Report if the calculated cache stride size is zero, otherwise the cache flushing routine will never finish and hang the machine.
This can be reproduced with a testcase in qemu, where the firmware reports wrong cache values.
--- arch/parisc/kernel/cache.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/parisc/kernel/cache.c +4 -0
@@ -264,6 +264,10 @@ parisc_cache_init(void) icache_stride =CAFL_STRIDE (cache_info.ic_conf);#undef CAFL_STRIDE +/* stride needs to be non-zero, otherwise cache flushes will not work */ +WARN_ON (cache_info.dc_size && dcache_stride ==0 ); +WARN_ON (cache_info.ic_size && icache_stride ==0 ); +if ((boot_cpu_data.pdc.capabilities &PDC_MODEL_NVA_MASK ) ==PDC_MODEL_NVA_UNSUPPORTED ) {printk (KERN_WARNING "parisc_cache_init: Only equivalent aliasing supported!\n" );
Signature · 1 line
2.43.0
PATCH 4/7 parisc: Prevent hung tasks when printing inventory on serial console
In reply to [email protected]From: Helge Deller <[email protected]>
Printing the inventory on a serial console can be quite slow and thus may trigger the hung task detector (CONFIG_DETECT_HUNG_TASK=y) and possibly reboot the machine. Adding a cond_resched() prevents this.
--- arch/parisc/kernel/drivers.c | 3 +++ 1 file changed, 3 insertions(+)
arch/parisc/kernel/drivers.c +3 -0
@@ -1004,6 +1004,9 @@ static __init int qemu_print_iodc_data(struct device *lin_dev, void *data)pr_info ("\n" ); +/* Prevent hung task messages when printing on serial console */ +cond_resched (); +pr_info ("#define HPA_%08lx_DESCRIPTION \"%s\"\n" , hpa,parisc_hardware_description (&dev->id));
Signature · 1 line
2.43.0
PATCH 5/7 parisc: Drop unneeded semicolon in parse_tree_node()
In reply to [email protected]From: Helge Deller <[email protected]>
--- arch/parisc/kernel/drivers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/kernel/drivers.c +1 -1
@@ -742,7 +742,7 @@ parse_tree_node(struct device *parent, int index, struct hardware_path *modpath) };if (device_for_each_child (parent, &recurse_data, descend_children)) - {/* nothing */ }; + {/* nothing */ }return d.dev; }
Signature · 1 line
2.43.0
PATCH 6/7 parisc: Fix random data corruption from exception handler
In reply to [email protected]From: Helge Deller <[email protected]>
The current exception handler implementation, which assists when accessing user space memory, may exhibit random data corruption if the compiler decides to use a different register than the given register %r29 (defined in ASM_EXCEPTIONTABLE_REG) for the error code. If the compiler choose another register, the fault handler will nevertheless store -EFAULT into %r29 and thus trash whatever this register is used for.
Looking at the assembly I found that this happened e.g. in emulate_ldd().
To solve the issue, the easiest solution would be if it somehow is possible to tell the fault handler which register is used to hold the error code. Using %0 or %1 in the inline assembly is not posssible as it will show up as e.g. %r29 (with the "%r" prefix), which the GNU assembler can not convert to an integer.
This patch takes another, better and more flexible approach:
We extend the __ex_table (which is out of the execution path) by one 32-word. In this word we tell the compiler to insert the assembler instruction "ldi 1,%reg", where %reg references the register which the compiler choosed for the error return code.
In case of an access failure, the fault handler finds the __ex_table entry and can examine the opcode. The used register is encoded in the lowest 5 bits, and the fault handler can then store -EFAULT into this register.
--- arch/parisc/include/asm/assembly.h | 1 + arch/parisc/include/asm/extable.h | 64 +++++++++++++++++++++++++ arch/parisc/include/asm/special_insns.h | 4 +- arch/parisc/include/asm/uaccess.h | 48 +++---------------- arch/parisc/kernel/cache.c | 4 +- arch/parisc/kernel/unaligned.c | 44 ++++++++--------- arch/parisc/mm/fault.c | 10 ++-- 7 files changed, 105 insertions(+), 70 deletions(-) create mode 100644 arch/parisc/include/asm/extable.h
arch/parisc/include/asm/assembly.h +1 -0
@@ -576,6 +576,7 @@ .section __ex_table,"aw" ! \ .align 4 ! \ .word (fault_addr - .), (except_addr - .) ! \ + ldi 0,%r0 ! \ .previous
arch/parisc/include/asm/extable.h new file +64 -0
64 lines not on this page · raw message
arch/parisc/include/asm/special_insns.h +2 -2
@@ -8,7 +8,7 @@"copy %%r0,%0\n" \"8:\tlpa %%r0(%1),%0\n" \"9:\n" \ -ASM_EXCEPTIONTABLE_ENTRY (8b ,9b ) \ +ASM_EXCEPTIONTABLE_ENTRY (8b ,9b ,"nop" ) \ : "=&r" (pa) \: " r" (va) \ : " memory" \
@@ -22,7 +22,7 @@"copy %%r0,%0\n" \"8:\tlpa %%r0(%%sr3,%1),%0\n" \"9:\n" \ -ASM_EXCEPTIONTABLE_ENTRY (8b ,9b ) \ +ASM_EXCEPTIONTABLE_ENTRY (8b ,9b ,"nop" ) \ : "=&r" (pa) \: " r" (va) \ : " memory" \
arch/parisc/include/asm/uaccess.h +7 -41
94 lines not on this page · raw message
arch/parisc/kernel/cache.c +2 -2
@@ -854,7 +854,7 @@ SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, bytes,#endif " fic,m %3(%4,%0)\n" "2: sync\n" -ASM_EXCEPTIONTABLE_ENTRY_EFAULT (1b ,2b ) +ASM_EXCEPTIONTABLE_ENTRY_EFAULT (1b ,2b ,"%1" ) : "+r" (start), "+r" (error) : "r" (end), "r" (dcache_stride), "i" (SR_USER)); }
@@ -869,7 +869,7 @@ SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, bytes,#endif " fdc,m %3(%4,%0)\n" "2: sync\n" -ASM_EXCEPTIONTABLE_ENTRY_EFAULT (1b ,2b ) +ASM_EXCEPTIONTABLE_ENTRY_EFAULT (1b ,2b ,"%1" ) : "+r" (start), "+r" (error) : "r" (end), "r" (icache_stride), "i" (SR_USER)); }
arch/parisc/kernel/unaligned.c +22 -22
92 lines not on this page · raw message
arch/parisc/mm/fault.c +7 -3
@@ -150,11 +150,15 @@ int fixup_exception(struct pt_regs *regs)* Fix up get_user() and put_user(). * ASM_EXCEPTIONTABLE_ENTRY_EFAULT() sets the least-significant * bit in the relative address of the fixup routine to indicate -* that gr[ASM_EXCEPTIONTABLE_REG] should be loaded with -* -EFAULT to report a userspace access error. +* that the register, encoded in the additonal "ldi" opcode, should +* be loaded with -EFAULT to report a userspace access error. */ if (fix->fixup &1 ) { - regs->gr[ASM_EXCEPTIONTABLE_REG ] = -EFAULT ; +int fault_error_reg = fix->err_opcode &0x1f ; +if (fault_error_reg) + regs->gr[fault_error_reg] = -EFAULT ; +pr_debug ("FIXUP REG %d at %pS\n" , fault_error_reg, + (void *)regs->iaoq[0 ]);/* zero target register for get_user() */ if (parisc_acctyp (0 , regs->iir) ==VM_READ ) {
Signature · 1 line
2.43.0
PATCH 7/7 parisc: Show kernel unaligned memory accesses
In reply to [email protected]From: Helge Deller <[email protected]>
Warn if some kernel function triggers unaligned memory accesses.
--- arch/parisc/kernel/unaligned.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/parisc/kernel/unaligned.c +7 -0
@@ -399,6 +399,13 @@ void handle_unaligned(struct pt_regs *regs)if (!unaligned_enabled) goto force_sigbus; + }else { + static DEFINE_RATELIMIT_STATE(kernel_ratelimit, 5 * HZ, 5); +if (!(current->thread.flags &PARISC_UAC_NOPRINT ) && +__ratelimit (&kernel_ratelimit)) +pr_warn ("Kernel: unaligned access to " RFMT " in %pS " +"(iir " RFMT ")\n" , + regs->ior, (void *)regs->iaoq[0 ], regs->iir); }/* handle modification - OK, it's ugly, see the instruction manual */
Signature · 1 line
2.43.0