s390/mm,fault: get rid of do_low_address()
authorHeiko Carstens <hca@linux.ibm.com>
Thu, 12 Oct 2023 07:40:46 +0000 (09:40 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Mon, 23 Oct 2023 16:21:22 +0000 (18:21 +0200)
There is only one caller of do_low_address(). Given that this code is
quite special just get rid of do_low_address, and add it to
do_protection_exception() in order to make the code a bit more
readable.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/mm/fault.c

index ee8a40917592042775566d8b5050f524fcaadf5d..87bfcf4d30827142324198cf21a91ad525d35e0c 100644 (file)
@@ -257,20 +257,6 @@ static void do_no_context(struct pt_regs *regs, vm_fault_t fault)
        die(regs, "Oops");
 }
 
-static void do_low_address(struct pt_regs *regs)
-{
-       /*
-        * Low-address protection hit in kernel mode means
-        * NULL pointer write access in kernel mode.
-        */
-       if (regs->psw.mask & PSW_MASK_PSTATE) {
-               /* Low-address protection hit in user mode: 'cannot happen' */
-               die(regs, "Low-address protection");
-       }
-
-       do_no_context(regs, VM_FAULT_BADACCESS);
-}
-
 static void do_sigbus(struct pt_regs *regs)
 {
        force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)get_fault_address(regs));
@@ -504,8 +490,15 @@ void do_protection_exception(struct pt_regs *regs)
         * field is not guaranteed to contain valid data in this case.
         */
        if (unlikely(!teid.b61)) {
-               do_low_address(regs);
-               return;
+               if (user_mode(regs)) {
+                       /* Low-address protection in user mode: cannot happen */
+                       die(regs, "Low-address protection");
+               }
+               /*
+                * Low-address protection in kernel mode means
+                * NULL pointer write access in kernel mode.
+                */
+               return do_no_context(regs, VM_FAULT_BADACCESS);
        }
        if (unlikely(MACHINE_HAS_NX && teid.b56)) {
                regs->int_parm_long = (teid.addr * PAGE_SIZE) | (regs->psw.addr & PAGE_MASK);