Commit 17a363dc authored by Heiko Carstens's avatar Heiko Carstens

s390/traps,mm: add conditional trap handlers

Add conditional trap handlers similar to conditional system calls
(COND_SYSCALL), to reduce the number of ifdefs.

Trap handlers which may or may not exist depending on config options
are supposed to have a COND_TRAP entry, which redirects to
default_trap_handler() for non-existent trap handlers during link
time.

This allows to get rid of the secure execution trap handlers for the
!PGSTE case.
Reviewed-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 61311e32
...@@ -26,7 +26,6 @@ void do_dat_exception(struct pt_regs *regs); ...@@ -26,7 +26,6 @@ void do_dat_exception(struct pt_regs *regs);
void do_secure_storage_access(struct pt_regs *regs); void do_secure_storage_access(struct pt_regs *regs);
void do_non_secure_storage_access(struct pt_regs *regs); void do_non_secure_storage_access(struct pt_regs *regs);
void do_secure_storage_violation(struct pt_regs *regs); void do_secure_storage_violation(struct pt_regs *regs);
void default_trap_handler(struct pt_regs *regs);
void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str); void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str);
void kernel_stack_overflow(struct pt_regs * regs); void kernel_stack_overflow(struct pt_regs * regs);
void do_signal(struct pt_regs *regs); void do_signal(struct pt_regs *regs);
......
...@@ -79,7 +79,7 @@ void do_per_trap(struct pt_regs *regs) ...@@ -79,7 +79,7 @@ void do_per_trap(struct pt_regs *regs)
} }
NOKPROBE_SYMBOL(do_per_trap); NOKPROBE_SYMBOL(do_per_trap);
void default_trap_handler(struct pt_regs *regs) static void default_trap_handler(struct pt_regs *regs)
{ {
if (user_mode(regs)) { if (user_mode(regs)) {
report_user_fault(regs, SIGSEGV, 0); report_user_fault(regs, SIGSEGV, 0);
...@@ -404,3 +404,12 @@ static void (*pgm_check_table[128])(struct pt_regs *regs) = { ...@@ -404,3 +404,12 @@ static void (*pgm_check_table[128])(struct pt_regs *regs) = {
[0x40] = monitor_event_exception, [0x40] = monitor_event_exception,
[0x41 ... 0x7f] = default_trap_handler, [0x41 ... 0x7f] = default_trap_handler,
}; };
#define COND_TRAP(x) asm( \
".weak " __stringify(x) "\n\t" \
".set " __stringify(x) "," \
__stringify(default_trap_handler))
COND_TRAP(do_secure_storage_access);
COND_TRAP(do_non_secure_storage_access);
COND_TRAP(do_secure_storage_violation);
...@@ -783,6 +783,7 @@ early_initcall(pfault_irq_init); ...@@ -783,6 +783,7 @@ early_initcall(pfault_irq_init);
#endif /* CONFIG_PFAULT */ #endif /* CONFIG_PFAULT */
#if IS_ENABLED(CONFIG_PGSTE) #if IS_ENABLED(CONFIG_PGSTE)
void do_secure_storage_access(struct pt_regs *regs) void do_secure_storage_access(struct pt_regs *regs)
{ {
unsigned long addr = regs->int_parm_long & __FAIL_ADDR_MASK; unsigned long addr = regs->int_parm_long & __FAIL_ADDR_MASK;
...@@ -859,19 +860,4 @@ void do_secure_storage_violation(struct pt_regs *regs) ...@@ -859,19 +860,4 @@ void do_secure_storage_violation(struct pt_regs *regs)
send_sig(SIGSEGV, current, 0); send_sig(SIGSEGV, current, 0);
} }
#else #endif /* CONFIG_PGSTE */
void do_secure_storage_access(struct pt_regs *regs)
{
default_trap_handler(regs);
}
void do_non_secure_storage_access(struct pt_regs *regs)
{
default_trap_handler(regs);
}
void do_secure_storage_violation(struct pt_regs *regs)
{
default_trap_handler(regs);
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment