alpha: remove misaligned access emulation code
The alpha part contains code in the kernel to handle unaligned memory accesses from userland programs, to prevent them from dying in horrible SIGBUS. This made sense in the '90s, but since then people have learned to work with strict-alignment architectures, and this code has been less and less triggered - in my own experience I don't remember seeing it triggered in the last 20 years. I think it's time to send it to the Attic for a well-deserved retirement, and let these ill-behaved userland programs catch the SIGBUS they deserve. Index: etc/etc.alpha/sysctl.conf === RCS file: /OpenBSD/src/etc/etc.alpha/sysctl.conf,v retrieving revision 1.8 diff -u -p -r1.8 sysctl.conf --- etc/etc.alpha/sysctl.conf 2 Mar 2013 22:53:10 - 1.8 +++ etc/etc.alpha/sysctl.conf 9 Aug 2022 06:16:34 - @@ -1,5 +1,2 @@ -#machdep.unaligned_print=0 # 0 - disable printing of unaligned access -#machdep.unaligned_fix=0 # 0 - disable fixup of unaligned access -#machdep.unaligned_sigbus=0# 0 - don't sigbus on unaligned access #machdep.allowaperture=1 # see xf86(4) #machdep.led_blink=1 # blink chassis leds on DEC 3000 Index: sys/arch/alpha/alpha/machdep.c === RCS file: /OpenBSD/src/sys/arch/alpha/alpha/machdep.c,v retrieving revision 1.196 diff -u -p -r1.196 machdep.c --- sys/arch/alpha/alpha/machdep.c 6 Oct 2021 15:46:03 - 1.196 +++ sys/arch/alpha/alpha/machdep.c 9 Aug 2022 06:16:34 - @@ -180,9 +180,6 @@ u_int8_tdec_3000_scsiid[2], dec_3000_sc struct platform platform; /* for cpu_sysctl() */ -intalpha_unaligned_print = 1; /* warn about unaligned accesses */ -intalpha_unaligned_fix = 1;/* fix up unaligned accesses */ -intalpha_unaligned_sigbus = 1; /* SIGBUS on fixed-up accesses */ #ifndef NO_IEEE intalpha_fp_sync_complete = 0; /* fp fixup if sync even without /s */ #endif @@ -1555,18 +1552,6 @@ cpu_sysctl(int *name, u_int namelen, voi sizeof consdev)); #ifndef SMALL_KERNEL - case CPU_UNALIGNED_PRINT: - return (sysctl_int(oldp, oldlenp, newp, newlen, - _unaligned_print)); - - case CPU_UNALIGNED_FIX: - return (sysctl_int(oldp, oldlenp, newp, newlen, - _unaligned_fix)); - - case CPU_UNALIGNED_SIGBUS: - return (sysctl_int(oldp, oldlenp, newp, newlen, - _unaligned_sigbus)); - case CPU_BOOTED_KERNEL: return (sysctl_rdstring(oldp, oldlenp, newp, bootinfo.booted_kernel)); Index: sys/arch/alpha/alpha/trap.c === RCS file: /OpenBSD/src/sys/arch/alpha/alpha/trap.c,v retrieving revision 1.100 diff -u -p -r1.100 trap.c --- sys/arch/alpha/alpha/trap.c 9 Dec 2021 00:26:11 - 1.100 +++ sys/arch/alpha/alpha/trap.c 9 Aug 2022 06:16:35 - @@ -110,21 +110,6 @@ #endif #include -#ifndef SMALL_KERNEL - -unsigned long Sfloat_to_reg(unsigned int); -unsigned int reg_to_Sfloat(unsigned long); -unsigned long Tfloat_reg_cvt(unsigned long); -#ifdef FIX_UNALIGNED_VAX_FP -unsigned long Ffloat_to_reg(unsigned int); -unsigned int reg_to_Ffloat(unsigned long); -unsigned long Gfloat_reg_cvt(unsigned long); -#endif - -intunaligned_fixup(unsigned long, unsigned long, - unsigned long, struct proc *); -#endif /* SMALL_KERNEL */ - inthandle_opdec(struct proc *p, u_int64_t *ucodep); #ifndef NO_IEEE @@ -249,19 +234,10 @@ trap(a0, a1, a2, entry, framep) switch (entry) { case ALPHA_KENTRY_UNA: /* -* If user-land, do whatever fixups, printing, and -* signalling is appropriate (based on system-wide -* and per-process unaligned-access-handling flags). +* If user-land, deliver SIGBUS unconditionally. */ if (user) { -#ifndef SMALL_KERNEL - KERNEL_LOCK(); - i = unaligned_fixup(a0, a1, a2, p); - KERNEL_UNLOCK(); - if (i == 0) - goto out; -#endif - + i = SIGBUS; ucode = ILL_ILLADR; v = (caddr_t)a0; break; @@ -716,11 +692,6 @@ ast(framep) userret(p); } -/* - * Unaligned access handler. It's not clear that this can get much slower... - * - */ - const static int reg_to_framereg[32] = { FRAME_V0, FRAME_T0, FRAME_T1, FRAME_T2, FRAME_T3, FRAME_T4, FRAME_T5, FRAME_T6, @@ -736,356 +707,6 @@ const static int reg_to_framereg[32] = { ((reg_to_framereg[(reg)] == -1) ? NULL :\
Re: mips64: trigger deferred timer interrupt from splx(9)
> Other platforms (architectures?) (powerpc, powerpc64, arm64, riscv64) > multiplex their singular interrupt clock to schedule both a > fixed-period hardclock and a pseudorandom statclock. > > This is the direction I intend to take every platform, mips64 > included, after the next release. > > In that context, would there be any reason to prefer glxclk to > CP0.count? No. The cop0 timer is supposed to be the most reliable timer available. (although one may argue that, on sgi, the xbow timer on some systems is even better quality)
Re: mips64: trigger deferred timer interrupt from splx(9)
> Do those machines not have Coprocessor 0? If they do, why would you > prefer glxclk over CP0? cop0 only provides one timer, from which both the scheduling clock and statclk are derived. glxclk allows two timers to be used, and thus can provide a more reliable statclk (see the Torek paper, etc - it is even mentioned in the glxclk manual page).
libc/yp internals mop up
Following the switch to ypconnect(), several fields in the dom_binding struct used internally are no longer needed. The following diff removes them. Index: yp/ypinternal.h === RCS file: /OpenBSD/src/lib/libc/yp/ypinternal.h,v retrieving revision 1.13 diff -u -p -r1.13 ypinternal.h --- yp/ypinternal.h 17 Jul 2022 03:08:58 - 1.13 +++ yp/ypinternal.h 22 Jul 2022 06:43:15 - @@ -31,14 +31,9 @@ * yp_prot.h and yp.h. */ struct dom_binding { - struct dom_binding *dom_pnext; - char dom_domain[YPMAXDOMAIN + 1]; struct sockaddr_in dom_server_addr; - u_short dom_server_port; int dom_socket; CLIENT *dom_client; - u_short dom_local_port; - long dom_vers; }; #define BINDINGDIR "/var/yp/binding" Index: yp/yp_first.c === RCS file: /OpenBSD/src/lib/libc/yp/yp_first.c,v retrieving revision 1.11 diff -u -p -r1.11 yp_first.c --- yp/yp_first.c 13 Sep 2015 20:57:28 - 1.11 +++ yp/yp_first.c 22 Jul 2022 06:43:15 - @@ -69,7 +69,6 @@ again: if (r != RPC_SUCCESS) { if (tries++) clnt_perror(ysd->dom_client, "yp_first: clnt_call"); - ysd->dom_vers = -1; goto again; } if (!(r = ypprot_err(yprkv.stat))) { Index: yp/yp_maplist.c === RCS file: /OpenBSD/src/lib/libc/yp/yp_maplist.c,v retrieving revision 1.9 diff -u -p -r1.9 yp_maplist.c --- yp/yp_maplist.c 16 Jan 2015 16:48:51 - 1.9 +++ yp/yp_maplist.c 22 Jul 2022 06:43:15 - @@ -56,7 +56,6 @@ again: if (r != RPC_SUCCESS) { if (tries++) clnt_perror(ysd->dom_client, "yp_maplist: clnt_call"); - ysd->dom_vers = -1; goto again; } *outmaplist = ypml.maps; Index: yp/yp_master.c === RCS file: /OpenBSD/src/lib/libc/yp/yp_master.c,v retrieving revision 1.9 diff -u -p -r1.9 yp_master.c --- yp/yp_master.c 16 Jan 2015 16:48:51 - 1.9 +++ yp/yp_master.c 22 Jul 2022 06:43:15 - @@ -65,7 +65,6 @@ again: if (r != RPC_SUCCESS) { if (tries++) clnt_perror(ysd->dom_client, "yp_master: clnt_call"); - ysd->dom_vers = -1; goto again; } if (!(r = ypprot_err(yprm.stat))) { Index: yp/yp_order.c === RCS file: /OpenBSD/src/lib/libc/yp/yp_order.c,v retrieving revision 1.10 diff -u -p -r1.10 yp_order.c --- yp/yp_order.c 16 Jan 2015 16:48:51 - 1.10 +++ yp/yp_order.c 22 Jul 2022 06:43:15 - @@ -72,7 +72,6 @@ again: } if (r != RPC_SUCCESS) { clnt_perror(ysd->dom_client, "yp_order: clnt_call"); - ysd->dom_vers = -1; goto again; } *outorder = ypro.ordernum; Index: yp/ypmatch_cache.c === RCS file: /OpenBSD/src/lib/libc/yp/ypmatch_cache.c,v retrieving revision 1.17 diff -u -p -r1.17 ypmatch_cache.c --- yp/ypmatch_cache.c 13 Sep 2015 20:57:28 - 1.17 +++ yp/ypmatch_cache.c 22 Jul 2022 06:43:15 - @@ -187,7 +187,6 @@ again: if (r != RPC_SUCCESS) { if (tries++) clnt_perror(ysd->dom_client, "yp_match: clnt_call"); - ysd->dom_vers = -1; goto again; } if (!(r = ypprot_err(yprv.stat))) { @@ -248,7 +247,6 @@ again: if (r != RPC_SUCCESS) { if (tries++) clnt_perror(ysd->dom_client, "yp_next: clnt_call"); - ysd->dom_vers = -1; goto again; } if (!(r = ypprot_err(yprkv.stat))) {
arm64 pwmbl(4): simplify ramp case
When the fdt does not provide a list of brightness states, pwmbl(4) builds a 256 state ramp (i.e. state[i] = i with 0 <= i < 256). The following diff keeps that behaviour, but gets rid of the malloc call for that ramp, since the values are trivially known. Compiles but not tested due to the lack of such hardware. Index: sys/dev/fdt/pwmbl.c === RCS file: /OpenBSD/src/sys/dev/fdt/pwmbl.c,v retrieving revision 1.6 diff -u -p -r1.6 pwmbl.c --- sys/dev/fdt/pwmbl.c 24 Oct 2021 17:52:26 - 1.6 +++ sys/dev/fdt/pwmbl.c 4 Jul 2022 18:45:16 - @@ -35,7 +35,7 @@ struct pwmbl_softc { struct device sc_dev; uint32_t*sc_pwm; int sc_pwm_len; - uint32_t*sc_levels; + uint32_t*sc_levels; /* NULL if simple ramp */ int sc_nlevels; uint32_tsc_max_level; uint32_tsc_def_level; @@ -73,7 +73,7 @@ pwmbl_attach(struct device *parent, stru struct pwmbl_softc *sc = (struct pwmbl_softc *)self; struct fdt_attach_args *faa = aux; uint32_t *gpios; - int i, len; + int len; len = OF_getproplen(faa->fa_node, "pwms"); if (len < 0) { @@ -95,7 +95,7 @@ pwmbl_attach(struct device *parent, stru } len = OF_getproplen(faa->fa_node, "brightness-levels"); - if (len > 0) { + if (len >= sizeof(uint32_t)) { sc->sc_levels = malloc(len, M_DEVBUF, M_WAITOK); OF_getpropintarray(faa->fa_node, "brightness-levels", sc->sc_levels, len); @@ -107,13 +107,9 @@ pwmbl_attach(struct device *parent, stru sc->sc_def_level = sc->sc_nlevels - 1; sc->sc_def_level = sc->sc_levels[sc->sc_def_level]; } else { + /* No levels, assume a simple 0..255 ramp. */ sc->sc_nlevels = 256; - sc->sc_levels = mallocarray(sc->sc_nlevels, - sizeof(uint32_t), M_DEVBUF, M_WAITOK); - for (i = 0; i < sc->sc_nlevels; i++) - sc->sc_levels[i] = i; - sc->sc_max_level = sc->sc_levels[sc->sc_nlevels - 1]; - sc->sc_def_level = sc->sc_levels[sc->sc_nlevels - 1]; + sc->sc_max_level = sc->sc_def_level = sc->sc_nlevels - 1; } printf("\n"); @@ -144,17 +140,22 @@ pwmbl_find_brightness(struct pwmbl_softc uint32_t mid; int i; - for (i = 0; i < sc->sc_nlevels - 1; i++) { - mid = (sc->sc_levels[i] + sc->sc_levels[i + 1]) / 2; - if (sc->sc_levels[i] <= level && level <= mid) + if (sc->sc_levels) { + for (i = 0; i < sc->sc_nlevels - 1; i++) { + mid = (sc->sc_levels[i] + sc->sc_levels[i + 1]) / 2; + if (sc->sc_levels[i] <= level && level <= mid) + return sc->sc_levels[i]; + if (mid < level && level <= sc->sc_levels[i + 1]) + return sc->sc_levels[i + 1]; + } + if (level < sc->sc_levels[0]) + return sc->sc_levels[0]; + else return sc->sc_levels[i]; - if (mid < level && level <= sc->sc_levels[i + 1]) - return sc->sc_levels[i + 1]; + + } else { + return level < sc->sc_nlevels ? level : sc->sc_nlevels - 1; } - if (level < sc->sc_levels[0]) - return sc->sc_levels[0]; - else - return sc->sc_levels[i]; } int
Re: powerpc, macppc: retrigger deferred DEC interrupts from splx(9)
> We only run on New World Macs, and the only ones without openpic(4) > might be the oldest models of iMac G3 from 1998; these would attach > macintr0 and not openpic0 in dmesg. I don't know anyone who might > have such an iMac. The iMac model PowerMac2,1 from 1999 (with the > (slot-loading cd drive) does have openpic(4). This diff appears to work on PowerMac1,1 using macintr0 (dmesg below). vmstat -i reports 99 clock and stat interrupts per second, ntpd does not complain about clock drift so far. [ using 1319132 bytes of bsd ELF symbol table ] console out [ATY,Rage128y] console in [keyboard]USB and ADB found, using USB : memaddr 8400, size 400 : consaddr 8400 : ioaddr 80b2, size 2: width 640 linebytes 640 height 480 depth 8 Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2022 OpenBSD. All rights reserved. https://www.OpenBSD.org OpenBSD 7.1-current (GENERIC) #1: Thu Jun 30 13:45:19 GMT 2022 m...@allanche.gentiane.org:/usr/src/sys/arch/macppc/compile/GENERIC real mem = 268435456 (256MB) avail mem = 244858880 (233MB) random: good seed from bootblocks mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root: model PowerMac1,1 cpu0 at mainbus0: 750 (Revision 0x202): 400 MHz: 1MB backside cache mem0 at mainbus0 mpcpcibr0 at mainbus0 pci: grackle pci0 at mpcpcibr0 bus 0 ppb0 at pci0 dev 13 function 0 "DEC 21154" rev 0x02 pci1 at ppb0 bus 1 macobio0 at pci1 dev 5 function 0 "Apple Paddington" rev 0x00 macintr0 at macobio0 offset 0x10 "scsi" at macobio0 offset 0x1 not configured "escc-legacy" at macobio0 offset 0x12000 not configured zs0 at macobio0 offset 0x13000: irq 15,16 zstty0 at zs0 channel 0 zstty1 at zs0 channel 1 awacs0 at macobio0 offset 0x14000: irq 17,8,9 headphones audio0 at awacs0 "power-mgt" at macobio0 offset 0x0 not configured "fdc" at macobio0 offset 0x15000 not configured adb0 at macobio0 offset 0x16000: irq 18, via-cuda, 0 targets wdc0 at macobio0 offset 0x2 irq 13: DMA atapiscsi0 at wdc0 channel 0 drive 0 scsibus1 at atapiscsi0: 2 targets cd0 at scsibus1 targ 0 lun 0: removable cd0(wdc0:0:0): using BIOS timings, DMA mode 2 bm0 at macobio0 offset 0x11000 irq 42,33: address 00:50:e4:fa:e4:72 lxtphy0 at bm0 phy 0: LXT970 10/100 PHY, rev. 1 "nvram" at macobio0 offset 0x6 not configured "TI TSB12LV21 FireWire" rev 0x02 at pci1 dev 0 function 0 not configured pciide0 at pci1 dev 1 function 0 "CMD Technology PCI0646" rev 0x07: DMA, channel 0 configured to native-PCI, channel 1 configured to native-PCI pciide0: using irq 26 for native-PCI interrupt wd0 at pciide0 channel 0 drive 0: wd0: 16-sector PIO, LBA, 12427MB, 25450992 sectors wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2 pciide0: channel 1 ignored (disabled) fxp0 at pci1 dev 4 function 0 "Intel 8255x" rev 0x02, i82557: irq 25, address 00:a0:c9:ab:37:29 inphy0 at fxp0 phy 1: i82555 10/100 PHY, rev. 0 ohci0 at pci1 dev 6 function 0 "Opti 82C861" rev 0x10: irq 28, version 1.0, legacy support usb0 at ohci0: USB revision 1.0 uhub0 at usb0 configuration 1 interface 0 "Opti OHCI root hub" rev 1.00/1.00 addr 1 vgafb0 at pci0 dev 16 function 0 "ATI Rage 128" rev 0x00, mmio wsdisplay0 at vgafb0 mux 1: console (std, vt100 emulation) wsdisplay0: screen 1-5 added (std, vt100 emulation) uhub1 at uhub0 port 1 configuration 1 interface 0 "Mitsumi Electric Hub in Apple Extended USB Keyboard" rev 1.10/4.10 addr 2 uhidev0 at uhub1 port 3 configuration 1 interface 0 "Mitsumi Electric Apple Extended USB Keyboard" rev 1.10/4.10 addr 3 uhidev0: iclass 3/1 ukbd0 at uhidev0: 8 variable keys, 6 key codes, country code 13 wskbd0 at ukbd0: console keyboard, using wsdisplay0 uhidev1 at uhub1 port 3 configuration 1 interface 1 "Mitsumi Electric Apple Extended USB Keyboard" rev 1.10/4.10 addr 3 uhidev1: iclass 3/0, 3 report ids uhid0 at uhidev1 reportid 2: input=1, output=0, feature=0 ucc0 at uhidev1 reportid 3: 4 usages, 4 keys, enum wskbd1 at ucc0 mux 1 wskbd1: connecting to wsdisplay0 vscsi0 at root scsibus2 at vscsi0: 256 targets softraid0 at root scsibus3 at softraid0: 256 targets bootpath: /pci/@d/pci-ata@1/ata-4@0/disk@0:/bsd root on wd0a (410f22971b6a6734.a) swap on wd0b dump on wd0b
Re: kernel: remove global "randompid" toggle
> Are we keeping this "randompid" global around to make it possible to > disable random PIDs by toggling it in ddb(4)? IIRC this logic was needed because some kthreads were created before arc4random was operational, but that was before substantial changes to the random generator. However since the panic-if-invoked-early has been removed in sys/dev/rnd.c 1.126, this is indeed probably no longer needed.
Re: powerpc*: make EXC_LAST less awkward
> > As seen in sys/arch/powerpc64/include/trap.h, not-so-ancient PowerPC and > > POWER processors define exception addresses past EXC_LAST. > > Erh, wait, not really. EXC_AST is "fake" and EXC_USER is a flag that > indicates we came from userland. I was referring to the few hardware vectors above 0x2f00 defined in the powerpc64 trap.h: #define EXC_DEBUG 0x2f10 /* Debug trap */ #define EXC_VECAST_E0x2f20 /* Altivec Assist (Book-E) */ #define EXC_SPFPD 0x2f30 /* SPE Floating-point Data */ #define EXC_SPFPR 0x2f40 /* SPE Floating-point Round */ [...] > Should we rename EXC_LAST to EXC_END? That should avoid confusion > with the FreeBSD code that I used as a model to implement the > low-lever powerpc64 code. Why not. What about that diff, then? Index: sys/arch/macppc/macppc/machdep.c === RCS file: /OpenBSD/src/sys/arch/macppc/macppc/machdep.c,v retrieving revision 1.195 diff -u -p -r1.195 machdep.c --- sys/arch/macppc/macppc/machdep.c7 Dec 2021 17:50:44 - 1.195 +++ sys/arch/macppc/macppc/machdep.c18 May 2022 06:08:00 - @@ -169,7 +169,7 @@ initppc(u_int startkernel, u_int endkern /* * Set up trap vectors */ - for (exc = EXC_RSVD; exc <= EXC_LAST; exc += 0x100) { + for (exc = EXC_RSVD; exc < EXC_END; exc += 0x100) { switch (exc) { default: bcopy(, (void *)exc, (size_t)); @@ -212,7 +212,7 @@ initppc(u_int startkernel, u_int endkern } /* Grr, ALTIVEC_UNAVAIL is a vector not ~0xff aligned: 0x0f20 */ - bcopy(, (void *)0xf20, (size_t)); + bcopy(, (void *)EXC_VEC, (size_t)); /* * since trapsize is > 0x20, we just overwrote the EXC_PERF handler @@ -222,7 +222,7 @@ initppc(u_int startkernel, u_int endkern * do not generate EXC_PERF exceptions... */ - syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100); + syncicache((void *)EXC_RST, EXC_END - EXC_RST); /* * Now enable translation (and machine checks/recoverable interrupts). Index: sys/arch/powerpc/include/trap.h === RCS file: /OpenBSD/src/sys/arch/powerpc/include/trap.h,v retrieving revision 1.7 diff -u -p -r1.7 trap.h --- sys/arch/powerpc/include/trap.h 26 Apr 2007 21:36:32 - 1.7 +++ sys/arch/powerpc/include/trap.h 18 May 2022 06:08:00 - @@ -58,7 +58,7 @@ #defineEXC_DLMISS 0x1100 /* Data load translation miss */ #defineEXC_DSMISS 0x1200 /* Data store translation miss */ -#defineEXC_LAST0x2f00 /* Last possible exception vector */ +#defineEXC_END 0x3000 /* End of exception vectors */ #defineEXC_AST 0x3000 /* Fake AST vector */ Index: sys/arch/powerpc64/include/trap.h === RCS file: /OpenBSD/src/sys/arch/powerpc64/include/trap.h,v retrieving revision 1.8 diff -u -p -r1.8 trap.h --- sys/arch/powerpc64/include/trap.h 11 Mar 2021 11:17:00 - 1.8 +++ sys/arch/powerpc64/include/trap.h 18 May 2022 06:08:00 - @@ -1,3 +1,4 @@ +/* $OpenBSD$ */ /*- * SPDX-License-Identifier: BSD-4-Clause * @@ -105,7 +106,7 @@ /* POWER8 */ #define EXC_SOFT_PATCH 0x1500 /* POWER8 Soft Patch Exception */ -#defineEXC_LAST0x2f00 /* Last possible exception vector */ +#defineEXC_END 0x3000 /* End of exception vectors */ #defineEXC_AST 0x3000 /* Fake AST vector */ Index: sys/arch/powerpc64/powerpc64/machdep.c === RCS file: /OpenBSD/src/sys/arch/powerpc64/powerpc64/machdep.c,v retrieving revision 1.71 diff -u -p -r1.71 machdep.c --- sys/arch/powerpc64/powerpc64/machdep.c 6 Dec 2021 21:21:10 - 1.71 +++ sys/arch/powerpc64/powerpc64/machdep.c 18 May 2022 06:08:00 - @@ -239,7 +239,7 @@ init_powernv(void *fdt, void *tocbase) * Initialize all traps with the stub that calls the generic * trap handler. */ - for (trap = EXC_RST; trap < EXC_LAST; trap += 32) + for (trap = EXC_RST; trap < EXC_END; trap += 32) memcpy((void *)trap, trapcode, trapcodeend - trapcode); /* Hypervisor interrupts needs special handling. */ @@ -262,7 +262,7 @@ init_powernv(void *fdt, void *tocbase) *((void **)TRAP_RSTENTRY) = cpu_idle_restore_context; /* Make the stubs visible to the CPU. */ - __syncicache(EXC_RSVD, EXC_LAST - EXC_RSVD); + __syncicache(EXC_RSVD, EXC_END - EXC_RSVD); /* We're now ready to take traps. */ msr = mfmsr(); @@ -305,7 +305,7 @@ init_powernv(void *fdt, void *tocbase) /*
powerpc*: make EXC_LAST less awkward
As seen in sys/arch/powerpc64/include/trap.h, not-so-ancient PowerPC and POWER processors define exception addresses past EXC_LAST. The following diff changes EXC_LAST to no longer be the last "traditional" (0x100 bytes long) exception address, but the (conveniently page-aligned) end of the exception vectors area, and updates the pointer arithmetic accordingly. While there, this replaces a hardcoded number for the main Altivec exception with the proper symbolic constant (although the comment block following that ought to be updated). Tested on macppc, not tested on powerpc64 due to lack of hardware. Index: sys/arch/macppc/macppc/machdep.c === RCS file: /OpenBSD/src/sys/arch/macppc/macppc/machdep.c,v retrieving revision 1.195 diff -u -p -r1.195 machdep.c --- sys/arch/macppc/macppc/machdep.c7 Dec 2021 17:50:44 - 1.195 +++ sys/arch/macppc/macppc/machdep.c17 May 2022 14:56:04 - @@ -169,7 +169,7 @@ initppc(u_int startkernel, u_int endkern /* * Set up trap vectors */ - for (exc = EXC_RSVD; exc <= EXC_LAST; exc += 0x100) { + for (exc = EXC_RSVD; exc < EXC_LAST; exc += 0x100) { switch (exc) { default: bcopy(, (void *)exc, (size_t)); @@ -212,7 +212,7 @@ initppc(u_int startkernel, u_int endkern } /* Grr, ALTIVEC_UNAVAIL is a vector not ~0xff aligned: 0x0f20 */ - bcopy(, (void *)0xf20, (size_t)); + bcopy(, (void *)EXC_VEC, (size_t)); /* * since trapsize is > 0x20, we just overwrote the EXC_PERF handler @@ -222,7 +222,7 @@ initppc(u_int startkernel, u_int endkern * do not generate EXC_PERF exceptions... */ - syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100); + syncicache((void *)EXC_RST, EXC_LAST - EXC_RST); /* * Now enable translation (and machine checks/recoverable interrupts). Index: sys/arch/powerpc/include/trap.h === RCS file: /OpenBSD/src/sys/arch/powerpc/include/trap.h,v retrieving revision 1.7 diff -u -p -r1.7 trap.h --- sys/arch/powerpc/include/trap.h 26 Apr 2007 21:36:32 - 1.7 +++ sys/arch/powerpc/include/trap.h 17 May 2022 14:56:04 - @@ -58,7 +58,8 @@ #defineEXC_DLMISS 0x1100 /* Data load translation miss */ #defineEXC_DSMISS 0x1200 /* Data store translation miss */ -#defineEXC_LAST0x2f00 /* Last possible exception vector */ +#defineEXC_LAST0x3000 /* End of last possible exception + vector */ #defineEXC_AST 0x3000 /* Fake AST vector */ Index: sys/arch/powerpc64/include/trap.h === RCS file: /OpenBSD/src/sys/arch/powerpc64/include/trap.h,v retrieving revision 1.8 diff -u -p -r1.8 trap.h --- sys/arch/powerpc64/include/trap.h 11 Mar 2021 11:17:00 - 1.8 +++ sys/arch/powerpc64/include/trap.h 17 May 2022 14:56:04 - @@ -1,3 +1,4 @@ +/* $OpenBSD$ */ /*- * SPDX-License-Identifier: BSD-4-Clause * @@ -105,7 +106,8 @@ /* POWER8 */ #define EXC_SOFT_PATCH 0x1500 /* POWER8 Soft Patch Exception */ -#defineEXC_LAST0x2f00 /* Last possible exception vector */ +#defineEXC_LAST0x3000 /* End of last possible exception + vector */ #defineEXC_AST 0x3000 /* Fake AST vector */
pf: remove unused include files
sys/net/pf.c r1.968 added a call to m_print() #ifdef DDB in a troublesome situation. Once the root cause of the problem was fixed, the DDB-specific code path was removed in r1.970, but the added includes were kept, although nothing in pf.c depends on DDB anymore. Index: pf.c === RCS file: /OpenBSD/src/sys/net/pf.c,v retrieving revision 1.1129 diff -u -p -r1.1129 pf.c --- pf.c5 May 2022 16:44:22 - 1.1129 +++ pf.c17 May 2022 18:38:34 - @@ -103,11 +103,6 @@ struct pfsync_deferral; #endif /* NPFSYNC > 0 */ -#ifdef DDB -#include -#include -#endif - /* * Global variables */
riscv64: minor tweaks to sig_machdep.c
Two simple changes here: - dumpframe() is not used by anything. I opted to remove it, but it could be wrapped in #if 0 or #ifdef DEBUG if people want to keep it around. - the /* NOTREACHED */ comment in sendsig() is obviously reachable, so remove it and update the comment to match the new world order. Completely untested (see a trend there?) Index: sig_machdep.c === RCS file: /OpenBSD/src/sys/arch/riscv64/riscv64/sig_machdep.c,v retrieving revision 1.9 diff -u -p -r1.9 sig_machdep.c --- sig_machdep.c 6 Oct 2021 15:46:03 - 1.9 +++ sig_machdep.c 21 Mar 2022 20:21:57 - @@ -84,24 +84,6 @@ process_frame(struct proc *p) return p->p_addr->u_pcb.pcb_tf; } -void dumpframe (char *msg, struct trapframe *tf, void *p) -{ - int i; - printf("%s\n",msg); - printf("pc %lx ra %lx sp %lx tp %lx\n", tf->tf_sepc, tf->tf_ra, tf->tf_sp, tf->tf_tp); - for(i = 0; i < 7; i++) - printf("%st%d %lx", (i==0)?"":", ", i, tf->tf_t[i]); - printf("\n"); - for(i = 0; i < 12; i++) - printf("%ss%d %lx", (i==0)?"":", ", i, tf->tf_s[i]); - printf("\n"); - for(i = 0; i < 8; i++) - printf("%sa%d %lx", (i==0)?"":", ", i, tf->tf_a[i]); - printf("\n"); - if (p != NULL) - printf("fp %p\n", p); -} - /* * Send an interrupt to process. * @@ -176,10 +158,10 @@ sendsig(sig_t catcher, int sig, sigset_t frame.sf_sc.sc_cookie = (long)>sf_sc ^ p->p_p->ps_sigcookie; if (copyout(, fp, sizeof(frame)) != 0) { /* -* Process has trashed its stack; give it an illegal -* instruction to halt it in its tracks. +* Process has trashed its stack; alert caller which +* will give it an illegal instruction to halt it in +* its tracks. */ - /* NOTREACHED */ return 1; }
riscv64: fix kernel longjmp
Unlike userland, the OpenBSD kernel longjmp() function does not take a return value for setjmp as second argument, but is guaranteed to return nonzero. The following diff makes sure the code matches this expectation. Completely untested, yadda yadda. Index: support.S === RCS file: /OpenBSD/src/sys/arch/riscv64/riscv64/support.S,v retrieving revision 1.2 diff -u -p -r1.2 support.S --- support.S 12 May 2021 01:20:52 - 1.2 +++ support.S 21 Mar 2022 20:02:03 - @@ -58,7 +58,7 @@ ENTRY(setjmp) sd s11, (11 * 8)(a0) sd ra, (12 * 8)(a0) - /* Return value */ + /* Return zero */ li a0, 0 ret END(setjmp) @@ -83,7 +83,7 @@ ENTRY(longjmp) ld s11, (11 * 8)(a0) ld ra, (12 * 8)(a0) - /* Load the return value */ - mv a0, a1 + /* Return nonzero */ + li a0, 1 ret END(longjmp)
riscv64: faster setregs()
The current state of the kernel starts userland processes with register a0 pointing to the stack, with a comment mentioning this is copied from FreeBSD. But while FreeBSD userland startup code (lib/csu) depends on this, OpenBSD binaries do not need this. Thus, don't bother setting up a0 upon startup. Completely untested. Index: machdep.c === RCS file: /OpenBSD/src/sys/arch/riscv64/riscv64/machdep.c,v retrieving revision 1.26 diff -u -p -r1.26 machdep.c --- machdep.c 14 Sep 2021 12:03:49 - 1.26 +++ machdep.c 21 Mar 2022 19:58:15 - @@ -418,7 +418,6 @@ setregs(struct proc *p, struct exec_pack tf->tf_sstatus |= SSTATUS_FS_OFF; memset(tf, 0, sizeof(*tf)); - tf->tf_a[0] = stack; // XXX Inherited from FreeBSD. Why? tf->tf_sp = STACKALIGN(stack); tf->tf_ra = pack->ep_entry; tf->tf_sepc = pack->ep_entry;
riscv64: adjust VM_MIN_ADDRESS
A long, long time ago (I think it was late 2003), OpenBSD/i386 was vulnerable to a trusted-yet-NULL pointer dereference in the agp code. The attack involved using mmap(2) with MAP_FIXED and a hint of zero. Shortly afterwards, in addition to fixing the overtrusting code, it was decided never to allow mmap(2) to allow address zero to get mapped, by never making VM_MIN_ADDRESS equal to zero (I actually argued for this change to only be applied to platforms with shared kernel/userland address spaces, but the party's line prevailed), which is why VM_MIN_ADDRESS is nowadays PAGE_SIZE instead of zero. Except on riscv64. The following diff adjusts VM_MIN_ADDRESS to follow the party's line. Completely untested due to lack of hardware. Index: vmparam.h === RCS file: /OpenBSD/src/sys/arch/riscv64/include/vmparam.h,v retrieving revision 1.5 diff -u -p -r1.5 vmparam.h --- vmparam.h 2 Jul 2021 10:42:22 - 1.5 +++ vmparam.h 21 Mar 2022 19:49:00 - @@ -111,8 +111,7 @@ * VM_MIN_USER_ADDRESS and VM_MAX_USER_ADDRESS define the start and end of the * user address space. */ -// XXX OpenBSD/arm64 starts VM_MIN_ADDRESS from PAGE_SIZE. Why? -#defineVM_MIN_ADDRESS (0xUL) +#defineVM_MIN_ADDRESS ((vaddr_t)PAGE_SIZE) #defineVM_MAX_ADDRESS (0xUL) #defineVM_MIN_KERNEL_ADDRESS (0xffc0UL)
riscv64: simplify
The riscv64 was likely copied from an architecture providing optimized byte-swapping code (I'd bet arm64), but doesn't have any such optimization, and copies the MI code. Acknowledge this by dropping the __HAVE_MD_SWAP define to get the MI code for free, rather than duplicating it. Completely untested due to lack of applicable hardware. Index: endian.h === RCS file: /OpenBSD/src/sys/arch/riscv64/include/endian.h,v retrieving revision 1.2 diff -u -p -r1.2 endian.h --- endian.h12 May 2021 01:20:52 - 1.2 +++ endian.h21 Mar 2022 19:47:43 - @@ -19,51 +19,11 @@ #ifndef _MACHINE_ENDIAN_H_ #define _MACHINE_ENDIAN_H_ -#ifndef __FROM_SYS__ENDIAN -#include -#endif - -static __inline __uint16_t -__swap16md(__uint16_t _x) -{ - __uint32_t ret; - ret = ((_x >> 8) | ((_x << 8) & 0xff00)); - - return ((__uint16_t)ret); -} - -static __inline __uint32_t -__swap32md(__uint32_t _x) -{ - return ((_x >> 24) | ((_x >> 8) & 0xff00) | ((_x << 8) & 0xff) | - ((_x << 24) & 0xff00)); -} - -static __inline __uint64_t -__swap64md(__uint64_t _x) -{ - __uint64_t ret; - - ret = (_x >> 56); - ret |= ((_x >> 40) & 0xff00); - ret |= ((_x >> 24) & 0xff); - ret |= ((_x >> 8) & 0xff00); - ret |= ((_x << 8) & ((__uint64_t)0xff << 32)); - ret |= ((_x << 24) & ((__uint64_t)0xff << 40)); - ret |= ((_x << 40) & ((__uint64_t)0xff << 48)); - ret |= (_x << 56); - - return (ret); -} - -/* Tell sys/endian.h we have MD variants of the swap macros. */ -#define __HAVE_MD_SWAP - - #define _BYTE_ORDER _LITTLE_ENDIAN #define__STRICT_ALIGNMENT #ifndef __FROM_SYS__ENDIAN #include #endif + #endif /* _MACHINE_ENDIAN_H_ */
constify *_hw_if
The following diff makes {audio,midi,radio,video}_hw_if structs in the kernel const, in order to move them to rodata. Index: share/man/man9/audio.9 === RCS file: /OpenBSD/src/share/man/man9/audio.9,v retrieving revision 1.29 diff -u -p -r1.29 audio.9 --- share/man/man9/audio.9 13 Sep 2019 15:47:47 - 1.29 +++ share/man/man9/audio.9 21 Mar 2022 12:08:58 - @@ -104,7 +104,7 @@ when the latter calls This call is: .Bd -literal -offset indent struct device * -audio_attach_mi(struct audio_hw_if *ahwp, void *hdl, +audio_attach_mi(const struct audio_hw_if *ahwp, void *hdl, struct device *dev); .Ed .Pp Index: share/man/man9/radio.9 === RCS file: /OpenBSD/src/share/man/man9/radio.9,v retrieving revision 1.11 diff -u -p -r1.11 radio.9 --- share/man/man9/radio.9 31 Aug 2016 16:54:33 - 1.11 +++ share/man/man9/radio.9 21 Mar 2022 12:08:58 - @@ -53,7 +53,7 @@ when the latter calls This call should be .Bd -literal .Ft void -.Fn radio_attach_mi "struct radio_hw_if *rhwp" "void *hdlp" \ +.Fn radio_attach_mi "const struct radio_hw_if *rhwp" "void *hdlp" \ "struct device * dev" .Ed .Pp Index: sys/arch/hppa/gsc/harmony.c === RCS file: /OpenBSD/src/sys/arch/hppa/gsc/harmony.c,v retrieving revision 1.37 diff -u -p -r1.37 harmony.c --- sys/arch/hppa/gsc/harmony.c 13 Mar 2022 08:04:38 - 1.37 +++ sys/arch/hppa/gsc/harmony.c 21 Mar 2022 12:08:58 - @@ -73,7 +73,7 @@ int harmony_trigger_output(void *, v int harmony_trigger_input(void *, void *, void *, int, void (*intr)(void *), void *, struct audio_params *); -struct audio_hw_if harmony_sa_hw_if = { +const struct audio_hw_if harmony_sa_hw_if = { harmony_open, harmony_close, harmony_set_params, Index: sys/arch/luna88k/cbus/nec86.c === RCS file: /OpenBSD/src/sys/arch/luna88k/cbus/nec86.c,v retrieving revision 1.4 diff -u -p -r1.4 nec86.c --- sys/arch/luna88k/cbus/nec86.c 16 Feb 2022 06:21:18 - 1.4 +++ sys/arch/luna88k/cbus/nec86.c 21 Mar 2022 12:08:58 - @@ -67,7 +67,7 @@ * Define our interface to the higher level audio driver. */ -struct audio_hw_if nec86_hw_if = { +const struct audio_hw_if nec86_hw_if = { .open = nec86hw_open, .close = nec86hw_close, .set_params = nec86hw_set_params, Index: sys/arch/luna88k/cbus/nec86var.h === RCS file: /OpenBSD/src/sys/arch/luna88k/cbus/nec86var.h,v retrieving revision 1.1 diff -u -p -r1.1 nec86var.h --- sys/arch/luna88k/cbus/nec86var.h28 Dec 2014 13:03:18 - 1.1 +++ sys/arch/luna88k/cbus/nec86var.h21 Mar 2022 12:08:58 - @@ -55,7 +55,7 @@ struct nec86_softc { int sc_intlevel; }; -extern struct audio_hw_if nec86_hw_if; +extern const struct audio_hw_if nec86_hw_if; intnec86_probesubr(bus_space_tag_t, bus_space_handle_t, bus_space_handle_t); void nec86_attachsubr(struct nec86_softc *); Index: sys/arch/macppc/dev/aoa.c === RCS file: /OpenBSD/src/sys/arch/macppc/dev/aoa.c,v retrieving revision 1.13 diff -u -p -r1.13 aoa.c --- sys/arch/macppc/dev/aoa.c 13 Mar 2022 12:33:01 - 1.13 +++ sys/arch/macppc/dev/aoa.c 21 Mar 2022 12:08:58 - @@ -65,7 +65,7 @@ struct cfdriver aoa_cd = { NULL, "aoa", DV_DULL }; -struct audio_hw_if aoa_hw_if = { +const struct audio_hw_if aoa_hw_if = { i2s_open, i2s_close, i2s_set_params, Index: sys/arch/macppc/dev/awacs.c === RCS file: /OpenBSD/src/sys/arch/macppc/dev/awacs.c,v retrieving revision 1.36 diff -u -p -r1.36 awacs.c --- sys/arch/macppc/dev/awacs.c 13 Mar 2022 12:33:01 - 1.36 +++ sys/arch/macppc/dev/awacs.c 21 Mar 2022 12:08:58 - @@ -126,7 +126,7 @@ struct cfdriver awacs_cd = { NULL, "awacs", DV_DULL }; -struct audio_hw_if awacs_hw_if = { +const struct audio_hw_if awacs_hw_if = { awacs_open, awacs_close, awacs_set_params, Index: sys/arch/macppc/dev/daca.c === RCS file: /OpenBSD/src/sys/arch/macppc/dev/daca.c,v retrieving revision 1.12 diff -u -p -r1.12 daca.c --- sys/arch/macppc/dev/daca.c 13 Mar 2022 12:33:01 - 1.12 +++ sys/arch/macppc/dev/daca.c 21 Mar 2022 12:08:58 - @@ -71,7 +71,7 @@ struct cfdriver daca_cd = { NULL, "daca", DV_DULL }; -struct audio_hw_if daca_hw_if = { +const struct audio_hw_if daca_hw_if = { i2s_open, i2s_close, i2s_set_params, Index: sys/arch/macppc/dev/onyx.c
Re: fix boot timeout on arm64
> This issue has been fixed somewhat recently in U-Boot. It only > happens if you connect a USB keyboard to the machine. With the > exception of Apple machines and possibly the Raspberry Pi, I expect > most people to use a serial console on arm64 (and armv7 and riscv64) > machines. And Apple machines will have a fixed U-Boot. > > Note that this bug not only affects the timeout. It makes loading the > kernel from disk slow as well. So we probably should patch the U-Boot > version we ship and/or update to U-Boot 2022.04 when it is released in > a few weeks. That would be a good idea. > It may still be worth doing something like this, but would a middle > groun of making it loop something like a 100 times be an option? Using 10 is already the middle ground between the existing code using 1000 and the pre-1999 behaviour of checking on every iteration, i.e. 1. Until an U-Boot upgrade is available, using 100 would cause a delay of 8 seconds between timeout checks.
fix boot timeout on arm64
By default (with no override in /etc/boot.conf), the arm64 boot loader will attempt to boot the kernel after a 5 second timeout. On the RPi 4b here, it will indeed boot the kernel, but after about 80 seconds. The reason for this delay is that there is logic in the boot code, while waiting for keystrokes, to limit the timeout check to "only once every 1000 times the console reports no keystroke". That logic was introduced almost 23 years ago to cope with some slow i386 BIOses. However, when there is no console activity, the EFI routine to check for a keystroke will itself wait for about 80 millisecond before returning failure, which in turn causes the timeout check to be performed only once every 80 seconds. Bummer. The following diff introduces a compile-time symbol to reduce the loop counter from 1000 to 10, and enables this on arm64. This results in accurate timeout processing, and the system correctly boots after 5 seconds of idleness. That change might be needed on some other systems (armv7, riscv64?) as well. Index: arch/arm64/stand/efiboot/Makefile === RCS file: /OpenBSD/src/sys/arch/arm64/stand/efiboot/Makefile,v retrieving revision 1.15 diff -u -p -r1.15 Makefile --- arch/arm64/stand/efiboot/Makefile 14 Mar 2022 19:09:32 - 1.15 +++ arch/arm64/stand/efiboot/Makefile 17 Mar 2022 10:53:34 - @@ -49,6 +49,7 @@ CPPFLAGS+=-I${EFIDIR}/include -I${EFIDI CPPFLAGS+= -D_STANDALONE CPPFLAGS+= -DSMALL -DSLOW -DNOBYFOUR -D__INTERNAL_LIBSA_CREAD CPPFLAGS+= -DNEEDS_HEAP_H -DMDRANDOM -DFWRANDOM +CPPFLAGS+= -DSLOW_CNISCHAR COPTS+=-Wno-attributes -Wno-format COPTS+=-ffreestanding -fno-stack-protector COPTS+=-fshort-wchar -fPIC -fno-builtin Index: arch/arm64/stand/efiboot/conf.c === RCS file: /OpenBSD/src/sys/arch/arm64/stand/efiboot/conf.c,v retrieving revision 1.36 diff -u -p -r1.36 conf.c --- arch/arm64/stand/efiboot/conf.c 14 Mar 2022 19:09:32 - 1.36 +++ arch/arm64/stand/efiboot/conf.c 17 Mar 2022 10:53:34 - @@ -46,7 +46,7 @@ #include "efipxe.h" #include "softraid_arm64.h" -const char version[] = "1.8"; +const char version[] = "1.9"; intdebug = 0; struct fs_ops file_system[] = { Index: stand/boot/cmd.c === RCS file: /OpenBSD/src/sys/stand/boot/cmd.c,v retrieving revision 1.68 diff -u -p -r1.68 cmd.c --- stand/boot/cmd.c24 Oct 2021 17:49:19 - 1.68 +++ stand/boot/cmd.c17 Mar 2022 10:53:35 - @@ -238,6 +238,18 @@ whatcmd(const struct cmd_table **ct, cha return q; } +/* + * If there is a timeout, we want to honour it as best as possible, but + * the getsecs() call might be expensive, so we don't want to check for + * timeout too frequently... unless cnischar() itself takes a long time + * to report no activity. + */ +#ifdef SLOW_CNISCHAR +#defineTIMEOUT_LOOP10 +#else +#defineTIMEOUT_LOOP1000 +#endif + static int readline(char *buf, size_t n, int to) { @@ -254,10 +266,9 @@ readline(char *buf, size_t n, int to) if (debug > 2) printf ("readline: timeout(%d) at %u\n", to, tt); #endif - /* check for timeout expiration less often - (for some very constrained archs) */ + /* Check for timeout expiration */ while (!cnischar()) - if (!(i++ % 1000) && (getsecs() >= tt)) + if (!(i++ % TIMEOUT_LOOP) && (getsecs() >= tt)) break; if (!cnischar()) {
network drivers' manual page consistency
I have noticed that a few manual page for network drivers mention the duplex options in square brackets. This is inconsistent with the vast majority of the network drivers' manual pages, so let's homogeneize this. Index: bse.4 === RCS file: /OpenBSD/src/share/man/man4/bse.4,v retrieving revision 1.5 diff -u -p -r1.5 bse.4 --- bse.4 8 Sep 2021 20:29:21 - 1.5 +++ bse.4 17 Mar 2022 09:14:08 - @@ -37,19 +37,19 @@ driver supports several media types, whi command. The supported media types are: .Bl -tag -width "media" -offset indent -.It media autoselect +.It Cm media No autoselect Attempt to autoselect the media type (default) -.It media 1000baseT mediaopt full-duplex +.It Cm media No 1000baseT Cm mediaopt No full-duplex Use 1000baseT on copper, full duplex -.It media 1000baseT Op mediaopt half-duplex +.It Cm media No 1000baseT Cm mediaopt No half-duplex Use 1000baseT on copper, half duplex -.It media 100baseTX mediaopt full-duplex +.It Cm media No 100baseTX Cm mediaopt No full-duplex Use 100baseTX, full duplex -.It media 100baseTX Op mediaopt half-duplex +.It Cm media No 100baseTX Cm mediaopt No half-duplex Use 100baseTX, half duplex -.It media 10baseT mediaopt full-duplex +.It Cm media No 10baseT Cm mediaopt No full-duplex Use 10baseT, full duplex -.It media 10baseT Op mediaopt half-duplex +.It Cm media No 10baseT Cm mediaopt No half-duplex Use 10baseT, half duplex .El .Sh SEE ALSO Index: cas.4 === RCS file: /OpenBSD/src/share/man/man4/cas.4,v retrieving revision 1.9 diff -u -p -r1.9 cas.4 --- cas.4 8 Sep 2021 20:29:21 - 1.9 +++ cas.4 17 Mar 2022 09:14:08 - @@ -54,23 +54,23 @@ driver supports several media types, whi command. The supported media types are: .Bl -tag -width "media" -offset indent -.It media autoselect +.It Cm media No autoselect Attempt to autoselect the media type (default) -.It media 1000baseT mediaopt full-duplex +.It Cm media No 1000baseT Cm mediaopt No full-duplex Use 1000baseT on copper, full duplex -.It media 1000baseT Op mediaopt half-duplex +.It Cm media No 1000baseT Cm mediaopt No half-duplex Use 1000baseT on copper, half duplex -.It media 1000baseSX mediaopt full-duplex +.It Cm media No 1000baseSX Cm mediaopt No full-duplex Use 1000baseSX on fiber, full duplex -.It media 1000baseSX Op mediaopt half-duplex +.It Cm media No 1000baseSX Cm mediaopt No half-duplex Use 1000baseSX on fiber, half duplex -.It media 100baseTX mediaopt full-duplex +.It Cm media No 100baseTX Cm mediaopt No full-duplex Use 100baseTX, full duplex -.It media 100baseTX Op mediaopt half-duplex +.It Cm media No 100baseTX Cm mediaopt No half-duplex Use 100baseTX, half duplex -.It media 10baseT mediaopt full-duplex +.It Cm media No 10baseT Cm mediaopt No full-duplex Use 10baseT, full duplex -.It media 10baseT Op mediaopt half-duplex +.It Cm media No 10baseT Cm mediaopt No half-duplex Use 10baseT, half duplex .El .Sh SEE ALSO Index: dwge.4 === RCS file: /OpenBSD/src/share/man/man4/dwge.4,v retrieving revision 1.5 diff -u -p -r1.5 dwge.4 --- dwge.4 8 Sep 2021 20:29:21 - 1.5 +++ dwge.4 17 Mar 2022 09:14:08 - @@ -38,15 +38,15 @@ driver supports several media types, whi command. The supported media types are: .Bl -tag -width "media" -offset indent -.It media autoselect +.It Cm media No autoselect Attempt to autoselect the media type (default) -.It media 1000baseT mediaopt full-duplex +.It Cm media No 1000baseT Cm mediaopt No full-duplex Use 1000baseT on copper, full duplex -.It media 1000baseT Op mediaopt half-duplex +.It Cm media No 1000baseT Cm mediaopt No half-duplex Use 1000baseT on copper, half duplex -.It media 100baseTX mediaopt full-duplex +.It Cm media No 100baseTX Cm mediaopt No full-duplex Use 100baseTX, full duplex -.It media 100baseTX Op mediaopt half-duplex +.It Cm media No 100baseTX Cm mediaopt No half-duplex Use 100baseTX, half duplex .El .Sh SEE ALSO Index: dwxe.4 === RCS file: /OpenBSD/src/share/man/man4/dwxe.4,v retrieving revision 1.2 diff -u -p -r1.2 dwxe.4 --- dwxe.4 8 Sep 2021 20:29:21 - 1.2 +++ dwxe.4 17 Mar 2022 09:14:08 - @@ -37,15 +37,15 @@ driver supports several media types, whi command. The supported media types are: .Bl -tag -width "media" -offset indent -.It media autoselect +.It Cm media No autoselect Attempt to autoselect the media type (default) -.It media 1000baseT mediaopt full-duplex +.It Cm media No 1000baseT Cm mediaopt No full-duplex Use 1000baseT on copper, full duplex -.It media 1000baseT Op mediaopt half-duplex +.It Cm media No 1000baseT Cm mediaopt No half-duplex Use 1000baseT on copper, half duplex -.It media 100baseTX mediaopt full-duplex +.It Cm media No 100baseTX Cm mediaopt No
bwfm@sdmmc: use symbolic constants for matching
The following diff declares the various devices bwfm@sdmmc checks for, and introduces no functional change. Index: if_bwfm_sdio.c === RCS file: /OpenBSD/src/sys/dev/sdmmc/if_bwfm_sdio.c,v retrieving revision 1.42 diff -u -p -r1.42 if_bwfm_sdio.c --- if_bwfm_sdio.c 2 Nov 2021 14:49:53 - 1.42 +++ if_bwfm_sdio.c 17 Mar 2022 07:59:57 - @@ -45,6 +45,7 @@ #include +#include #include #include @@ -207,27 +208,27 @@ bwfm_sdio_match(struct device *parent, v /* Look for Broadcom. */ cis = >sc->sc_fn0->cis; - if (cis->manufacturer != 0x02d0) + if (cis->manufacturer != SDMMC_VENDOR_BROADCOM) return 0; /* Look for supported chips. */ switch (cis->product) { - case 0x4324: - case 0x4330: - case 0x4334: - case 0x4329: - case 0x4335: - case 0x4339: - case 0x4345: - case 0x4354: - case 0x4356: - case 0x4359: - case 0xa887:/* BCM43143 */ - case 0xa94c:/* BCM43340 */ - case 0xa94d:/* BCM43341 */ - case 0xa962:/* BCM43362 */ - case 0xa9a6:/* BCM43430 */ - case 0xa9bf:/* BCM43364 */ + case SDMMC_PRODUCT_BROADCOM_BCM4324: + case SDMMC_PRODUCT_BROADCOM_BCM4329: + case SDMMC_PRODUCT_BROADCOM_BCM4330: + case SDMMC_PRODUCT_BROADCOM_BCM4334: + case SDMMC_PRODUCT_BROADCOM_BCM4335: + case SDMMC_PRODUCT_BROADCOM_BCM4339: + case SDMMC_PRODUCT_BROADCOM_BCM4345: + case SDMMC_PRODUCT_BROADCOM_BCM4354: + case SDMMC_PRODUCT_BROADCOM_BCM4356: + case SDMMC_PRODUCT_BROADCOM_BCM4359: + case SDMMC_PRODUCT_BROADCOM_BCM43143: + case SDMMC_PRODUCT_BROADCOM_BCM43340: + case SDMMC_PRODUCT_BROADCOM_BCM43341: + case SDMMC_PRODUCT_BROADCOM_BCM43362: + case SDMMC_PRODUCT_BROADCOM_BCM43430: + case SDMMC_PRODUCT_BROADCOM_BCM43364: break; default: return 0; Index: sdmmcdevs === RCS file: /OpenBSD/src/sys/dev/sdmmc/sdmmcdevs,v retrieving revision 1.8 diff -u -p -r1.8 sdmmcdevs --- sdmmcdevs 11 May 2007 17:16:16 - 1.8 +++ sdmmcdevs 17 Mar 2022 07:59:57 - @@ -24,6 +24,7 @@ vendor CGUYS 0x0092 C-guys, Inc. vendor TOSHIBA 0x0098 Toshiba vendor SOCKETCOM 0x0104 Socket Communications, Inc. vendor ATHEROS 0x0271 Atheros +vendor BROADCOM0x02d0 Broadcom vendor SYCHIP 0x02db SyChip Inc. vendor SPECTEC 0x02fe Spectec Computer Co., Ltd vendor GLOBALSAT 0x0501 Globalsat Technology Co. @@ -42,6 +43,24 @@ product ATHEROS AR6001_80x0108 AR6001 product ATHEROSAR6001_90x0109 AR6001 product ATHEROSAR6001_a0x010a AR6001 product ATHEROSAR6001_b0x010b AR6001 + +/* Broadcom */ +productBROADCOM BCM43240x4324 BCM4324 +productBROADCOM BCM43290x4329 BCM4329 +productBROADCOM BCM43300x4330 BCM4330 +productBROADCOM BCM43340x4334 BCM4334 +productBROADCOM BCM43350x4335 BCM4335 +productBROADCOM BCM43390x4339 BCM4339 +productBROADCOM BCM43450x4345 BCM4345 +productBROADCOM BCM43540x4354 BCM4354 +productBROADCOM BCM43560x4356 BCM4356 +productBROADCOM BCM43590x4359 BCM4359 +productBROADCOM BCM43143 0xa887 BCM43143 +productBROADCOM BCM43340 0xa94c BCM43340 +productBROADCOM BCM43341 0xa94d BCM43341 +productBROADCOM BCM43362 0xa962 BCM43362 +productBROADCOM BCM43430 0xa9a6 BCM43430 +productBROADCOM BCM43364 0xa9bf BCM43364 /* C-guys, Inc. */ product CGUYS TIACX100 0x0001 TI ACX100 SD-Link11b WiFi Card
sdmmc: simplify devlist2h
sys/dev/sdmmc/devlist2h.awk was based upon sys/dev/pcmcia/devlist2h.awk. The latter contains code to define optional CIS tuple overrides, which are not used in sdmmc - there is only one override and it is applied in sdmmc_check_cis_quirks(). The following diff removes this feature from devlist2h. As a result, there will no longer be SDMMC_CIS_* defines in sdmmcdevs.h. Index: devlist2h.awk === RCS file: /OpenBSD/src/sys/dev/sdmmc/devlist2h.awk,v retrieving revision 1.2 diff -u -p -r1.2 devlist2h.awk --- devlist2h.awk 2 Jun 2006 21:16:44 - 1.2 +++ devlist2h.awk 17 Mar 2022 07:59:44 - @@ -80,7 +80,6 @@ NR == 1 { $1 == "vendor" { nvendors++ - vendorindex[$2] = nvendors; # record index for this name, for later. vendors[nvendors, 1] = $2; # name vendors[nvendors, 2] = $3; # id printf("#define\tSDMMC_VENDOR_%s\t%s\t", vendors[nvendors, 1], @@ -95,45 +94,8 @@ $1 == "product" { products[nproducts, 1] = $2;# vendor name products[nproducts, 2] = $3;# product id products[nproducts, 3] = $4;# id - - f = 5; - - if ($4 == "{") { - products[nproducts, 3] = "SDMMC_PRODUCT_INVALID" - z = "{ " - for (i = 0; i < 4; i++) { - if (f <= NF) { - gsub("", " ", $f) - gsub("", "\t", $f) - gsub("", "\n", $f) - z = z $f " " - f++ - } - else { - if (i == 3) - z = z "NULL " - else - z = z "NULL, " - } - } - products[nproducts, 4] = z $f - f++ - } - else { - products[nproducts, 4] = "{ NULL, NULL, NULL, NULL }" - } - printf("#define\tSDMMC_CIS_%s_%s\t%s\n", - products[nproducts, 1], products[nproducts, 2], - products[nproducts, 4]) > hfile printf("#define\tSDMMC_PRODUCT_%s_%s\t%s\n", products[nproducts, 1], products[nproducts, 2], products[nproducts, 3]) > hfile - -# products[nproducts, 5] = collectline(f, line) -# -# printf("#define\tSDMMC_STR_%s_%s\t\"%s\"\n", -# products[nproducts, 1], products[nproducts, 2], -# products[nproducts, 5]) > hfile - next } {
Re: add -k / --keep for gzip(1)
> I think this makes sense if only for better GNU gzip compatibility. > OK millert@ But does the `-k' flag needs to be added to compress(1) too?
Re: makefs, inodes, the universe and everything
> Should the default for makefs not be changed, rather than requiring an > argument? I'm not fond of that idea, but why not, as long as it gets documented. > 100 seem extremely small. Imagine a person installing a machine with 5 > drives. Our installer lets people iterate over all their drives. MAKEDEV > will create 32 inodes per drive. For 5 drives, that 160 inodes, plus the > 10 or so /tmp files created during build... it is way more than the 100 you > propose as being satisfactory. Even a person with two drives will use 64 > inodes, leaving 36 for the script, but if someone had 3 drives it will blow > up. 100 was a starting point to start the discussion. Using a larger value will probably cause more miniroot geometries to be updated, but that's a once-in-10-years kind of change anyway. > I guess this went quietly off the rails when we switched to using > makefs. This "minimalism" decision it makes is not really compatible > with our wish to make disk device nodes on the fly. Indeed. > So should it be -f 200, or 250, and/or should the minimum default built-in > be changed? Basically 100% of makefs use is for our install media, is it not > right to change the default? Well it would be interesting to hear from people using makefs for other purposes. Are there any?
makefs, inodes, the universe and everything
As you may vaguely remember, I have plans to clean up MAKEDEV a bit, which have the side effect of removing many unneeded device nodes from the ramdisk target, used on the installation media. Doing this will in turn expose a slight difference in filesystem creation between the pre-makefs(8) world order (using newfs and populating a vnd) and the current usage of makefs: while newfs will create a fixed number of inodes, based upon the geometry parameters (one inode per four fragments), makefs is lazier and will only build "enough" inodes, where "enough" means that the number of available inodes will be rounded to the number of inodes in a cylinder group. tl;dr: by removing unneeded MAKEDEV entries, some platforms will end up with makefs creating a file system with 256 inodes, of which about 250 are used, and installation will misbehave in interesting ways due to the lack of free inodes. There are two ways to address this: 1. fix makefs to initialize inodes in all cylinder groups. 2. let the `-f' option of makefs, used to specify a given number of free inodes, be accepted even when using a fixed geometry. The following diff implements choice #2 (which is the easiest to do), and adds `-f 100' to require 100 free inodes, in every installation media. The advantage, IMHO, of going this way, is that if the geometry does not allow for enough free inodes, building installation media will fail, and this will get noticed quickly. Case in point: at the moment, the alpha bsd.rd uses a geometry providing up to 384 inodes, of which 277 are used. Building with -f 100, requiring thus 377 inodes, completes, while trying -f 120 will fail: makefs -o disklabel=rdroot,minfree=0,density=8192 -f 120 mr.fs mr.fs.d Calculated size of `mr.fs': 2940928 bytes, 397 inodes Extent size set to 8192 mr.fs: 2.8MB (5744 sectors) block size 8192, fragment size 1024 using 1 cylinder groups of 2.80MB, 359 blks, 384 inodes. super-block backups (for fsck -b #) at: 32, makefs: Image file `mr.fs' has 384 free inodes; 397 are required. makefs: Image file `mr.fs' not created. *** Error 1 in /usr/src/distrib/alpha/miniroot (Makefile:89 'mr.fs') I have not been able to test that diff on all platforms, therefore I don't know which platforms will require tweaks to their miniroot filesystem geometry to build with that "100 free inodes" requirement. Maybe the amount can be adjusted on legacy platforms. Also, the makefs diff can go in and installation media changes applied later on a tested-platform basis. In any case, keep in mind that I have upcoming changes which will free a bunch of inodes from every miniroot. Index: usr.sbin/makefs/ffs.c === RCS file: /OpenBSD/src/usr.sbin/makefs/ffs.c,v retrieving revision 1.36 diff -u -p -r1.36 ffs.c --- usr.sbin/makefs/ffs.c 11 Jan 2022 05:34:32 - 1.36 +++ usr.sbin/makefs/ffs.c 25 Feb 2022 16:47:17 - @@ -324,10 +324,9 @@ ffs_validate(const char *dir, fsnode *ro if (pp->p_fragblock == 0) errx(1, "fragment size missing in disktab"); if (fsopts->freeblocks != 0 || fsopts->freeblockpc != 0 || - fsopts->freefiles != 0 || fsopts->freefilepc != 0 || fsopts->minsize != 0 || fsopts->maxsize != 0 || fsopts->sectorsize != -1 || fsopts->size != 0) - errx(1, "-bfMmSs and disklabel are mutually exclusive"); + errx(1, "-bMmSs and disklabel are mutually exclusive"); if (ffs_opts->fsize != -1 || ffs_opts->bsize != -1) errx(1, "b/fsize and disklabel are mutually exclusive"); Index: distrib/alpha/miniroot/Makefile === RCS file: /OpenBSD/src/distrib/alpha/miniroot/Makefile,v retrieving revision 1.23 diff -u -p -r1.23 Makefile --- distrib/alpha/miniroot/Makefile 26 Jul 2021 12:47:44 - 1.23 +++ distrib/alpha/miniroot/Makefile 25 Feb 2022 16:47:17 - @@ -12,7 +12,7 @@ LISTS=${.CURDIR}/list UTILS= ${.CURDIR}/../../miniroot MRDISKTYPE=rdroot -MRMAKEFSARGS= -o disklabel=${MRDISKTYPE},minfree=0,density=8192 +MRMAKEFSARGS= -o disklabel=${MRDISKTYPE},minfree=0,density=8192 -f 100 all: ${FS} ${CDROM} Index: distrib/amd64/ramdiskA/Makefile === RCS file: /OpenBSD/src/distrib/amd64/ramdiskA/Makefile,v retrieving revision 1.16 diff -u -p -r1.16 Makefile --- distrib/amd64/ramdiskA/Makefile 26 Jul 2021 12:47:44 - 1.16 +++ distrib/amd64/ramdiskA/Makefile 25 Feb 2022 16:47:17 - @@ -30,7 +30,7 @@ ${FS}: bsd.gz rm -f vnd MRDISKTYPE=rdroot -MRMAKEFSARGS= -o disklabel=${MRDISKTYPE},minfree=0,density=4096 +MRMAKEFSARGS= -o disklabel=${MRDISKTYPE},minfree=0,density=4096 -f 100 bsd.gz: bsd.rd objcopy -S
Re: more MAKEDEV cleanup
> What happened to this? I need to split this into orthogonal diffs, and also since this will expose an issue in makefs(8), I need to polish and send a fix for makefs first...
Re: Use installboot(8) in install.md of riscv64
> Index: usr.sbin/installboot/armv7_installboot.c > === > RCS file: src/usr.sbin/installboot/armv7_installboot.c,v > retrieving revision 1.11 > diff -u -p -r1.11 armv7_installboot.c > --- usr.sbin/installboot/armv7_installboot.c 20 Jul 2021 14:51:56 - > 1.11 > +++ usr.sbin/installboot/armv7_installboot.c 2 Feb 2022 14:11:08 - > @@ -55,6 +55,19 @@ > > #include "installboot.h" > > +#if defined(__aarch64__) > +#define BOOTEFI_SRC "BOOTAA64.EFI" > +#define BOOTEFI_DST "bootaa64.efi" > +#elif defined(__arm__) > +#define BOOTEFI_SRC "BOOTARM.EFI" > +#define BOOTEFI_DST "bootarm.efi" > +#elif defined(__riscv) > +#define BOOTEFI_SRC "BOOTRISCV64.EFI" > +#define BOOTEFI_DST "bootriscv64.efi" > +#else > +#error "unhandled architecture" > +#endif Wouldn't these defines better set at the Makefile level, since there is already logic to pick different files depending upon the architecture?
[macppc] mpcpcibr buglet
On PowerMac11,2 systems, the PCIe bus attaches as: mpcpcibr0 at mainbus0 pci: u4-pcie pci0 at mpcpcibr0 bus 0 However none of the devices attached to pci0 will appear in pcidump. This is caused by an incorrect bus number during attachment of the pci(4) subdevice. The following diff queries the `bus-range' property in order to use the correct number (and also contains a bunch of whitespace and KNF fixes). With the diff below applied, the attachment becomes: mpcpcibr0 at mainbus0 pci: u4-pcie pci0 at mpcpcibr0 bus 10 and pci0 devices will appear in the pcidump output. Index: mpcpcibus.c === RCS file: /OpenBSD/src/sys/arch/macppc/pci/mpcpcibus.c,v retrieving revision 1.47 diff -u -p -r1.47 mpcpcibus.c --- mpcpcibus.c 3 Jun 2015 08:41:43 - 1.47 +++ mpcpcibus.c 2 Feb 2022 10:40:48 - @@ -168,7 +168,7 @@ mpcpcibus_find_ranges_32(struct pcibr_so sc->sc_iobus_space.bus_size = prange[found].size_lo; } - /* the mem space ranges + /* the mem space ranges * apple openfirmware always puts full * addresses in config information, * it is not necessary to have correct bus @@ -185,12 +185,12 @@ mpcpcibus_find_ranges_32(struct pcibr_so prange[i].size_lo); #endif if (base != 0) { - if ((base + size) == prange[i].phys) + if ((base + size) == prange[i].phys) size += prange[i].size_lo; else { base = prange[i].phys; size = prange[i].size_lo; - } + } } else { base = prange[i].phys; size = prange[i].size_lo; @@ -263,7 +263,7 @@ mpcpcibus_find_ranges_64(struct pcibr_so sc->sc_iobus_space.bus_size = prange[found].size_lo; } - /* the mem space ranges + /* the mem space ranges * apple openfirmware always puts full * addresses in config information, * it is not necessary to have correct bus @@ -307,7 +307,6 @@ mpcpcibrattach(struct device *parent, st struct confargs *ca = aux; struct pcibr_config *lcp; struct pcibus_attach_args pba; - int of_node = 0; char compat[32]; u_int32_t addr_offset; u_int32_t data_offset; @@ -315,41 +314,39 @@ mpcpcibrattach(struct device *parent, st int len; int rangesize; u_int32_t range_store[32]; + int busrange[2]; if (ca->ca_node == 0) { printf("invalid node on mpcpcibr config\n"); return; } - len=OF_getprop(ca->ca_node, "name", compat, sizeof (compat)); + len = OF_getprop(ca->ca_node, "name", compat, sizeof(compat)); compat[len] = '\0'; if (len > 0) printf(" %s", compat); - len=OF_getprop(ca->ca_node, "compatible", compat, - sizeof (compat)); - if (len <= 0 ) { - len=OF_getprop(ca->ca_node, "name", compat, - sizeof (compat)); + len = OF_getprop(ca->ca_node, "compatible", compat, sizeof(compat)); + if (len <= 0) { + len = OF_getprop(ca->ca_node, "name", compat, sizeof(compat)); if (len <= 0) { printf(" compatible and name not found\n"); return; } - compat[len] = 0; - if (strcmp (compat, "bandit") != 0) { + compat[len] = 0; + if (strcmp(compat, "bandit") != 0) { printf(" compatible not found and name %s found\n", compat); return; } } - compat[len] = 0; + compat[len] = 0; if ((rangesize = OF_getprop(ca->ca_node, "ranges", range_store, sizeof (range_store))) <= 0) { if (strcmp(compat, "u3-ht") == 0) { range_store[0] = 0xabb10113; /* appl U3; */ - } else + } else printf("range lookup failed, node %x\n", ca->ca_node); } - /* translate byte(s) into item count*/ lcp = >pcibr_config; @@ -363,16 +360,16 @@ mpcpcibrattach(struct device *parent, st M_DEVBUF, NULL, 0, EX_NOWAIT | EX_FILLED); if (ppc_proc_is_64b) - mpcpcibus_find_ranges_64 (sc, range_store, rangesize); + mpcpcibus_find_ranges_64(sc, range_store, rangesize); else - mpcpcibus_find_ranges_32 (sc, range_store, rangesize); + mpcpcibus_find_ranges_32(sc, range_store, rangesize); addr_offset = 0;
Re: in4_cksum changes, step 1
> The register is set to -1, all bits set, and then its upper half > is cleared. Now that the "and" has been removed, the value seems > unused. The result of the removed "and" seemed unused too. Oh, indeed, you're right, that makes things even simpler. New diff: Index: sys/arch/alpha/alpha/in_cksum.c === RCS file: /OpenBSD/src/sys/arch/alpha/alpha/in_cksum.c,v retrieving revision 1.9 diff -u -p -r1.9 in_cksum.c --- sys/arch/alpha/alpha/in_cksum.c 21 Aug 2014 14:24:08 - 1.9 +++ sys/arch/alpha/alpha/in_cksum.c 31 Jan 2022 19:39:56 - @@ -200,7 +200,7 @@ in4_cksum(struct mbuf *m, u_int8_t nxt, int clen = 0; caddr_t addr; union q_util q_util; - union l_util l_util; + union l_util l_util; struct ipovly ipov; if (nxt != 0) { @@ -212,14 +212,14 @@ in4_cksum(struct mbuf *m, u_int8_t nxt, panic("in4_cksum: bad mbuf chain"); #endif - memset(, 0, sizeof(ipov)); - - ipov.ih_len = htons(len); + ipov.ih_x1[8] = 0; ipov.ih_pr = nxt; + ipov.ih_len = htons(len); ipov.ih_src = mtod(m, struct ip *)->ip_src; ipov.ih_dst = mtod(m, struct ip *)->ip_dst; - sum += in_cksumdata((caddr_t) , sizeof(ipov)); + /* first 8 bytes are zeroes */ + sum += in_cksumdata((caddr_t) + 8, sizeof(ipov) - 8); } /* skip over unnecessary part */ @@ -241,7 +241,7 @@ in4_cksum(struct mbuf *m, u_int8_t nxt, sum += in_cksumdata(addr, mlen) << 8; else sum += in_cksumdata(addr, mlen); - + clen += mlen; len -= mlen; } Index: sys/arch/m88k/m88k/in_cksum.c === RCS file: /OpenBSD/src/sys/arch/m88k/m88k/in_cksum.c,v retrieving revision 1.4 diff -u -p -r1.4 in_cksum.c --- sys/arch/m88k/m88k/in_cksum.c 21 Aug 2014 14:24:08 - 1.4 +++ sys/arch/m88k/m88k/in_cksum.c 31 Jan 2022 19:39:56 - @@ -95,19 +95,22 @@ in4_cksum(struct mbuf *m, uint8_t nxt, i { u_int16_t *w; u_int sum = 0; - struct ipovly ipov; + union { + struct ipovly ipov; + u_int16_t w[10]; + } u; if (nxt != 0) { /* pseudo header */ - bzero(, sizeof(ipov)); - ipov.ih_len = htons(len); - ipov.ih_pr = nxt; - ipov.ih_src = mtod(m, struct ip *)->ip_src; - ipov.ih_dst = mtod(m, struct ip *)->ip_dst; - w = (u_int16_t *) - /* assumes sizeof(ipov) == 20 */ - sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; sum += w[4]; - sum += w[5]; sum += w[6]; sum += w[7]; sum += w[8]; sum += w[9]; + u.ipov.ih_x1[8] = 0; + u.ipov.ih_pr = nxt; + u.ipov.ih_len = htons(len); + u.ipov.ih_src = mtod(m, struct ip *)->ip_src; + u.ipov.ih_dst = mtod(m, struct ip *)->ip_dst; + w = u.w; + /* assumes sizeof(ipov) == 20 and first 8 bytes are zeroes */ + sum += w[4]; sum += w[5]; sum += w[6]; + sum += w[7]; sum += w[8]; sum += w[9]; } /* skip unnecessary part */ Index: sys/arch/powerpc/powerpc/in_cksum.c === RCS file: /OpenBSD/src/sys/arch/powerpc/powerpc/in_cksum.c,v retrieving revision 1.10 diff -u -p -r1.10 in_cksum.c --- sys/arch/powerpc/powerpc/in_cksum.c 22 Jul 2014 10:35:35 - 1.10 +++ sys/arch/powerpc/powerpc/in_cksum.c 31 Jan 2022 19:39:56 - @@ -87,7 +87,7 @@ in_cksum_internal(struct mbuf *m, int of * of a word spanning between this mbuf and the * last mbuf. * -* s_util.c[0] is already saved when scanning previous +* s_util.c[0] is already saved when scanning previous * mbuf. */ s_util.c[1] = *w++; @@ -254,15 +254,15 @@ in4_cksum(struct mbuf *m, uint8_t nxt, i if (nxt != 0) { /* pseudo header */ - memset(, 0, sizeof(u.ipov)); + u.ipov.ih_x1[8] = 0; + u.ipov.ih_pr = nxt; u.ipov.ih_len = htons(len); - u.ipov.ih_pr = nxt; - u.ipov.ih_src = mtod(m, struct ip *)->ip_src; + u.ipov.ih_src = mtod(m, struct ip *)->ip_src; u.ipov.ih_dst = mtod(m, struct ip *)->ip_dst; w = u.w; - /* assumes sizeof(ipov) == 20 */ - sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; sum += w[4]; - sum += w[5]; sum
Re: in4_cksum changes, step 1
> > - sum += in_cksumdata((caddr_t) , sizeof(ipov)); > > + sum += in_cksumdata((caddr_t) + 8, sizeof(ipov) - 8); > > I think this would be clearer with a comment. Sure, added one. > Please remove the trailing space that some of the changed lines have. Ok. Updated patch below. > > Index: sys/arch/sparc64/sparc64/in4_cksum.c > > + __asm volatile( > > + " lduw [%5 + 12], %1; " > > + " lduw [%5 + 16], %2; " > > " mov -1, %3; add %0, %1, %0; " > > " srl %3, 0, %3; add %0, %2, %0; " > > - " srlx %0, 32, %2; and %0, %3, %1; " > > + " srlx %0, 32, %2; " > > " add %0, %2, %0; " > > : "=r" (sum), "=" (tmp1), "=" (tmp2), "=" (tmp3) > > - : "0" (sum), "r" (w)); > > + : "0" (sum), "r" ()); > > I might be missing something, but is the temporary register %3 needed > at all? Yes, it is set to -1 and used for shifts, at the moment. Miod Index: sys/arch/alpha/alpha/in_cksum.c === RCS file: /OpenBSD/src/sys/arch/alpha/alpha/in_cksum.c,v retrieving revision 1.9 diff -u -p -r1.9 in_cksum.c --- sys/arch/alpha/alpha/in_cksum.c 21 Aug 2014 14:24:08 - 1.9 +++ sys/arch/alpha/alpha/in_cksum.c 30 Jan 2022 18:35:18 - @@ -200,7 +200,7 @@ in4_cksum(struct mbuf *m, u_int8_t nxt, int clen = 0; caddr_t addr; union q_util q_util; - union l_util l_util; + union l_util l_util; struct ipovly ipov; if (nxt != 0) { @@ -212,14 +212,14 @@ in4_cksum(struct mbuf *m, u_int8_t nxt, panic("in4_cksum: bad mbuf chain"); #endif - memset(, 0, sizeof(ipov)); - - ipov.ih_len = htons(len); + ipov.ih_x1[8] = 0; ipov.ih_pr = nxt; + ipov.ih_len = htons(len); ipov.ih_src = mtod(m, struct ip *)->ip_src; ipov.ih_dst = mtod(m, struct ip *)->ip_dst; - sum += in_cksumdata((caddr_t) , sizeof(ipov)); + /* first 8 bytes are zeroes */ + sum += in_cksumdata((caddr_t) + 8, sizeof(ipov) - 8); } /* skip over unnecessary part */ @@ -241,7 +241,7 @@ in4_cksum(struct mbuf *m, u_int8_t nxt, sum += in_cksumdata(addr, mlen) << 8; else sum += in_cksumdata(addr, mlen); - + clen += mlen; len -= mlen; } Index: sys/arch/m88k/m88k/in_cksum.c === RCS file: /OpenBSD/src/sys/arch/m88k/m88k/in_cksum.c,v retrieving revision 1.4 diff -u -p -r1.4 in_cksum.c --- sys/arch/m88k/m88k/in_cksum.c 21 Aug 2014 14:24:08 - 1.4 +++ sys/arch/m88k/m88k/in_cksum.c 30 Jan 2022 18:35:18 - @@ -95,19 +95,22 @@ in4_cksum(struct mbuf *m, uint8_t nxt, i { u_int16_t *w; u_int sum = 0; - struct ipovly ipov; + union { + struct ipovly ipov; + u_int16_t w[10]; + } u; if (nxt != 0) { /* pseudo header */ - bzero(, sizeof(ipov)); - ipov.ih_len = htons(len); - ipov.ih_pr = nxt; - ipov.ih_src = mtod(m, struct ip *)->ip_src; - ipov.ih_dst = mtod(m, struct ip *)->ip_dst; - w = (u_int16_t *) - /* assumes sizeof(ipov) == 20 */ - sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; sum += w[4]; - sum += w[5]; sum += w[6]; sum += w[7]; sum += w[8]; sum += w[9]; + u.ipov.ih_x1[8] = 0; + u.ipov.ih_pr = nxt; + u.ipov.ih_len = htons(len); + u.ipov.ih_src = mtod(m, struct ip *)->ip_src; + u.ipov.ih_dst = mtod(m, struct ip *)->ip_dst; + w = u.w; + /* assumes sizeof(ipov) == 20 and first 8 bytes are zeroes */ + sum += w[4]; sum += w[5]; sum += w[6]; + sum += w[7]; sum += w[8]; sum += w[9]; } /* skip unnecessary part */ Index: sys/arch/powerpc/powerpc/in_cksum.c === RCS file: /OpenBSD/src/sys/arch/powerpc/powerpc/in_cksum.c,v retrieving revision 1.10 diff -u -p -r1.10 in_cksum.c --- sys/arch/powerpc/powerpc/in_cksum.c 22 Jul 2014 10:35:35 - 1.10 +++ sys/arch/powerpc/powerpc/in_cksum.c 30 Jan 2022 18:35:18 - @@ -87,7 +87,7 @@ in_cksum_internal(struct mbuf *m, int of * of a word spanning between this mbuf and the * last mbuf. * -* s_util.c[0] is already saved when scanning previous +* s_util.c[0] is already saved when scanning previous
Re: passwd(1) does not need librpcsvc
> Hi, > > linking with librpcsvc should be superfluous now. Then you should also update DPADD to remove $(LIBRPCSVC}... > Index: Makefile > === > RCS file: /var/cvs/src/usr.bin/passwd/Makefile,v > retrieving revision 1.41 > diff -u -p -r1.41 Makefile > --- Makefile 26 Nov 2015 19:01:47 - 1.41 > +++ Makefile 27 Jan 2022 14:59:09 - > @@ -7,7 +7,7 @@ SRCS= local_passwd.c passwd.c getpwent.c > pwd_check.c > .PATH: ${.CURDIR}/../../lib/libc/gen > DPADD+= ${LIBRPCSVC} ${LIBUTIL} > -LDADD+= -lrpcsvc -lutil > +LDADD+= -lutil > CFLAGS+= -I${.CURDIR} > > CFLAGS+=-I${.CURDIR}/../../lib/libc/include > > -- > Greetings Ben >
in4_cksum changes, step 1
in4_cksum(), used to compute packet checksums for the legacy internet protocol, has been hand-optimized for speed on most elderly platforms, with the most recent pieces of silicon using a portable C implementation. Most of these implementations, in a not-so-uncommon case, need to checksum an extra (``overlay'') header, and invoke memset or bzero on such an overlay, prior to initializing it and checksumming it. However, except for one byte, the zeroed parts are useless since they will not change the checksum, so that memset/bzero call can be removed, and the sum can omit the first 8 bytes which will always be zero. The following diff implements that idea. Plus on sparc64 you get one useless assembly instruction removed, for free, isn't that awesome? Affected platforms: alpha, amd64, arm64, hppa, landisk, luna88k, macppc, octeon, powerpc64, riscv64, sparc64. No need to test on armv7 and i386. Index: sys/arch/alpha/alpha/in_cksum.c === RCS file: /OpenBSD/src/sys/arch/alpha/alpha/in_cksum.c,v retrieving revision 1.9 diff -u -p -r1.9 in_cksum.c --- sys/arch/alpha/alpha/in_cksum.c 21 Aug 2014 14:24:08 - 1.9 +++ sys/arch/alpha/alpha/in_cksum.c 25 Jan 2022 20:21:06 - @@ -212,14 +212,13 @@ in4_cksum(struct mbuf *m, u_int8_t nxt, panic("in4_cksum: bad mbuf chain"); #endif - memset(, 0, sizeof(ipov)); - - ipov.ih_len = htons(len); + ipov.ih_x1[8] = 0; ipov.ih_pr = nxt; + ipov.ih_len = htons(len); ipov.ih_src = mtod(m, struct ip *)->ip_src; ipov.ih_dst = mtod(m, struct ip *)->ip_dst; - sum += in_cksumdata((caddr_t) , sizeof(ipov)); + sum += in_cksumdata((caddr_t) + 8, sizeof(ipov) - 8); } /* skip over unnecessary part */ Index: sys/arch/m88k/m88k/in_cksum.c === RCS file: /OpenBSD/src/sys/arch/m88k/m88k/in_cksum.c,v retrieving revision 1.4 diff -u -p -r1.4 in_cksum.c --- sys/arch/m88k/m88k/in_cksum.c 21 Aug 2014 14:24:08 - 1.4 +++ sys/arch/m88k/m88k/in_cksum.c 25 Jan 2022 20:21:07 - @@ -95,19 +95,22 @@ in4_cksum(struct mbuf *m, uint8_t nxt, i { u_int16_t *w; u_int sum = 0; - struct ipovly ipov; + union { + struct ipovly ipov; + u_int16_t w[10]; + } u; if (nxt != 0) { /* pseudo header */ - bzero(, sizeof(ipov)); - ipov.ih_len = htons(len); - ipov.ih_pr = nxt; - ipov.ih_src = mtod(m, struct ip *)->ip_src; - ipov.ih_dst = mtod(m, struct ip *)->ip_dst; - w = (u_int16_t *) - /* assumes sizeof(ipov) == 20 */ - sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; sum += w[4]; - sum += w[5]; sum += w[6]; sum += w[7]; sum += w[8]; sum += w[9]; + u.ipov.ih_x1[8] = 0; + u.ipov.ih_pr = nxt; + u.ipov.ih_len = htons(len); + u.ipov.ih_src = mtod(m, struct ip *)->ip_src; + u.ipov.ih_dst = mtod(m, struct ip *)->ip_dst; + w = u.w; + /* assumes sizeof(ipov) == 20 and first 8 bytes are zeroes */ + sum += w[4]; sum += w[5]; sum += w[6]; + sum += w[7]; sum += w[8]; sum += w[9]; } /* skip unnecessary part */ Index: sys/arch/powerpc/powerpc/in_cksum.c === RCS file: /OpenBSD/src/sys/arch/powerpc/powerpc/in_cksum.c,v retrieving revision 1.10 diff -u -p -r1.10 in_cksum.c --- sys/arch/powerpc/powerpc/in_cksum.c 22 Jul 2014 10:35:35 - 1.10 +++ sys/arch/powerpc/powerpc/in_cksum.c 25 Jan 2022 20:21:07 - @@ -254,15 +254,15 @@ in4_cksum(struct mbuf *m, uint8_t nxt, i if (nxt != 0) { /* pseudo header */ - memset(, 0, sizeof(u.ipov)); - u.ipov.ih_len = htons(len); + u.ipov.ih_x1[8] = 0; u.ipov.ih_pr = nxt; + u.ipov.ih_len = htons(len); u.ipov.ih_src = mtod(m, struct ip *)->ip_src; u.ipov.ih_dst = mtod(m, struct ip *)->ip_dst; w = u.w; - /* assumes sizeof(ipov) == 20 */ - sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3]; sum += w[4]; - sum += w[5]; sum += w[6]; sum += w[7]; sum += w[8]; sum += w[9]; + /* assumes sizeof(ipov) == 20 and first 8 bytes are zeroes */ + sum += w[4]; sum += w[5]; sum += w[6]; + sum += w[7]; sum += w[8]; sum += w[9]; } /* skip unnecessary part */ Index: sys/arch/sparc64/sparc64/in4_cksum.c === RCS file:
Re: kubsan tcp timer shift
> Sounds like a call for the huge U change. Since none of these #define seem to be used by .S files, go for it. We don't really want to bring Mach's U() macro back.
Re: kubsan tcp timer shift
> An unsinged TF_TIMER does not create that problem. Why don't you simply append an U suffix to TF_TMR_REXMT?
fix isascii(3) manpage
All the is*() ctype.h functions take an int as argument, but valid values are only EOF, and the range of values of `unsigned char'. All, but one: the XPG4 isascii(), which has no such restriction. Quoting https://pubs.opengroup.org/onlinepubs/9699919799/ : ``The isascii() function is defined on all integer values.'' Hence the following diff. Index: isascii.3 === RCS file: /OpenBSD/src/lib/libc/gen/isascii.3,v retrieving revision 1.13 diff -u -p -r1.13 isascii.3 --- isascii.3 17 Jul 2013 05:42:11 - 1.13 +++ isascii.3 11 Jun 2021 09:54:13 - @@ -77,11 +77,3 @@ The .Fn isascii function first appeared in .At v7 . -.Sh CAVEATS -The argument to -.Fn isascii -must be -.Dv EOF -or representable as an -.Li unsigned char ; -otherwise, the result is undefined.
remove gccism from com(4)
`return f()' when f is a void function is not allowed by the C standard but is a gcc extension. Index: com.c === RCS file: /OpenBSD/src/sys/dev/ic/com.c,v retrieving revision 1.173 diff -u -p -r1.173 com.c --- com.c 14 Aug 2020 18:14:11 - 1.173 +++ com.c 6 May 2021 19:55:13 - @@ -1609,9 +1609,9 @@ com_write_reg(struct com_softc *sc, bus_ reg <<= sc->sc_reg_shift; if (sc->sc_reg_width == 4) - return bus_space_write_4(sc->sc_iot, sc->sc_ioh, reg, value); + bus_space_write_4(sc->sc_iot, sc->sc_ioh, reg, value); else - return bus_space_write_1(sc->sc_iot, sc->sc_ioh, reg, value); + bus_space_write_1(sc->sc_iot, sc->sc_ioh, reg, value); } #ifdef COM_CONSOLE @@ -1636,9 +1636,9 @@ comcn_write_reg(bus_size_t reg, uint8_t reg <<= comcons_reg_shift; if (comcons_reg_width == 4) - return bus_space_write_4(comconsiot, comconsioh, reg, value); + bus_space_write_4(comconsiot, comconsioh, reg, value); else - return bus_space_write_1(comconsiot, comconsioh, reg, value); + bus_space_write_1(comconsiot, comconsioh, reg, value); } #endif
dead clock functions
The todr_handle struct contains two unused function pointers, which are either not implemented or with clones of eopnotsupp(). The following diff removes this waste of kernel text. Index: arch/sparc64/dev/rtc.c === RCS file: /OpenBSD/src/sys/arch/sparc64/dev/rtc.c,v retrieving revision 1.10 diff -u -p -r1.10 rtc.c --- arch/sparc64/dev/rtc.c 11 Jul 2014 08:18:31 - 1.10 +++ arch/sparc64/dev/rtc.c 21 Apr 2021 19:24:32 - @@ -119,8 +119,6 @@ int rtc_gettime(todr_chip_handle_t, stru int rtc_settime(todr_chip_handle_t, struct timeval *); int rtc_bq4802_gettime(todr_chip_handle_t, struct timeval *); int rtc_bq4802_settime(todr_chip_handle_t, struct timeval *); -int rtc_getcal(todr_chip_handle_t, int *); -int rtc_setcal(todr_chip_handle_t, int); int rtc_match(struct device *parent, void *cf, void *aux) @@ -166,8 +164,6 @@ rtc_attach(struct device *parent, struct handle->cookie = sc; handle->todr_gettime = rtc_gettime; handle->todr_settime = rtc_settime; - handle->todr_getcal = rtc_getcal; - handle->todr_setcal = rtc_setcal; handle->bus_cookie = NULL; handle->todr_setwen = NULL; @@ -403,16 +399,4 @@ rtc_bq4802_settime(todr_chip_handle_t ha csr &= ~BQ4802_UTI; bus_space_write_1(iot, ioh, BQ4802_CTRL, csr); return (0); -} - -int -rtc_getcal(todr_chip_handle_t handle, int *vp) -{ - return (EOPNOTSUPP); -} - -int -rtc_setcal(todr_chip_handle_t handle, int v) -{ - return (EOPNOTSUPP); } Index: dev/clock_subr.h === RCS file: /OpenBSD/src/sys/dev/clock_subr.h,v retrieving revision 1.6 diff -u -p -r1.6 clock_subr.h --- dev/clock_subr.h17 May 2020 13:21:20 - 1.6 +++ dev/clock_subr.h21 Apr 2021 19:24:32 - @@ -35,8 +35,6 @@ * * todr_gettime: convert time-of-day clock into a `struct timeval' * todr_settime: set time-of-day clock from a `struct timeval' - * todr_getcal: get current TOD clock calibration value in ppm - * todr_setcal: set calibration value in ppm in TOD clock * * (this is probably not so useful:) * todr_setwen: provide a machine-dependent TOD clock write-enable callback @@ -49,16 +47,12 @@ struct todr_chip_handle { int (*todr_gettime)(struct todr_chip_handle *, struct timeval *); int (*todr_settime)(struct todr_chip_handle *, struct timeval *); - int (*todr_getcal)(struct todr_chip_handle *, int *); - int (*todr_setcal)(struct todr_chip_handle *, int); int (*todr_setwen)(struct todr_chip_handle *, int); }; typedef struct todr_chip_handle *todr_chip_handle_t; #define todr_gettime(ct, t)((*(ct)->todr_gettime)(ct, t)) #define todr_settime(ct, t)((*(ct)->todr_settime)(ct, t)) -#define todr_getcal(ct, vp)((*(ct)->todr_gettime)(ct, vp)) -#define todr_setcal(ct, v) ((*(ct)->todr_settime)(ct, v)) #define todr_wenable(ct, v)if ((ct)->todr_setwen) \ ((*(ct)->todr_setwen)(ct, v)) Index: dev/fdt/sxirtc.c === RCS file: /OpenBSD/src/sys/dev/fdt/sxirtc.c,v retrieving revision 1.4 diff -u -p -r1.4 sxirtc.c --- dev/fdt/sxirtc.c11 Aug 2019 14:46:18 - 1.4 +++ dev/fdt/sxirtc.c21 Apr 2021 19:24:32 - @@ -146,8 +146,6 @@ sxirtc_attach(struct device *parent, str handle->cookie = self; handle->todr_gettime = sxirtc_gettime; handle->todr_settime = sxirtc_settime; - handle->todr_getcal = NULL; - handle->todr_setcal = NULL; handle->bus_cookie = NULL; handle->todr_setwen = NULL; todr_handle = handle; Index: dev/i2c/ds1307.c === RCS file: /OpenBSD/src/sys/dev/i2c/ds1307.c,v retrieving revision 1.2 diff -u -p -r1.2 ds1307.c --- dev/i2c/ds1307.c27 Apr 2020 12:41:44 - 1.2 +++ dev/i2c/ds1307.c21 Apr 2021 19:24:32 - @@ -72,8 +72,6 @@ int maxrtc_enable_osc(struct maxrtc_soft intmaxrtc_set_24h_mode(struct maxrtc_softc *); intmaxrtc_gettime(struct todr_chip_handle *, struct timeval *); intmaxrtc_settime(struct todr_chip_handle *, struct timeval *); -intmaxrtc_getcal(struct todr_chip_handle *, int *); -intmaxrtc_setcal(struct todr_chip_handle *, int); /* * Driver glue structures. @@ -114,8 +112,6 @@ maxrtc_attach(struct device *parent, str sc->sc_todr.cookie = sc; sc->sc_todr.todr_gettime = maxrtc_gettime; sc->sc_todr.todr_settime = maxrtc_settime; - sc->sc_todr.todr_getcal = maxrtc_getcal; - sc->sc_todr.todr_setcal = maxrtc_setcal; sc->sc_todr.todr_setwen = NULL; if (maxrtc_enable_osc(sc) == -1) @@ -275,16 +271,4 @@ maxrtc_settime(struct todr_chip_handle * } return (0); -} - -int -maxrtc_getcal(struct todr_chip_handle *ch,
more MAKEDEV cleanup
The following diff attempts to clean up a few loose ends in the current MAKEDEV files: - remove no-longer applicable device definitions (MSCP and SMD disks, this kind of thing). - makes sure all platforms use the same `ramdisk' target for installation media devices, rather than a mix of `ramd' and `ramdisk'. - moves as many `ramdisk' devices to MI land (bio, diskmap, random, etc). - reduces the number of block devices in `ramdisk' targets to only one per device, since the installer script will invoke MAKEDEV by itself for the devices it needs to use. - sort device names in `all' and `ramdisk' MI lists to make maintainence easier. This causes some ordering change in the `all' target in the generated MAKEDEVs. Index: MAKEDEV.common === RCS file: /OpenBSD/src/etc/MAKEDEV.common,v retrieving revision 1.113 diff -u -p -r1.113 MAKEDEV.common --- MAKEDEV.common 12 Feb 2021 10:26:33 - 1.113 +++ MAKEDEV.common 5 Apr 2021 09:18:49 - @@ -114,7 +114,7 @@ dnl make a 'disktgt' macro that automati dnl disktgt(rd, {-rd-}) dnl dnltarget(all,rd,0) -dnltarget(ramd,rd,0) +dnltarget(ramdisk,rd,0) dnldisk_q(rd) dnl__devitem(rd, {-rd*-}, {-rd-})dnl dnl @@ -122,62 +122,60 @@ dnl Note: not all devices are generated dnlits own extra list. dnl divert(1)dnl +target(all, acpi)dnl +target(all, apm)dnl +target(all, bio)dnl +target(all, bpf)dnl +twrget(all, com, tty0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b)dnl +twrget(all, czs, cua, a, b, c, d)dnl +target(all, diskmap)dnl +target(all, dt)dnl twrget(all, fdesc, fd)dnl -target(all, st, 0, 1)dnl -target(all, std)dnl -target(all, ra, 0, 1, 2, 3)dnl -target(all, rx, 0, 1)dnl -target(all, wd, 0, 1, 2, 3)dnl -target(all, xd, 0, 1, 2, 3)dnl +target(all, fuse)dnl +target(all, hotplug)dnl +target(all, joy, 0, 1)dnl +target(all, kcov)dnl +target(all, kstat)dnl +target(all, local)dnl +target(all, lpt, 0, 1, 2)dnl +twrget(all, lpt, lpa, 0, 1, 2)dnl +target(all, par, 0)dnl +target(all, pci, 0, 1, 2, 3)dnl target(all, pctr)dnl target(all, pctr0)dnl target(all, pf)dnl -target(all, apm)dnl -target(all, acpi)dnl +target(all, pppac)dnl +target(all, pppx)dnl +target(all, ptm)dnl +target(all, pty, 0)dnl +target(all, pvbus, 0, 1)dnl +target(all, radio, 0)dnl +target(all, rmidi, 0, 1, 2, 3, 4, 5, 6, 7)dnl +twrget(all, rnd, random)dnl +twrget(all, speak, speaker)dnl +target(all, st, 0, 1)dnl +target(all, std)dnl +target(all, switch, 0, 1, 2, 3)dnl +target(all, tap, 0, 1, 2, 3)dnl twrget(all, tth, ttyh, 0, 1)dnl target(all, ttyA, 0, 1)dnl -twrget(all, mac_tty0, tty0, 0, 1)dnl -twrget(all, tzs, tty, a, b, c, d)dnl -twrget(all, czs, cua, a, b, c, d)dnl target(all, ttyc, 0, 1, 2, 3, 4, 5, 6, 7)dnl -twrget(all, com, tty0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b)dnl -twrget(all, mmcl, mmclock)dnl -target(all, lpt, 0, 1, 2)dnl -twrget(all, lpt, lpa, 0, 1, 2)dnl -target(all, joy, 0, 1)dnl -twrget(all, rnd, random)dnl -target(all, uk, 0)dnl -twrget(all, vi, video, 0, 1)dnl -twrget(all, speak, speaker)dnl -target(all, asc, 0)dnl -target(all, radio, 0)dnl +target(all, tun, 0, 1, 2, 3)dnl target(all, tuner, 0)dnl -target(all, rmidi, 0, 1, 2, 3, 4, 5, 6, 7)dnl +twrget(all, tzs, tty, a, b, c, d)dnl target(all, uall)dnl -target(all, pci, 0, 1, 2, 3)dnl -twrget(all, wsmouse, wscons)dnl -target(all, par, 0)dnl -target(all, apci, 0)dnl -target(all, local)dnl -target(all, ptm)dnl -target(all, hotplug)dnl -target(all, pppx)dnl -target(all, pppac)dnl -target(all, fuse)dnl +target(all, uk, 0)dnl +twrget(all, vi, video, 0, 1)dnl target(all, vmm)dnl -target(all, pvbus, 0, 1)dnl -target(all, bpf)dnl -target(all, kcov)dnl -target(all, dt)dnl -target(all, kstat)dnl +target(all, vnd, 0, 1, 2, 3)dnl +target(all, vscsi, 0)dnl +target(all, wd, 0, 1, 2, 3)dnl +twrget(all, wsmouse, wscons)dnl dnl _mkdev(all, {-all-}, {-dnl show_target(all)dnl -})dnl dnl -dnl XXX some arches use ramd, others ramdisk - needs to be fixed eventually -__devitem(ramdisk, ramdisk, Ramdisk kernel devices,nothing)dnl -dnl target(usb, usb, 0, 1, 2, 3, 4, 5, 6, 7)dnl target(usb, uhid, 0, 1, 2, 3, 4, 5, 6, 7)dnl twrget(usb, fido, fido)dnl @@ -208,26 +206,26 @@ __devitem(ch, {-ch*-}, SCSI media change _mcdev(ch, ch*, ch, {-major_ch_c-}, 660, operator)dnl __devitem(uk, uk*, Unknown SCSI devices)dnl _mcdev(uk, uk*, uk, {-major_uk_c-}, 640, operator)dnl -dnl XXX see ramdisk above -__devitem(ramd, ramdisk, Ramdisk kernel devices,nothing)dnl dnl -_mkdev(ramd, ramdisk, {-dnl -show_target(ramd)dnl +__devitem(ramdisk, ramdisk, Ramdisk kernel devices,nothing)dnl +_mkdev(ramdisk, ramdisk, {-dnl +show_target(ramdisk)dnl -})dnl dnl -target(ramd, std)dnl -target(ramd, bpf)dnl -twrget(ramd, com, tty0, 0, 1)dnl -target(ramd, sd, 0, 1, 2, 3, 4)dnl -target(ramd, wd, 0, 1, 2, 3, 4)dnl -target(ramd, st, 0, 1)dnl -target(ramd, cd, 0, 1)dnl -target(ramd, rd, 0)dnl +target(ramdisk, bio)dnl +target(ramdisk, bpf)dnl +target(ramdisk, cd, 0)dnl
no ptys on ramdisk filesystems
A few platforms create pty nodes in /dev in the installation media filesystem. That wastes 2x62 inodes on an tight filesystem. The following diff removes these useless (since installation media kernels lack the pty pseudo-device) /dev entries. Miod PS: while there, one might want to unify the creation of pty nodes in the `all' target, as most platforms build one set of 62 ptys, but a few (loongson, octeon, sgi) build three. Index: etc.hppa/MAKEDEV.md === RCS file: /OpenBSD/src/etc/etc.hppa/MAKEDEV.md,v retrieving revision 1.66 diff -u -p -r1.66 MAKEDEV.md --- etc.hppa/MAKEDEV.md 23 Jan 2021 05:08:33 - 1.66 +++ etc.hppa/MAKEDEV.md 29 Mar 2021 20:02:02 - @@ -85,7 +85,7 @@ divert(__mddivert)dnl dnl ramdisk) _recurse std fd st0 st1 sd0 sd1 sd2 sd3 rd0 random - _recurse pty0 bpf bio diskmap + _recurse bpf bio diskmap ;; _std(1, 2, 25, 6) @@ -110,5 +110,3 @@ target(all, cd, 0, 1)dnl target(all, sd, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)dnl target(all, vnd, 0, 1, 2, 3)dnl target(all, switch, 0, 1, 2, 3)dnl -target(ramd, pty, 0)dnl -target(ramd, hil)dnl Index: etc.loongson/MAKEDEV.md === RCS file: /OpenBSD/src/etc/etc.loongson/MAKEDEV.md,v retrieving revision 1.34 diff -u -p -r1.34 MAKEDEV.md --- etc.loongson/MAKEDEV.md 12 Feb 2021 10:26:34 - 1.34 +++ etc.loongson/MAKEDEV.md 29 Mar 2021 20:02:02 - @@ -113,7 +113,6 @@ target(all, vnd, 0, 1, 2, 3)dnl target(all, switch, 0, 1, 2, 3)dnl target(all, dri)dnl target(all, drm, 0, 1, 2, 3)dnl -target(ramd, pty, 0)dnl target(ramd, bio)dnl target(ramd, diskmap)dnl target(ramd, random)dnl Index: etc.luna88k/MAKEDEV.md === RCS file: /OpenBSD/src/etc/etc.luna88k/MAKEDEV.md,v retrieving revision 1.35 diff -u -p -r1.35 MAKEDEV.md --- etc.luna88k/MAKEDEV.md 6 Jul 2020 06:11:27 - 1.35 +++ etc.luna88k/MAKEDEV.md 29 Mar 2021 20:02:02 - @@ -65,7 +65,6 @@ dnl dnl ramdisk) dnl twrget(ramd, sio, tty, a)dnl -target(ramd, pty, 0)dnl target(ramd, bio)dnl target(ramd, diskmap)dnl target(ramd, random)dnl Index: etc.macppc/MAKEDEV.md === RCS file: /OpenBSD/src/etc/etc.macppc/MAKEDEV.md,v retrieving revision 1.77 diff -u -p -r1.77 MAKEDEV.md --- etc.macppc/MAKEDEV.md 12 Feb 2021 10:26:34 - 1.77 +++ etc.macppc/MAKEDEV.md 29 Mar 2021 20:02:02 - @@ -136,7 +136,6 @@ target(all, drm, 0, 1, 2, 3)dnl target(all, switch, 0, 1, 2, 3)dnl target(ramd, ttya, 0, 1)dnl target(ramd, ttyb, 0, 1)dnl -target(ramd, pty, 0)dnl target(ramd, bio)dnl target(ramd, diskmap)dnl target(ramd, random)dnl Index: etc.octeon/MAKEDEV.md === RCS file: /OpenBSD/src/etc/etc.octeon/MAKEDEV.md,v retrieving revision 1.20 diff -u -p -r1.20 MAKEDEV.md --- etc.octeon/MAKEDEV.md 23 Jan 2021 05:08:33 - 1.20 +++ etc.octeon/MAKEDEV.md 29 Mar 2021 20:02:02 - @@ -116,7 +116,6 @@ target(all, sd, 0, 1, 2, 3, 4, 5, 6, 7, target(all, vnd, 0, 1, 2, 3)dnl target(all, octcf, 0)dnl target(all, switch, 0, 1, 2, 3)dnl -target(ramd, pty, 0)dnl target(ramd, bio)dnl target(ramd, diskmap)dnl target(ramd, random)dnl Index: etc.sgi/MAKEDEV.md === RCS file: /OpenBSD/src/etc/etc.sgi/MAKEDEV.md,v retrieving revision 1.55 diff -u -p -r1.55 MAKEDEV.md --- etc.sgi/MAKEDEV.md 23 Jan 2021 05:08:33 - 1.55 +++ etc.sgi/MAKEDEV.md 29 Mar 2021 20:02:02 - @@ -118,7 +118,6 @@ twrget(all, zs, tty, a, b)dnl twrget(wscons, wscons, ttyD, cfg, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b)dnl twrget(wscons, wscons, ttyE, cfg, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b)dnl twrget(wscons, wscons, ttyF, cfg, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b)dnl -target(ramd, pty, 0)dnl target(ramd, bio)dnl target(ramd, diskmap)dnl target(ramd, random)dnl
Re: safer sigcode page filling
> I guess the rest of the page contains 0? No, it contains a truncated copy of the sigcode. > It would be better if it contained "trap" instructions. We still don't > have an ideal way of doing that tho. That would work, but that would make the code a bit more complicated. And I'm not sure it's worth doing anyway. Running into an unmapped page will segfault anyway.
safer sigcode page filling
The code responsible for filling a page with repeated copies of the signal trampoline code assumes that PAGE_SIZE % sigfillsz == 0. While this is true on all currently supported OpenBSD platforms, this might not be the case in the future (and isn't the case on some no-longer official platforms). The following diff makes sure that we don't try to write more than PAGE_SIZE bytes in this page. Another possibility would be to assert that PAGE_SIZE % sigfillsz == 0 and only apply this diff once it becomes truly needed. Index: sys/kern/kern_exec.c === RCS file: /OpenBSD/src/sys/kern/kern_exec.c,v retrieving revision 1.208 diff -u -p -r1.208 kern_exec.c --- sys/kern/kern_exec.c2 Aug 2019 02:17:35 - 1.208 +++ sys/kern/kern_exec.c25 Nov 2019 10:09:48 - @@ -832,7 +832,7 @@ exec_sigcode_map(struct process *pr, str if (e->e_sigobject == NULL) { extern int sigfillsiz; extern u_char sigfill[]; - size_t off; + size_t off, left; vaddr_t va; int r; @@ -846,8 +846,12 @@ exec_sigcode_map(struct process *pr, str return (ENOMEM); } - for (off = 0; off < round_page(sz); off += sigfillsiz) - memcpy((caddr_t)va + off, sigfill, sigfillsiz); + for (off = 0, left = round_page(sz); left != 0; + off += sigfillsiz) { + size_t chunk = ulmin(left, sigfillsiz); + memcpy((caddr_t)va + off, sigfill, chunk); + left -= chunk; + } memcpy((caddr_t)va, e->e_sigcode, sz); uvm_unmap(kernel_map, va, va + round_page(sz)); }
harmonize maxusers on 64-bit platforms
The following diff causes all 64-bit platforms to use the same maxusers settings. (which in turn affects the maxprocess, maxthread, maxfiles and initialvnodes kernel variables) Index: sys/arch/alpha/conf/files.alpha === RCS file: /OpenBSD/src/sys/arch/alpha/conf/files.alpha,v retrieving revision 1.107 diff -u -p -r1.107 files.alpha --- sys/arch/alpha/conf/files.alpha 14 Feb 2018 23:51:49 - 1.107 +++ sys/arch/alpha/conf/files.alpha 28 Feb 2021 17:36:45 - @@ -6,7 +6,7 @@ # maxpartitions must be first item in files.${ARCH} maxpartitions 16 -maxusers 2 8 128 +maxusers 2 16 128 # this loses, but there's no way to define attributes which have attributes define alpha_shared_intr Index: sys/arch/arm64/conf/files.arm64 === RCS file: /OpenBSD/src/sys/arch/arm64/conf/files.arm64,v retrieving revision 1.32 diff -u -p -r1.32 files.arm64 --- sys/arch/arm64/conf/files.arm64 25 Jul 2020 12:26:09 - 1.32 +++ sys/arch/arm64/conf/files.arm64 28 Feb 2021 17:36:45 - @@ -1,7 +1,7 @@ # $OpenBSD: files.arm64,v 1.32 2020/07/25 12:26:09 tobhe Exp $ maxpartitions 16 -maxusers 2 8 128 +maxusers 2 16 128 major {wd = 16} major {sd = 24} Index: sys/arch/loongson/conf/GENERIC === RCS file: /OpenBSD/src/sys/arch/loongson/conf/GENERIC,v retrieving revision 1.64 diff -u -p -r1.64 GENERIC --- sys/arch/loongson/conf/GENERIC 4 Feb 2021 16:25:39 - 1.64 +++ sys/arch/loongson/conf/GENERIC 28 Feb 2021 17:36:45 - @@ -11,7 +11,7 @@ machineloongson mips64 include"../../../conf/GENERIC" -maxusers 32 +maxusers 80 option CPU_LOONGSON2 option CPU_LOONGSON3 Index: sys/arch/loongson/conf/files.loongson === RCS file: /OpenBSD/src/sys/arch/loongson/conf/files.loongson,v retrieving revision 1.26 diff -u -p -r1.26 files.loongson --- sys/arch/loongson/conf/files.loongson 30 Sep 2020 22:23:41 - 1.26 +++ sys/arch/loongson/conf/files.loongson 28 Feb 2021 17:36:45 - @@ -2,7 +2,7 @@ # Standard stanzas config(8) can't run without maxpartitions 16 -maxusers 2 8 64 +maxusers 2 16 128 # Major number for block devices, for ``root on'' lines major { sd = 0 } Index: sys/arch/octeon/conf/GENERIC === RCS file: /OpenBSD/src/sys/arch/octeon/conf/GENERIC,v retrieving revision 1.58 diff -u -p -r1.58 GENERIC --- sys/arch/octeon/conf/GENERIC4 Feb 2021 16:25:39 - 1.58 +++ sys/arch/octeon/conf/GENERIC28 Feb 2021 17:36:45 - @@ -11,7 +11,7 @@ machineocteon mips64 include"../../../conf/GENERIC" -maxusers 32 +maxusers 80 option CPU_MIPS64R2 option CPU_OCTEON Index: sys/arch/octeon/conf/files.octeon === RCS file: /OpenBSD/src/sys/arch/octeon/conf/files.octeon,v retrieving revision 1.58 diff -u -p -r1.58 files.octeon --- sys/arch/octeon/conf/files.octeon 25 Oct 2020 10:31:33 - 1.58 +++ sys/arch/octeon/conf/files.octeon 28 Feb 2021 17:36:45 - @@ -2,7 +2,7 @@ # Standard stanzas config(8) can't run without maxpartitions 16 -maxusers 2 8 64 +maxusers 2 16 128 # Major number for block devices, for ``root on'' lines major { sd = 0 } Index: sys/arch/powerpc64/conf/files.powerpc64 === RCS file: /OpenBSD/src/sys/arch/powerpc64/conf/files.powerpc64,v retrieving revision 1.26 diff -u -p -r1.26 files.powerpc64 --- sys/arch/powerpc64/conf/files.powerpc64 23 Jan 2021 12:10:08 - 1.26 +++ sys/arch/powerpc64/conf/files.powerpc64 28 Feb 2021 17:36:45 - @@ -1,7 +1,7 @@ # $OpenBSD: files.powerpc64,v 1.26 2021/01/23 12:10:08 kettenis Exp $ maxpartitions 16 -maxusers 2 8 128 +maxusers 2 16 128 major {rd = 2} major {sd = 3} Index: sys/arch/sgi/conf/GENERIC-IP22 === RCS file: /OpenBSD/src/sys/arch/sgi/conf/GENERIC-IP22,v retrieving revision 1.18 diff -u -p -r1.18 GENERIC-IP22 --- sys/arch/sgi/conf/GENERIC-IP22 14 Feb 2018 23:51:49 - 1.18 +++ sys/arch/sgi/conf/GENERIC-IP22 28 Feb 2021 17:36:45 - @@ -13,7 +13,7 @@ machinesgi mips64 include"../../../conf/GENERIC" -maxusers 32 # Estimated number of users +maxusers 80 # Estimated number of users # Make options makeoption LINK_ADDRESS="0x8880" Index: sys/arch/sgi/conf/GENERIC-IP26 === RCS file:
Re: occasional SSIGSEGV on C++ exception handling
> No problem, real-life often takes precedence. No way! operator(7) would need an update!
hppa: terminate backtrace of secondary processors
When asking for the backtrace of a secondary processor in ddb, if that backtrace reaches the secondary cpu startup code before the switch_trampoline call, it will trust uninitialized stack data and is likely to panic with an unaligned access at db_stack_trace_print+0x1d0. (this was found the hard way by landry@ many years ago due to another bug which got quickly fixed) The following diff makes sure the secondary processor stack is correctly set up to hint the backtrace code that it should not attempt to go further. Index: locore.S === RCS file: /OpenBSD/src/sys/arch/hppa/hppa/locore.S,v retrieving revision 1.193 diff -u -p -r1.193 locore.S --- locore.S23 Oct 2014 16:57:45 - 1.193 +++ locore.S2 Feb 2021 17:08:57 - @@ -2970,6 +2970,9 @@ ENTRY(hw_cpu_spinup_trampoline, 0) stw r0, HPPA_FRAME_CRP(sp) stw r0, HPPA_FRAME_PSP(sp) + ldilL%TFF_LAST, t1 + stw t1, TF_FLAGS-TRAPFRAME_SIZEOF(sp) + /* Provide CPU with page tables. */ ldilL%hppa_vtop, t1 ldw R%hppa_vtop(t1), t1
Re: all platforms: isolate hardclock(9) from statclock()
> My understanding is that HZ=100 was a practical choice because the > machines of the day could not reliably drive a faster clock interrupt. The VAX architecture defines a 100Hz timer, which is the only timer you can be sure will be available to the kernel. A few of the later models (VAXstation 4000 comes to mind) have a so-called diagnostic timer with a better precision. Thus when BSD was ported to VAX, there was no choice but have HZ=100. And when it was ported to other platforms (such as hp300), that value was kept because there was no good reason to change it. The value of hz became adjustable because some hardware came with clocks which required a power-of-two divider, such as the 4.4BSD pmax port which had HZ=64. And of course, later, alpha was architected to have a 1024Hz timer, so HZ=1024 on these systems as well.
Re: libc/regex: safer pointer arithmetic
> regcomp.c uses the "start + count < end" idiom to check that there are > "count" bytes available in an array of char "start" and "end" both point > to. > > This is fine, unless "start + count" goes beyond the last element of the > array. In this case, pedantic interpretation of the C standard makes > the comparison of such a pointer against "end" undefined, and optimizers > from hell will happily remove as much code as possible because of this. I am only noticing now that llvm contains a copy of OpenBSD's libc regex code (with an llvm_ prefix to the public interfaces) in its llvmSupport library. I am thus surprised that one of their sanitizers did not expose that wrong construct already. I'll report this to the llvm project tomorrow. In the meantime, under OpenBSD, it might be worth investigating shutting that copy and having llvm_re* aliases of libc's re* functions, if only to make the code smaller.
Re: compress sparc64 bsd.rd
> > Rebooting with command: boot bsd.rd.gz > > This is interesting. The change has it just being named bsd.rd, without the > .gz. That's just me testing a compressed bsd.rd.
Re: compress sparc64 bsd.rd
> Since this change went in, bsd.rd doesn't boot unless I uncompress it first. > > upgrade detected: switching to /bsd.upgrade > Trying /bsd.upgrade... > NOTE: random seed is being reused. > Booting /pci@400/pci@2/pci@0/pci@c/nvme@0/disk@1:a/bsd.upgrade > 4246528@0x100+5120@0x140cc00+3248796@0x1c0+945508@0x1f1929c > OF_map_phys(ff84,8192,fee5,-1) failed > no space for symbol table > Program terminated What machine and OpenBoot version are you using? gzipped kernels work here (as they used to) on: Sun Ultra 1 UPA/SBus (UltraSPARC 167MHz), No Keyboard OpenBoot 3.1, 128 MB memory installed, Serial #8592590. Ethernet address 8:0:20:83:1c:ce, Host ID: 80831cce. Rebooting with command: boot bsd.rd.gz Boot device: /sbus/SUNW,fas@e,880/sd@0,0 File and args: bsd.rd.gz OpenBSD IEEE 1275 Bootblock 2.1 ..>> OpenBSD BOOT 1.21 Booting /sbus@1f,0/SUNW,fas@e,880/sd@0,0:a/bsd.rd.gz 4249968@0x100+1680@0x140d970+3249820@0x1c0+944484@0x1f1969c symbols @ 0xffe88400 249148+165+369384+224195 start=0x100 console is /sbus@1f,0/zs@f,110:a Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2020 OpenBSD. All rights reserved. https://www.OpenBSD.org (etc, etc)
libc/regex: drop debug helpers
regex(3) documents non-standard extensions REG_ITOA and REG_ATOI to regerror(). In the OpenBSD tree, the only use of them is by the regress test, so why not move that specific code to the regress test and shrink libc a bit - remember that this code is present in the installation media through grep(1). Assuming there are no objections against this, it would be worth trying a ports build with this diff to confirm there are no 3rd-party users of these extensions. Index: include/regex.h === RCS file: /OpenBSD/src/include/regex.h,v retrieving revision 1.7 diff -u -p -r1.7 regex.h --- include/regex.h 5 Dec 2012 23:19:57 - 1.7 +++ include/regex.h 3 Jan 2021 17:48:03 - @@ -83,8 +83,6 @@ typedef struct { #defineREG_EMPTY 14 #defineREG_ASSERT 15 #defineREG_INVARG 16 -#defineREG_ATOI255 /* convert name to number (!) */ -#defineREG_ITOA0400/* convert number to name (!) */ /* regexec() flags */ #defineREG_NOTBOL 1 Index: lib/libc/regex/regerror.c === RCS file: /OpenBSD/src/lib/libc/regex/regerror.c,v retrieving revision 1.15 diff -u -p -r1.15 regerror.c --- lib/libc/regex/regerror.c 30 Dec 2020 08:56:38 - 1.15 +++ lib/libc/regex/regerror.c 3 Jan 2021 17:48:03 - @@ -48,26 +48,25 @@ static const char *regatoi(const regex_t static const struct rerr { int code; - const char *name; const char *explain; } rerrs[] = { - { REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match" }, - { REG_BADPAT, "REG_BADPAT", "invalid regular expression" }, - { REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element" }, - { REG_ECTYPE, "REG_ECTYPE", "invalid character class" }, - { REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)" }, - { REG_ESUBREG, "REG_ESUBREG", "invalid backreference number" }, - { REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced" }, - { REG_EPAREN, "REG_EPAREN", "parentheses not balanced" }, - { REG_EBRACE, "REG_EBRACE", "braces not balanced" }, - { REG_BADBR,"REG_BADBR","invalid repetition count(s)" }, - { REG_ERANGE, "REG_ERANGE", "invalid character range" }, - { REG_ESPACE, "REG_ESPACE", "out of memory" }, - { REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid" }, - { REG_EMPTY,"REG_EMPTY","empty (sub)expression" }, - { REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug" }, - { REG_INVARG, "REG_INVARG", "invalid argument to regex routine" }, - { 0,"", "*** unknown regexp error code ***" } + { REG_NOMATCH, "regexec() failed to match" }, + { REG_BADPAT, "invalid regular expression" }, + { REG_ECOLLATE, "invalid collating element" }, + { REG_ECTYPE, "invalid character class" }, + { REG_EESCAPE, "trailing backslash (\\)" }, + { REG_ESUBREG, "invalid backreference number" }, + { REG_EBRACK, "brackets ([ ]) not balanced" }, + { REG_EPAREN, "parentheses not balanced" }, + { REG_EBRACE, "braces not balanced" }, + { REG_BADBR,"invalid repetition count(s)" }, + { REG_ERANGE, "invalid character range" }, + { REG_ESPACE, "out of memory" }, + { REG_BADRPT, "repetition-operator operand invalid" }, + { REG_EMPTY,"empty (sub)expression" }, + { REG_ASSERT, "\"can't happen\" -- you found a bug" }, + { REG_INVARG, "invalid argument to regex routine" }, + { 0,"unknown regexp error code ***" } }; /* @@ -79,51 +78,15 @@ regerror(int errcode, const regex_t *pre { const struct rerr *r; size_t len; - int target = errcode &~ REG_ITOA; - const char *s; - char convbuf[50]; - if (errcode == REG_ATOI) - s = regatoi(preg, convbuf, sizeof convbuf); - else { - for (r = rerrs; r->code != 0; r++) - if (r->code == target) - break; - - if (errcode_ITOA) { - if (r->code != 0) { - assert(strlen(r->name) < sizeof(convbuf)); - (void) strlcpy(convbuf, r->name, sizeof convbuf); - } else - (void)snprintf(convbuf, sizeof convbuf, - "REG_0x%x", target); - s = convbuf; - } else - s = r->explain; - } + for (r = rerrs; r->code != 0; r++) + if (r->code == errcode) + break; if (errbuf_size != 0) - len = strlcpy(errbuf, s, errbuf_size); + len =
Re: libc/regex: turn unsafe macros to inline functions
> Is there a reason not to do > > return (cs->ptr[(uch)c] & cs->mask) != 0; > > This would allow us to get rid of the !! construct in regcomp.c Why not. What about that? Index: regcomp.c === RCS file: /OpenBSD/src/lib/libc/regex/regcomp.c,v retrieving revision 1.41 diff -u -p -r1.41 regcomp.c --- regcomp.c 31 Dec 2020 17:24:05 - 1.41 +++ regcomp.c 3 Jan 2021 16:43:50 - @@ -1101,7 +1099,7 @@ freezeset(struct parse *p, cset *cs) if (cs2->hash == h && cs2 != cs) { /* maybe */ for (i = 0; i < css; i++) - if (!!CHIN(cs2, i) != !!CHIN(cs, i)) + if (CHIN(cs2, i) != CHIN(cs, i)) break; /* no */ if (i == css) break; /* yes */ Index: regex2.h === RCS file: /OpenBSD/src/lib/libc/regex/regex2.h,v retrieving revision 1.10 diff -u -p -r1.10 regex2.h --- regex2.h31 Dec 2020 17:20:19 - 1.10 +++ regex2.h3 Jan 2021 16:43:50 - @@ -107,10 +107,26 @@ typedef struct { uch mask; /* bit within array */ uch hash; /* hash code */ } cset; -/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */ -#defineCHadd(cs, c)((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c)) -#defineCHsub(cs, c)((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c)) -#defineCHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask) + +static inline void +CHadd(cset *cs, char c) +{ + cs->ptr[(uch)c] |= cs->mask; + cs->hash += c; +} + +static inline void +CHsub(cset *cs, char c) +{ + cs->ptr[(uch)c] &= ~cs->mask; + cs->hash -= c; +} + +static inline int +CHIN(const cset *cs, char c) +{ + return (cs->ptr[(uch)c] & cs->mask) != 0; +} /* * main compiled-expression structure
libc/regex: turn unsafe macros to inline functions
That code was written before inline functions were supported by compilers; now that they are even part of the language standard, turn macros into inline functions so that there is no need to document in comments that they will evaluate their arguments multiple times. (one may consider switching their names to lowercase now that these are no longer macros.) Index: regex2.h === RCS file: /OpenBSD/src/lib/libc/regex/regex2.h,v retrieving revision 1.10 diff -u -p -r1.10 regex2.h --- regex2.h31 Dec 2020 17:20:19 - 1.10 +++ regex2.h2 Jan 2021 15:59:51 - @@ -107,10 +107,24 @@ typedef struct { uch mask; /* bit within array */ uch hash; /* hash code */ } cset; -/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */ -#defineCHadd(cs, c)((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c)) -#defineCHsub(cs, c)((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c)) -#defineCHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask) + +static inline void +CHadd(cset *cs, char c) +{ + cs->ptr[(uch)c] |= cs->mask; + cs->hash += c; +} +static inline void +CHsub(cset *cs, char c) +{ + cs->ptr[(uch)c] &= ~cs->mask; + cs->hash -= c; +} +static inline uch +CHIN(const cset *cs, char c) +{ + return cs->ptr[(uch)c] & cs->mask; +} /* * main compiled-expression structure
libc/regex: more dead code
The removal of the categories code made these two functions unused, so remove them as well. Index: regcomp.c === RCS file: /OpenBSD/src/lib/libc/regex/regcomp.c,v retrieving revision 1.41 diff -u -p -r1.41 regcomp.c --- regcomp.c 31 Dec 2020 17:24:05 - 1.41 +++ regcomp.c 2 Jan 2021 15:59:51 - @@ -90,8 +90,6 @@ static void freeset(struct parse *, cset static int freezeset(struct parse *, cset *); static int firstch(struct parse *, cset *); static int nch(struct parse *, cset *); -static int isinsets(struct re_guts *, int); -static int samesets(struct re_guts *, int, int); static sopno dupl(struct parse *, sopno, sopno); static void doemit(struct parse *, sop, size_t); static void doinsert(struct parse *, sop, size_t, sopno); @@ -1148,41 +1146,6 @@ nch(struct parse *p, cset *cs) } /* - - isinsets - is this character in any sets? - */ -static int /* predicate */ -isinsets(struct re_guts *g, int c) -{ - uch *col; - int i; - int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; - unsigned uc = (uch)c; - - for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) - if (col[uc] != 0) - return(1); - return(0); -} - -/* - - samesets - are these two characters in exactly the same sets? - */ -static int /* predicate */ -samesets(struct re_guts *g, int c1, int c2) -{ - uch *col; - int i; - int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; - unsigned uc1 = (uch)c1; - unsigned uc2 = (uch)c2; - - for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) - if (col[uc1] != col[uc2]) - return(0); - return(1); -} - -/* - dupl - emit a duplicate of a bunch of sops */ static sopno /* start of duplicate */ @@ -1394,7 +1357,7 @@ findmust(struct parse *p, struct re_guts *cp++ = (char)OPND(s); } assert(cp == g->must + g->mlen); - *cp++ = '\0'; /* just on general principles */ + *cp = '\0'; /* just on general principles */ } /*
libc/regex: more regular error handling
The REQUIRE macro is used to check for a condition, and set an error in the parse struct if it is not satisfied. This changes it from ((condition) || function call) to a, IMHO more readable, if() test. Index: regcomp.c === RCS file: /OpenBSD/src/lib/libc/regex/regcomp.c,v retrieving revision 1.38 diff -u -p -r1.38 regcomp.c --- regcomp.c 30 Dec 2020 08:59:17 - 1.38 +++ regcomp.c 31 Dec 2020 07:21:31 - @@ -84,7 +84,7 @@ static void ordinary(struct parse *, int static void backslash(struct parse *, int); static void nonnewline(struct parse *); static void repeat(struct parse *, sopno, int, int); -static int seterr(struct parse *, int); +static void seterr(struct parse *, int); static cset *allocset(struct parse *); static void freeset(struct parse *, cset *); static int freezeset(struct parse *, cset *); @@ -121,7 +120,7 @@ static char nuls[10]; /* place to point #defineNEXTn(n)(p->next += (n)) #defineGETNEXT() (*p->next++) #defineSETERROR(e) seterr(p, (e)) -#defineREQUIRE(co, e) (void) ((co) || SETERROR(e)) +#defineREQUIRE(co, e) do { if (!(co)) SETERROR(e); } while (0) #defineEMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd)) #defineINSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos) #defineAHEAD(pos) dofwd(p, pos, HERE()-(pos)) @@ -1010,14 +996,13 @@ repeat(struct parse *p, /* - seterr - set an error condition */ -static int /* useless but makes type checking happy */ +static void seterr(struct parse *p, int e) { if (p->error == 0) /* keep earliest error condition */ p->error = e; p->next = nuls; /* try to bring things to a halt */ p->end = nuls; - return(0); /* make the return value well-defined */ } /*
libc/regex: drop more unused data
re_guts catspace[] is only written to (via categories[]), and never used for anything, so don't bother keeping that. Index: lib/libc/regex/regcomp.c === RCS file: /OpenBSD/src/lib/libc/regex/regcomp.c,v retrieving revision 1.38 diff -u -p -r1.38 regcomp.c --- lib/libc/regex/regcomp.c30 Dec 2020 08:59:17 - 1.38 +++ lib/libc/regex/regcomp.c31 Dec 2020 07:20:39 - @@ -92,7 +92,6 @@ static int firstch(struct parse *, cset static int nch(struct parse *, cset *); static int isinsets(struct re_guts *, int); static int samesets(struct re_guts *, int, int); -static void categorize(struct parse *, struct re_guts *); static sopno dupl(struct parse *, sopno, sopno); static void doemit(struct parse *, sop, size_t); static void doinsert(struct parse *, sop, size_t, sopno); @@ -198,9 +197,6 @@ regcomp(regex_t *preg, const char *patte g->must = NULL; g->mlen = 0; g->nsub = 0; - g->ncategories = 1; /* category 0 is "everything else" */ - g->categories = >catspace[-(CHAR_MIN)]; - memset(g->catspace, 0, sizeof(g->catspace)); g->backrefs = 0; /* do it */ @@ -216,7 +212,6 @@ regcomp(regex_t *preg, const char *patte g->laststate = THERE(); /* tidy up loose ends and fill things in */ - categorize(p, g); stripsnug(p, g); findmust(p, g); g->nplus = pluscount(p, g); @@ -883,15 +878,10 @@ bothcases(struct parse *p, int ch) static void ordinary(struct parse *p, int ch) { - cat_t *cap = p->g->categories; - if ((p->g->cflags_ICASE) && isalpha((uch)ch) && othercase(ch) != ch) bothcases(p, ch); - else { + else EMIT(OCHAR, (uch)ch); - if (cap[ch] == 0) - cap[ch] = p->g->ncategories++; - } } /* @@ -1195,31 +1180,6 @@ samesets(struct re_guts *g, int c1, int if (col[uc1] != col[uc2]) return(0); return(1); -} - -/* - - categorize - sort out character categories - */ -static void -categorize(struct parse *p, struct re_guts *g) -{ - cat_t *cats = g->categories; - int c; - int c2; - cat_t cat; - - /* avoid making error situations worse */ - if (p->error != 0) - return; - - for (c = CHAR_MIN; c <= CHAR_MAX; c++) - if (cats[c] == 0 && isinsets(g, c)) { - cat = g->ncategories++; - cats[c] = cat; - for (c2 = c+1; c2 <= CHAR_MAX; c2++) - if (cats[c2] == 0 && samesets(g, c, c2)) - cats[c2] = cat; - } } /* Index: lib/libc/regex/regex2.h === RCS file: /OpenBSD/src/lib/libc/regex/regex2.h,v retrieving revision 1.9 diff -u -p -r1.9 regex2.h --- lib/libc/regex/regex2.h 30 Dec 2020 08:54:42 - 1.9 +++ lib/libc/regex/regex2.h 31 Dec 2020 07:20:39 - @@ -112,9 +112,6 @@ typedef struct { #defineCHsub(cs, c)((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c)) #defineCHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask) -/* stuff for character categories */ -typedef unsigned char cat_t; - /* * main compiled-expression structure */ @@ -136,15 +133,11 @@ struct re_guts { # define BAD 04 /* something wrong */ int nbol; /* number of ^ used */ int neol; /* number of $ used */ - int ncategories;/* how many character categories */ - cat_t *categories; /* ->catspace[-CHAR_MIN] */ char *must; /* match must contain this string */ int mlen; /* length of must */ size_t nsub;/* copy of re_nsub */ int backrefs; /* does it use back references? */ sopno nplus;/* how deep does it nest +s? */ - /* catspace must be last */ - cat_t catspace[NC]; /* actually [NC] */ }; /* misc utilities */ Index: regress/lib/libc/regex/debug.c === RCS file: /OpenBSD/src/regress/lib/libc/regex/debug.c,v retrieving revision 1.4 diff -u -p -r1.4 debug.c --- regress/lib/libc/regex/debug.c 31 Jul 2003 21:48:03 - 1.4 +++ regress/lib/libc/regex/debug.c 31 Dec 2020 07:20:39 - @@ -26,10 +26,8 @@ FILE *d; register int i; register int c; register int last; - int nincat[NC]; - fprintf(d, "%ld states, %d categories", (long)g->nstates, - g->ncategories); + fprintf(d, "%ld states", (long)g->nstates); fprintf(d, ", first %ld last %ld", (long)g->firststate, (long)g->laststate); if
libc/regex: const'r'us
Spencer's code was written before const was a thing, but we can do better. Neither regcomp(3) nor regex(3) modify the strings they are being passed, so we can keep internal pointers as const as well and avoid {dub,spur}ious casts. While there, the temporary array in nonnewline() can be made static const as well rather than recreated every time. Index: regcomp.c === RCS file: /OpenBSD/src/lib/libc/regex/regcomp.c,v retrieving revision 1.38 diff -u -p -r1.38 regcomp.c --- regcomp.c 30 Dec 2020 08:59:17 - 1.38 +++ regcomp.c 31 Dec 2020 07:21:31 - @@ -53,8 +53,8 @@ * other clumsinesses */ struct parse { - char *next; /* next character in RE */ - char *end; /* end of string (-> NUL normally) */ + const char *next; /* next character in RE */ + const char *end;/* end of string (-> NUL normally) */ int error; /* has an error been seen? */ sop *strip; /* malloced strip */ sopno ssize;/* malloced strip size (allocated) */ @@ -179,7 +178,7 @@ regcomp(regex_t *preg, const char *patte /* set things up */ p->g = g; - p->next = (char *)pattern; /* convenience; we do not modify it */ + p->next = pattern; p->end = p->next + len; p->error = 0; p->ncsalloc = 0; @@ -754,7 +749,7 @@ p_b_term(struct parse *p, cset *cs) static void p_b_cclass(struct parse *p, cset *cs) { - char *sp = p->next; + const char *sp = p->next; const struct cclass *cp; size_t len; const char *u; @@ -816,7 +811,7 @@ static char /* value of collating elem p_b_coll_elem(struct parse *p, int endc) /* name ended by endc,']' */ { - char *sp = p->next; + const char *sp = p->next; const struct cname *cp; size_t len; @@ -860,8 +855,8 @@ othercase(int ch) static void bothcases(struct parse *p, int ch) { - char *oldnext = p->next; - char *oldend = p->end; + const char *oldnext = p->next; + const char *oldend = p->end; char bracket[3]; ch = (uch)ch; @@ -921,16 +911,12 @@ backslash(struct parse *p, int ch) static void nonnewline(struct parse *p) { - char *oldnext = p->next; - char *oldend = p->end; - char bracket[4]; + const char *oldnext = p->next; + const char *oldend = p->end; + static const char bracket[4] = { '^', '\n', ']', '\0' }; p->next = bracket; p->end = bracket+3; - bracket[0] = '^'; - bracket[1] = '\n'; - bracket[2] = ']'; - bracket[3] = '\0'; p_bracket(p); assert(p->next == bracket+3); p->next = oldnext;
compress sparc64 bsd.rd
Up until 6.5, sparc64 bsd.rd were gzipped kernels. This got lost during the Great Installation Media Unification of the 6.6 release cycle, and since then bsd.rd are uncompressed. The following diff ought to fix this and bring back sparc64 netboot times down to acceptable times. Index: miniroot/Makefile === RCS file: /OpenBSD/src/distrib/sparc64/miniroot/Makefile,v retrieving revision 1.23 diff -u -p -r1.23 Makefile --- miniroot/Makefile 18 May 2020 06:20:44 - 1.23 +++ miniroot/Makefile 30 Dec 2020 20:35:55 - @@ -100,7 +100,7 @@ unconfig: .ifdef RELEASEDIR install: - cp bsd.rd ${RELEASEDIR}/bsd.rd + cp bsd.gz ${RELEASEDIR}/bsd.rd chmod a+r ${RELEASEDIR}/bsd.rd cp ${FS} ${RELEASEDIR} cp ${CDROM} ${RELEASEDIR}
libc/regex: safer pointer arithmetic
regcomp.c uses the "start + count < end" idiom to check that there are "count" bytes available in an array of char "start" and "end" both point to. This is fine, unless "start + count" goes beyond the last element of the array. In this case, pedantic interpretation of the C standard makes the comparison of such a pointer against "end" undefined, and optimizers from hell will happily remove as much code as possible because of this. An example of this occurs in regcomp.c's bothcases(), which defines bracket[3], sets "next" to "bracket" and "end" to "bracket + 2". Then it invokes p_bracket(), which starts with "if (p->next + 5 < p->end)"... Because bothcases() and p_bracket() are static functions in regcomp.c, there is a real risk of miscompilation if aggressive inlining happens. The following diff rewrites the "start + count < end" constructs into "end - start > count". Assuming "end" and "start" are always pointing in the array (such as "bracket[3]" above), "end - start" is well-defined and can be compared without trouble. As a bonus, MORE2() implies MORE() therefore SEETWO() can be simplified a bit. Index: regcomp.c === RCS file: /OpenBSD/src/lib/libc/regex/regcomp.c,v retrieving revision 1.35 diff -u -p -r1.35 regcomp.c --- regcomp.c 13 Oct 2020 04:42:28 - 1.35 +++ regcomp.c 29 Dec 2020 10:24:18 - @@ -113,10 +110,10 @@ static char nuls[10]; /* place to point */ #definePEEK() (*p->next) #definePEEK2() (*(p->next+1)) -#defineMORE() (p->next < p->end) -#defineMORE2() (p->next+1 < p->end) +#defineMORE() (p->end - p->next > 0) +#defineMORE2() (p->end - p->next > 1) #defineSEE(c) (MORE() && PEEK() == (c)) -#defineSEETWO(a, b)(MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b)) +#defineSEETWO(a, b)(MORE2() && PEEK() == (a) && PEEK2() == (b)) #defineEAT(c) ((SEE(c)) ? (NEXT(), 1) : 0) #defineEATTWO(a, b)((SEETWO(a, b)) ? (NEXT2(), 1) : 0) #defineNEXT() (p->next++) @@ -623,15 +620,17 @@ p_bracket(struct parse *p) int invert = 0; /* Dept of Truly Sickening Special-Case Kludges */ - if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) { - EMIT(OBOW, 0); - NEXTn(6); - return; - } - if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) { - EMIT(OEOW, 0); - NEXTn(6); - return; + if (p->end - p->next > 5) { + if (strncmp(p->next, "[:<:]]", 6) == 0) { + EMIT(OBOW, 0); + NEXTn(6); + return; + } + if (strncmp(p->next, "[:>:]]", 6) == 0) { + EMIT(OEOW, 0); + NEXTn(6); + return; + } } if ((cs = allocset(p)) == NULL) {
libc/regex: regerror minor tweaks
The following diff constifies the strings in regerror.c and also makes use of the strlcpy() return value to avoid a redundant strlen() call. Index: regerror.c === RCS file: /OpenBSD/src/lib/libc/regex/regerror.c,v retrieving revision 1.14 diff -u -p -r1.14 regerror.c --- regerror.c 1 Nov 2015 03:45:29 - 1.14 +++ regerror.c 29 Dec 2020 10:24:18 - @@ -44,12 +44,12 @@ #include "utils.h" -static char *regatoi(const regex_t *, char *, int); +static const char *regatoi(const regex_t *, char *, int); -static struct rerr { +static const struct rerr { int code; - char *name; - char *explain; + const char *name; + const char *explain; } rerrs[] = { { REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match" }, { REG_BADPAT, "REG_BADPAT", "invalid regular expression" }, @@ -77,10 +77,10 @@ static struct rerr { size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) { - struct rerr *r; + const struct rerr *r; size_t len; int target = errcode &~ REG_ITOA; - char *s; + const char *s; char convbuf[50]; if (errcode == REG_ATOI) @@ -102,21 +102,21 @@ regerror(int errcode, const regex_t *pre s = r->explain; } - len = strlen(s) + 1; - if (errbuf_size > 0) { - strlcpy(errbuf, s, errbuf_size); - } + if (errbuf_size != 0) + len = strlcpy(errbuf, s, errbuf_size); + else + len = strlen(s); - return(len); + return len + 1; } /* - regatoi - internal routine to implement REG_ATOI */ -static char * +static const char * regatoi(const regex_t *preg, char *localbuf, int localbufsize) { - struct rerr *r; + const struct rerr *r; for (r = rerrs; r->code != 0; r++) if (strcmp(r->name, preg->re_endp) == 0)
libc/regex: remove dead code
cclasses[] multis field is always an empty string. Remove it and code dealing with it. This code was incomplete anyway. Index: cclass.h === RCS file: /OpenBSD/src/lib/libc/regex/cclass.h,v retrieving revision 1.6 diff -u -p -r1.6 cclass.h --- cclass.h13 Oct 2020 04:42:28 - 1.6 +++ cclass.h29 Dec 2020 09:30:53 - @@ -39,30 +39,22 @@ static const struct cclass { const char *name; const char *chars; - const char *multis; } cclasses[] = { { "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ -0123456789", ""} , - { "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", - ""} , - { "blank", " \t", ""} , +0123456789" }, + { "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" }, + { "blank", " \t" }, { "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\ -\25\26\27\30\31\32\33\34\35\36\37\177",""} , - { "digit", "0123456789", ""} , +\25\26\27\30\31\32\33\34\35\36\37\177" }, + { "digit", "0123456789" }, { "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ -0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", - ""} , - { "lower", "abcdefghijklmnopqrstuvwxyz", - ""} , +0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" }, + { "lower", "abcdefghijklmnopqrstuvwxyz" }, { "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ -0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", - ""} , - { "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", - ""} , - { "space", "\t\n\v\f\r ", ""} , - { "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - ""} , - { "xdigit", "0123456789ABCDEFabcdef", - ""} , - { NULL, 0, "" } +0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ " }, + { "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" }, + { "space", "\t\n\v\f\r " }, + { "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ" }, + { "xdigit", "0123456789ABCDEFabcdef" }, + { NULL, 0 } }; Index: regcomp.c === RCS file: /OpenBSD/src/lib/libc/regex/regcomp.c,v retrieving revision 1.35 diff -u -p -r1.35 regcomp.c --- regcomp.c 13 Oct 2020 04:42:28 - 1.35 +++ regcomp.c 29 Dec 2020 09:30:53 - @@ -90,9 +90,6 @@ static void freeset(struct parse *, cset static int freezeset(struct parse *, cset *); static int firstch(struct parse *, cset *); static int nch(struct parse *, cset *); -static void mcadd(struct parse *, cset *, const char *); -static void mcinvert(struct parse *, cset *); -static void mccase(struct parse *, cset *); static int isinsets(struct re_guts *, int); static int samesets(struct re_guts *, int, int); static void categorize(struct parse *, struct re_guts *); @@ -666,8 +663,6 @@ p_bracket(struct parse *p) if (ci != i) CHadd(cs, ci); } - if (cs->multis != NULL) - mccase(p, cs); } if (invert) { int i; @@ -679,12 +674,8 @@ p_bracket(struct parse *p) CHadd(cs, i); if (p->g->cflags_NEWLINE) CHsub(cs, '\n'); - if (cs->multis != NULL) - mcinvert(p, cs); } - assert(cs->multis == NULL); /* xxx */ - if (nch(p, cs) == 1) { /* optimize singleton sets */ ordinary(p, firstch(p, cs)); freeset(p, cs); @@ -782,8 +773,6 @@ p_b_cclass(struct parse *p, cset *cs) u = cp->chars; while ((c = *u++) != '\0') CHadd(cs, c); - for (u = cp->multis; *u != '\0'; u += strlen(u) + 1) - MCadd(p, cs, u); } /* @@ -1073,8 +1062,6 @@ allocset(struct parse *p) cs->ptr = p->g->setbits + css*((no)/CHAR_BIT); cs->mask = 1 << ((no) % CHAR_BIT); cs->hash = 0; - cs->smultis = 0; - cs->multis = NULL; return(cs); nomem: @@ -1171,52 +1158,6 @@ nch(struct parse *p, cset *cs) if (CHIN(cs, i)) n++; return(n); -} - -/* - - mcadd - add a collating element to a cset - */ -static void -mcadd( struct parse *p, cset *cs, const char *cp) -{ - size_t oldend = cs->smultis; - void *np; - - cs->smultis += strlen(cp) + 1; - np = realloc(cs->multis, cs->smultis); - if (np == NULL) { -
libc/regex: constify more data
The following diff constifies the strings in cnames[]. No functional change. Index: cname.h === RCS file: /OpenBSD/src/lib/libc/regex/cname.h,v retrieving revision 1.5 diff -u -p -r1.5 cname.h --- cname.h 2 Jun 2003 20:18:36 - 1.5 +++ cname.h 29 Dec 2020 09:30:53 - @@ -36,8 +36,8 @@ */ /* character-name table */ -static struct cname { - char *name; +static const struct cname { + const char *name; char code; } cnames[] = { { "NUL",'\0' }, Index: regcomp.c === RCS file: /OpenBSD/src/lib/libc/regex/regcomp.c,v retrieving revision 1.35 diff -u -p -r1.35 regcomp.c --- regcomp.c 13 Oct 2020 04:42:28 - 1.35 +++ regcomp.c 29 Dec 2020 09:30:53 - @@ -826,7 +815,7 @@ p_b_coll_elem(struct parse *p, int endc) /* name ended by endc,']' */ { char *sp = p->next; - struct cname *cp; + const struct cname *cp; size_t len; while (MORE() && !SEETWO(endc, ']'))
Re: uvm_map_inentry() checks in trap()
> Repeating diffs from i386, amd64, sh. Improve alpha diff to handle an > additional fault case. Adding diffs for powerpc, powerc64, and m88k. The m88k diff is incomplete: - changes need to be done in both m88100_trap() and m88110_trap(). - the uvm_map_inentry() check should be put after the user_fault and m88110_user_fault labels, which implies the KERNEL_LOCK must be moved after these labels and removed from the two code paths jumping to these labels.
Re: fix eeprom(8) on macppc
> > Suggested diff below; clue from NetBSD. > I looked for openprom code there but only found it for SPARC, can you > point me to where you got the "clue" from exactly? http://bxr.su/NetBSD/sys/dev/ofw/openfirmio.c#205
fix eeprom(8) on macppc
I had noticed for years that eeprom(8) always reported failure when attempting to change OpenFirmware environment variables on macppc. Upon further examination, it doesn't - the variables get changed, but error is reported. This is caused by a difference in implementation behaviour between Apple's OpenFirmware and Sun's. Suggested diff below; clue from NetBSD. Before: # eeprom boot-command boot-command=mac-boot # eeprom boot-command=boot eeprom: invalid keyword: boot-command # eeprom boot-command boot-command=boot <-- yet the value has been changed After: # eeprom boot-command boot-command=mac-boot # eeprom boot-command=boot # eeprom boot-command boot-command=boot Index: openprom.c === RCS file: /OpenBSD/src/sys/arch/macppc/macppc/openprom.c,v retrieving revision 1.4 diff -u -p -r1.4 openprom.c --- openprom.c 19 Sep 2015 21:07:04 - 1.4 +++ openprom.c 20 Sep 2020 17:56:35 - @@ -186,7 +186,11 @@ openpromioctl(dev_t dev, u_long cmd, cad strlcpy(buf, name, 32); /* XXX */ len = OF_setprop(node, buf, value, op->op_buflen + 1); splx(s); - if (len != op->op_buflen) + /* +* For string properties, the Apple OpenFirmware implementation +* returns the buffer length including the trailing NUL. +*/ + if (len != op->op_buflen && len != op->op_buflen + 1) error = EINVAL; break;
Re: sigabort(), p_sigmask & p_siglist
> Something doesn't feel right. > > db_kill_cmd finds a process, called p, then kills it. In your new diff > calling sigexit, take note of the comment at the top: > > * Force the current process to exit with the specified signal, dumping core > > current process? Doesn't look like it, it looks like it kills p. But then > it calls exit1? Ah, yes, sigexit() ends up with a context switch. This is not a good idea for the places where Martin wants to use it, his first diff was better. Sorry for the noise.
Re: sigabort(), p_sigmask & p_siglist
> Diff below introduces an helper for sending an uncatchable SIGABRT and > annotate that `p_siglist' and `p_sigmask' are updated using atomic > operations. Why not use sigexit(p, SIGABRT); for that purpose?
Re: symmetric toeplitz hashing
>> Others have pointed out off-list that one can use __builtin_popcount(), >> but __builtin_parity() is exactly what I want. Is it available on all >> architectures? > > I don't think it is available on gcc 3.x for m88k but someone with > an m88k should confirm. __builtin_popcount() does not exist in gcc 3.
Re: powerpc64: ldbrx/stdbrx for endian.h?
> There is an interest in supporting PowerPC 970 ("G5"). That would > allow people to use more than 2G of RAM on the last generations of > Apple PowerMac machines. Otherwise I don't think we are interested in > anything before POWER8. Years ago, a decision was made to ditch 64-bit PA-RISC (mostly because toolchain limitations for 64-bit userland) and keep running a 32-bit kernels on 64-bit PA-RISC systems with a 32-bit PDC. Before that, mickey@ was adamant that earlier hppa64 systems (pre-astro) with 32-bit PCI busses and no way to have more than 2GB of memory (such as C240) were not worth supporting in 64-bit mode. At about the same time, it was also decided that G5 systems with more than 2 or 3 GB of memory were rare enough not to be worth supporting in 64-bit mode. Given the current "3GHz and gobs of ram or dust" party's line those days, I don't see a point in attempting to support G5 systems in 64-bit mode, if this seriously impacts support for sexier^Wmore modern designs.
Re: sparc64 boot issue on qemu
Yet another case where the emulator does not match the real hardware. Why bother with them? Get qemu to fix their shit so that the frame buffer metrics variable are aligned on 64-bit boundaries. There might not be a written specification for this requirement, but that's the way real hardware behaves, and it makes complete sense (the variables are OFW cells, which are 64-bit values and 64-bit aligned). If you really want to accomodate their broken firmware, you can avoid using memcpy by relying upon sparc64 being big-endian and do something like: - *fontwidth = (int)*(uint64_t *)romwidth; - *fontheight = (int)*(uint64_t *)romheight; - *wtop = (int)*(uint64_t *)windowtop; - *wleft = (int)*(uint64_t *)windowleft; + *fontwidth = *(uint32_t *)(romwidth + 4); + *fontheight = *(uint32_t *)(romheight + 4); + *wtop = *(uint32_t *)(windowtop + 4); + *wleft = *(uint32_t *)(windowleft + 4); Miod
tcpdump gtp bugfix
There seems to be a logic error in tcpdump's print-gtp.c. The code is printing some values by passing a pointer to the array of strings, and the index within the array, and the routine uses sizeof(array) / sizeof(array[0]) to figure out the bound. But since the caller is passing a pointer, sizeof returns the size of the pointer and not of the array itself (and clang will rightfully warn about this). The right fix is to have the caller pass the upper bound. Suggested fix below. Index: print-gtp.c === RCS file: /OpenBSD/src/usr.sbin/tcpdump/print-gtp.c,v retrieving revision 1.11 diff -u -p -r1.11 print-gtp.c --- print-gtp.c 22 Oct 2018 16:12:45 - 1.11 +++ print-gtp.c 1 May 2020 09:37:58 - @@ -57,12 +57,16 @@ #include "interface.h" #include "gtp.h" +#ifndef nitems +#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) +#endif + void gtp_print(const u_char *, u_int, u_short, u_short); void gtp_decode_ie(const u_char *, u_short, int); void gtp_print_tbcd(const u_char *, u_int); void gtp_print_user_address(const u_char *, u_int); void gtp_print_apn(const u_char *, u_int); -void gtp_print_str(const char **, u_int); +void gtp_print_str(const char **, u_int, u_int); void gtp_v0_print(const u_char *, u_int, u_short, u_short); void gtp_v0_print_prime(const u_char *); @@ -466,10 +470,9 @@ gtp_print_apn(const u_char *cp, u_int le /* Print string from array. */ void -gtp_print_str(const char **strs, u_int index) +gtp_print_str(const char **strs, u_int bound, u_int index) { - - if (index >= (sizeof(*strs) / sizeof(*strs[0]))) + if (index >= bound) printf(": %u", index); else if (strs[index] != NULL) printf(": %s", strs[index]); @@ -727,7 +730,8 @@ gtp_v0_print_tv(const u_char *cp, u_int /* 12.15 7.3.4.5.3 - Packet Transfer Command. */ TCHECK2(cp[0], GTPV0_TV_PACKET_XFER_CMD_LENGTH - 1); printf("Packet Transfer Command"); - gtp_print_str(gtp_packet_xfer_cmd, cp[0]); + gtp_print_str(gtp_packet_xfer_cmd, nitems(gtp_packet_xfer_cmd), + cp[0]); ielen = GTPV0_TV_PACKET_XFER_CMD_LENGTH; break; @@ -1315,7 +1319,8 @@ gtp_v1_print_tv(const u_char *cp, u_int /* 32.295 6.2.4.5.2 - Packet Transfer Command. */ TCHECK2(cp[0], GTPV1_TV_PACKET_XFER_CMD_LENGTH - 1); printf("Packet Transfer Command"); - gtp_print_str(gtp_packet_xfer_cmd, cp[0]); + gtp_print_str(gtp_packet_xfer_cmd, nitems(gtp_packet_xfer_cmd), + cp[0]); ielen = GTPV1_TV_PACKET_XFER_CMD_LENGTH; break; @@ -1515,7 +1520,7 @@ gtp_v1_print_tlv(const u_char *cp, u_int /* 29.060 7.7.50 - RAT Type. */ printf("RAT"); - gtp_print_str(gtp_rat_type, cp[0]); + gtp_print_str(gtp_rat_type, nitems(gtp_rat_type), cp[0]); break; case GTPV1_TLV_USER_LOCATION_INFO: @@ -1607,7 +1612,8 @@ gtp_v1_print_tlv(const u_char *cp, u_int /* 29.060 7.7.66 - MBMS 2G/3G Indicator. */ printf("MBMS 2G/3G Indicator"); - gtp_print_str(mbms_2g3g_indicator, cp[0]); + gtp_print_str(mbms_2g3g_indicator, nitems(mbms_2g3g_indicator), + cp[0]); break; case GTPV1_TLV_ENHANCED_NSAPI: @@ -1697,7 +1703,8 @@ gtp_v1_print_tlv(const u_char *cp, u_int /* 29.060 7.7.80 - MS Info Change Reporting. */ printf("MS Info Change Reporting"); - gtp_print_str(ms_info_change_rpt, cp[0]); + gtp_print_str(ms_info_change_rpt, nitems(ms_info_change_rpt), + cp[0]); break; case GTPV1_TLV_DIRECT_TUNNEL_FLAGS:
Re: Increase default number of devices created for LDOMs on sparc64
> Learning how LDOMs work on this T4-1 and we only create 8 devices > (each /dev/ldom* and /dev/ttyV*) by default. The now-commonly-available > T4-1 machines can do far more than that pretty easily, so bump up the > number created by default from 8 to 16. > > ok? MAKEDEV is a generated file. Edit the second-to-last line of MAKEDEV.md to add the extra 8 nodes.
Re: Code changes for clarity
> For instance, in the wsdisplay_emulops structure, there are: > > int (*alloc_attr)(void *c, int fg, int bg, int flags, long *attrp); > void (*unpack_attr)(void *c, long attr, int *fg, int *bg, int *ul); > > And at the end of the structure is this comment, showing that at > least someone (other than me) was confused by it: > /* XXX need a free_attr() ??? */ `alloc_attr' was named that way because there was a theoretical possibility that drivers would actually need to allocate storage for attribute-related information (which is why attributes are longs rather than uint32_t). A `free_attr' routine would then make sense, except that there is no clear lifetime for attributes (e.g. the kernel messages attribute has to survive free_screen). Since in practice, no driver actually allocates anything and all attributes fit in either 8 bits (vga text mode) or 32 bits (rasops), it would make sense to rename this function to `compute_attr' or `pack_attr' and narrow the attribute type from `long' to `uint32_t'. $.02 Miod
ld.so and ldconfig manpage nits
This ensures consistent spelling of set-{user,group}-ID, and also mentions LD_DEBUG is ignored by ld.so for such binaries. Index: ld.so.1 === RCS file: /OpenBSD/src/libexec/ld.so/ld.so.1,v retrieving revision 1.23 diff -u -p -r1.23 ld.so.1 --- ld.so.1 14 Feb 2019 07:26:31 - 1.23 +++ ld.so.1 8 May 2020 09:11:30 - @@ -161,6 +161,7 @@ are recognised and have their usual mean When set, be verbose about what .Nm does. +This variable is ignored for set-user-ID and set-group-ID executables. .El .Sh FILES .Bl -tag -width /var/run/ld.so.hintsXXX -compact Index: ldconfig/ldconfig.8 === RCS file: /OpenBSD/src/libexec/ld.so/ldconfig/ldconfig.8,v retrieving revision 1.29 diff -u -p -r1.29 ldconfig.8 --- ldconfig/ldconfig.8 4 Jul 2016 20:56:50 - 1.29 +++ ldconfig/ldconfig.8 8 May 2020 09:11:30 - @@ -120,9 +120,7 @@ Switch on verbose mode. .El .Sh SECURITY Special care must be taken when loading shared libraries into the address -space of -.Ev set-user-Id -programs. +space of set-user-ID and set-group-ID programs. Whenever such a program is run, .Xr ld.so 1 will only load shared libraries from the @@ -141,7 +139,7 @@ It is presumed that the set of directori .Nm are under control of the system's administrator. .Xr ld.so 1 -further assists set-user-Id programs by erasing the +further assists set-user-ID and set-group-ID programs by erasing the .Ev LD_LIBRARY_PATH from the environment. .Sh ENVIRONMENT
Re: Kill indirect configuration in autoconf(9)
>> While discussing recent config_detach(9) vs close(2) race I figured >> out that the 'indirect' flag (`cd_indirect') is never set. Some struct cfdriver initialize it to 1. See isa_cd in sys/dev/isa/isa.c. >> Time to kill this feature? Please don't.
Re: fd(4): tsleep(9) -> tsleep_nsec(9), timeout_add(9) -> timeout_add_msec(9)
> Convert ticks to milliseconds. > > The 33 milliseconds in the timeout_add_msec(9) call will be truncated > to 3 ticks, but that was already the case with the current (hz / 30) > code so this is no worse. [...] > /* allow 1/30 second for heads to settle */ > - timeout_add(>fdcpseudointr_to, hz / 30); > + timeout_add_msec(>fdcpseudointr_to, 33); Why not simply write `1000 / 30' rather than 33, to match the comment?
sparc64: simplify boot()
Although Open Firmware supports it, there is no way from OpenBSD to reboot with a specified boot command line, so drop vestigial support for it from boot(). Index: sparc64/machdep.c === RCS file: /OpenBSD/src/sys/arch/sparc64/sparc64/machdep.c,v retrieving revision 1.191 diff -u -p -r1.191 machdep.c --- sparc64/machdep.c 1 Apr 2019 07:00:52 - 1.191 +++ sparc64/machdep.c 3 Jan 2020 19:24:45 - @@ -593,9 +593,6 @@ struct pcb dumppcb; __dead void boot(int howto) { - int i; - static char str[128]; - if ((howto & RB_RESET) != 0) goto doreset; @@ -655,30 +652,7 @@ haltsys: doreset: printf("rebooting\n\n"); -#if 0 - if (user_boot_string && *user_boot_string) { - i = strlen(user_boot_string); - if (i > sizeof(str)) - OF_boot(user_boot_string); /* XXX */ - bcopy(user_boot_string, str, i); - } else -#endif - { - i = 1; - str[0] = '\0'; - } - - if ((howto & RB_SINGLE) != 0) - str[i++] = 's'; - if ((howto & RB_KDB) != 0) - str[i++] = 'd'; - if (i > 1) { - if (str[0] == '\0') - str[0] = '-'; - str[i] = 0; - } else - str[0] = 0; - OF_boot(str); + OF_boot(""); panic("cpu_reboot -- failed"); for (;;) continue;
sparc64: kill BOOT_ARG
BOOT_ARG from is a NetBSDism which did not make its way to OpenBSD, where parsing kernel commandline options is done inline. It is no surprise then, that it is only used by the sparc64 boot blocks; but boot blocks really only care about one option, -a, so there is no need to check for more letters. The following diff removes BOOT_ARG and simplifies boot blocks logic. Moreover, since the kernel will pick its options from Open Firmware and not from the boot blocks, it makes absolutely no sense for the boot blocks to try and rebuild a commandline with the various options, so let's get rid of this as well while changing the boot blocks. Note that, after this diff is applied, none of the original contents of remain, and the licence block ought to be updated. This is left as an exercize for the appropriate developer. Index: include/boot_flag.h === RCS file: /OpenBSD/src/sys/arch/sparc64/include/boot_flag.h,v retrieving revision 1.5 diff -u -p -r1.5 boot_flag.h --- include/boot_flag.h 26 Nov 2014 20:06:53 - 1.5 +++ include/boot_flag.h 3 Jan 2020 18:27:05 - @@ -30,39 +30,6 @@ #ifndef _MACHINE_BOOT_FLAG_H_ #define _MACHINE_BOOT_FLAG_H_ -#include - -/* - * Recognize standard boot arguments. If the flag is known, appropriate - * value is or'ed to retval, otherwise retval is left intact. - * Note that not all ports use all flags recognized here. This list is mere - * concatenation of all non-conflicting standard boot flags. Individual ports - * might use also other flags (see e.g. alpha). - */ -#defineBOOT_FLAG(arg, retval) do { \ - switch (arg) { \ - case 'a': /* ask for file name to boot from */ \ - (retval) |= RB_ASKNAME; \ - break; \ - case 'b': /* always halt, never reboot */ \ - (retval) |= RB_HALT;\ - break; \ - case 'c': /* userconf */\ - (retval) |= RB_CONFIG; \ - break; \ - case 'd': /* break into the kernel debugger ASAP (if compiled in) */ \ - (retval) |= RB_KDB; \ - break; \ - case 's': /* boot to single user */ \ - (retval) |= RB_SINGLE; \ - break; \ - default: /* something else, do nothing */ \ - break; \ - } /* switch */ \ - \ - } while (/* CONSTCOND */ 0) - - /* softraid boot information */ #define BOOTSR_UUID_MAX 16 #define BOOTSR_CRYPTO_MAXKEYBYTES 32 Index: stand/ofwboot/boot.c === RCS file: /OpenBSD/src/sys/arch/sparc64/stand/ofwboot/boot.c,v retrieving revision 1.32 diff -u -p -r1.32 boot.c --- stand/ofwboot/boot.c29 Oct 2019 02:55:52 - 1.32 +++ stand/ofwboot/boot.c3 Jan 2020 18:27:05 - @@ -53,7 +53,6 @@ #include #include #include -#include #include #include @@ -124,10 +123,18 @@ parseargs(char *str, int *howtop) while (*cp == ' ') ++cp; } + /* +* Note that, if only options have been passed, without a kernel +* name, str == cp and options will be ignored at the boot blocks +* level. +* This a feature intended to make `boot -a' behave as intended. +* If you want the bootblocks to handle arguments explicitly, a +* kernel filename needs to be provided (as in `boot bsd -a'). +*/ *str = 0; - switch(*cp) { + switch (*cp) { default: - printf ("boot options string <%s> must start with -\n", cp); + printf("boot options string <%s> must start with -\n", cp); return -1; case 0: return 0; @@ -137,9 +144,10 @@ parseargs(char *str, int *howtop) ++cp; while (*cp) { - BOOT_FLAG(*cp, *howtop); - /* handle specialties */ switch (*cp++) { + case 'a': + *howtop |= RB_ASKNAME; + break; case 'd': if (!debug) debug = 1; break; @@ -379,7 +387,7 @@ main(void) int chosen; char bootline[512]; /* Should check size? */ char *cp; - int i, fd, len; + int i, fd; #ifdef
Re: TIMESPEC_TO_NSEC(), futex(2) & __thrsleep(2)
> Should we use inline instead of __inline for new code? inline is a C99 keyword, C99 is 20 years old now, and the kernel source is using C99 named initializers, therefore it is safe to assume C99 support from the compiler. It's time to stop defining __const, __inline, __signed and __volatile in and use underscore-free, lo-carb, keywords.
sparc64: remove bogus comment
sparc_bus_protect() was copied from uvm_chgkprot() (which was a KGDB support routine and is no longer present in uvm_glue.c). The "cheezy hack" comment predates the pmap_extract() interface change of 2001 (uvm_glue.c 1.15) and ought to have been removed back then. Index: machdep.c === RCS file: /OpenBSD/src/sys/arch/sparc64/sparc64/machdep.c,v retrieving revision 1.191 diff -u -p -r1.191 machdep.c --- machdep.c 1 Apr 2019 07:00:52 - 1.191 +++ machdep.c 31 Dec 2019 08:00:16 - @@ -1712,15 +1712,10 @@ sparc_bus_protect(bus_space_tag_t t, bus eva = round_page((vaddr_t)addr + size); for (sva = trunc_page((vaddr_t)addr); sva < eva; sva += PAGE_SIZE) { -/* - * Extract physical address for the page. - * We use a cheezy hack to differentiate physical - * page 0 from an invalid mapping, not that it - * really matters... - */ if (pmap_extract(pmap_kernel(), sva, ) == FALSE) panic("bus_space_protect(): invalid page"); -pmap_enter(pmap_kernel(), sva, pa | pm_flags, prot, prot | PMAP_WIRED); +pmap_enter(pmap_kernel(), sva, pa | pm_flags, prot, + prot | PMAP_WIRED); } pmap_update(pmap_kernel());
grep -R with no path
grep(1), when invoked with the -R option but no path, displays a "recursive search of stdin" warning and acts as if -R had not been specified. GNU grep, in that case, will perform a recursive search in the current directory, i.e. uses an implicit "." path if none is given. This is IMO a much better behaviour. What about the following diff? Index: grep.c === RCS file: /OpenBSD/src/usr.bin/grep/grep.c,v retrieving revision 1.62 diff -u -p -r1.62 grep.c --- grep.c 7 Oct 2019 20:04:00 - 1.62 +++ grep.c 2 Dec 2019 08:27:09 - @@ -473,8 +473,12 @@ main(int argc, char *argv[]) ++argv; } - if (Rflag && argc == 0) - warnx("warning: recursive search of stdin"); + if (Rflag && argc == 0) { + /* default to . if no path given */ + static char *dot_argv[] = { ".", NULL }; + argv = dot_argv; + argc = 1; + } if (Eflag) cflags |= REG_EXTENDED; if (Fflag)
Re: syscall call-from verification
> For dynamic binaries, valid regions are ld.so's text segment, the signal > trampoline, and libc.so's text segment... AND the main program's text. > > Unfortunately our current go build model hasn't followed solaris/macos > approach yet of calling libc stubs, and uses the inappropriate "embed > system calls directly" method, so for now we'll need to authorize the main > program text as well. A comment in exec_elf.c explains this. > > If go is adapted to call library-based system call stubs on OpenBSD as > well, this problem will go away. There may be other environments creating > raw system calls. I guess we'll need to find them as time goes by, and > hope in time we can repair those also. Or you could use an ELF note to flag binaries allowed to issue syscalls from their text section: only static binaries (including ld.so) and go binaries would need them.
Re: ppppoe octeon kernel panic .6.6
> Try changing all the final 0 in sppp_auth_send() to 0UL and this ought > to work. This function needs __attribute__((__sentinel__)) as well to > prevent such mistakes from occurring again. The sentinel attribute wants a pointer, not a zero size_t, unfortunately. Please try this diff. Index: if_spppsubr.c === RCS file: /OpenBSD/src/sys/net/if_spppsubr.c,v retrieving revision 1.179 diff -u -p -r1.179 if_spppsubr.c --- if_spppsubr.c 24 Jun 2019 21:36:53 - 1.179 +++ if_spppsubr.c 23 Oct 2019 17:12:53 - @@ -3340,7 +3340,7 @@ sppp_chap_input(struct sppp *sp, struct sizeof digest, digest, strlen(sp->myauth.name), sp->myauth.name, - 0); + 0UL); break; case CHAP_SUCCESS: @@ -3460,7 +3460,7 @@ sppp_chap_input(struct sppp *sp, struct /* action scn, tld */ sppp_auth_send(, sp, CHAP_FAILURE, h->ident, sizeof(FAILMSG) - 1, (u_char *)FAILMSG, - 0); + 0UL); chap.tld(sp); break; } @@ -3469,7 +3469,7 @@ sppp_chap_input(struct sppp *sp, struct sp->state[IDX_CHAP] == STATE_OPENED) sppp_auth_send(, sp, CHAP_SUCCESS, h->ident, sizeof(SUCCMSG) - 1, (u_char *)SUCCMSG, - 0); + 0UL); if (sp->state[IDX_CHAP] == STATE_REQ_SENT) { sppp_cp_change_state(, sp, STATE_OPENED); chap.tlu(sp); @@ -3647,7 +3647,7 @@ sppp_chap_scr(struct sppp *sp) (size_t)AUTHCHALEN, sp->chap_challenge, strlen(sp->myauth.name), sp->myauth.name, - 0); + 0UL); } /* *--* @@ -3726,7 +3726,7 @@ sppp_pap_input(struct sppp *sp, struct m sppp_auth_send(, sp, PAP_NAK, h->ident, sizeof mlen, (const char *), sizeof(FAILMSG) - 1, (u_char *)FAILMSG, - 0); + 0UL); pap.tld(sp); break; } @@ -3737,7 +3737,7 @@ sppp_pap_input(struct sppp *sp, struct m sppp_auth_send(, sp, PAP_ACK, h->ident, sizeof mlen, (const char *), sizeof(SUCCMSG) - 1, (u_char *)SUCCMSG, - 0); + 0UL); } if (sp->state[IDX_PAP] == STATE_REQ_SENT) { sppp_cp_change_state(, sp, STATE_OPENED); @@ -3952,7 +3952,7 @@ sppp_pap_scr(struct sppp *sp) (size_t)idlen, sp->myauth.name, sizeof pwdlen, (const char *), (size_t)pwdlen, sp->myauth.secret, - 0); + 0UL); } /* * Random miscellaneous functions.
Re: ppppoe octeon kernel panic .6.6
> The system has a trap 2, which I looked up as: > > #define T_TLB_LD_MISS 2 /* TLB miss on load or ifetch */ > > what happens before this patch, I think, is that there is a varargs size_t > (which is size 8 in mips64), that gets promoted (I think) in varargs to int > (which would likely be size 4). Then what happens is the char * that is > va_arg'ed after that is somehow corrupted on length 1, bcopy would trap #2 > on this. Try changing all the final 0 in sppp_auth_send() to 0UL and this ought to work. This function needs __attribute__((__sentinel__)) as well to prevent such mistakes from occurring again.
Re: minor INSTALL.loongson tweaks
> Is suspend-resume not working on the lemote anymore? It works (or used to work) on the Yeeloong, not on the Gdium (different battery controller chip).
minor INSTALL.loongson tweaks
Hello, I have noticed a few inaccuracies in the installation notes. The following diff fixes them. Index: hardware === RCS file: /OpenBSD/src/distrib/notes/loongson/hardware,v retrieving revision 1.10 diff -u -p -r1.10 hardware --- hardware27 Feb 2014 18:48:15 - 1.10 +++ hardware10 Aug 2019 16:43:12 - @@ -21,5 +21,4 @@ The following machines are supported by all onboard devices (keyboard, trackpad, display, SD card reader, USB ports, Ethernet adapter, wireless network adapter, battery information) are supported except for the audio controller; - suspend/resume is not supported yet; keyboard actions involving - the `Fn' key are not working either at the moment. + suspend/resume is not supported yet. Index: install === RCS file: /OpenBSD/src/distrib/notes/loongson/install,v retrieving revision 1.14 diff -u -p -r1.14 install --- install 19 Mar 2014 01:59:48 - 1.14 +++ install 10 Aug 2019 16:43:12 - @@ -35,9 +35,12 @@ dnl you can boot the kernel from an usb dnl dnlPMON> boot /dev/fs/fat@usb0:/bsd.rd -Netbooting the installation kernel can be done as well: +Netbooting the installation kernel can be done as well. First, check the name +of the PMON device for the onboard interface using the ``devls'' command. +This is likely to be either rtl0 (on Yeeloong) or rtk0 (on Fuloong). Then, +assign it an address and fetch the installation kernel from a tftp server: -PMON> ifaddr rtl0 +PMON> ifaddr PMON> boot -k tftp:///bsd.rd OpenBSDInstallPart2
missing splnet in network drivers
The recent mii_tick diff made me ponder whether the mii tick timeout could be put in the mii_data struct rather than each driver softc (not that a good idea, actually). While looking at this, I noticed that two drivers may end up invoking mii_tick() while not being at IPL_NET. bnx: bnx_tick() can get invoked either from the interrupt handler, or from a timeout. sk: on some boards, sk_tick() gets invoked from timeout, but may end up invoking sk_intr_bcom() which is intended to run at IPL_NET. This diff has only been compile-tested, for lack of such hardware. Index: if_bnx.c === RCS file: /OpenBSD/src/sys/dev/pci/if_bnx.c,v retrieving revision 1.125 diff -u -p -r1.125 if_bnx.c --- if_bnx.c10 Mar 2018 10:51:46 - 1.125 +++ if_bnx.c3 Jul 2019 06:40:47 - @@ -5457,6 +5457,9 @@ bnx_tick(void *xsc) struct ifnet*ifp = >arpcom.ac_if; struct mii_data *mii = NULL; u_int32_t msg; + int s; + + s = splnet(); /* Tell the firmware that the driver is still running. */ #ifdef BNX_DEBUG @@ -5489,7 +5492,7 @@ bnx_tick(void *xsc) } bnx_tick_exit: - return; + splx(s); } // Index: if_sk.c === RCS file: /OpenBSD/src/sys/dev/pci/if_sk.c,v retrieving revision 1.189 diff -u -p -r1.189 if_sk.c --- if_sk.c 4 Jun 2017 04:29:23 - 1.189 +++ if_sk.c 3 Jul 2019 06:40:47 - @@ -1703,15 +1703,20 @@ sk_tick(void *xsc_if) struct sk_if_softc *sc_if = xsc_if; struct mii_data *mii = _if->sk_mii; struct ifnet *ifp = _if->arpcom.ac_if; - int i; + int i, s; DPRINTFN(2, ("sk_tick\n")); - if (!(ifp->if_flags & IFF_UP)) + s = splnet(); + + if (!(ifp->if_flags & IFF_UP)) { + splx(s); return; + } if (sc_if->sk_phytype == SK_PHYTYPE_BCOM) { sk_intr_bcom(sc_if); + splx(s); return; } @@ -1729,6 +1734,7 @@ sk_tick(void *xsc_if) if (i != 3) { timeout_add_sec(_if->sk_tick_ch, 1); + splx(s); return; } @@ -1736,6 +1742,7 @@ sk_tick(void *xsc_if) SK_XM_CLRBIT_2(sc_if, XM_IMR, XM_IMR_GP0_SET); SK_XM_READ_2(sc_if, XM_ISR); mii_tick(mii); + splx(s); timeout_del(_if->sk_tick_ch); }
unused sparc64 extern
The following declaration has actually never been used, for `ver' is a local in cpuattach() and locore does rdpr %ver every time it needs the value. Index: include/psl.h === RCS file: /OpenBSD/src/sys/arch/sparc64/include/psl.h,v retrieving revision 1.34 diff -u -p -r1.34 psl.h --- include/psl.h 20 Aug 2018 15:02:07 - 1.34 +++ include/psl.h 29 Jun 2019 10:35:40 - @@ -227,8 +227,6 @@ #if defined(_KERNEL) && !defined(_LOCORE) -extern u_int64_t ver; /* Copy of v9 version register. We need to read this only once, in locore.s. */ - #ifdef DIAGNOSTIC /* * Although this function is implemented in MI code, it must be in this MD
missing trap.c code for m88k
Exception handling code on superH and m88k does not check for a valid stack pointer, like other platforms do. The following (mechanical) diff addresses the m88k case, and has been tested to work on 88100 and 88110 processors. Index: sys/arch/m88k/m88k/trap.c === RCS file: /OpenBSD/src/sys/arch/m88k/m88k/trap.c,v retrieving revision 1.107 diff -u -p -u -p -r1.107 trap.c --- sys/arch/m88k/m88k/trap.c 8 Sep 2017 05:36:52 - 1.107 +++ sys/arch/m88k/m88k/trap.c 17 Jun 2019 17:54:48 - @@ -239,6 +239,9 @@ m88100_trap(u_int type, struct trapframe type += T_USER; p->p_md.md_tf = frame; /* for ptrace/signals */ refreshcreds(p); + if (!uvm_map_inentry(p, >p_spinentry, PROC_STACK(p), "sp", + uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) + return; } fault_type = SI_NOINFO; fault_code = 0; @@ -679,6 +682,9 @@ m88110_trap(u_int type, struct trapframe type += T_USER; p->p_md.md_tf = frame; /* for ptrace/signals */ refreshcreds(p); + if (!uvm_map_inentry(p, >p_spinentry, PROC_STACK(p), "sp", + uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) + return; } if (sig != 0)
Re: free() sizes in zlib
> I have serious doubt whether the whole "plan" for using the sizes to > change the malloc implementation is feasable. The drm(4) code for > example relies on emulation of Linux memory allocation APIs to keep > the diffs small and jsg@ and myself sane. Most of these APIs don't > pass sizes in their "free" interfaces. There's always the choice of keeping the existing implementation for some types (such as M_DRM) and use a different implementation for other types. And then see how better the new implementation fares. > If passing the sizes around in this bit of code has benefits for > sanity checking purposes, I have no objection. But if it is just > there to silence the kernel printf and actually hurts updating the > code in the future then I wouldn't bother. I seriously doubt there is much coming from upstream zlib in the future.
free() sizes in zlib
This tries to keep diffability against upstream, hence a questionable choice of the size type for zcfree() - but all sizes should fit in 32 bits anyway. Since all zcfree routines used in the tree cope with NULL arguments (including the various alloc.c used by the boot blocks), I have simplified TRY_FREE to compensate for the growth. Index: lib/libz/deflate.c === RCS file: /OpenBSD/src/sys/lib/libz/deflate.c,v retrieving revision 1.3 diff -u -p -r1.3 deflate.c --- lib/libz/deflate.c 14 Mar 2016 23:08:06 - 1.3 +++ lib/libz/deflate.c 14 May 2019 13:47:03 - @@ -873,12 +873,12 @@ int ZEXPORT deflateEnd (strm) } /* Deallocate in reverse order of allocations: */ -TRY_FREE(strm, strm->state->pending_buf); -TRY_FREE(strm, strm->state->head); -TRY_FREE(strm, strm->state->prev); -TRY_FREE(strm, strm->state->window); +TRY_FREE(strm, strm->state->pending_buf, strm->state->pending_buf_size); +TRY_FREE(strm, strm->state->head, strm->state->hash_size * sizeof(Pos)); +TRY_FREE(strm, strm->state->prev, strm->state->w_size * sizeof(Pos)); +TRY_FREE(strm, strm->state->window, strm->state->w_size * 2 * sizeof(Byte)); -ZFREE(strm, strm->state); +ZFREE(strm, strm->state, sizeof(deflate_state)); strm->state = Z_NULL; return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; Index: lib/libz/infback.c === RCS file: /OpenBSD/src/sys/lib/libz/infback.c,v retrieving revision 1.5 diff -u -p -r1.5 infback.c --- lib/libz/infback.c 20 Jul 2005 15:56:45 - 1.5 +++ lib/libz/infback.c 14 May 2019 13:47:03 - @@ -630,7 +630,7 @@ z_streamp strm; { if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; -ZFREE(strm, strm->state); +ZFREE(strm, strm->state, sizeof(struct inflate_state)); strm->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; Index: lib/libz/inflate.c === RCS file: /OpenBSD/src/sys/lib/libz/inflate.c,v retrieving revision 1.14 diff -u -p -r1.14 inflate.c --- lib/libz/inflate.c 23 Mar 2016 19:39:48 - 1.14 +++ lib/libz/inflate.c 14 May 2019 13:47:03 - @@ -176,7 +176,7 @@ int stream_size; #endif } if (windowBits < 8 || windowBits > 15) { -ZFREE(strm, state); +ZFREE(strm, state, sizeof(struct inflate_state)); strm->state = Z_NULL; return Z_STREAM_ERROR; } @@ -1238,8 +1238,8 @@ z_streamp strm; if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; -if (state->window != Z_NULL) ZFREE(strm, state->window); -ZFREE(strm, strm->state); +if (state->window != Z_NULL) ZFREE(strm, state->window, 1U << state->wbits); +ZFREE(strm, strm->state, sizeof(struct inflate_state)); strm->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; @@ -1423,7 +1423,7 @@ z_streamp source; window = (unsigned char FAR *) ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); if (window == Z_NULL) { -ZFREE(source, copy); +ZFREE(source, copy, sizeof(struct inflate_state)); return Z_MEM_ERROR; } } Index: lib/libz/zlib.h === RCS file: /OpenBSD/src/sys/lib/libz/zlib.h,v retrieving revision 1.11 diff -u -p -r1.11 zlib.h --- lib/libz/zlib.h 12 May 2019 15:56:56 - 1.11 +++ lib/libz/zlib.h 14 May 2019 13:47:04 - @@ -76,7 +76,7 @@ extern "C" { */ typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); +typedef void (*free_func) OF((voidpf opaque, voidpf address, uInt size)); struct internal_state; Index: lib/libz/zopenbsd.c === RCS file: /OpenBSD/src/sys/lib/libz/zopenbsd.c,v retrieving revision 1.6 diff -u -p -r1.6 zopenbsd.c --- lib/libz/zopenbsd.c 14 Mar 2015 03:38:51 - 1.6 +++ lib/libz/zopenbsd.c 14 May 2019 13:47:04 - @@ -5,17 +5,13 @@ * Space allocation and freeing routines for use by zlib routines. */ void * -zcalloc(notused, items, size) -void *notused; -u_int items, size; +zcalloc(void *notused, u_int items, u_int size) { return mallocarray(items, size, M_DEVBUF, M_NOWAIT); } void -zcfree(notused, ptr) -void *notused; -void *ptr; +zcfree(void *notused, void *ptr, u_int size) { -free(ptr, M_DEVBUF, 0); +free(ptr, M_DEVBUF, size); } Index: lib/libz/zutil.h === RCS file: /OpenBSD/src/sys/lib/libz/zutil.h,v retrieving revision 1.18 diff
free() sizes for ahc(4)
Note ahc_set_name() gets invoked with the dv_xname field of a struct device, so it's not a good idea to free anything, should it be invoked more than once. Tested on: ahc0 at pci0 dev 1 function 0 "Adaptec AIC-7880" rev 0x00: irq 8 ahc0: Host Adapter Bios disabled. Using default SCSI device parameters scsibus0 at ahc0: 16 targets, initiator 7 sd0 at scsibus0 targ 1 lun 0: SCSI3 0/direct fixed serial.SGI_IBM_DNES-318350Y_AK0T7943 sd0: 17364MB, 512 bytes/sector, 35563040 sectors cd0 at scsibus0 targ 4 lun 0: SCSI2 5/cdrom removable ahc1 at pci0 dev 2 function 0 "Adaptec AIC-7880" rev 0x00: irq 9 ahc1: Host Adapter Bios disabled. Using default SCSI device parameters scsibus1 at ahc1: 16 targets, initiator 7 Index: dev/ic/aic7xxx.c === RCS file: /OpenBSD/src/sys/dev/ic/aic7xxx.c,v retrieving revision 1.93 diff -u -p -u -p -r1.93 aic7xxx.c --- dev/ic/aic7xxx.c12 Dec 2017 12:33:36 - 1.93 +++ dev/ic/aic7xxx.c14 May 2019 10:28:10 - @@ -1688,7 +1688,7 @@ ahc_free_tstate(struct ahc_softc *ahc, u scsi_id += 8; tstate = ahc->enabled_targets[scsi_id]; if (tstate != NULL) - free(tstate, M_DEVBUF, 0); + free(tstate, M_DEVBUF, sizeof(*tstate)); ahc->enabled_targets[scsi_id] = NULL; } #endif @@ -3957,8 +3957,6 @@ ahc_set_unit(struct ahc_softc *ahc, int void ahc_set_name(struct ahc_softc *ahc, char *name) { - if (ahc->name != NULL) - free(ahc->name, M_DEVBUF, 0); ahc->name = name; } @@ -3997,21 +3995,21 @@ ahc_free(struct ahc_softc *ahc) lstate = tstate->enabled_luns[j]; if (lstate != NULL) { /*xpt_free_path(lstate->path);*/ - free(lstate, M_DEVBUF, 0); + free(lstate, M_DEVBUF, sizeof(*lstate)); } } #endif - free(tstate, M_DEVBUF, 0); + free(tstate, M_DEVBUF, sizeof(*tstate)); } } #ifdef AHC_TARGET_MODE if (ahc->black_hole != NULL) { /*xpt_free_path(ahc->black_hole->path);*/ - free(ahc->black_hole, M_DEVBUF, 0); + free(ahc->black_hole, M_DEVBUF, sizeof(*ahc->black_hole)); } #endif if (ahc->seep_config != NULL) - free(ahc->seep_config, M_DEVBUF, 0); + free(ahc->seep_config, M_DEVBUF, sizeof(*ahc->seep_config)); return; } @@ -4329,7 +4327,7 @@ ahc_fini_scbdata(struct ahc_softc *ahc) ahc_freedmamem(ahc->parent_dmat, PAGE_SIZE, sg_map->sg_dmamap, (caddr_t)sg_map->sg_vaddr, _map->sg_dmasegs, sg_map->sg_nseg); - free(sg_map, M_DEVBUF, 0); + free(sg_map, M_DEVBUF, sizeof(*sg_map)); } } /*FALLTHROUGH*/ @@ -4350,8 +4348,10 @@ ahc_fini_scbdata(struct ahc_softc *ahc) case 0: break; } - if (scb_data->scbarray != NULL) - free(scb_data->scbarray, M_DEVBUF, 0); + if (scb_data->scbarray != NULL) { + free(scb_data->scbarray, M_DEVBUF, + AHC_SCB_MAX_ALLOC * sizeof(struct scb)); + } } void @@ -4383,7 +4383,7 @@ ahc_alloc_scbs(struct ahc_softc *ahc) (caddr_t *)_map->sg_vaddr, _map->sg_physaddr, _map->sg_dmasegs, _map->sg_nseg, ahc_name(ahc), "SG space") < 0) { - free(sg_map, M_DEVBUF, 0); + free(sg_map, M_DEVBUF, sizeof(*sg_map)); return; } @@ -6859,7 +6859,7 @@ ahc_handle_en_lun(struct ahc_softc *ahc, xpt_path_target_id(ccb->ccb_h.path), xpt_path_lun_id(ccb->ccb_h.path)); if (status != CAM_REQ_CMP) { - free(lstate, M_DEVBUF, 0); + free(lstate, M_DEVBUF, sizeof(*lstate)); xpt_print_path(ccb->ccb_h.path); printf("Couldn't allocate path\n"); ccb->ccb_h.status = CAM_RESRC_UNAVAIL; @@ -6980,7 +6980,7 @@ ahc_handle_en_lun(struct ahc_softc *ahc, xpt_print_path(ccb->ccb_h.path); printf("Target mode disabled\n"); xpt_free_path(lstate->path); - free(lstate, M_DEVBUF, 0); + free(lstate, M_DEVBUF, sizeof(*lstate)); ahc_pause(ahc); /* Can we clean up the target too? */ Index: dev/ic/aic7xxx_seeprom.c === RCS file: /OpenBSD/src/sys/dev/ic/aic7xxx_seeprom.c,v retrieving revision 1.7 diff
free() sizes in sys/arch/alpha
Index: dev/sgmap_common.c === RCS file: /OpenBSD/src/sys/arch/alpha/dev/sgmap_common.c,v retrieving revision 1.14 diff -u -p -r1.14 sgmap_common.c --- dev/sgmap_common.c 9 Dec 2014 06:58:28 - 1.14 +++ dev/sgmap_common.c 13 May 2019 16:39:50 - @@ -150,6 +150,8 @@ alpha_sgmap_dmamap_setup(map, nsegments, { map->_dm_cookie = mallocarray(nsegments, sizeof(struct extent_region), M_DEVBUF, (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK); + if (map->_dm_cookie != NULL) + map->_dm_cookiesize = nsegments * sizeof(struct extent_region); return (map->_dm_cookie == NULL); } @@ -187,7 +189,7 @@ void alpha_sgmap_dmamap_teardown(map) bus_dmamap_t map; { - free(map->_dm_cookie, M_DEVBUF, 0); + free(map->_dm_cookie, M_DEVBUF, map->_dm_cookiesize); } void Index: include/bus.h === RCS file: /OpenBSD/src/sys/arch/alpha/include/bus.h,v retrieving revision 1.31 diff -u -p -r1.31 bus.h --- include/bus.h 8 May 2017 00:27:45 - 1.31 +++ include/bus.h 13 May 2019 16:39:50 - @@ -648,6 +648,7 @@ struct alpha_bus_dmamap { * Private cookie to be used by the DMA back-end. */ void*_dm_cookie; + size_t _dm_cookiesize; /* size allocated for _dm_cookie */ /* * The DMA window that we ended up being mapped in. Index: isa/isadma_bounce.c === RCS file: /OpenBSD/src/sys/arch/alpha/isa/isadma_bounce.c,v retrieving revision 1.12 diff -u -p -r1.12 isadma_bounce.c --- isa/isadma_bounce.c 27 Sep 2015 10:12:09 - 1.12 +++ isa/isadma_bounce.c 13 May 2019 16:39:50 - @@ -115,6 +115,7 @@ isadma_bounce_dmamap_create(bus_dma_tag_ map = *dmamp; map->_dm_cookie = NULL; + map->_dm_cookiesize = 0; cookiesize = sizeof(*cookie); @@ -156,6 +157,7 @@ isadma_bounce_dmamap_create(bus_dma_tag_ cookie = (struct isadma_bounce_cookie *)cookiestore; cookie->id_flags = cookieflags; map->_dm_cookie = cookie; + map->_dm_cookiesize = cookiesize; if (cookieflags & ID_MIGHT_NEED_BOUNCE) { /* @@ -190,7 +192,7 @@ isadma_bounce_dmamap_destroy(bus_dma_tag if (cookie->id_flags & ID_HAS_BOUNCE) isadma_bounce_free_bouncebuf(t, map); - free(cookie, M_DEVBUF, 0); + free(cookie, M_DEVBUF, map->_dm_cookiesize); _bus_dmamap_destroy(t, map); }
Re: Removing PF
> Will the bpf JIT changes be done in time for 6.6? I have no doubt > that "pfctl -p /dev/bfp" can be made to work in time but for a truly > performant firewall we will need bpf JIT. I wrote a vax BPF jit as a simple exercize some time ago, so all you really need now is to implement vax-to-${ARCH} jit on an MD basis. This should be very easy to do as long as BPF does not get extended to use floating-point values.
Re: replacing timeout_add() with timeout_add_msec()
> The intent was to wait a 30th of a second. In practice it has always > fired 30ms hence. It's a magic number, so I'd just call it 30ms. > miod might have an opinion on whether those extra milliseconds would > be useful in the event that sparc64 is ever able to timeout with > millisecond or better precision on OpenBSD. That's not sparc64-specific. There is the same 1/30th logic in sys/dev/isa/fd.c which is used on i386 and amd64, you know.
Re: minor ttyflags(8) diff
> > Opening a pseudo-tty (/dev/tty[p-zP-T][0-9a-zA-Z]) causes the kernel to > > allocate a struct tty for it, as well as ring buffers for tty data. This > > memory will not get released if the pseudo-tty is closed, for it may be > > opened again in the future. > > The change seems reasonable to me. > > Years ago weren't we more lazy about allocating the tty buffer data? I have had a look at the history, but not beyond ~15 years. ttymalloc() will always cause the ring buffers to be allocated, and only removable devices such as ucom will release tty resources (upon detach).
minor ttyflags(8) diff
Opening a pseudo-tty (/dev/tty[p-zP-T][0-9a-zA-Z]) causes the kernel to allocate a struct tty for it, as well as ring buffers for tty data. This memory will not get released if the pseudo-tty is closed, for it may be opened again in the future. On pseudo-ttys, the largest possible ring buffer size is used, which causes 26KB to be allocated (three 8KB rings plus two 1KB quote buffers). On a default OpenBSD install, only /dev/tty[pqr][0-9a-zA-Z] are created. That's 186 ttys. If they were to be opened, this would cause 4836KB of kernel memory to be allocated. And that's exactly what ttyflags(8) does: it will happily open every tty listed in /etc/ttys, and issue a TIOCSFLAGS ioctl to it, then close it. But pseudo-ttys ignore TIOCSFLAGS completely, so there is no point for ttyflags to open them, to begin with. On memory challenged systems, this is a significant waste of memory. I am therefore proposing the following diff, which will cause ttyflags -a to skip pseudo-ttys. Without this diff, after a multiuser boot: kern.malloc.kmemstat.ttys=(inuse = 1128, calls = 1128, memuse = 4982K, limblocks = 0, mapblocks = 0, maxused = 4982K, limit = 78644K, spare = 0, sizes = (512,1024,8192)) With this diff: kern.malloc.kmemstat.ttys=(inuse = 18, calls = 18, memuse = 80K, limblocks = 0, mapblocks = 0, maxused = 80K, limit = 78644K, spare = 0, sizes = (512,1024,8192)) Index: ttyflags.c === RCS file: /OpenBSD/src/sbin/ttyflags/ttyflags.c,v retrieving revision 1.13 diff -u -p -r1.13 ttyflags.c --- ttyflags.c 4 Dec 2012 02:27:00 - 1.13 +++ ttyflags.c 13 Jan 2019 16:14:59 - @@ -112,9 +112,13 @@ all(int print) int rval; rval = 0; - for (tep = getttyent(); tep != NULL; tep = getttyent()) + for (tep = getttyent(); tep != NULL; tep = getttyent()) { + /* pseudo-tty ignore TIOCSFLAGS, so don't bother */ + if (strcmp(tep->ty_type, "network") == 0) + continue; if (ttyflags(tep, print)) rval = 1; + } return (rval); }
SGI O2 mec(4) cold boot issue (and workaround)
I have noticed, for a while, that my O2 systems were horribly slow during installs or upgrades, when fetching sets from the network (28 *minutes* to fetch base64.tgz). At first, I thought this was a bsd.rd specific bug, but couldn't find anything obvious. After gathering enough data, I found out that the problem only occurs on a cold boot. After a reboot, the network performance is as good as it can be. That would explain why I would only notice it during upgrades. I also noticed that, on a warm boot, the dmesg would show: mec0 at macebus0 base 0x0028 irq 3: MAC-110 rev 1, address 08:00:69:0e:bf:a1 nsphy0 at mec0 phy 8: DP83840 10/100 PHY, rev. 1 but on cold boots, it would show: mec0 at macebus0 base 0x0028 irq 3: MAC-110 rev 1, address 08:00:69:0e:bf:a1 nsphy0 at mec0 phy 10: DP83840 10/100 PHY, rev. 1 Note that, in these cases, the phy seems to attach to a different address. In these cases, after booting, "ifconfig mec0" would show: mec0: flags=8843 mtu 1500 lladdr 08:00:69:0e:bf:a1 llprio 3 media: Ethernet autoselect status: active inet 10.0.1.193 netmask 0xff00 broadcast 10.255.255.255 while one would expect the "media" line to be similar to: media: Ethernet autoselect (100baseTX full-duplex) Investigating further, it seems that, after a cold boot, the MII bus takes some time to initialize; the phy does not answer to address 8 but to a larger address (10 or 11), then, after being reset, to its correct address of 8. So the kernel would discover the phy at a wrong address, attach it, and after it gets reset, reading from the phy at the wrong address would return either all bits clear or all bits set, confusing the link speed logic without any way to recover. What I tried but did not work: - invoking mii_attach() twice in the mec driver. This would attach nsphy twice, once at the wrong address, then once at the correct address, but the first (wrong) attachment would be preferred. - adding a one second delay between the Ethernet interface reset and mii_attach(). This would work most of the time, but not always. What I tried and works: - the first time the interface is reset, the mii bus is walked and all phys found on it are reset. Thus, by the time mii_attach() runs and walks the bus again, the phy will answer at the right address. The diff below implements this (last chunk of if_mec.c), and also cleans the mii read/write routines a bit (all the other chunks). Tested on three different R5K family O2 systems, which have all been exposing that problem on cold boot. Index: dev/if_mec.c === RCS file: /OpenBSD/src/sys/arch/sgi/dev/if_mec.c,v retrieving revision 1.37 diff -u -p -r1.37 if_mec.c --- dev/if_mec.c22 Jan 2017 10:17:37 - 1.37 +++ dev/if_mec.c8 Dec 2018 15:00:04 - @@ -264,7 +264,6 @@ struct mec_softc { bus_dma_tag_t sc_dmat; /* bus_dma tag. */ struct mii_data sc_mii; /* MII/media information. */ - int sc_phyaddr; /* MII address. */ struct timeout sc_tick_ch; /* Tick timeout. */ bus_dmamap_t sc_cddmamap; /* bus_dma map for control data. */ @@ -329,7 +328,7 @@ voidmec_start(struct ifnet *); void mec_watchdog(struct ifnet *); void mec_tick(void *); intmec_ioctl(struct ifnet *, u_long, caddr_t); -void mec_reset(struct mec_softc *); +void mec_reset(struct mec_softc *, int); void mec_iff(struct mec_softc *); intmec_intr(void *arg); void mec_stop(struct ifnet *); @@ -422,7 +421,7 @@ mec_attach(struct device *parent, struct enaddr_aton(bios_enaddr, sc->sc_ac.ac_enaddr); /* Reset device. */ - mec_reset(sc); + mec_reset(sc, 1); command = bus_space_read_8(sc->sc_st, sc->sc_sh, MEC_MAC_CONTROL); @@ -451,7 +450,6 @@ mec_attach(struct device *parent, struct ifmedia_set(>sc_mii.mii_media, IFM_ETHER | IFM_MANUAL); } else { ifmedia_set(>sc_mii.mii_media, IFM_ETHER | IFM_AUTO); - sc->sc_phyaddr = child->mii_phy; } bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); @@ -499,21 +497,19 @@ mec_mii_readreg(struct device *self, int struct mec_softc *sc = (void *)self; bus_space_tag_t st = sc->sc_st; bus_space_handle_t sh = sc->sc_sh; - uint32_t val; + uint64_t val; int i; if (mec_mii_wait(sc) != 0) return 0; - bus_space_write_4(st, sh, MEC_PHY_ADDRESS, + bus_space_write_8(st, sh, MEC_PHY_ADDRESS, (phy << MEC_PHY_ADDR_DEVSHIFT) | (reg & MEC_PHY_ADDR_REGISTER)); bus_space_write_8(st, sh, MEC_PHY_READ_INITIATE, 1); - delay(25); for (i = 0; i < 20; i++) { - delay(30); - - val = bus_space_read_4(st, sh, MEC_PHY_DATA); + delay(25); + val =
hppa minor cleanup
In the never ending story of "encoding of diag instructions is hard, let's go shopping" (as shown by at least rev 1.65, 1.66 and 1.189 of hppa locore.S), the following diff attempts to clean and fix things for good: - macros get a cpu-family suffix, since encoding differ accross processor families. - source of the information, when known, is mentioned. - two unused routines get removed. This does not change anything in the object code, as the remaining wrong encodings were only used in pbtlb_l which has not been used for ages. Index: hppa/locore.S === RCS file: /OpenBSD/src/sys/arch/hppa/hppa/locore.S,v retrieving revision 1.199 diff -u -p -r1.199 locore.S --- hppa/locore.S 16 Jul 2017 22:47:37 - 1.199 +++ hppa/locore.S 15 Nov 2018 20:25:21 - @@ -76,16 +76,23 @@ #include "assym.h" /* - * hv-specific instructions + * hw-specific instructions */ -#defineDR_PAGE0.word 0x14001200 -#defineDR_PAGE1.word 0x14001240 -#defineMTCPU_T(x,t).word 0x14001600 | ((t) << 21) | ((x) << 16) -#defineMFCPU_T(r,x).word 0x14001a00 | ((r) << 21) | ((x) << 16) -#defineMTCPU_C(x,t).word 0x14000240 | ((t) << 21) | ((x) << 16) -#defineMFCPU_C(r,x).word 0x14000600 | ((r) << 21) | ((x) << 16) -#defineMFCPU_U(r,x).word 0x140008a0 | ((r) << 21) | ((x)) -#defineMTCPU_U(x,r).word 0x14001840 | ((r) << 21) | ((x) << 16) + +/* source: mklinux cache.s */ +#defineMFCPU_C_PCXST(r,x) .word 0x14001a00 | ((r) << 21) | ((x) << 16) +#defineMTCPU_PCXST(x,r).word 0x14001600 | ((r) << 21) | ((x) << 16) + +/* source: PCXL and PCXL2 ERS */ +/* Use MFCPU_C for DR0-8; MFCPU_T for DR25,27,28,29 */ +#defineMFCPU_C_PCXL(r,x) .word 0x14000600 | ((r) << 21) | ((x) << 16) +#defineMFCPU_T_PCXL(r,x) .word 0x14001800 | ((r) << 21) | ((x)) +#defineMTCPU_PCXL(x,r) .word 0x14000240 | ((r) << 21) | ((x) << 16) +#defineDR_PAGE0_PCXL .word 0x14000e00 +#defineDR_PAGE1_PCXL .word 0x14000e40 + +#defineMFCPU_PCXU(r,x) .word 0x140008a0 | ((r) << 21) | ((x)) +#defineMTCPU_PCXU(x,r) .word 0x14001840 | ((r) << 21) | ((x) << 16) .import $global$, data .import pdc, data @@ -1646,8 +1653,8 @@ EXIT(TLABEL(all)) */ LEAF_ENTRY(desidhash_s) sync - MFCPU_T(DR_CPUCFG,22) /* t1 */ - MFCPU_T(DR_CPUCFG,22) + MFCPU_C_PCXST(DR_CPUCFG,22) /* t1 */ + MFCPU_C_PCXST(DR_CPUCFG,22) nop nop depi0, DR0_PCXS_DHE, 3, t1 /* 3: DR0_PCXS_DOMAIN|DR0_PCXS_IHE */ @@ -1656,8 +1663,8 @@ LEAF_ENTRY(desidhash_s) depi0, DR0_PCXS_DHPMC, 1, t1 depi0, DR0_PCXS_ILPMC, 1, t1 sync - MTCPU_T(22,DR_CPUCFG) - MTCPU_T(22,DR_CPUCFG) + MTCPU_PCXST(22,DR_CPUCFG) + MTCPU_PCXST(22,DR_CPUCFG) nop nop bv 0(rp) @@ -1671,8 +1678,8 @@ EXIT(desidhash_s) */ LEAF_ENTRY(desidhash_t) sync - MFCPU_T(DR_CPUCFG,22) /* t1 */ - MFCPU_T(DR_CPUCFG,22) + MFCPU_C_PCXST(DR_CPUCFG,22) /* t1 */ + MFCPU_C_PCXST(DR_CPUCFG,22) nop nop depi0, DR0_PCXT_IHE, 1, t1 @@ -1681,8 +1688,8 @@ LEAF_ENTRY(desidhash_t) depi0, DR0_PCXT_DHPMC, 1, t1 depi0, DR0_PCXT_ILPMC, 1, t1 sync - MTCPU_T(22,DR_CPUCFG) - MTCPU_T(22,DR_CPUCFG) + MTCPU_PCXST(22,DR_CPUCFG) + MTCPU_PCXST(22,DR_CPUCFG) nop nop bv 0(rp) @@ -1697,7 +1704,7 @@ LEAF_ENTRY(eaio_l2) ldilL%eaio_l2_mask, t2 ldw R%eaio_l2_mask(t2), t1 or t1, arg0, t1 - MTCPU_C(22, DR0_PCXL2_ACCEL_IO) + MTCPU_PCXL(22, DR0_PCXL2_ACCEL_IO) nop nop bv 0(rp) @@ -1719,54 +1726,11 @@ LEAF_ENTRY(ibtlb_l) mtsmt4 EXIT(ibtlb_l) -/* hpti_l(addr,size) */ -LEAF_ENTRY(hpti_l) - ldo -1(arg1), arg1 - depi0, 31, 12, arg1 - ldi 0x1c0, t1 /* cache size assumed 128k XXX */ - or arg0, t1, arg0 - sync - MTCPU_C(26,DR0_PCXL2_HTLB_ADDR) - MTCPU_C(25,DR0_PCXL2_HTLB_CFG) - nop - nop - bv,nr0(rp) - nop -EXIT(hpti_l) - -/* - * int - * pbtlb_l(int i) - */ -LEAF_ENTRY(pbtlb_l) - ; DR_PAGE0 - rsm (PSL_R|PSL_I), t4 - nop ! nop ! nop ! nop - ldilL%0xc041, t1 - ldo R%0xc041(t1), t1 - dep arg0, 30, 3, t1 - sync - MTCPU_T(22,DR_DTLB) /* t1 */ - nop - nop - mtspr0, sr1 - idtlba r0,(sr1,r0) - idtlbp r0,(sr1,r0) - zdepi -1, 18, 1, t1 - nop - sync - MTCPU_T(22,DR_DTLB) - nop - nop - bv 0(rp) - mtsmt4
Remove debug options in hppa GENERIC
The hppa GENERIC kernel contains various debug options for pcmcia and cardbus code. None of the other platforms enables these options in GENERIC. Index: sys/arch/hppa/conf/GENERIC === RCS file: /OpenBSD/src/sys/arch/hppa/conf/GENERIC,v retrieving revision 1.177 diff -u -p -u -p -r1.177 GENERIC --- sys/arch/hppa/conf/GENERIC 22 Aug 2018 15:38:46 - 1.177 +++ sys/arch/hppa/conf/GENERIC 3 Nov 2018 13:54:34 - @@ -78,9 +78,8 @@ lpt0 at ssio? # CardBus bus support cbb* at pci? cardslot* at cbb? -option CARDBUS_DEBUG,CARDSLOT_DEBUG,CARDBUS_MAP_DEBUG cardbus* at cardslot? -option PCMCIADEBUG,PCMCIAVERBOSE +option PCMCIAVERBOSE pcmcia*at cardslot? # PCI USB Controllers
Re: re-enable -Wshadow for openssl(1)?
> The -Wshadow warning was briefly enabled, but it turned out to break vax > builds with gcc3. Among other things, this warning helps catching stupid > mistakes in refactoring early, so I was wondering whether we could > re-enable it. The commit that disabled it also mentions gcc3, so I'm > unsure whether luna88k would be affected by this. gcc3 will warn like this: In file included from /usr/src/usr.bin/openssl/apps.h:117, from /usr/src/usr.bin/openssl/apps.c:138: /usr/include/openssl/bio.h:342: warning: declaration of `write' shadows a global declaration /usr/include/unistd.h:374: warning: shadowed declaration is here This is caused by the BIO_meth_*() prototypes using formal parameters nawed `read', `puts', etc. Alternatively, you may choose to enable -Wshadow only if building with a non-gcc3 toolchain.
[sparc64] dead code in emul.c
emul.c r1.19 removed a bunch of code, but not enough, and left dead code around. Index: emul.c === RCS file: /OpenBSD/src/sys/arch/sparc64/sparc64/emul.c,v retrieving revision 1.23 diff -u -p -r1.23 emul.c --- emul.c 16 Nov 2014 12:30:59 - 1.23 +++ emul.c 6 Aug 2018 20:11:00 - @@ -49,13 +49,9 @@ #define GPR(tf, i) ((int32_t *)(u_long)>tf_global)[i] #define IPR(tf, i) ((int32_t *)(u_long)tf->tf_out[6])[i - 16] -#define FPR(p, i) ((int32_t) p->p_md.md_fpstate->fs_regs[i]) -#define FPRSET(p, i, v)p->p_md.md_fpstate->fs_regs[i] = (v) static __inline int readgpreg(struct trapframe64 *, int, void *); -static __inline int readfpreg(struct proc *, int, void *); static __inline int writegpreg(struct trapframe64 *, int, const void *); -static __inline int writefpreg(struct proc *, int, const void *); static __inline int decodeaddr(struct trapframe64 *, union instr *, void *); static int muldiv(struct trapframe64 *, union instr *, int32_t *, int32_t *, int32_t *); @@ -81,7 +77,6 @@ readgpreg(tf, i, val) return error; } - static __inline int writegpreg(tf, i, val) struct trapframe64 *tf; @@ -99,28 +94,6 @@ writegpreg(tf, i, val) error = copyout((caddr_t) val, (tf, i), sizeof(int32_t)); return error; -} - - -static __inline int -readfpreg(p, i, val) - struct proc *p; - int i; - void *val; -{ - *(int32_t *) val = FPR(p, i); - return 0; -} - - -static __inline int -writefpreg(p, i, val) - struct proc *p; - int i; - const void *val; -{ - FPRSET(p, i, *(const int32_t *) val); - return 0; } static __inline int
Re: reduce hppa interrupt guts awfulness
> Regarding your diff. The approach seems reasonable to me. The magic > number in the gscbus.c doesn't fill me with joy. > > > + r[4] = cpu_gethpa(0) | (31 - irqbit); /* iar */ > > I realise you're following existing practice, but maybe you could you > add a gscbus_reg struct similar to what was used in the asp/lasi/wax > code and use that? I agree this wouldn't hurt, but then, locore uses hardcoded numbers because these offsets don't end up in genassym.cf. Oh well, some partial cleanup can't hurt. New diff - also, because the interrupt assignments at gsc are actually local to gsc interrupt controllers, there is no need to reverse the order of cpu_intr_findirq(). The "irq" mention in dmesg is a bit misleading, but fixing that would require the print function to be passed to pdc_scanbus() and it's a bit out of scope of these changes. Index: conf/GENERIC === RCS file: /OpenBSD/src/sys/arch/hppa/conf/GENERIC,v retrieving revision 1.175 diff -u -p -r1.175 GENERIC --- conf/GENERIC14 Feb 2018 23:51:49 - 1.175 +++ conf/GENERIC3 May 2018 17:08:26 - @@ -46,21 +46,19 @@ uturn0 at mainbus0 # U2/UTurn Runway IO uturn1 at mainbus0 astro* at mainbus0 # Astro memory & I/O controller -lasi0 at mainbus0 offset 0x10 irq 28 # LASI host adapter -lasi0 at mainbus0 offset 0xfd0 irq 28 # LASI on C1[01]0, J2[01]0 -lasi0 at phantomas0 offset 0xfd0 irq 28 # LASI on [AB]* -lasi0 at uturn? offset 0xfd0 irq 28 # LASI on [CJ]* -lasi1 at mainbus0 offset 0x50 irq 27 # 712 GIO card -asp* at mainbus0 irq 28 # this one comes w/ Viper and LEDs -wax* at mainbus0 irq 24 # Wax may host EISA as well -wax* at phantomas0 irq 24# Wax on [AB]* -wax* at uturn? irq 24# Wax on C* +lasi0 at mainbus0 offset 0x10 # LASI host adapter +lasi0 at mainbus0 offset 0xfd0# LASI on C1[01]0, J2[01]0 +lasi0 at phantomas0 offset 0xfd0 # LASI on [AB]* +lasi0 at uturn? offset 0xfd0 # LASI on [CJ]* +lasi1 at mainbus0 offset 0x50 # 712 GIO card +asp* at mainbus0 # this one comes w/ Viper and LEDs +wax* at mainbus0 # Wax may host EISA as well +wax* at phantomas0 # Wax on [AB]* +wax* at uturn? # Wax on C* mongoose* at mainbus0 irq 17 # EISA Bus Adapter (i82350 or TI???) #vmeb* at mainbus0 irq ? # VME bus adapter -dino0 at phantomas? irq 26# PCI bus bridge on [AB]* -dino1 at phantomas? irq 25 -dino0 at uturn0 irq 26# PCI bus bridge on [CJ]* -dino1 at uturn1 irq 25 +dino* at phantomas? # PCI bus bridge on [AB]* +dino* at uturn? # PCI bus bridge on [CJ]* pci* at dino? option PCIVERBOSE #pckbc0at dino? irq 9 @@ -176,12 +174,9 @@ onewire* at uow? udl* at uhub?# DisplayLink USB displays wsdisplay* at udl? -sti0 at mainbus0 irq 11 # [H]CRX-{8,24,48}[Z] graphics -sti0 at phantomas0 irq 11# builtin graphics on BC* -sti0 at uturn? irq 11 -sti1 at mainbus0 irq 12 -sti1 at phantomas0 irq 12 -sti1 at uturn? irq 12 +sti* at mainbus0 # [H]CRX-{8,24,48}[Z] graphics +sti* at phantomas0 # builtin graphics on BC* +sti* at uturn? sti* at pci? # EG-PCI, FX* # internal i/o space Index: conf/RAMDISK === RCS file: /OpenBSD/src/sys/arch/hppa/conf/RAMDISK,v retrieving revision 1.109 diff -u -p -r1.109 RAMDISK --- conf/RAMDISK30 Dec 2016 22:36:07 - 1.109 +++ conf/RAMDISK3 May 2018 17:08:26 - @@ -48,20 +48,18 @@ uturn0 at mainbus0 # U2/UTurn Runway I uturn1 at mainbus0 astro* at mainbus0 # Astro memory & I/O controller -lasi0 at mainbus0 offset 0x10 irq 28 # LASI host adapter -lasi0 at mainbus0 offset 0xfd0 irq 28 # LASI on C1[01]0, J2[01]0 -lasi0 at phantomas0 offset 0xfd0 irq 28 # LASI on [AB]* -lasi0 at uturn? offset 0xfd0 irq 28 # LASI on [CJ]* -lasi1 at mainbus0 offset 0x50 irq 27 # 712 GIO card -asp* at mainbus0 irq 28 # this one comes w/ Viper and LEDs -wax* at mainbus0 irq 24 # Wax may host EISA as well -wax* at phantomas0 irq 24# Wax on [AB]* -wax* at uturn? irq 24# Wax on C* +lasi0 at mainbus0 offset 0x10 # LASI host adapter +lasi0 at mainbus0 offset 0xfd0# LASI on C1[01]0, J2[01]0 +lasi0 at phantomas0 offset 0xfd0 # LASI on [AB]* +lasi0 at uturn? offset 0xfd0 # LASI on [CJ]* +lasi1 at mainbus0 offset 0x50 # 712 GIO card +asp* at mainbus0 # this one comes w/ Viper and LEDs +wax*