summaryrefslogtreecommitdiff
path: root/tests/kernel
diff options
context:
space:
mode:
authorkamil <kamil@NetBSD.org>2018-05-30 17:31:34 +0000
committerkamil <kamil@NetBSD.org>2018-05-30 17:31:34 +0000
commitca6ad33a9855119a058a070fb46daeaeb6f91155 (patch)
treec1de9e147fe68146eb298d269c6c43ac95e73d75 /tests/kernel
parentee9284b3760b1356dfe874b7ea49091ee6c7edc0 (diff)
Make the trigger_bus() test compatible with more CPUs (at least ALPHA)
If we write a byte character into a pointer, a compiler can emit a read-modify-write operation, especially when a CPU cannot access directly a character wide address. In this scenario calling mmap(2) with PROT_WRITE, without PROT_READ will emit unexpected trap. There are two possible workarounds for this issue: - write register wide memory without rmw sequence, - mark the region with additional protection PROT_READ Both work for NetBSD/alpha. Go for the latter as perhaps more safe for dump compilers emitting rmw sequences. Investigated by <martin>
Diffstat (limited to 'tests/kernel')
-rw-r--r--tests/kernel/h_segv.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/kernel/h_segv.c b/tests/kernel/h_segv.c
index b81491949c6..44a7efec637 100644
--- a/tests/kernel/h_segv.c
+++ b/tests/kernel/h_segv.c
@@ -1,4 +1,4 @@
-/* $NetBSD: h_segv.c,v 1.5 2018/05/27 17:04:45 kamil Exp $ */
+/* $NetBSD: h_segv.c,v 1.6 2018/05/30 17:31:34 kamil Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: h_segv.c,v 1.5 2018/05/27 17:04:45 kamil Exp $");
+__RCSID("$NetBSD: h_segv.c,v 1.6 2018/05/30 17:31:34 kamil Exp $");
#include <sys/types.h>
#include <sys/mman.h>
@@ -120,7 +120,7 @@ trigger_bus(void)
err(EXIT_FAILURE, "tmpfile");
/* Map an empty file with mmap(2) to a pointer. */
- p = mmap(0, 1, PROT_WRITE, MAP_PRIVATE, fileno(fp), 0);
+ p = mmap(0, 1, PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(fp), 0);
if (p == MAP_FAILED)
err(EXIT_FAILURE, "mmap");