From 0f1a14e0348eb48e93e139af569944349b725f3f Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Thu, 12 Oct 2023 09:40:48 +0200 Subject: [PATCH] s390/mm,fault: simplify kfence fault handling do_no_context() can be simplified by removing its fault parameter, which is only used to decide if kfence_handle_page_fault() should be called. If the fault happened within the kernel space it is ok to always check if this happened on a page which was unmapped because of the kfence feature. Limiting the check to the VM_FAULT_BADCONTEXT case doesn't add any value. Reviewed-by: Claudio Imbrenda Signed-off-by: Heiko Carstens Signed-off-by: Vasily Gorbik --- arch/s390/mm/fault.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 9ed979690665..e0dbc231828c 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -234,7 +234,7 @@ static void do_sigsegv(struct pt_regs *regs, int si_code) force_sig_fault(SIGSEGV, si_code, (void __user *)get_fault_address(regs)); } -static void do_no_context(struct pt_regs *regs, vm_fault_t fault) +static void do_no_context(struct pt_regs *regs) { enum fault_type fault_type; unsigned long address; @@ -243,7 +243,7 @@ static void do_no_context(struct pt_regs *regs, vm_fault_t fault) if (fixup_exception(regs)) return; fault_type = get_fault_type(regs); - if ((fault_type == KERNEL_FAULT) && (fault == VM_FAULT_BADCONTEXT)) { + if (fault_type == KERNEL_FAULT) { address = get_fault_address(regs); is_write = fault_is_write(regs); if (kfence_handle_page_fault(address, is_write, regs)) @@ -279,28 +279,28 @@ static void do_fault_error(struct pt_regs *regs, vm_fault_t fault) } fallthrough; case VM_FAULT_BADCONTEXT: - do_no_context(regs, fault); + do_no_context(regs); break; case VM_FAULT_SIGNAL: if (!user_mode(regs)) - do_no_context(regs, fault); + do_no_context(regs); break; default: /* fault & VM_FAULT_ERROR */ if (fault & VM_FAULT_OOM) { if (!user_mode(regs)) - do_no_context(regs, fault); + do_no_context(regs); else pagefault_out_of_memory(); } else if (fault & VM_FAULT_SIGSEGV) { /* Kernel mode? Handle exceptions or die */ if (!user_mode(regs)) - do_no_context(regs, fault); + do_no_context(regs); else do_sigsegv(regs, SEGV_MAPERR); } else if (fault & VM_FAULT_SIGBUS) { /* Kernel mode? Handle exceptions or die */ if (!user_mode(regs)) - do_no_context(regs, fault); + do_no_context(regs); else do_sigbus(regs); } else { @@ -497,7 +497,7 @@ void do_protection_exception(struct pt_regs *regs) * Low-address protection in kernel mode means * NULL pointer write access in kernel mode. */ - return do_no_context(regs, VM_FAULT_BADACCESS); + return do_no_context(regs); } if (unlikely(MACHINE_HAS_NX && teid.b56)) { regs->int_parm_long = (teid.addr * PAGE_SIZE) | (regs->psw.addr & PAGE_MASK);