forked from Minki/linux
325678fd05
Commit9d1988ca87
("powerpc/64: treat low kernel text as irqs soft-masked") ends up catching too much code, including ret_from_fork, and parts of interrupt and syscall return that do not expect to be interrupts to be soft-masked. If an interrupt gets marked pending, and then the code proceeds out of the implicit soft-masked region it will fail to deal with the pending interrupt. Fix this by adding a new table of addresses which explicitly marks the regions of code that are soft masked. This table is only checked for interrupts that below __end_soft_masked, so most kernel interrupts will not have the overhead of the table search. Fixes:9d1988ca87
("powerpc/64: treat low kernel text as irqs soft-masked") Reported-by: Sachin Sant <sachinp@linux.vnet.ibm.com> Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Tested-by: Sachin Sant <sachinp@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20210630074621.2109197-5-npiggin@gmail.com
57 lines
1.3 KiB
C
57 lines
1.3 KiB
C
#include <asm/interrupt.h>
|
|
#include <asm/kprobes.h>
|
|
|
|
struct soft_mask_table_entry {
|
|
unsigned long start;
|
|
unsigned long end;
|
|
};
|
|
|
|
struct restart_table_entry {
|
|
unsigned long start;
|
|
unsigned long end;
|
|
unsigned long fixup;
|
|
};
|
|
|
|
extern struct soft_mask_table_entry __start___soft_mask_table[];
|
|
extern struct soft_mask_table_entry __stop___soft_mask_table[];
|
|
|
|
extern struct restart_table_entry __start___restart_table[];
|
|
extern struct restart_table_entry __stop___restart_table[];
|
|
|
|
/* Given an address, look for it in the soft mask table */
|
|
bool search_kernel_soft_mask_table(unsigned long addr)
|
|
{
|
|
struct soft_mask_table_entry *smte = __start___soft_mask_table;
|
|
|
|
while (smte < __stop___soft_mask_table) {
|
|
unsigned long start = smte->start;
|
|
unsigned long end = smte->end;
|
|
|
|
if (addr >= start && addr < end)
|
|
return true;
|
|
|
|
smte++;
|
|
}
|
|
return false;
|
|
}
|
|
NOKPROBE_SYMBOL(search_kernel_soft_mask_table);
|
|
|
|
/* Given an address, look for it in the kernel exception table */
|
|
unsigned long search_kernel_restart_table(unsigned long addr)
|
|
{
|
|
struct restart_table_entry *rte = __start___restart_table;
|
|
|
|
while (rte < __stop___restart_table) {
|
|
unsigned long start = rte->start;
|
|
unsigned long end = rte->end;
|
|
unsigned long fixup = rte->fixup;
|
|
|
|
if (addr >= start && addr < end)
|
|
return fixup;
|
|
|
|
rte++;
|
|
}
|
|
return 0;
|
|
}
|
|
NOKPROBE_SYMBOL(search_kernel_restart_table);
|