CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Sep 18 21:34:57 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
Fix trailing backslashes in a macro that got misaligned.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/cpu_in_cksum.S
diff -u src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.10 src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.11
--- src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.10	Sat Sep 18 19:21:39 2021
+++ src/sys/arch/sh3/sh3/cpu_in_cksum.S	Sat Sep 18 21:34:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_in_cksum.S,v 1.10 2021/09/18 19:21:39 uwe Exp $	*/
+/*	$NetBSD: cpu_in_cksum.S,v 1.11 2021/09/18 21:34:56 uwe Exp $	*/
 
 /*-
  * Copyright (c) 2000 SHIMIZU Ryo 
@@ -34,7 +34,7 @@
 #include 
 #include "assym.h"
 
-__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.10 2021/09/18 19:21:39 uwe Exp $")
+__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.11 2021/09/18 21:34:56 uwe Exp $")
 
 
 #define	reg_byte_swapped	r1
@@ -58,9 +58,9 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum
 
 #if _BYTE_ORDER == BIG_ENDIAN
 #define	ADDB	\
-	mov.b	@reg_w+, r0		; \
-	ROL; \
-	extu.b	r0, r0	; \
+	mov.b	@reg_w+, r0	; \
+	ROL			; \
+	extu.b	r0, r0		; \
 	add	r0, reg_sum	; \
 	not	reg_byte_swapped, reg_byte_swapped
 #else



CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Sep 18 21:34:57 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
Fix trailing backslashes in a macro that got misaligned.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Sep 18 19:21:39 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
Fix one comment edit missed in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/cpu_in_cksum.S
diff -u src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.9 src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.10
--- src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.9	Sat Sep 18 15:09:05 2021
+++ src/sys/arch/sh3/sh3/cpu_in_cksum.S	Sat Sep 18 19:21:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_in_cksum.S,v 1.9 2021/09/18 15:09:05 uwe Exp $	*/
+/*	$NetBSD: cpu_in_cksum.S,v 1.10 2021/09/18 19:21:39 uwe Exp $	*/
 
 /*-
  * Copyright (c) 2000 SHIMIZU Ryo 
@@ -34,7 +34,7 @@
 #include 
 #include "assym.h"
 
-__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.9 2021/09/18 15:09:05 uwe Exp $")
+__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.10 2021/09/18 19:21:39 uwe Exp $")
 
 
 #define	reg_byte_swapped	r1
@@ -213,7 +213,7 @@ mbuf_loop_done:
 
 	tst	reg_byte_swapped, reg_byte_swapped
 	bt/s	1f
-	REDUCE		/* 1st instruction break only r0(r0) */
+	REDUCE		/* 1st instruction break only r0 */
 	ROL
 1:
 



CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Sep 18 19:21:39 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
Fix one comment edit missed in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Sep 18 15:09:05 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
Do not obfuscate r0 as "reg_tmp0".

Using r0 as a temp is a common choice.  Some instructions _must_ use
r0 as the destination (like mova or instructions with immediates).
ABI uses r0 as the return register.  So a helpful name is not that
helpful for the former use case (temp) and is confusing for the latter
two (ISA or ABI constraints).  Same object code is generated.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/cpu_in_cksum.S
diff -u src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.8 src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.9
--- src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.8	Sat Sep 18 14:57:10 2021
+++ src/sys/arch/sh3/sh3/cpu_in_cksum.S	Sat Sep 18 15:09:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_in_cksum.S,v 1.8 2021/09/18 14:57:10 uwe Exp $	*/
+/*	$NetBSD: cpu_in_cksum.S,v 1.9 2021/09/18 15:09:05 uwe Exp $	*/
 
 /*-
  * Copyright (c) 2000 SHIMIZU Ryo 
@@ -34,10 +34,9 @@
 #include 
 #include "assym.h"
 
-__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.8 2021/09/18 14:57:10 uwe Exp $")
+__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.9 2021/09/18 15:09:05 uwe Exp $")
 
 
-#define	reg_tmp0		r0
 #define	reg_byte_swapped	r1
 #define	reg_mlen		r2
 #define	reg_tmp3		r3
@@ -49,39 +48,39 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum
 
 
 #define	REDUCE	\
-	swap.w	reg_sum, reg_tmp0	; \
+	swap.w	reg_sum, r0		; \
 	extu.w	reg_sum, reg_sum	; \
-	extu.w	reg_tmp0, reg_tmp0	; \
-	add	reg_tmp0, reg_sum
+	extu.w	r0, r0			; \
+	add	r0, reg_sum
 
 #define	ROL	\
 	shll8	reg_sum
 
 #if _BYTE_ORDER == BIG_ENDIAN
 #define	ADDB	\
-	mov.b	@reg_w+, reg_tmp0	; \
+	mov.b	@reg_w+, r0		; \
 	ROL; \
-	extu.b	reg_tmp0, reg_tmp0	; \
-	add	reg_tmp0, reg_sum	; \
+	extu.b	r0, r0	; \
+	add	r0, reg_sum	; \
 	not	reg_byte_swapped, reg_byte_swapped
 #else
 #define	ADDB	\
-	mov.b	@reg_w+, reg_tmp0	; \
-	extu.b	reg_tmp0, reg_tmp0	; \
-	add	reg_tmp0, reg_sum	; \
-	ROL; \
+	mov.b	@reg_w+, r0	; \
+	extu.b	r0, r0		; \
+	add	r0, reg_sum	; \
+	ROL			; \
 	not	reg_byte_swapped, reg_byte_swapped
 #endif
 
 
 #define	ADDS	\
-	mov.w	@reg_w+, reg_tmp0	; \
-	extu.w	reg_tmp0, reg_tmp0	; \
-	add	reg_tmp0, reg_sum
+	mov.w	@reg_w+, r0	; \
+	extu.w	r0, r0		; \
+	add	r0, reg_sum
 
 #define	ADDCL	\
-	mov.l	@reg_w+, reg_tmp0	; \
-	addc	reg_tmp0, reg_sum
+	mov.l	@reg_w+, r0	; \
+	addc	r0, reg_sum
 
 #define	FORWARD1	\
 	add	#-1, reg_mlen
@@ -149,38 +148,38 @@ mbuf_loop:
 	sub	reg_mlen, reg_len
 
 
-	mov	reg_w, reg_tmp0
-	tst	#1, reg_tmp0
+	mov	reg_w, r0
+	tst	#1, r0
 	bt/s	1f
-	REDUCE		/* 1st instruction break only reg_tmp0(r0) */
+	REDUCE		/* 1st instruction break only r0 */
 	ADDB
 	FORWARD1
 1:
 
 
-	mov	#1, reg_tmp0
-	cmp/gt	reg_tmp0, reg_mlen
+	mov	#1, r0
+	cmp/gt	r0, reg_mlen
 	bf/s	1f
-	mov	reg_w, reg_tmp0
-	tst	#2, reg_tmp0
+	mov	reg_w, r0
+	tst	#2, r0
 	bt/s	1f
-	REDUCE		/* 1st instruction break only reg_tmp0(r0) */
+	REDUCE		/* 1st instruction break only r0 */
 	ADDS
 	FORWARD2
 1:
 
 
 
-	mov	#127, reg_tmp0
-	cmp/hi	reg_tmp0, reg_mlen
+	mov	#127, r0
+	cmp/hi	r0, reg_mlen
 	bf	1f
 
 do_cksum128:
 	bsr	cksum128
 	 nop
 
-	mov	#127, reg_tmp0
-	cmp/hi	reg_tmp0, reg_mlen
+	mov	#127, r0
+	cmp/hi	r0, reg_mlen
 	bt	do_cksum128
 1:
 
@@ -190,8 +189,8 @@ do_cksum128:
 
 	REDUCE
 
-	mov	#1, reg_tmp0
-	cmp/gt	reg_tmp0, reg_mlen
+	mov	#1, r0
+	cmp/gt	r0, reg_mlen
 	bf	1f
 	ADDS
 	FORWARD2
@@ -214,7 +213,7 @@ mbuf_loop_done:
 
 	tst	reg_byte_swapped, reg_byte_swapped
 	bt/s	1f
-	REDUCE		/* 1st instruction break only reg_tmp0(r0) */
+	REDUCE		/* 1st instruction break only r0(r0) */
 	ROL
 1:
 
@@ -230,13 +229,13 @@ in_cksum_return:
 
 
 out_of_mbufs:
-	mova	.L_message_out_of_data, reg_tmp0
+	mova	.L_message_out_of_data, r0
 	mov.l	.L_printf, reg_tmp3
 
 	mov.l	reg_sum, @-sp	/* save: call clobbered register */
 
 1:	CALL	reg_tmp3
-	 mov	reg_tmp0, r4
+	 mov	r0, r4
 
 	bra	in_cksum_return
 	 mov.l	@sp+, reg_sum	/* restore */
@@ -256,14 +255,14 @@ out_of_mbufs:
 
 	.align	2
 cksum128mod:
-	mov	reg_mlen, reg_tmp0
-	and	#124, reg_tmp0
-	sub	reg_tmp0, reg_mlen
-	mov	reg_tmp0, reg_tmp3
-
-	mova	cksum128_tail, reg_tmp0
-	sub	reg_tmp3, reg_tmp0
-	jmp	@reg_tmp0
+	mov	reg_mlen, r0
+	and	#124, r0
+	sub	r0, reg_mlen
+	mov	r0, reg_tmp3
+
+	mova	cksum128_tail, r0
+	sub	reg_tmp3, r0
+	jmp	@r0
 	 clrt
 
 	.align	2
@@ -305,6 +304,6 @@ cksum128_unroll:
 	ADDCL
 	ADDCL
 cksum128_tail:
-	mov	#0, reg_tmp0
+	mov	#0, r0
 	rts
-	 addc	reg_tmp0, reg_sum
+	 addc	r0, reg_sum



CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Sep 18 15:09:05 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
Do not obfuscate r0 as "reg_tmp0".

Using r0 as a temp is a common choice.  Some instructions _must_ use
r0 as the destination (like mova or instructions with immediates).
ABI uses r0 as the return register.  So a helpful name is not that
helpful for the former use case (temp) and is confusing for the latter
two (ISA or ABI constraints).  Same object code is generated.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Sep 18 14:57:10 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
Space after comma in operands.  Same object code is generated.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/cpu_in_cksum.S
diff -u src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.7 src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.8
--- src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.7	Sat Sep 18 06:32:41 2021
+++ src/sys/arch/sh3/sh3/cpu_in_cksum.S	Sat Sep 18 14:57:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_in_cksum.S,v 1.7 2021/09/18 06:32:41 rin Exp $	*/
+/*	$NetBSD: cpu_in_cksum.S,v 1.8 2021/09/18 14:57:10 uwe Exp $	*/
 
 /*-
  * Copyright (c) 2000 SHIMIZU Ryo 
@@ -34,7 +34,7 @@
 #include 
 #include "assym.h"
 
-__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.7 2021/09/18 06:32:41 rin Exp $")
+__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.8 2021/09/18 14:57:10 uwe Exp $")
 
 
 #define	reg_tmp0		r0
@@ -49,45 +49,45 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum
 
 
 #define	REDUCE	\
-	swap.w	reg_sum,reg_tmp0	; \
-	extu.w	reg_sum,reg_sum		; \
-	extu.w	reg_tmp0,reg_tmp0	; \
-	add	reg_tmp0,reg_sum
+	swap.w	reg_sum, reg_tmp0	; \
+	extu.w	reg_sum, reg_sum	; \
+	extu.w	reg_tmp0, reg_tmp0	; \
+	add	reg_tmp0, reg_sum
 
 #define	ROL	\
 	shll8	reg_sum
 
 #if _BYTE_ORDER == BIG_ENDIAN
 #define	ADDB	\
-	mov.b	@reg_w+,reg_tmp0	; \
+	mov.b	@reg_w+, reg_tmp0	; \
 	ROL; \
-	extu.b	reg_tmp0,reg_tmp0	; \
-	add	reg_tmp0,reg_sum	; \
-	not	reg_byte_swapped,reg_byte_swapped
+	extu.b	reg_tmp0, reg_tmp0	; \
+	add	reg_tmp0, reg_sum	; \
+	not	reg_byte_swapped, reg_byte_swapped
 #else
 #define	ADDB	\
-	mov.b	@reg_w+,reg_tmp0	; \
-	extu.b	reg_tmp0,reg_tmp0	; \
-	add	reg_tmp0,reg_sum	; \
+	mov.b	@reg_w+, reg_tmp0	; \
+	extu.b	reg_tmp0, reg_tmp0	; \
+	add	reg_tmp0, reg_sum	; \
 	ROL; \
-	not	reg_byte_swapped,reg_byte_swapped
+	not	reg_byte_swapped, reg_byte_swapped
 #endif
 
 
 #define	ADDS	\
-	mov.w	@reg_w+,reg_tmp0	; \
-	extu.w	reg_tmp0,reg_tmp0	; \
-	add	reg_tmp0,reg_sum
+	mov.w	@reg_w+, reg_tmp0	; \
+	extu.w	reg_tmp0, reg_tmp0	; \
+	add	reg_tmp0, reg_sum
 
 #define	ADDCL	\
-	mov.l	@reg_w+,reg_tmp0	; \
-	addc	reg_tmp0,reg_sum
+	mov.l	@reg_w+, reg_tmp0	; \
+	addc	reg_tmp0, reg_sum
 
 #define	FORWARD1	\
-	add	#-1,reg_mlen
+	add	#-1, reg_mlen
 
 #define	FORWARD2	\
-	add	#-2,reg_mlen
+	add	#-2, reg_mlen
 
 
 /*
@@ -97,7 +97,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum
  * LINTSTUB: Func: int cpu_in_cksum(struct mbuf *m, int len, int off, uint32_t initial_sum);
  */
 ENTRY(cpu_in_cksum)
-	sts.l	pr,@-sp
+	sts.l	pr, @-sp
 	PIC_PROLOGUE(.L_got)
 
 	tst	reg_len, reg_len
@@ -128,13 +128,13 @@ ENTRY(cpu_in_cksum)
 
 
 mbuf_loop:
-	tst	reg_m,reg_m
+	tst	reg_m, reg_m
 	bt	out_of_mbufs
 
-	mov.l	@(M_LEN,reg_m),reg_mlen
-	tst	reg_mlen,reg_mlen
+	mov.l	@(M_LEN, reg_m), reg_mlen
+	tst	reg_mlen, reg_mlen
 	bt/s	mbuf_loop_continue
-	mov.l	@(M_DATA,reg_m),reg_w
+	mov.l	@(M_DATA, reg_m), reg_w
 
 
 	!! Entry point for mbuf loop.  We jump here after we have
@@ -142,15 +142,15 @@ mbuf_loop:
 	!! offset.  reg_mlen and reg_w were adjusted to point at the
 	!! first interesting byte of data.
 .L_mbuf_loop_enter:
-	cmp/ge	reg_mlen,reg_len
+	cmp/ge	reg_mlen, reg_len
 	bt	1f
-	mov	reg_len,reg_mlen
+	mov	reg_len, reg_mlen
 1:
-	sub	reg_mlen,reg_len
+	sub	reg_mlen, reg_len
 
 
-	mov	reg_w,reg_tmp0
-	tst	#1,reg_tmp0
+	mov	reg_w, reg_tmp0
+	tst	#1, reg_tmp0
 	bt/s	1f
 	REDUCE		/* 1st instruction break only reg_tmp0(r0) */
 	ADDB
@@ -158,11 +158,11 @@ mbuf_loop:
 1:
 
 
-	mov	#1,reg_tmp0
-	cmp/gt	reg_tmp0,reg_mlen
+	mov	#1, reg_tmp0
+	cmp/gt	reg_tmp0, reg_mlen
 	bf/s	1f
-	mov	reg_w,reg_tmp0
-	tst	#2,reg_tmp0
+	mov	reg_w, reg_tmp0
+	tst	#2, reg_tmp0
 	bt/s	1f
 	REDUCE		/* 1st instruction break only reg_tmp0(r0) */
 	ADDS
@@ -171,16 +171,16 @@ mbuf_loop:
 
 
 
-	mov	#127,reg_tmp0
-	cmp/hi	reg_tmp0,reg_mlen
+	mov	#127, reg_tmp0
+	cmp/hi	reg_tmp0, reg_mlen
 	bf	1f
 
 do_cksum128:
 	bsr	cksum128
 	 nop
 
-	mov	#127,reg_tmp0
-	cmp/hi	reg_tmp0,reg_mlen
+	mov	#127, reg_tmp0
+	cmp/hi	reg_tmp0, reg_mlen
 	bt	do_cksum128
 1:
 
@@ -190,29 +190,29 @@ do_cksum128:
 
 	REDUCE
 
-	mov	#1,reg_tmp0
-	cmp/gt	reg_tmp0,reg_mlen
+	mov	#1, reg_tmp0
+	cmp/gt	reg_tmp0, reg_mlen
 	bf	1f
 	ADDS
 	FORWARD2
 1:
 
-	mov	reg_mlen,r0
-	tst	#1,r0
+	mov	reg_mlen, r0
+	tst	#1, r0
 	bt	1f
 	ADDB
 1:
 
 
 mbuf_loop_continue:
-	mov.l	@(M_NEXT,reg_m),reg_m
+	mov.l	@(M_NEXT, reg_m), reg_m
 
-	tst	reg_len,reg_len
+	tst	reg_len, reg_len
 	bf/s	mbuf_loop
 mbuf_loop_done:
 
 
-	tst	reg_byte_swapped,reg_byte_swapped
+	tst	reg_byte_swapped, reg_byte_swapped
 	bt/s	1f
 	REDUCE		/* 1st instruction break only reg_tmp0(r0) */
 	ROL
@@ -222,24 +222,24 @@ mbuf_loop_done:
 	REDUCE
 
 in_cksum_return:
-	not	reg_sum,r0
+	not	reg_sum, r0
 	PIC_EPILOGUE
-	lds.l	@sp+,pr
+	lds.l	

CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Sep 18 14:57:10 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
Space after comma in operands.  Same object code is generated.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Sep 18 06:32:41 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
Support __PIC__ build, in order to avoid text relocations for
/usr/tests/net/in_cksum/in_cksum.

Now, all the tests for in_cksum successfully pass for sh[34].

No binary changes for kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/cpu_in_cksum.S
diff -u src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.6 src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.7
--- src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.6	Sat Sep 18 06:31:46 2021
+++ src/sys/arch/sh3/sh3/cpu_in_cksum.S	Sat Sep 18 06:32:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_in_cksum.S,v 1.6 2021/09/18 06:31:46 rin Exp $	*/
+/*	$NetBSD: cpu_in_cksum.S,v 1.7 2021/09/18 06:32:41 rin Exp $	*/
 
 /*-
  * Copyright (c) 2000 SHIMIZU Ryo 
@@ -34,7 +34,7 @@
 #include 
 #include "assym.h"
 
-__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.6 2021/09/18 06:31:46 rin Exp $")
+__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.7 2021/09/18 06:32:41 rin Exp $")
 
 
 #define	reg_tmp0		r0
@@ -98,6 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum
  */
 ENTRY(cpu_in_cksum)
 	sts.l	pr,@-sp
+	PIC_PROLOGUE(.L_got)
 
 	tst	reg_len, reg_len
 	bt/s	mbuf_loop_done
@@ -222,6 +223,7 @@ mbuf_loop_done:
 
 in_cksum_return:
 	not	reg_sum,r0
+	PIC_EPILOGUE
 	lds.l	@sp+,pr
 	rts
 	 extu.w	r0,r0
@@ -233,15 +235,17 @@ out_of_mbufs:
 
 	mov.l	reg_sum,@-sp	/* save: call clobbered register */
 
-	jsr	@reg_tmp3
+1:	CALL	reg_tmp3
 	 mov	reg_tmp0,r4
 
 	bra	in_cksum_return
 	 mov.l	@sp+,reg_sum	/* restore */
 
 	.align 2
+.L_got:
+	PIC_GOT_DATUM
 .L_printf:
-	.long	_C_LABEL(printf)
+	CALL_DATUM(_C_LABEL(printf), 1b)
 
 	.align 2	/* mova target */
 .L_message_out_of_data:



CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Sep 18 06:32:41 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
Support __PIC__ build, in order to avoid text relocations for
/usr/tests/net/in_cksum/in_cksum.

Now, all the tests for in_cksum successfully pass for sh[34].

No binary changes for kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Sep 18 06:31:46 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
cksum128mod: Prepare jump address by 'mova', instead of 'mov.l'.

Since both this 'mova' and 'and #imm' above must be used against r0,
we need extra 'mov r0, r3'. However, this should still be good both for
sh3 and sh4:

- For sh3, 'mov.l' at odd half-word address is removed; pipeline hazard
  due to instruction fetch is resolved.

- For sh4, data cache line is no longer assigned for this 'mov.l'.

Also:

- Upcoming __PIC__ support (in order to avoid text relocations when built
  in tests/net/in_cksum) becomes simpler; no need CALL_DATUM_LOCAL() for
  cksum128_tail.

- Shave off 4 bytes from text.

No regression is observed for sh3 (hpcsh) and sh4 (landisk).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-18 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Sep 18 06:31:46 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: cpu_in_cksum.S

Log Message:
cksum128mod: Prepare jump address by 'mova', instead of 'mov.l'.

Since both this 'mova' and 'and #imm' above must be used against r0,
we need extra 'mov r0, r3'. However, this should still be good both for
sh3 and sh4:

- For sh3, 'mov.l' at odd half-word address is removed; pipeline hazard
  due to instruction fetch is resolved.

- For sh4, data cache line is no longer assigned for this 'mov.l'.

Also:

- Upcoming __PIC__ support (in order to avoid text relocations when built
  in tests/net/in_cksum) becomes simpler; no need CALL_DATUM_LOCAL() for
  cksum128_tail.

- Shave off 4 bytes from text.

No regression is observed for sh3 (hpcsh) and sh4 (landisk).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sh3/sh3/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/cpu_in_cksum.S
diff -u src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.5 src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.6
--- src/sys/arch/sh3/sh3/cpu_in_cksum.S:1.5	Tue Jan  6 17:43:16 2015
+++ src/sys/arch/sh3/sh3/cpu_in_cksum.S	Sat Sep 18 06:31:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_in_cksum.S,v 1.5 2015/01/06 17:43:16 christos Exp $	*/
+/*	$NetBSD: cpu_in_cksum.S,v 1.6 2021/09/18 06:31:46 rin Exp $	*/
 
 /*-
  * Copyright (c) 2000 SHIMIZU Ryo 
@@ -34,7 +34,7 @@
 #include 
 #include "assym.h"
 
-__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.5 2015/01/06 17:43:16 christos Exp $")
+__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.6 2021/09/18 06:31:46 rin Exp $")
 
 
 #define	reg_tmp0		r0
@@ -255,18 +255,14 @@ cksum128mod:
 	mov	reg_mlen,reg_tmp0
 	and	#124,reg_tmp0
 	sub	reg_tmp0,reg_mlen
+	mov	reg_tmp0,reg_tmp3
 
-	mov.l	.L_cksum128_tail_p,reg_tmp3
-	sub	reg_tmp0,reg_tmp3
-	jmp	@reg_tmp3
+	mova	cksum128_tail,reg_tmp0
+	sub	reg_tmp3,reg_tmp0
+	jmp	@reg_tmp0
 	 clrt
 
 	.align	2
-.L_cksum128_tail_p:
-	.long	cksum128_tail
-
-
-	.align	2
 cksum128:
 	add	#-128,reg_mlen
 	clrt



CVS commit: src/sys/arch/sh3/sh3

2021-09-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep 15 11:03:25 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: exception.c

Log Message:
For kernel mode address error, do not overwrite tf->tf_spc and tf->tf_r0
*before* checking pcb->pbc_onfault != NULL.

Should fix part of

PR port-sh3/56382
PR port-sh3/56401

i.e., DDB will no longer wrongly indicate NULL as fault PC for kernel mode
address error (and 0xe == EFAULT as r0).

Yes, we have another bugs that cause panics described in the two PRs, but
now we can examine them more easily :).


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/sh3/sh3/exception.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep 15 11:03:25 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: exception.c

Log Message:
For kernel mode address error, do not overwrite tf->tf_spc and tf->tf_r0
*before* checking pcb->pbc_onfault != NULL.

Should fix part of

PR port-sh3/56382
PR port-sh3/56401

i.e., DDB will no longer wrongly indicate NULL as fault PC for kernel mode
address error (and 0xe == EFAULT as r0).

Yes, we have another bugs that cause panics described in the two PRs, but
now we can examine them more easily :).


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/sh3/sh3/exception.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/exception.c
diff -u src/sys/arch/sh3/sh3/exception.c:1.73 src/sys/arch/sh3/sh3/exception.c:1.74
--- src/sys/arch/sh3/sh3/exception.c:1.73	Tue Dec  3 12:42:21 2019
+++ src/sys/arch/sh3/sh3/exception.c	Wed Sep 15 11:03:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: exception.c,v 1.73 2019/12/03 12:42:21 ad Exp $	*/
+/*	$NetBSD: exception.c,v 1.74 2021/09/15 11:03:24 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2019 The NetBSD Foundation, Inc. All rights reserved.
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.73 2019/12/03 12:42:21 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.74 2021/09/15 11:03:24 rin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -196,11 +196,10 @@ general_exception(struct lwp *l, struct 
 	case EXPEVT_ADDR_ERR_LD: /* FALLTHROUGH */
 	case EXPEVT_ADDR_ERR_ST:
 		pcb = lwp_getpcb(l);
-		KDASSERT(pcb->pcb_onfault != NULL);
+		if (__predict_false(pcb->pcb_onfault == NULL))
+			goto do_panic;
 		tf->tf_spc = (int)pcb->pcb_onfault;
 		tf->tf_r0 = EFAULT;
-		if (tf->tf_spc == 0)
-			goto do_panic;
 		break;
 
 	case EXPEVT_ADDR_ERR_LD | EXP_USER: /* FALLTHROUGH */



Re: CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama

On 2021/09/08 20:47, Izumi Tsutsui wrote:

Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:22:56 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Redo a part of rev 1.89:

- Remove redundant parentheses/braces/comments.
- Fix indents.

No binary changes confirmed this time.


---
-   if (kva) {
+   if (kva)
entry |= PG_V | PG_SH |
((prot & VM_PROT_WRITE) ?
(PG_PR_KRW | PG_D) : PG_PR_KRO);
-   } else {
+   else
entry |= PG_V |
((prot & VM_PROT_WRITE) ?
(PG_PR_URW | PG_D) : PG_PR_URO);
-   }
}
---

This part doesn't match KNF:
  http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style#rev1.58


Update style around single-line braces according to discussion.

https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html

Retain some examples of technically unnecessary braces that likely
aid legibility from the previous commit.


So I don't think removing existing ones per "redundant" is a valid reason.


Oops, I misread style. These and one more similar braces have been restored.
Thanks for pointing it out!

rin


CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 12:00:50 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Hmm, remove one more parentheses from return.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.93 src/sys/arch/sh3/sh3/pmap.c:1.94
--- src/sys/arch/sh3/sh3/pmap.c:1.93	Wed Sep  8 11:59:43 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 12:00:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.93 2021/09/08 11:59:43 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.94 2021/09/08 12:00:50 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.93 2021/09/08 11:59:43 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.94 2021/09/08 12:00:50 rin Exp $");
 
 #include 
 #include 
@@ -814,7 +814,7 @@ pmap_clear_reference(struct vm_page *pg)
 	int s;
 
 	if ((pvh->pvh_flags & PVH_REFERENCED) == 0)
-		return (false);
+		return false;
 
 	pvh->pvh_flags &= ~PVH_REFERENCED;
 



CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 12:00:50 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Hmm, remove one more parentheses from return.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 11:59:43 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Restore braces for if/else statements which have logically single line,
but physically multiple lines.

This is recommended by an example in style:
http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style#rev1.58

Thanks tsutsui@ for pointing it out.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 11:59:43 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Restore braces for if/else statements which have logically single line,
but physically multiple lines.

This is recommended by an example in style:
http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style#rev1.58

Thanks tsutsui@ for pointing it out.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.92 src/sys/arch/sh3/sh3/pmap.c:1.93
--- src/sys/arch/sh3/sh3/pmap.c:1.92	Wed Sep  8 07:25:55 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 11:59:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.92 2021/09/08 07:25:55 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.93 2021/09/08 11:59:43 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.92 2021/09/08 07:25:55 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.93 2021/09/08 11:59:43 rin Exp $");
 
 #include 
 #include 
@@ -371,14 +371,15 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 			panic("%s: cannot allocate pv", __func__);
 		}
 	} else {	/* bus-space (always uncached map) */
-		if (kva)
+		if (kva) {
 			entry |= PG_V | PG_SH |
 			((prot & VM_PROT_WRITE) ?
 			(PG_PR_KRW | PG_D) : PG_PR_KRO);
-		else
+		} else {
 			entry |= PG_V |
 			((prot & VM_PROT_WRITE) ?
 			(PG_PR_URW | PG_D) : PG_PR_URO);
+		}
 	}
 
 	/* Register to page table */
@@ -788,9 +789,10 @@ pmap_copy_page(paddr_t src, paddr_t dst)
 		sh_dcache_wbinv_all();
 		memcpy((void *)SH3_PHYS_TO_P2SEG(dst),
 		(void *)SH3_PHYS_TO_P2SEG(src), PAGE_SIZE);
-	} else
+	} else {
 		memcpy((void *)SH3_PHYS_TO_P1SEG(dst),
 		(void *)SH3_PHYS_TO_P1SEG(src), PAGE_SIZE);
+	}
 }
 
 bool



Re: CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Izumi Tsutsui
> Module Name:  src
> Committed By: rin
> Date: Wed Sep  8 07:22:56 UTC 2021
> 
> Modified Files:
>   src/sys/arch/sh3/sh3: pmap.c
> 
> Log Message:
> Redo a part of rev 1.89:
> 
> - Remove redundant parentheses/braces/comments.
> - Fix indents.
> 
> No binary changes confirmed this time.

---
-   if (kva) {
+   if (kva)
entry |= PG_V | PG_SH |
((prot & VM_PROT_WRITE) ?
(PG_PR_KRW | PG_D) : PG_PR_KRO);
-   } else {
+   else
entry |= PG_V |
((prot & VM_PROT_WRITE) ?
(PG_PR_URW | PG_D) : PG_PR_URO);
-   }
}
---

This part doesn't match KNF:
 http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style#rev1.58

> Update style around single-line braces according to discussion.
> 
> https://mail-index.netbsd.org/tech-userlevel/2020/07/12/msg012536.html
> https://mail-index.netbsd.org/tech-kern/2020/07/12/msg026594.html
> 
> Retain some examples of technically unnecessary braces that likely
> aid legibility from the previous commit.

So I don't think removing existing ones per "redundant" is a valid reason.

---
Izumi Tsutsui


CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:25:55 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Redo a part of rev 1.89:
- Improve uniformity of panic messages. Also, use __func__ instead of
  hard-coded function names.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.91 src/sys/arch/sh3/sh3/pmap.c:1.92
--- src/sys/arch/sh3/sh3/pmap.c:1.91	Wed Sep  8 07:22:56 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 07:25:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.91 2021/09/08 07:22:56 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.92 2021/09/08 07:25:55 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.91 2021/09/08 07:22:56 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.92 2021/09/08 07:25:55 rin Exp $");
 
 #include 
 #include 
@@ -192,7 +192,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 
 	return __pmap_kve;
  error:
-	panic("pmap_growkernel: out of memory.");
+	panic("%s: out of memory", __func__);
 	/* NOTREACHED */
 }
 
@@ -368,7 +368,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 		if (__pmap_pv_enter(pmap, pg, va)) {
 			if (flags & PMAP_CANFAIL)
 return ENOMEM;
-			panic("%s: __pmap_pv_enter failed", __func__);
+			panic("%s: cannot allocate pv", __func__);
 		}
 	} else {	/* bus-space (always uncached map) */
 		if (kva)
@@ -392,7 +392,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	__pmap_pv_remove(pmap, pg, va);
 return ENOMEM;
 			}
-			panic("%s: __pmap_pte_alloc failed", __func__);
+			panic("%s: cannot allocate pte", __func__);
 		}
 	}
 
@@ -666,7 +666,7 @@ pmap_protect(pmap_t pmap, vaddr_t sva, v
 
 	switch (prot) {
 	default:
-		panic("pmap_protect: invalid protection mode %x", prot);
+		panic("%s: invalid protection mode %x", __func__, prot);
 		/* NOTREACHED */
 	case VM_PROT_READ:
 	case VM_PROT_READ | VM_PROT_EXECUTE:
@@ -1096,7 +1096,7 @@ __pmap_asid_alloc(void)
 		}
 	}
 
-	panic("No ASID allocated.");
+	panic("%s: no ASID allocated", __func__);
 	/* NOTREACHED */
 }
 



CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:25:55 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Redo a part of rev 1.89:
- Improve uniformity of panic messages. Also, use __func__ instead of
  hard-coded function names.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:22:56 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Redo a part of rev 1.89:

- Remove redundant parentheses/braces/comments.
- Fix indents.

No binary changes confirmed this time.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.90 src/sys/arch/sh3/sh3/pmap.c:1.91
--- src/sys/arch/sh3/sh3/pmap.c:1.90	Wed Sep  8 07:13:18 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 07:22:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.91 2021/09/08 07:22:56 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.91 2021/09/08 07:22:56 rin Exp $");
 
 #include 
 #include 
@@ -153,7 +153,7 @@ pmap_steal_memory(vsize_t size, vaddr_t 
 	va = SH3_PHYS_TO_P1SEG(pa);
 	memset((void *)va, 0, size);
 
-	return (va);
+	return va;
 }
 
 vaddr_t
@@ -162,7 +162,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 	int i, n;
 
 	if (maxkvaddr <= __pmap_kve)
-		return (__pmap_kve);
+		return __pmap_kve;
 
 	i = __PMAP_PTP_INDEX(__pmap_kve - VM_MIN_KERNEL_ADDRESS);
 	__pmap_kve = __PMAP_PTP_TRUNC(maxkvaddr);
@@ -190,7 +190,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 		}
 	}
 
-	return (__pmap_kve);
+	return __pmap_kve;
  error:
 	panic("pmap_growkernel: out of memory.");
 	/* NOTREACHED */
@@ -248,7 +248,7 @@ pmap_create(void)
 		uvm_pagealloc(NULL, 0, NULL,
 			UVM_PGA_USERESERVE | UVM_PGA_ZERO)));
 
-	return (pmap);
+	return pmap;
 }
 
 void
@@ -271,7 +271,7 @@ pmap_destroy(pmap_t pmap)
 			for (j = 0; j < __PMAP_PTP_PG_N; j++, pte++)
 KDASSERT(*pte == 0);
 		}
-#endif /* DEBUG */
+#endif
 		/* Purge cache entry for next use of this page. */
 		if (SH_HAS_VIRTUAL_ALIAS)
 			sh_dcache_inv_range(va, PAGE_SIZE);
@@ -323,7 +323,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	struct vm_page *pg;
 	struct vm_page_md *pvh;
 	pt_entry_t entry, *pte;
-	bool kva = (pmap == pmap_kernel());
+	bool kva = pmap == pmap_kernel();
 
 	/* "flags" never exceed "prot" */
 	KDASSERT(prot != 0 && ((flags & VM_PROT_ALL) & ~prot) == 0);
@@ -362,7 +362,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 
 		/* Check for existing mapping */
 		if (__pmap_map_change(pmap, va, pa, prot, entry))
-			return (0);
+			return 0;
 
 		/* Add to physical-virtual map list of this page */
 		if (__pmap_pv_enter(pmap, pg, va)) {
@@ -371,15 +371,14 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 			panic("%s: __pmap_pv_enter failed", __func__);
 		}
 	} else {	/* bus-space (always uncached map) */
-		if (kva) {
+		if (kva)
 			entry |= PG_V | PG_SH |
 			((prot & VM_PROT_WRITE) ?
 			(PG_PR_KRW | PG_D) : PG_PR_KRO);
-		} else {
+		else
 			entry |= PG_V |
 			((prot & VM_PROT_WRITE) ?
 			(PG_PR_URW | PG_D) : PG_PR_URO);
-		}
 	}
 
 	/* Register to page table */
@@ -410,7 +409,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 		pmap->pm_stats.wired_count++;
 	pmap->pm_stats.resident_count++;
 
-	return (0);
+	return 0;
 }
 
 /*
@@ -428,13 +427,13 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 	vaddr_t eva = va + PAGE_SIZE;
 
 	if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
-	((oentry = *pte) == 0))
-		return (false);		/* no mapping exists. */
+	(oentry = *pte) == 0)
+		return false;		/* no mapping exists. */
 
 	if (pa != (oentry & PG_PPN)) {
 		/* Enter a mapping at a mapping to another physical page. */
 		pmap_remove(pmap, va, eva);
-		return (false);
+		return false;
 	}
 
 	/* Pre-existing mapping */
@@ -454,10 +453,10 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 	} else if (entry & _PG_WIRED) {
 		/* unwired -> wired. make sure to reflect "flags" */
 		pmap_remove(pmap, va, eva);
-		return (false);
+		return false;
 	}
 
-	return (true);	/* mapping was changed. */
+	return true;	/* mapping was changed. */
 }
 
 /*
@@ -575,7 +574,7 @@ __pmap_pv_remove(pmap_t pmap, struct vm_
 #ifdef DEBUG
 	/* Check duplicated map. */
 	SLIST_FOREACH(pv, >pvh_head, pv_link)
-	KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
+		KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
 #endif
 	splx(s);
 }
@@ -638,17 +637,17 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa
 	if (pmap == pmap_kernel() && (va >> 30) == 2) {
 		if (pap != NULL)
 			*pap = va & SH3_PHYS_MASK;
-		return (true);
+		return true;
 	}
 
 	pte = __pmap_pte_lookup(pmap, va);
 	if (pte == NULL || *pte == 0)
-		return (false);
+		return false;
 
 	if (pap != NULL)
 		*pap = (*pte & PG_PPN) | (va & PGOFSET);
 
-	return (true);
+	return true;
 }
 
 void
@@ -670,20 +669,17 @@ pmap_protect(pmap_t pmap, vaddr_t sva, v
 		panic("pmap_protect: 

CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:22:56 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Redo a part of rev 1.89:

- Remove redundant parentheses/braces/comments.
- Fix indents.

No binary changes confirmed this time.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:13:18 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Revert rev 1.89:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sh3/sh3/pmap.c#rev1.89

I misunderstood evaluation order of ? operator.

I should have split the commit into two parts, i.e., with and without
binary diffs, in order to avoid such a serious mistake.

Thanks rillig@ so much for careful check


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.89 src/sys/arch/sh3/sh3/pmap.c:1.90
--- src/sys/arch/sh3/sh3/pmap.c:1.89	Wed Sep  8 00:35:56 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 07:13:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.89 2021/09/08 00:35:56 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.89 2021/09/08 00:35:56 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $");
 
 #include 
 #include 
@@ -153,7 +153,7 @@ pmap_steal_memory(vsize_t size, vaddr_t 
 	va = SH3_PHYS_TO_P1SEG(pa);
 	memset((void *)va, 0, size);
 
-	return va;
+	return (va);
 }
 
 vaddr_t
@@ -162,7 +162,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 	int i, n;
 
 	if (maxkvaddr <= __pmap_kve)
-		return __pmap_kve;
+		return (__pmap_kve);
 
 	i = __PMAP_PTP_INDEX(__pmap_kve - VM_MIN_KERNEL_ADDRESS);
 	__pmap_kve = __PMAP_PTP_TRUNC(maxkvaddr);
@@ -190,9 +190,9 @@ pmap_growkernel(vaddr_t maxkvaddr)
 		}
 	}
 
-	return __pmap_kve;
+	return (__pmap_kve);
  error:
-	panic("%s: out of memory", __func__);
+	panic("pmap_growkernel: out of memory.");
 	/* NOTREACHED */
 }
 
@@ -248,7 +248,7 @@ pmap_create(void)
 		uvm_pagealloc(NULL, 0, NULL,
 			UVM_PGA_USERESERVE | UVM_PGA_ZERO)));
 
-	return pmap;
+	return (pmap);
 }
 
 void
@@ -271,7 +271,7 @@ pmap_destroy(pmap_t pmap)
 			for (j = 0; j < __PMAP_PTP_PG_N; j++, pte++)
 KDASSERT(*pte == 0);
 		}
-#endif
+#endif /* DEBUG */
 		/* Purge cache entry for next use of this page. */
 		if (SH_HAS_VIRTUAL_ALIAS)
 			sh_dcache_inv_range(va, PAGE_SIZE);
@@ -323,7 +323,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	struct vm_page *pg;
 	struct vm_page_md *pvh;
 	pt_entry_t entry, *pte;
-	bool kva = pmap == pmap_kernel();
+	bool kva = (pmap == pmap_kernel());
 
 	/* "flags" never exceed "prot" */
 	KDASSERT(prot != 0 && ((flags & VM_PROT_ALL) & ~prot) == 0);
@@ -362,23 +362,24 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 
 		/* Check for existing mapping */
 		if (__pmap_map_change(pmap, va, pa, prot, entry))
-			return 0;
+			return (0);
 
 		/* Add to physical-virtual map list of this page */
 		if (__pmap_pv_enter(pmap, pg, va)) {
 			if (flags & PMAP_CANFAIL)
 return ENOMEM;
-			panic("%s: cannot allocate pv", __func__);
+			panic("%s: __pmap_pv_enter failed", __func__);
 		}
 	} else {	/* bus-space (always uncached map) */
-		if (kva)
+		if (kva) {
 			entry |= PG_V | PG_SH |
-			(prot & VM_PROT_WRITE) ?
-			(PG_PR_KRW | PG_D) : PG_PR_KRO;
-		else
+			((prot & VM_PROT_WRITE) ?
+			(PG_PR_KRW | PG_D) : PG_PR_KRO);
+		} else {
 			entry |= PG_V |
-			(prot & VM_PROT_WRITE) ?
-			(PG_PR_URW | PG_D) : PG_PR_URO;
+			((prot & VM_PROT_WRITE) ?
+			(PG_PR_URW | PG_D) : PG_PR_URO);
+		}
 	}
 
 	/* Register to page table */
@@ -392,7 +393,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	__pmap_pv_remove(pmap, pg, va);
 return ENOMEM;
 			}
-			panic("%s: cannot allocate pte", __func__);
+			panic("%s: __pmap_pte_alloc failed", __func__);
 		}
 	}
 
@@ -409,7 +410,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 		pmap->pm_stats.wired_count++;
 	pmap->pm_stats.resident_count++;
 
-	return 0;
+	return (0);
 }
 
 /*
@@ -427,13 +428,13 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 	vaddr_t eva = va + PAGE_SIZE;
 
 	if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
-	(oentry = *pte) == 0)
-		return false;		/* no mapping exists. */
+	((oentry = *pte) == 0))
+		return (false);		/* no mapping exists. */
 
 	if (pa != (oentry & PG_PPN)) {
 		/* Enter a mapping at a mapping to another physical page. */
 		pmap_remove(pmap, va, eva);
-		return false;
+		return (false);
 	}
 
 	/* Pre-existing mapping */
@@ -453,10 +454,10 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 	} else if (entry & _PG_WIRED) {
 		/* unwired -> wired. make sure to reflect "flags" */
 		pmap_remove(pmap, va, eva);
-		return false;
+		return (false);
 	}
 
-	return true;	/* mapping was changed. */
+	return (true);	/* mapping was changed. */
 }
 
 /*
@@ -574,7 +575,7 @@ __pmap_pv_remove(pmap_t pmap, struct vm_
 #ifdef DEBUG
 	/* Check duplicated map. */
 	SLIST_FOREACH(pv, >pvh_head, pv_link)
-		

CVS commit: src/sys/arch/sh3/sh3

2021-09-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 07:13:18 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Revert rev 1.89:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sh3/sh3/pmap.c#rev1.89

I misunderstood evaluation order of ? operator.

I should have split the commit into two parts, i.e., with and without
binary diffs, in order to avoid such a serious mistake.

Thanks rillig@ so much for careful check


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-07 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 00:35:56 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Misc cosmetic fixes:
- Remove redundant parentheses/braces/comments.
- Improve uniformity of panic messages. Also, use __func__ instead of
  hard-coded function names.
- Fix indents.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.88 src/sys/arch/sh3/sh3/pmap.c:1.89
--- src/sys/arch/sh3/sh3/pmap.c:1.88	Wed Sep  8 00:24:29 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 00:35:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.88 2021/09/08 00:24:29 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.89 2021/09/08 00:35:56 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.88 2021/09/08 00:24:29 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.89 2021/09/08 00:35:56 rin Exp $");
 
 #include 
 #include 
@@ -153,7 +153,7 @@ pmap_steal_memory(vsize_t size, vaddr_t 
 	va = SH3_PHYS_TO_P1SEG(pa);
 	memset((void *)va, 0, size);
 
-	return (va);
+	return va;
 }
 
 vaddr_t
@@ -162,7 +162,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 	int i, n;
 
 	if (maxkvaddr <= __pmap_kve)
-		return (__pmap_kve);
+		return __pmap_kve;
 
 	i = __PMAP_PTP_INDEX(__pmap_kve - VM_MIN_KERNEL_ADDRESS);
 	__pmap_kve = __PMAP_PTP_TRUNC(maxkvaddr);
@@ -190,9 +190,9 @@ pmap_growkernel(vaddr_t maxkvaddr)
 		}
 	}
 
-	return (__pmap_kve);
+	return __pmap_kve;
  error:
-	panic("pmap_growkernel: out of memory.");
+	panic("%s: out of memory", __func__);
 	/* NOTREACHED */
 }
 
@@ -248,7 +248,7 @@ pmap_create(void)
 		uvm_pagealloc(NULL, 0, NULL,
 			UVM_PGA_USERESERVE | UVM_PGA_ZERO)));
 
-	return (pmap);
+	return pmap;
 }
 
 void
@@ -271,7 +271,7 @@ pmap_destroy(pmap_t pmap)
 			for (j = 0; j < __PMAP_PTP_PG_N; j++, pte++)
 KDASSERT(*pte == 0);
 		}
-#endif /* DEBUG */
+#endif
 		/* Purge cache entry for next use of this page. */
 		if (SH_HAS_VIRTUAL_ALIAS)
 			sh_dcache_inv_range(va, PAGE_SIZE);
@@ -323,7 +323,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	struct vm_page *pg;
 	struct vm_page_md *pvh;
 	pt_entry_t entry, *pte;
-	bool kva = (pmap == pmap_kernel());
+	bool kva = pmap == pmap_kernel();
 
 	/* "flags" never exceed "prot" */
 	KDASSERT(prot != 0 && ((flags & VM_PROT_ALL) & ~prot) == 0);
@@ -362,24 +362,23 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 
 		/* Check for existing mapping */
 		if (__pmap_map_change(pmap, va, pa, prot, entry))
-			return (0);
+			return 0;
 
 		/* Add to physical-virtual map list of this page */
 		if (__pmap_pv_enter(pmap, pg, va)) {
 			if (flags & PMAP_CANFAIL)
 return ENOMEM;
-			panic("%s: __pmap_pv_enter failed", __func__);
+			panic("%s: cannot allocate pv", __func__);
 		}
 	} else {	/* bus-space (always uncached map) */
-		if (kva) {
+		if (kva)
 			entry |= PG_V | PG_SH |
-			((prot & VM_PROT_WRITE) ?
-			(PG_PR_KRW | PG_D) : PG_PR_KRO);
-		} else {
+			(prot & VM_PROT_WRITE) ?
+			(PG_PR_KRW | PG_D) : PG_PR_KRO;
+		else
 			entry |= PG_V |
-			((prot & VM_PROT_WRITE) ?
-			(PG_PR_URW | PG_D) : PG_PR_URO);
-		}
+			(prot & VM_PROT_WRITE) ?
+			(PG_PR_URW | PG_D) : PG_PR_URO;
 	}
 
 	/* Register to page table */
@@ -393,7 +392,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	__pmap_pv_remove(pmap, pg, va);
 return ENOMEM;
 			}
-			panic("%s: __pmap_pte_alloc failed", __func__);
+			panic("%s: cannot allocate pte", __func__);
 		}
 	}
 
@@ -410,7 +409,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 		pmap->pm_stats.wired_count++;
 	pmap->pm_stats.resident_count++;
 
-	return (0);
+	return 0;
 }
 
 /*
@@ -428,13 +427,13 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 	vaddr_t eva = va + PAGE_SIZE;
 
 	if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
-	((oentry = *pte) == 0))
-		return (false);		/* no mapping exists. */
+	(oentry = *pte) == 0)
+		return false;		/* no mapping exists. */
 
 	if (pa != (oentry & PG_PPN)) {
 		/* Enter a mapping at a mapping to another physical page. */
 		pmap_remove(pmap, va, eva);
-		return (false);
+		return false;
 	}
 
 	/* Pre-existing mapping */
@@ -454,10 +453,10 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 	} else if (entry & _PG_WIRED) {
 		/* unwired -> wired. make sure to reflect "flags" */
 		pmap_remove(pmap, va, eva);
-		return (false);
+		return false;
 	}
 
-	return (true);	/* mapping was changed. */
+	return true;	/* mapping was changed. */
 }
 
 /*
@@ -575,7 +574,7 @@ __pmap_pv_remove(pmap_t pmap, struct vm_
 #ifdef DEBUG
 	/* Check duplicated map. */
 	SLIST_FOREACH(pv, >pvh_head, pv_link)
-	KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
+		KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
 #endif
 	

CVS commit: src/sys/arch/sh3/sh3

2021-09-07 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 00:35:56 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Misc cosmetic fixes:
- Remove redundant parentheses/braces/comments.
- Improve uniformity of panic messages. Also, use __func__ instead of
  hard-coded function names.
- Fix indents.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-07 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 00:24:29 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Turn KASSERT's added for PR port-sh3/56381 into KDASSERT's;
they are less likely expected to fire again.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.87 src/sys/arch/sh3/sh3/pmap.c:1.88
--- src/sys/arch/sh3/sh3/pmap.c:1.87	Thu Sep  2 08:02:33 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Wed Sep  8 00:24:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.87 2021/09/02 08:02:33 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.88 2021/09/08 00:24:29 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.87 2021/09/02 08:02:33 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.88 2021/09/08 00:24:29 rin Exp $");
 
 #include 
 #include 
@@ -737,10 +737,10 @@ pmap_page_protect(struct vm_page *pg, vm
 		while ((pv = SLIST_FIRST(>pvh_head)) != NULL) {
 			pmap = pv->pv_pmap;
 			va = pv->pv_va;
-#ifdef DIAGNOSTIC
+#ifdef DEBUG
 			pt_entry_t *pte = __pmap_pte_lookup(pmap, va);
-			KASSERT(pte != NULL);
-			KASSERT(*pte != 0);
+			KDASSERT(pte != NULL);
+			KDASSERT(*pte != 0);
 #endif
 			pmap_remove(pmap, va, va + PAGE_SIZE);
 		}



CVS commit: src/sys/arch/sh3/sh3

2021-09-07 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Sep  8 00:24:29 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Turn KASSERT's added for PR port-sh3/56381 into KDASSERT's;
they are less likely expected to fire again.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-02 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep  2 08:02:33 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Add missing NULL check for __pmap_pv_alloc() (== pool_get() with
PR_NOWAIT) in __pmap_pv_enter().

Then, handle this failure in pmap_enter(); return ENOMEM if
PMAP_CANFAIL, and panic otherwise.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-02 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep  2 08:02:33 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
Add missing NULL check for __pmap_pv_alloc() (== pool_get() with
PR_NOWAIT) in __pmap_pv_enter().

Then, handle this failure in pmap_enter(); return ENOMEM if
PMAP_CANFAIL, and panic otherwise.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.86 src/sys/arch/sh3/sh3/pmap.c:1.87
--- src/sys/arch/sh3/sh3/pmap.c:1.86	Thu Sep  2 07:55:56 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Thu Sep  2 08:02:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.86 2021/09/02 07:55:56 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.87 2021/09/02 08:02:33 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.86 2021/09/02 07:55:56 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.87 2021/09/02 08:02:33 rin Exp $");
 
 #include 
 #include 
@@ -77,7 +77,7 @@ struct pv_entry {
 };
 #define	__pmap_pv_alloc()	pool_get(&__pmap_pv_pool, PR_NOWAIT)
 #define	__pmap_pv_free(pv)	pool_put(&__pmap_pv_pool, (pv))
-STATIC void __pmap_pv_enter(pmap_t, struct vm_page *, vaddr_t);
+STATIC int __pmap_pv_enter(pmap_t, struct vm_page *, vaddr_t);
 STATIC void __pmap_pv_remove(pmap_t, struct vm_page *, vaddr_t);
 STATIC void *__pmap_pv_page_alloc(struct pool *, int);
 STATIC void __pmap_pv_page_free(struct pool *, void *);
@@ -365,8 +365,11 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 			return (0);
 
 		/* Add to physical-virtual map list of this page */
-		__pmap_pv_enter(pmap, pg, va);
-
+		if (__pmap_pv_enter(pmap, pg, va)) {
+			if (flags & PMAP_CANFAIL)
+return ENOMEM;
+			panic("%s: __pmap_pv_enter failed", __func__);
+		}
 	} else {	/* bus-space (always uncached map) */
 		if (kva) {
 			entry |= PG_V | PG_SH |
@@ -458,11 +461,11 @@ __pmap_map_change(pmap_t pmap, vaddr_t v
 }
 
 /*
- * void __pmap_pv_enter(pmap_t pmap, struct vm_page *pg, vaddr_t vaddr):
+ * int __pmap_pv_enter(pmap_t pmap, struct vm_page *pg, vaddr_t vaddr):
  *	Insert physical-virtual map to vm_page.
  *	Assume pre-existed mapping is already removed.
  */
-void
+int
 __pmap_pv_enter(pmap_t pmap, struct vm_page *pg, vaddr_t va)
 {
 	struct vm_page_md *pvh;
@@ -495,11 +498,16 @@ __pmap_pv_enter(pmap_t pmap, struct vm_p
 	/* Register pv map */
 	pvh = VM_PAGE_TO_MD(pg);
 	pv = __pmap_pv_alloc();
+	if (pv == NULL) {
+		splx(s);
+		return ENOMEM;
+	}
 	pv->pv_pmap = pmap;
 	pv->pv_va = va;
 
 	SLIST_INSERT_HEAD(>pvh_head, pv, pv_link);
 	splx(s);
+	return 0;
 }
 
 void



CVS commit: src/sys/arch/sh3/sh3

2021-09-02 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep  2 07:55:56 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
PR port-sh3/56381

pmap_enter() returns ENOMEM if __pmap_pte_alloc() fails and PMAP_CANFAIL
flag is specified. In this case, remove pv via __pmap_pv_remove() if it is
added to p-v map list via __pmap_pv_enter().

Otherwise, pmap becomes an inconsistent state, which results in an infinite
loop in pmap_page_protect(), as reported in the PR.

Also, KASSERT's are added for sure, in order to detect the infinite loops.

Great thanks to chs@ for finding out this bug!!


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/sh3/sh3

2021-09-02 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep  2 07:55:56 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: pmap.c

Log Message:
PR port-sh3/56381

pmap_enter() returns ENOMEM if __pmap_pte_alloc() fails and PMAP_CANFAIL
flag is specified. In this case, remove pv via __pmap_pv_remove() if it is
added to p-v map list via __pmap_pv_enter().

Otherwise, pmap becomes an inconsistent state, which results in an infinite
loop in pmap_page_protect(), as reported in the PR.

Also, KASSERT's are added for sure, in order to detect the infinite loops.

Great thanks to chs@ for finding out this bug!!


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/sh3/sh3/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.85 src/sys/arch/sh3/sh3/pmap.c:1.86
--- src/sys/arch/sh3/sh3/pmap.c:1.85	Mon Jul 26 21:43:11 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Thu Sep  2 07:55:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.85 2021/07/26 21:43:11 andvar Exp $	*/
+/*	$NetBSD: pmap.c,v 1.86 2021/09/02 07:55:56 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.85 2021/07/26 21:43:11 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.86 2021/09/02 07:55:56 rin Exp $");
 
 #include 
 #include 
@@ -385,9 +385,12 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	else {
 		pte = __pmap_pte_alloc(pmap, va);
 		if (pte == NULL) {
-			if (flags & PMAP_CANFAIL)
+			if (flags & PMAP_CANFAIL) {
+if (pg != NULL)
+	__pmap_pv_remove(pmap, pg, va);
 return ENOMEM;
-			panic("pmap_enter: cannot allocate pte");
+			}
+			panic("%s: __pmap_pte_alloc failed", __func__);
 		}
 	}
 
@@ -724,8 +727,14 @@ pmap_page_protect(struct vm_page *pg, vm
 		/* Remove all */
 		s = splvm();
 		while ((pv = SLIST_FIRST(>pvh_head)) != NULL) {
+			pmap = pv->pv_pmap;
 			va = pv->pv_va;
-			pmap_remove(pv->pv_pmap, va, va + PAGE_SIZE);
+#ifdef DIAGNOSTIC
+			pt_entry_t *pte = __pmap_pte_lookup(pmap, va);
+			KASSERT(pte != NULL);
+			KASSERT(*pte != 0);
+#endif
+			pmap_remove(pmap, va, va + PAGE_SIZE);
 		}
 		splx(s);
 	}



Re: CVS commit: src/sys/arch/sh3/sh3

2019-05-09 Thread Valery Ushakov
On Thu, May 09, 2019 at 16:48:31 +, Ryo Shimizu wrote:

> Module Name:  src
> Committed By: ryo
> Date: Thu May  9 16:48:31 UTC 2019
> 
> Modified Files:
>   src/sys/arch/sh3/sh3: db_trace.c
> 
> Log Message:
> fix backtrace. it was broken.
> - use db_read_bytes() to avoid faults.
> - quite a few functions do not use frame pointers,
>   therefore always detect stack depth without a frame pointer.
>   however, since the framepointer(=r14) is used as a trapframe,
>   the code to detect the frame pointer is still needed.
> - dump the contents of trapframe during backtracing.
> - KNF

It's a bit unfortunate that this commit lumps together semantic
changes and purely cosmetic stuff (like print() instead of
(*print)()), which clutters the diff and makes the former less
obvious.

-uwe


Re: CVS commit: src/sys/arch/sh3/sh3

2012-12-12 Thread Valeriy E. Ushakov
On Wed, Dec 12, 2012 at 13:34:49 +, Izumi Tsutsui wrote:

 Module Name:  src
 Committed By: tsutsui
 Date: Wed Dec 12 13:34:49 UTC 2012
 
 Modified Files:
   src/sys/arch/sh3/sh3: cache_sh4.c
 
 Log Message:
 Fix fallouts in rev 1.19:
  
 http://www.nerv.org/~ryo/netbsd/netbsd/?q=id:20080316T191753Z.1654448ada03ce3c4668f3fe472796d0b771e147
  - revert RUN_P1 - PAD_P1_SWITCH changes where RUN_P1 is
actually required  (all icache CCIA ops still need RUN_P2)

Why is it required?  The return address is in P1, so the normal ret
will jump back to P1.  Or is there some inlining I missed?


  - sh4_dcache_wbinv_all() and sh4_dcache_wbinv_range_index()
(which manipulate CCDA arrays) are no longer have RUN_P2 so
we can't call them directly from sh4_icache_sync_all() and
sh4_icache_sync_range_index() funcitons;  use function pointers
(which have appropriate addresses) instead for 7750 and 7750S
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sh3/sh3/cache_sh4.c

-uwe


Re: CVS commit: src/sys/arch/sh3/sh3

2012-12-12 Thread Izumi Tsutsui
uwe@ wrote:

  Log Message:
  Fix fallouts in rev 1.19:
   
  http://www.nerv.org/~ryo/netbsd/netbsd/?q=id:20080316T191753Z.1654448ada03ce3c4668f3fe472796d0b771e147
   - revert RUN_P1 - PAD_P1_SWITCH changes where RUN_P1 is
 actually required  (all icache CCIA ops still need RUN_P2)
 
 Why is it required?  The return address is in P1, so the normal ret
 will jump back to P1.  Or is there some inlining I missed?

Ah, I misunderstood it since the log message didn't mention changes
in icache functions (assumed returning into P1).

I'll revert this first part.

   - sh4_dcache_wbinv_all() and sh4_dcache_wbinv_range_index()
 (which manipulate CCDA arrays) are no longer have RUN_P2 so
 we can't call them directly from sh4_icache_sync_all() and
 sh4_icache_sync_range_index() funcitons;  use function pointers
 (which have appropriate addresses) instead for 7750 and 7750S

---
Izumi Tsutsui


Re: CVS commit: src/sys/arch/sh3/sh3

2012-12-12 Thread Valeriy E. Ushakov
On Wed, Dec 12, 2012 at 23:55:31 +0900, Izumi Tsutsui wrote:

 uwe@ wrote:
 
   Log Message:
   Fix fallouts in rev 1.19:

   http://www.nerv.org/~ryo/netbsd/netbsd/?q=id:20080316T191753Z.1654448ada03ce3c4668f3fe472796d0b771e147
- revert RUN_P1 - PAD_P1_SWITCH changes where RUN_P1 is
  actually required  (all icache CCIA ops still need RUN_P2)
  
  Why is it required?  The return address is in P1, so the normal ret
  will jump back to P1.  Or is there some inlining I missed?
 
 Ah, I misunderstood it since the log message didn't mention changes
 in icache functions (assumed returning into P1).

It's commented in cpu.h that was part of the changeset (which is hard
to see with cvs).


- sh4_dcache_wbinv_all() and sh4_dcache_wbinv_range_index()
  (which manipulate CCDA arrays) are no longer have RUN_P2 so
  we can't call them directly from sh4_icache_sync_all() and
  sh4_icache_sync_range_index() funcitons;  use function pointers
  (which have appropriate addresses) instead for 7750 and 7750S

Hmm looking at /* RUN_P2; */ /* called via P2 address if necessary */
comments there, I guess the above was intended but somehow lost.

Thanks for catching it!

-uwe


Re: CVS commit: src/sys/arch/sh3/sh3

2011-09-26 Thread Christos Zoulas
On Sep 27,  3:34am, u...@stderr.spb.ru (Valeriy E. Ushakov) wrote:
-- Subject: Re: CVS commit: src/sys/arch/sh3/sh3

| On Mon, Sep 26, 2011 at 18:43:08 -0400, Christos Zoulas wrote:
| 
|  Module Name:src
|  Committed By:   christos
|  Date:   Mon Sep 26 22:43:07 UTC 2011
|  
|  Modified Files:
|  src/sys/arch/sh3/sh3: cpu_in_cksum.S
|  
|  Log Message:
|  compute the entry size correctly.
|  
|  
|  To generate a diff of this commit:
|  cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sh3/sh3/cpu_in_cksum.S
| 
| It was correct.  cksum128mod is a local subroutine.

No, the name was wrong then. I will fix it.

christos


Re: CVS commit: src/sys/arch/sh3/sh3

2011-09-26 Thread Valeriy E. Ushakov
On Mon, Sep 26, 2011 at 20:33:19 -0400, Christos Zoulas wrote:

 On Sep 27,  3:34am, u...@stderr.spb.ru (Valeriy E. Ushakov) wrote:
 -- Subject: Re: CVS commit: src/sys/arch/sh3/sh3
 
 | On Mon, Sep 26, 2011 at 18:43:08 -0400, Christos Zoulas wrote:
 | 
 |  Module Name:  src
 |  Committed By: christos
 |  Date: Mon Sep 26 22:43:07 UTC 2011
 |  
 |  Modified Files:
 |src/sys/arch/sh3/sh3: cpu_in_cksum.S
 |  
 |  Log Message:
 |  compute the entry size correctly.
 |  
 |  
 |  To generate a diff of this commit:
 |  cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sh3/sh3/cpu_in_cksum.S
 | 
 | It was correct.  cksum128mod is a local subroutine.
 
 No, the name was wrong then. I will fix it.

Ah, I guess it was missed in the in_cksum - cpu_in_cksum rename.
Thanks!

-uwe