Skip to content

Commit 2714881

Browse files
Pull up following revision(s) (requested by skrll in ticket #1161):
sys/arch/hppa/hppa/trap.c: revision 1.124 sys/arch/hppa/hppa/trap.c: revision 1.125 sys/arch/hppa/hppa/trap.c: revision 1.126 sys/arch/hppa/hppa/trap.c: revision 1.127 sys/arch/hppa/hppa/trap.c: revision 1.128 Fix the inverted logic around probe access vs probe access immediate instructions. This affected the probe <__canonicalize_funcptr_for_compare+76>: probei,r (r20),3,r20 and manifested as tests/lib/libc/tls/t_tls_dynamic failures Remove empty else clause. Code style around probe instruction priviledge level. Actually use the PROBE_PL macro with a bitfield that covers the instruction's 'i' immediate or 'r' fields and mask the bottom two bits as the {read,write}_access_allowed architecture functions would. Remove a magic number with s/3/HPPA_PC_PRIV_MASK/ Whitespace
1 parent a4f469f commit 2714881

1 file changed

Lines changed: 29 additions & 26 deletions

File tree

sys/arch/hppa/hppa/trap.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: trap.c,v 1.121 2022/09/02 23:48:10 thorpej Exp $ */
1+
/* $NetBSD: trap.c,v 1.121.4.1 2025/09/23 12:50:45 martin Exp $ */
22

33
/*-
44
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
5858
*/
5959

6060
#include <sys/cdefs.h>
61-
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.121 2022/09/02 23:48:10 thorpej Exp $");
61+
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.121.4.1 2025/09/23 12:50:45 martin Exp $");
6262

6363
/* #define INTRDEBUG */
6464
/* #define TRAPDEBUG */
@@ -480,31 +480,34 @@ do { \
480480
#define __PABITS(x, y) __BITS(31 - (x), 31 - (y))
481481
#define __PABIT(x) __BIT(31 - (x))
482482

483-
#define LPA_MASK \
484-
( __PABITS(0, 5) | \
485-
__PABITS(18, 25))
486-
#define LPA \
487-
(__SHIFTIN(1, __PABITS(0, 5)) | \
488-
__SHIFTIN(0x4d, __PABITS(18, 25)))
483+
#define LPA_MASK \
484+
( __PABITS(0, 5) | \
485+
__PABITS(18, 25))
486+
#define LPA \
487+
(__SHIFTIN(1, __PABITS(0, 5)) | \
488+
__SHIFTIN(0x4d, __PABITS(18, 25)))
489489

490490

491-
#define PROBE_ENCS (0x46 | 0xc6 | 0x47 | 0xc7)
492-
#define PROBE_PL __PABITS(14, 15)
493-
#define PROBE_IMMED __PABIT(18)
494-
#define PROBE_RW __PABIT(25)
491+
#define PROBE_ENCS (0x46 | 0xc6 | 0x47 | 0xc7)
492+
#define PROBE_PL __PABITS(11, 15)
493+
#define PROBE_IMMED __PABIT(18)
494+
#define PROBE_RW __PABIT(25)
495495

496-
#define PROBE_MASK \
497-
(( __PABITS(0, 5) | \
498-
__PABITS(18, 25) | \
499-
__PABIT(26)) ^ \
496+
#define PROBE_MASK \
497+
(( __PABITS(0, 5) | \
498+
__PABITS(18, 25) | \
499+
__PABIT(26)) ^ \
500500
(PROBE_IMMED | PROBE_RW))
501501

502-
#define PROBE \
503-
((__SHIFTIN(1, __PABITS(0, 5)) | \
504-
__SHIFTIN(PROBE_ENCS, __PABITS(18, 25)) | \
505-
__SHIFTIN(0, __PABIT(26))) ^ \
502+
#define PROBE \
503+
((__SHIFTIN(1, __PABITS(0, 5)) | \
504+
__SHIFTIN(PROBE_ENCS, __PABITS(18, 25)) | \
505+
__SHIFTIN(0, __PABIT(26))) ^ \
506506
(PROBE_IMMED | PROBE_RW))
507507

508+
#define PLMASK __BITS(1, 0)
509+
510+
508511
/* for hppa64 */
509512
CTASSERT(sizeof(register_t) == sizeof(u_int));
510513
size_t hppa_regmap[] = {
@@ -931,16 +934,17 @@ trap(int type, struct trapframe *frame)
931934
frame->tf_ipsw |= PSW_N;
932935
} else if ((opcode & PROBE_MASK) == PROBE) {
933936
u_int pl;
934-
if ((opcode & PROBE_IMMED) == 0) {
935-
pl = __SHIFTOUT(opcode, __PABITS(14, 15));
937+
if ((opcode & PROBE_IMMED) != 0) {
938+
pl = __SHIFTOUT(opcode, PROBE_PL) & PLMASK;
936939
} else {
937940
const u_int plreg =
938-
__SHIFTOUT(opcode, __PABITS(11, 15));
939-
pl = tf_getregno(frame, plreg);
941+
__SHIFTOUT(opcode, PROBE_PL);
942+
pl = tf_getregno(frame, plreg) & PLMASK;
940943
}
944+
941945
bool ok = true;
942946
if ((user && space == HPPA_SID_KERNEL) ||
943-
(frame->tf_iioq_head & 3) != pl ||
947+
(frame->tf_iioq_head & HPPA_PC_PRIV_MASK) != pl ||
944948
(user && va >= VM_MAXUSER_ADDRESS)) {
945949
ok = false;
946950
} else {
@@ -964,7 +968,6 @@ trap(int type, struct trapframe *frame)
964968
tf_setregno(frame, regno, 0);
965969
frame->tf_ipsw |= PSW_N;
966970
}
967-
} else {
968971
}
969972
break;
970973

0 commit comments

Comments
 (0)