Skip to content

Commit 17a363d

Browse files
committed
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: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent 61311e3 commit 17a363d

3 files changed

Lines changed: 12 additions & 18 deletions

File tree

arch/s390/kernel/entry.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ void do_dat_exception(struct pt_regs *regs);
2626
void do_secure_storage_access(struct pt_regs *regs);
2727
void do_non_secure_storage_access(struct pt_regs *regs);
2828
void do_secure_storage_violation(struct pt_regs *regs);
29-
void default_trap_handler(struct pt_regs *regs);
3029
void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str);
3130
void kernel_stack_overflow(struct pt_regs * regs);
3231
void do_signal(struct pt_regs *regs);

arch/s390/kernel/traps.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void do_per_trap(struct pt_regs *regs)
7979
}
8080
NOKPROBE_SYMBOL(do_per_trap);
8181

82-
void default_trap_handler(struct pt_regs *regs)
82+
static void default_trap_handler(struct pt_regs *regs)
8383
{
8484
if (user_mode(regs)) {
8585
report_user_fault(regs, SIGSEGV, 0);
@@ -404,3 +404,12 @@ static void (*pgm_check_table[128])(struct pt_regs *regs) = {
404404
[0x40] = monitor_event_exception,
405405
[0x41 ... 0x7f] = default_trap_handler,
406406
};
407+
408+
#define COND_TRAP(x) asm( \
409+
".weak " __stringify(x) "\n\t" \
410+
".set " __stringify(x) "," \
411+
__stringify(default_trap_handler))
412+
413+
COND_TRAP(do_secure_storage_access);
414+
COND_TRAP(do_non_secure_storage_access);
415+
COND_TRAP(do_secure_storage_violation);

arch/s390/mm/fault.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ early_initcall(pfault_irq_init);
783783
#endif /* CONFIG_PFAULT */
784784

785785
#if IS_ENABLED(CONFIG_PGSTE)
786+
786787
void do_secure_storage_access(struct pt_regs *regs)
787788
{
788789
unsigned long addr = regs->int_parm_long & __FAIL_ADDR_MASK;
@@ -859,19 +860,4 @@ void do_secure_storage_violation(struct pt_regs *regs)
859860
send_sig(SIGSEGV, current, 0);
860861
}
861862

862-
#else
863-
void do_secure_storage_access(struct pt_regs *regs)
864-
{
865-
default_trap_handler(regs);
866-
}
867-
868-
void do_non_secure_storage_access(struct pt_regs *regs)
869-
{
870-
default_trap_handler(regs);
871-
}
872-
873-
void do_secure_storage_violation(struct pt_regs *regs)
874-
{
875-
default_trap_handler(regs);
876-
}
877-
#endif
863+
#endif /* CONFIG_PGSTE */

0 commit comments

Comments
 (0)