Skip to content

Commit 0f1a14e

Browse files
hcahcaVasily Gorbik
authored andcommitted
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 <imbrenda@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 64ea33f commit 0f1a14e

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

arch/s390/mm/fault.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static void do_sigsegv(struct pt_regs *regs, int si_code)
234234
force_sig_fault(SIGSEGV, si_code, (void __user *)get_fault_address(regs));
235235
}
236236

237-
static void do_no_context(struct pt_regs *regs, vm_fault_t fault)
237+
static void do_no_context(struct pt_regs *regs)
238238
{
239239
enum fault_type fault_type;
240240
unsigned long address;
@@ -243,7 +243,7 @@ static void do_no_context(struct pt_regs *regs, vm_fault_t fault)
243243
if (fixup_exception(regs))
244244
return;
245245
fault_type = get_fault_type(regs);
246-
if ((fault_type == KERNEL_FAULT) && (fault == VM_FAULT_BADCONTEXT)) {
246+
if (fault_type == KERNEL_FAULT) {
247247
address = get_fault_address(regs);
248248
is_write = fault_is_write(regs);
249249
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)
279279
}
280280
fallthrough;
281281
case VM_FAULT_BADCONTEXT:
282-
do_no_context(regs, fault);
282+
do_no_context(regs);
283283
break;
284284
case VM_FAULT_SIGNAL:
285285
if (!user_mode(regs))
286-
do_no_context(regs, fault);
286+
do_no_context(regs);
287287
break;
288288
default: /* fault & VM_FAULT_ERROR */
289289
if (fault & VM_FAULT_OOM) {
290290
if (!user_mode(regs))
291-
do_no_context(regs, fault);
291+
do_no_context(regs);
292292
else
293293
pagefault_out_of_memory();
294294
} else if (fault & VM_FAULT_SIGSEGV) {
295295
/* Kernel mode? Handle exceptions or die */
296296
if (!user_mode(regs))
297-
do_no_context(regs, fault);
297+
do_no_context(regs);
298298
else
299299
do_sigsegv(regs, SEGV_MAPERR);
300300
} else if (fault & VM_FAULT_SIGBUS) {
301301
/* Kernel mode? Handle exceptions or die */
302302
if (!user_mode(regs))
303-
do_no_context(regs, fault);
303+
do_no_context(regs);
304304
else
305305
do_sigbus(regs);
306306
} else {
@@ -497,7 +497,7 @@ void do_protection_exception(struct pt_regs *regs)
497497
* Low-address protection in kernel mode means
498498
* NULL pointer write access in kernel mode.
499499
*/
500-
return do_no_context(regs, VM_FAULT_BADACCESS);
500+
return do_no_context(regs);
501501
}
502502
if (unlikely(MACHINE_HAS_NX && teid.b56)) {
503503
regs->int_parm_long = (teid.addr * PAGE_SIZE) | (regs->psw.addr & PAGE_MASK);

0 commit comments

Comments
 (0)