Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64/sparc64 Worakround for traps on invalid VAs:
details: https://anonhg.NetBSD.org/src/rev/ee1fb5b7cedd
branches: trunk
changeset: 959149:ee1fb5b7cedd
user: martin <martin%NetBSD.org@localhost>
date: Tue Feb 02 08:18:42 2021 +0000
description:
Worakround for traps on invalid VAs:
uvm_fault() can not (currently) deal properly with invalid VAs (inside the
VA hole), so do not pass faults for such addresses to it, but instead
either panic (if fault is in kernel) or send a SIGSEGV to userland.
diffstat:
sys/arch/sparc64/sparc64/trap.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diffs (44 lines):
diff -r c961c0912cca -r ee1fb5b7cedd sys/arch/sparc64/sparc64/trap.c
--- a/sys/arch/sparc64/sparc64/trap.c Tue Feb 02 00:27:38 2021 +0000
+++ b/sys/arch/sparc64/sparc64/trap.c Tue Feb 02 08:18:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.192 2019/11/21 19:24:01 ad Exp $ */
+/* $NetBSD: trap.c,v 1.193 2021/02/02 08:18:42 martin Exp $ */
/*
* Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.192 2019/11/21 19:24:01 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.193 2021/02/02 08:18:42 martin Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -1092,6 +1092,25 @@
sticks = p->p_sticks;
tstate = tf->tf_tstate;
+#ifdef _LP64
+ /* deal with invalid VAs early */
+ if (__predict_false(addr >= (1UL<<HOLESHIFT) && addr < (1UL<<63))) {
+
+ if (tstate & TSTATE_PRIV)
+ panic("fault type %u for invalid va %lx", type, addr);
+
+ KSI_INIT_TRAP(&ksi);
+ ksi.ksi_signo = SIGSEGV;
+ ksi.ksi_code = SEGV_ACCERR;
+ ksi.ksi_trap = type;
+ ksi.ksi_addr = (void *)pc;
+ trapsignal(l, &ksi);
+ userret(l, pc, sticks);
+ share_fpu(l, tf);
+ return;
+ }
+#endif
+
/* Find the faulting va to give to uvm_fault */
va = trunc_page(addr);
Home |
Main Index |
Thread Index |
Old Index