Subject: toolchain/26021: "nbconfig" creates broken "ioconf.c" for NetBSD-sparc
To: None <gnats-bugs@gnats.NetBSD.org>
From: Matthias Scheler <tron@zhadum.de>
List: netbsd-bugs
Date: 06/23/2004 10:51:23
>Number:         26021
>Category:       toolchain
>Synopsis:       "nbconfig" creates broken "ioconf.c" for NetBSD-sparc
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 23 08:52:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 2.0_BETA / NetBSD 2.0F (2004-06-23 sources)
>Organization:
Matthias Scheler                                  http://scheler.de/~matthias/
>Environment:
System: NetBSD colwyn.zhadum.de 2.0_BETA NetBSD 2.0_BETA (COLWYN) #1: Wed Jun 16 20:11:07 CEST 2004 tron@colwyn.zhadum.de:/src/sys/compile/COLWYN i386
Architecture: i386
Machine: i386

>Description:
The kernel configuration program "nbconfig" built via "src/tools" creates a
broken "ioconf.c" for at least NetBSD-sparc. It looks like there is a sign
extension problem somewhere. Here is a diff of "ioconf.c" generated by
"config" vs. "nbconfig":

--- /tmp/ioconf.c	2004-06-23 10:41:46.000000000 +0200
+++ ioconf.c	2004-06-23 10:46:20.000000000 +0200
@@ -725,27 +725,27 @@
 	-1, -1, -1, -1, 3, 0x7c, 0x35ff02, 0x300000,
 	-1, -1, 0x40000, -1, -1, -1, -1, 3,
 	0x77, 0x200000, -1, -1, -1, -1, -1, -1,
-	-1, -1, 2, 0x40, 0xfa001000, 4, -1, -1,
-	0xf9000000, 6, -1, -1, -1, -1, 0xef000000, -1,
-	0xf2000000, -1, 0x2000000, -1, -1, -1, -1, -1,
-	0xf4000000, -1, 0x4000000, -1, -1, -1, -1, -1,
-	0xfd000000, 4, 0xfb300000, 4, 0xb300000, 4, -1, -1,
-	-1, -1, -1, -1, -1, -1, 0xfb000000, 4,
-	0xb000000, 4, -1, -1, -1, -1, 0xf1000000, 12,
-	0x1000000, 12, -1, -1, -1, -1, 0xf0000000, 12,
-	0x0, 12, -1, -1, 0xe0000000, 12, -1, -1,
+	-1, -1, 2, 0x40, 0xfffffffffa001000, 4, -1, -1,
+	0xfffffffff9000000, 6, -1, -1, -1, -1, 0xffffffffef000000, -1,
+	0xfffffffff2000000, -1, 0x2000000, -1, -1, -1, -1, -1,
+	0xfffffffff4000000, -1, 0x4000000, -1, -1, -1, -1, -1,
+	0xfffffffffd000000, 4, 0xfffffffffb300000, 4, 0xb300000, 4, -1, -1,
+	-1, -1, -1, -1, -1, -1, 0xfffffffffb000000, 4,
+	0xb000000, 4, -1, -1, -1, -1, 0xfffffffff1000000, 12,
+	0x1000000, 12, -1, -1, -1, -1, 0xfffffffff0000000, 12,
+	0x0, 12, -1, -1, 0xffffffffe0000000, 12, -1, -1,
 	-1, -1, -1, -1, -1, -1, -1, -1,
 	-1, -1, -1, -1, -1, -1, -1, -1,
 	-1, -1, -1, -1, -1, -1, -1, -1,
 	-1, -1, -1, -1, -1, -1, -1, -1,
 	-1, -1, -1, -1, -1, -1, -1, -1,
 	-1, -1, -1, -1, -1, -1, -1, -1,
-	0xfb300000, 4, 0xb300000, 4, 0xfb300000, 4, 0xb300000, 4,
+	0xfffffffffb300000, 4, 0xb300000, 4, 0xfffffffffb300000, 4, 0xb300000, 4,
 	-1, -1, 0xa000000, 3, -1, -1, -1, -1,
-	0xfa000000, 4, -1, -1, -1, -1, -1, -1,
-	-1, -1, 0xf6000000, 6, 0x6000000, 6, -1, -1,
-	-1, -1, -1, -1, 0xf2000000, -1, -1, -1,
-	0xf3000000, -1, 0x3000000, -1, -1, -1, -1, 0,
+	0xfffffffffa000000, 4, -1, -1, -1, -1, -1, -1,
+	-1, -1, 0xfffffffff6000000, 6, 0x6000000, 6, -1, -1,
+	-1, -1, -1, -1, 0xfffffffff2000000, -1, -1, -1,
+	0xfffffffff3000000, -1, 0x3000000, -1, -1, -1, -1, 0,
 	0, 1, -1, -1, -1, -1, -1, -1,
 	-1, -1, -1, -1, -1, -1, -1, -1,
 	1, -1, 0, 1,
@@ -955,7 +955,7 @@
 /* 11: isp* at sbus? slot -1 offset -1 */
     {"isp",		"isp_sbus",	 0, STAR, loc+134,      0, &pspec5,
      sbuscf_locnames},
-/* 12: le0 at obio0 addr 0xf9000000 level 6 */
+/* 12: le0 at obio0 addr 0xfffffffff9000000 level 6 */
     {"le",		"le_obio",	 0, NORM, loc+136,      0, &pspec7,
      obiocf_locnames},
 /* 13: le0 at sbus0 slot -1 offset -1 */
@@ -982,7 +982,7 @@
 /* 20: en0 at sbus? slot -1 offset -1 */
     {"en",		"en_sbus",	 0, NORM, loc+262,      0, &pspec5,
      sbuscf_locnames},
-/* 21: esp0 at obio0 addr 0xfa000000 level 4 */
+/* 21: esp0 at obio0 addr 0xfffffffffa000000 level 4 */
     {"esp",		"esp_obio",	 0, NORM, loc+264,      0, &pspec7,
      obiocf_locnames},
 /* 22: esp0 at sbus0 slot -1 offset -1 */
@@ -1027,7 +1027,7 @@
 /* 35: vme0 at sparcvme0 */
     {"vme",		"vme",		 0, NORM,     loc,      0, &pspec3,
      nullcf_locnames},
-/* 36: ie0 at obio0 addr 0xf6000000 level 6 */
+/* 36: ie0 at obio0 addr 0xfffffffff6000000 level 6 */
     {"ie",		"ie_obio",	 0, NORM, loc+274,      0, &pspec7,
      obiocf_locnames},
 /* 37: ie0 at obio0 addr 0x6000000 level 6 */
@@ -1093,13 +1093,13 @@
 /* 57: clock0 at obio0 addr -1 level -1 */
     {"clock",		"clock_obio",	 0, NORM, loc+282,      0, &pspec7,
      obiocf_locnames},
-/* 58: clock0 at obio0 addr 0xf2000000 level -1 */
+/* 58: clock0 at obio0 addr 0xfffffffff2000000 level -1 */
     {"clock",		"clock_obio",	 0, NORM, loc+284,      0, &pspec7,
      obiocf_locnames},
 /* 59: clock0 at bootbus0 slot -1 offset -1 */
     {"clock",		"clock_bootbus",	 0, NORM, loc+286,      0, &pspec8,
      bootbuscf_locnames},
-/* 60: oclock0 at obio0 addr 0xf3000000 level -1 */
+/* 60: oclock0 at obio0 addr 0xfffffffff3000000 level -1 */
     {"oclock",		"oclock",	 0, NORM, loc+288,      0, &pspec7,
      obiocf_locnames},
 /* 61: oclock0 at obio0 addr 0x3000000 level -1 */
@@ -1111,10 +1111,10 @@
 /* 63: timer0 at obio0 addr -1 level -1 */
     {"timer",		"timer_obio",	 0, NORM, loc+292,      0, &pspec7,
      obiocf_locnames},
-/* 64: timer0 at obio0 addr 0xef000000 level -1 */
+/* 64: timer0 at obio0 addr 0xffffffffef000000 level -1 */
     {"timer",		"timer_obio",	 0, NORM, loc+142,      0, &pspec7,
      obiocf_locnames},
-/* 65: eeprom0 at obio0 addr 0xf2000000 level -1 */
+/* 65: eeprom0 at obio0 addr 0xfffffffff2000000 level -1 */
     {"eeprom",		"eeprom",	 0, NORM, loc+144,      0, &pspec7,
      obiocf_locnames},
 /* 66: eeprom0 at obio0 addr 0x2000000 level -1 */
@@ -1135,7 +1135,7 @@
 /* 71: memreg0 at obio0 addr -1 level -1 */
     {"memreg",		"memreg_obio",	 0, NORM, loc+150,      0, &pspec7,
      obiocf_locnames},
-/* 72: memreg0 at obio0 addr 0xf4000000 level -1 */
+/* 72: memreg0 at obio0 addr 0xfffffffff4000000 level -1 */
     {"memreg",		"memreg_obio",	 0, NORM, loc+152,      0, &pspec7,
      obiocf_locnames},
 /* 73: memreg0 at obio0 addr 0x4000000 level -1 */
@@ -1156,10 +1156,10 @@
 /* 78: bwtwo0 at sbus0 slot -1 offset -1 */
     {"bwtwo",		"bwtwo_sbus",	 0, NORM, loc+158,      0, &pspec15,
      sbuscf_locnames},
-/* 79: bwtwo0 at obio0 addr 0xfd000000 level 4 */
+/* 79: bwtwo0 at obio0 addr 0xfffffffffd000000 level 4 */
     {"bwtwo",		"bwtwo_obio",	 0, NORM, loc+160,      0, &pspec7,
      obiocf_locnames},
-/* 80: bwtwo0 at obio0 addr 0xfb300000 level 4 */
+/* 80: bwtwo0 at obio0 addr 0xfffffffffb300000 level 4 */
     {"bwtwo",		"bwtwo_obio",	 0, NORM, loc+162,      0, &pspec7,
      obiocf_locnames},
 /* 81: bwtwo0 at obio0 addr 0xb300000 level 4 */
@@ -1177,7 +1177,7 @@
 /* 85: cgsix0 at sbus? slot -1 offset -1 */
     {"cgsix",		"cgsix_sbus",	 0, NORM, loc+172,      0, &pspec5,
      sbuscf_locnames},
-/* 86: cgsix0 at obio0 addr 0xfb000000 level 4 */
+/* 86: cgsix0 at obio0 addr 0xfffffffffb000000 level 4 */
     {"cgsix",		"cgsix_obio",	 0, NORM, loc+174,      0, &pspec7,
      obiocf_locnames},
 /* 87: cgsix0 at obio0 addr 0xb000000 level 4 */
@@ -1192,7 +1192,7 @@
 /* 90: zs0 at obio0 addr -1 level -1 */
     {"zs",		"zs_obio",	 0, NORM, loc+180,      0, &pspec7,
      obiocf_locnames},
-/* 91: zs0 at obio0 addr 0xf1000000 level 12 */
+/* 91: zs0 at obio0 addr 0xfffffffff1000000 level 12 */
     {"zs",		"zs_obio",	 0, NORM, loc+182,      0, &pspec7,
      obiocf_locnames},
 /* 92: zs0 at obio0 addr 0x1000000 level 12 */
@@ -1207,7 +1207,7 @@
 /* 95: zs1 at obio0 addr -1 level -1 */
     {"zs",		"zs_obio",	 1, NORM, loc+188,      0, &pspec7,
      obiocf_locnames},
-/* 96: zs1 at obio0 addr 0xf0000000 level 12 */
+/* 96: zs1 at obio0 addr 0xfffffffff0000000 level 12 */
     {"zs",		"zs_obio",	 1, NORM, loc+190,      0, &pspec7,
      obiocf_locnames},
 /* 97: zs1 at obio0 addr 0x0 level 12 */
@@ -1216,7 +1216,7 @@
 /* 98: zs1 at bootbus0 slot -1 offset -1 */
     {"zs",		"zs_bootbus",	 1, NORM, loc+194,      0, &pspec8,
      bootbuscf_locnames},
-/* 99: zs2 at obio0 addr 0xe0000000 level 12 */
+/* 99: zs2 at obio0 addr 0xffffffffe0000000 level 12 */
     {"zs",		"zs_obio",	 2, NORM, loc+196,      0, &pspec7,
      obiocf_locnames},
 /*100: zs* at bootbus? slot -1 offset -1 */
@@ -1258,7 +1258,7 @@
 /*112: xbox* at sbus? slot -1 offset -1 */
     {"xbox",		"xbox",		 0, STAR, loc+202,      0, &pspec5,
      sbuscf_locnames},
-/*113: dma0 at obio0 addr 0xfa001000 level 4 */
+/*113: dma0 at obio0 addr 0xfffffffffa001000 level 4 */
     {"dma",		"dma_obio",	 0, NORM, loc+132,      0, &pspec7,
      obiocf_locnames},
 /*114: dma0 at sbus0 slot -1 offset -1 */
@@ -1357,13 +1357,13 @@
 /*145: cgtwo0 at vme0 addr 0x400000 addr#1 -1 addr#2 -1 len -1 len#1 -1 len#2 -1 am -1 am#1 -1 am#2 -1 irq -1 vect 0xa8 */
     {"cgtwo",		"cgtwo",	 0, NORM, loc+  0,      0, &pspec20,
      vmecf_locnames},
-/*146: cgfour0 at obio0 addr 0xfb300000 level 4 */
+/*146: cgfour0 at obio0 addr 0xfffffffffb300000 level 4 */
     {"cgfour",		"cgfour",	 0, NORM, loc+248,      0, &pspec7,
      obiocf_locnames},
 /*147: cgfour0 at obio0 addr 0xb300000 level 4 */
     {"cgfour",		"cgfour",	 0, NORM, loc+250,      0, &pspec7,
      obiocf_locnames},
-/*148: cgeight0 at obio0 addr 0xfb300000 level 4 */
+/*148: cgeight0 at obio0 addr 0xfffffffffb300000 level 4 */
     {"cgeight",		"cgeight",	 0, NORM, loc+252,      0, &pspec7,
      obiocf_locnames},
 /*149: cgeight0 at obio0 addr 0xb300000 level 4 */

And it appears that large hex numbers get signed extended causing overflows
during the build:

#   compile  GENERIC/ioconf.o
/export/scratch/tron/build.19376a/tools/bin/sparc--netbsdelf-gcc -mno-fpu -ffree
standing -O2 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wm
issing-prototypes -Wstrict-prototypes -Wno-sign-compare -fno-zero-initialized-in
-bss -I. -I/export/scratch/tron/build.19376a/src/sys/arch -I/export/scratch/tron
/build.19376a/src/sys -nostdinc -DRASTERCONSOLE -DLKM -DMAXUSERS=32 -D_KERNEL -D
_KERNEL_OPT -c ioconf.c
ioconf.c:708: warning: integer constant is too large for "long" type
ioconf.c:708: warning: overflow in implicit constant conversion
ioconf.c:709: warning: integer constant is too large for "long" type
ioconf.c:709: warning: overflow in implicit constant conversion
ioconf.c:710: warning: integer constant is too large for "long" type
ioconf.c:710: warning: overflow in implicit constant conversion
ioconf.c:710: warning: integer constant is too large for "long" type
[...]

>How-To-Repeat:
cd src/sys/arch/sparc/conf
nbconfig GENERIC
cd ../compile/GENERIC
env USETOOLS=yes nbmake dependall

>Fix:
None provided.

>Release-Note:
>Audit-Trail:
>Unformatted: