diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-07-22 16:12:28 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-07-22 16:12:28 +0000 |
commit | b09caee8df96468359e9b8e113bc846634b5c661 (patch) | |
tree | 7f6b20b327065ceeb31715441706ac7fe2460300 | |
parent | b2691bb69e10ee363d42a3fc165247f330d25a67 (diff) |
Tolerate imprecise fault address on sparc64 where the hardware doesn't provide
tho low order bits.
ok deraadt@, visa@
-rw-r--r-- | regress/sys/kern/siginfo-fault/siginfo-fault.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/regress/sys/kern/siginfo-fault/siginfo-fault.c b/regress/sys/kern/siginfo-fault/siginfo-fault.c index b5b7c4ce98b..e56d3155e0e 100644 --- a/regress/sys/kern/siginfo-fault/siginfo-fault.c +++ b/regress/sys/kern/siginfo-fault/siginfo-fault.c @@ -1,4 +1,4 @@ -/* $OpenBSD: siginfo-fault.c,v 1.5 2017/07/20 18:22:25 bluhm Exp $ */ +/* $OpenBSD: siginfo-fault.c,v 1.6 2017/07/22 16:12:27 kettenis Exp $ */ /* * Copyright (c) 2014 Google Inc. * @@ -24,10 +24,20 @@ #include <setjmp.h> #include <signal.h> #include <stdio.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +/* + * Some architectures deliver an imprecise fault address. + */ +#ifdef __sparc64__ +#define EXPADDR_MASK ~(3UL) +#else +#define EXPADDR_MASK ~(0UL) +#endif + #define CHECK_EQ(a, b) assert((a) == (b)) #define CHECK_NE(a, b) assert((a) != (b)) #define CHECK_LE(a, b) assert((a) <= (b)) @@ -76,6 +86,9 @@ checksig(const char *name, int expsigno, int expcode, volatile char *expaddr) { int fail = 0; char str1[NL_TEXTMAX], str2[NL_TEXTMAX]; + + expaddr = (char *)((uintptr_t)expaddr & EXPADDR_MASK); + if (expsigno != gotsigno) { strlcpy(str1, strsignal(expsigno), sizeof(str1)); strlcpy(str2, strsignal(gotsigno), sizeof(str2)); |