Skip to content

Commit 3316628

Browse files
Pull up following revision(s) (requested by skrll in ticket #1967):
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 7c602ec commit 3316628

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.111.4.3 2022/06/10 17:34:22 martin Exp $ */
1+
/* $NetBSD: trap.c,v 1.111.4.4 2025/09/23 12:52:31 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.111.4.3 2022/06/10 17:34:22 martin Exp $");
61+
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.111.4.4 2025/09/23 12:52:31 martin Exp $");
6262

6363
/* #define INTRDEBUG */
6464
/* #define TRAPDEBUG */
@@ -484,31 +484,34 @@ do { \
484484
#define __PABITS(x, y) __BITS(31 - (x), 31 - (y))
485485
#define __PABIT(x) __BIT(31 - (x))
486486

487-
#define LPA_MASK \
488-
( __PABITS(0, 5) | \
489-
__PABITS(18, 25))
490-
#define LPA \
491-
(__SHIFTIN(1, __PABITS(0, 5)) | \
492-
__SHIFTIN(0x4d, __PABITS(18, 25)))
487+
#define LPA_MASK \
488+
( __PABITS(0, 5) | \
489+
__PABITS(18, 25))
490+
#define LPA \
491+
(__SHIFTIN(1, __PABITS(0, 5)) | \
492+
__SHIFTIN(0x4d, __PABITS(18, 25)))
493493

494494

495-
#define PROBE_ENCS (0x46 | 0xc6 | 0x47 | 0xc7)
496-
#define PROBE_PL __PABITS(14, 15)
497-
#define PROBE_IMMED __PABIT(18)
498-
#define PROBE_RW __PABIT(25)
495+
#define PROBE_ENCS (0x46 | 0xc6 | 0x47 | 0xc7)
496+
#define PROBE_PL __PABITS(11, 15)
497+
#define PROBE_IMMED __PABIT(18)
498+
#define PROBE_RW __PABIT(25)
499499

500-
#define PROBE_MASK \
501-
(( __PABITS(0, 5) | \
502-
__PABITS(18, 25) | \
503-
__PABIT(26)) ^ \
500+
#define PROBE_MASK \
501+
(( __PABITS(0, 5) | \
502+
__PABITS(18, 25) | \
503+
__PABIT(26)) ^ \
504504
(PROBE_IMMED | PROBE_RW))
505505

506-
#define PROBE \
507-
((__SHIFTIN(1, __PABITS(0, 5)) | \
508-
__SHIFTIN(PROBE_ENCS, __PABITS(18, 25)) | \
509-
__SHIFTIN(0, __PABIT(26))) ^ \
506+
#define PROBE \
507+
((__SHIFTIN(1, __PABITS(0, 5)) | \
508+
__SHIFTIN(PROBE_ENCS, __PABITS(18, 25)) | \
509+
__SHIFTIN(0, __PABIT(26))) ^ \
510510
(PROBE_IMMED | PROBE_RW))
511511

512+
#define PLMASK __BITS(1, 0)
513+
514+
512515
/* for hppa64 */
513516
CTASSERT(sizeof(register_t) == sizeof(u_int));
514517
size_t hppa_regmap[] = {
@@ -935,16 +938,17 @@ trap(int type, struct trapframe *frame)
935938
frame->tf_ipsw |= PSW_N;
936939
} else if ((opcode & PROBE_MASK) == PROBE) {
937940
u_int pl;
938-
if ((opcode & PROBE_IMMED) == 0) {
939-
pl = __SHIFTOUT(opcode, __PABITS(14, 15));
941+
if ((opcode & PROBE_IMMED) != 0) {
942+
pl = __SHIFTOUT(opcode, PROBE_PL) & PLMASK;
940943
} else {
941944
const u_int plreg =
942-
__SHIFTOUT(opcode, __PABITS(11, 15));
943-
pl = tf_getregno(frame, plreg);
945+
__SHIFTOUT(opcode, PROBE_PL);
946+
pl = tf_getregno(frame, plreg) & PLMASK;
944947
}
948+
945949
bool ok = true;
946950
if ((user && space == HPPA_SID_KERNEL) ||
947-
(frame->tf_iioq_head & 3) != pl ||
951+
(frame->tf_iioq_head & HPPA_PC_PRIV_MASK) != pl ||
948952
(user && va >= VM_MAXUSER_ADDRESS)) {
949953
ok = false;
950954
} else {
@@ -968,7 +972,6 @@ trap(int type, struct trapframe *frame)
968972
tf_setregno(frame, regno, 0);
969973
frame->tf_ipsw |= PSW_N;
970974
}
971-
} else {
972975
}
973976
break;
974977

0 commit comments

Comments
 (0)