Module Name:    src
Committed By:   rin
Date:           Thu Oct 15 22:30:34 UTC 2020

Modified Files:
        src/sys/arch/aarch64/aarch64: fault.c

Log Message:
For cpu_jump_onfault() in data_abort_handler(), stop returning
hard-coded EFAULT and use return value from uvm_fault() instead.

There are some paths that do not call uvm_fault():

(1) For fatalabort case, use EFAULT as before.
(2) When va range is invalid, use EFAULT instead of EINVAL.

These change fixes bytes_transfer_eof_* tests in
sys/lib/libc/sys/t_ptrace_wait*.

Note that without (2) above, some tests like
sys/lib/libc/sys/t_wait:write_error become newly failing.

I've confirmed that there's no new regression in full ATF run.

OK ryo


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/aarch64/fault.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/fault.c
diff -u src/sys/arch/aarch64/aarch64/fault.c:1.19 src/sys/arch/aarch64/aarch64/fault.c:1.20
--- src/sys/arch/aarch64/aarch64/fault.c:1.19	Sun Aug  9 07:26:20 2020
+++ src/sys/arch/aarch64/aarch64/fault.c	Thu Oct 15 22:30:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: fault.c,v 1.19 2020/08/09 07:26:20 skrll Exp $	*/
+/*	$NetBSD: fault.c,v 1.20 2020/10/15 22:30:34 rin Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.19 2020/08/09 07:26:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.20 2020/10/15 22:30:34 rin Exp $");
 
 #include "opt_compat_netbsd32.h"
 #include "opt_ddb.h"
@@ -134,7 +134,7 @@ data_abort_handler(struct trapframe *tf,
 	vaddr_t va;
 	uint32_t esr, fsc, rw;
 	vm_prot_t ftype;
-	int error = 0, len;
+	int error = EFAULT, len;
 	const bool user = IS_SPSR_USER(tf->tf_spsr) ? true : false;
 	bool is_pan_trap = false;
 
@@ -169,10 +169,8 @@ data_abort_handler(struct trapframe *tf,
 		map = &p->p_vmspace->vm_map;
 		UVMHIST_LOG(pmaphist, "use user vm_map %p (kernel_map=%p)",
 		   map, kernel_map, 0, 0);
-	} else {
-		error = EINVAL;
+	} else
 		goto do_fault;
-	}
 
 	if ((eclass == ESR_EC_INSN_ABT_EL0) || (eclass == ESR_EC_INSN_ABT_EL1))
 		ftype = VM_PROT_EXECUTE;
@@ -223,7 +221,7 @@ data_abort_handler(struct trapframe *tf,
 	if (curcpu()->ci_intr_depth == 0) {
 		fb = cpu_disable_onfault();
 		if (fb != NULL) {
-			cpu_jump_onfault(tf, fb, EFAULT);
+			cpu_jump_onfault(tf, fb, error);
 			return;
 		}
 	}

Reply via email to