Skip to content

Commit 6f21d35

Browse files
Pull up following revision(s) (requested by skrll in ticket #33):
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 0147dba commit 6f21d35

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.123 2023/10/05 19:41:04 ad Exp $ */
1+
/* $NetBSD: trap.c,v 1.123.8.1 2025/09/23 12:48:16 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.123 2023/10/05 19:41:04 ad Exp $");
61+
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.123.8.1 2025/09/23 12:48:16 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[] = {
@@ -929,16 +932,17 @@ trap(int type, struct trapframe *frame)
929932
frame->tf_ipsw |= PSW_N;
930933
} else if ((opcode & PROBE_MASK) == PROBE) {
931934
u_int pl;
932-
if ((opcode & PROBE_IMMED) == 0) {
933-
pl = __SHIFTOUT(opcode, __PABITS(14, 15));
935+
if ((opcode & PROBE_IMMED) != 0) {
936+
pl = __SHIFTOUT(opcode, PROBE_PL) & PLMASK;
934937
} else {
935938
const u_int plreg =
936-
__SHIFTOUT(opcode, __PABITS(11, 15));
937-
pl = tf_getregno(frame, plreg);
939+
__SHIFTOUT(opcode, PROBE_PL);
940+
pl = tf_getregno(frame, plreg) & PLMASK;
938941
}
942+
939943
bool ok = true;
940944
if ((user && space == HPPA_SID_KERNEL) ||
941-
(frame->tf_iioq_head & 3) != pl ||
945+
(frame->tf_iioq_head & HPPA_PC_PRIV_MASK) != pl ||
942946
(user && va >= VM_MAXUSER_ADDRESS)) {
943947
ok = false;
944948
} else {
@@ -962,7 +966,6 @@ trap(int type, struct trapframe *frame)
962966
tf_setregno(frame, regno, 0);
963967
frame->tf_ipsw |= PSW_N;
964968
}
965-
} else {
966969
}
967970
break;
968971

0 commit comments

Comments
 (0)