Re: Prevent off-by-one accounting hang in out-of-swap situations
> I wonder if the diff below makes a difference. It's hard to debug and it > might be worth adding a counter for bad swap slots. It did not help (but your diff is probably correct). > Index: uvm/uvm_anon.c > === > RCS file: /cvs/src/sys/uvm/uvm_anon.c,v > retrieving revision 1.56 > diff -u -p -r1.56 uvm_anon.c > --- uvm/uvm_anon.c2 Sep 2023 08:24:40 - 1.56 > +++ uvm/uvm_anon.c22 Oct 2023 21:27:42 - > @@ -116,7 +116,7 @@ uvm_anfree_list(struct vm_anon *anon, st > uvm_unlock_pageq(); /* free the daemon */ > } > } else { > - if (anon->an_swslot != 0) { > + if (anon->an_swslot != 0 && anon->an_swslot != SWSLOT_BAD) { > /* This page is no longer only in swap. */ > KASSERT(uvmexp.swpgonly > 0); > atomic_dec_int(&uvmexp.swpgonly);
Re: Prevent off-by-one accounting hang in out-of-swap situations
> On 21/10/23(Sat) 14:28, Miod Vallat wrote: > > > Stuart, Miod, I wonder if this also help for the off-by-one issue you > > > are seeing. It might not. > > > > It makes the aforementioned issue disappear on the affected machine. > > Thanks at lot for testing! Spoke too soon. I have just hit panic: kernel diagnostic assertion "uvmexp.swpgonly > 0" failed: file "/usr/src/sys/uvm/uvm_anon.c", line 121 Stopped at db_enter+0x8: add #0x4, r14 TIDPIDUID PRFLAGS PFLAGS CPU COMMAND *235984 11904 0 0x14000 0x2000 reaper db_enter() at db_enter+0x8 panic() at panic+0x74 __assert() at __assert+0x1c uvm_anfree_list() at uvm_anfree_list+0x156 amap_wipeout() at amap_wipeout+0xe6 uvm_unmap_detach() at uvm_unmap_detach+0x42 uvm_map_teardown() at uvm_map_teardown+0x104 uvmspace_free() at uvmspace_free+0x2a reaper() at reaper+0x86 ddb> show uvmexp Current UVM status: pagesize=4096 (0x1000), pagemask=0xfff, pageshift=12 14875 VM pages: 376 active, 2076 inactive, 1 wired, 7418 free (924 zero) min 10% (25) anon, 10% (25) vnode, 5% (12) vtext freemin=495, free-target=660, inactive-target=2809, wired-max=4958 faults=73331603, traps=39755714, intrs=33863551, ctxswitch=11641480 fpuswitch =0 softint=15742561, syscalls=39755712, kmapent=11 fault counts: noram=1, noanon=0, noamap=0, pgwait=1629, pgrele=0 ok relocks(total)=1523991(1524022), anget(retries)=23905247(950233), amapco py=9049749 neighbor anon/obj pg=12025732/40041442, gets(lock/unlock)=12859247/574102 cases: anon=20680175, anoncow=3225049, obj=11467884, prcopy=1391019, przero =36545783 daemon and swap counts: woke=6868, revs=6246, scans=3525644, obscans=511526, anscans=2930634 busy=0, freed=1973275, reactivate=83484, deactivate=3941988 pageouts=94506, pending=94506, nswget=949421 nswapdev=1 swpages=4194415, swpginuse=621, swpgonly=0 paging=0 kernel pointers: objs(kern)=0x8c3ca94c
Re: Prevent off-by-one accounting hang in out-of-swap situations
> Stuart, Miod, I wonder if this also help for the off-by-one issue you > are seeing. It might not. It makes the aforementioned issue disappear on the affected machine. > Comments, ok? > diff --git sys/uvm/uvm_pdaemon.c sys/uvm/uvm_pdaemon.c > index 284211d226c..a26a776df67 100644 > --- sys/uvm/uvm_pdaemon.c > +++ sys/uvm/uvm_pdaemon.c > @@ -917,9 +914,7 @@ uvmpd_scan(struct uvm_pmalloc *pma, struct > uvm_constraint_range *constraint) >*/ > free = uvmexp.free - BUFPAGES_DEFICIT; > swap_shortage = 0; > - if (free < uvmexp.freetarg && > - uvmexp.swpginuse == uvmexp.swpages && > - !uvm_swapisfull() && > + if (free < uvmexp.freetarg && uvm_swapisfilled() && !uvm_swapisfull() && > pages_freed == 0) { > swap_shortage = uvmexp.freetarg - free; > } It's unfortunate that you now invoke two uvm_swapisxxx() routines, which will both acquire a mutex. Maybe a third uvm_swapisxxx routine could be introduced to compute the swapisfilled && !swapisfull condition at once?
dwge(4): don't panic on truncated input packet
I had the misfortune of hitting a KASSERT in dwge: panic: kernel diagnostic assertion "len > 0" failed: file "/usr/src/sys/dev/fdt /if_dwge.c", line 1102 Stopped at panic+0x106:addia0,zero,256TIDPIDUID PR FLAGS PFLAGS CPU COMMAND *405136 98879 1500 0x3 00 git 301471 67731 0 0x14000 0x2001 softnet0 panic() at panic+0x106 panic() at panic dwge_rx_proc() at dwge_rx_proc+0x1d4 dwge_intr() at dwge_intr+0x4e plic_irq_dispatch() at plic_irq_dispatch+0xec plic_irq_handler() at plic_irq_handler+0x56 riscv_cpu_intr() at riscv_cpu_intr+0x22 cpu_exception_handler_supervisor() at cpu_exception_handler_supervisor+0x7a pmap_copy_page() at pmap_copy_page+0x94 uvm_pagerealloc_multi() at uvm_pagerealloc_multi+0x24e buf_realloc_pages() at buf_realloc_pages+0xa0 buf_flip_high() at buf_flip_high+0x64 bufcache_recover_dmapages() at bufcache_recover_dmapages+0x13a buf_get() at buf_get+0xec end trace frame: 0xffc04d9ac870, count: 0 The following diff should count the error and skirt the panic. Index: if_dwge.c === RCS file: /OpenBSD/src/sys/dev/fdt/if_dwge.c,v retrieving revision 1.19 diff -u -p -r1.19 if_dwge.c --- if_dwge.c 15 Aug 2023 08:27:30 - 1.19 +++ if_dwge.c 18 Oct 2023 16:37:59 - @@ -1099,13 +1101,15 @@ dwge_rx_proc(struct dwge_softc *sc) /* Strip off CRC. */ len -= ETHER_CRC_LEN; - KASSERT(len > 0); - - m = rxb->tb_m; - rxb->tb_m = NULL; - m->m_pkthdr.len = m->m_len = len; + if (len <= 0) { + ifp->if_ierrors++; + } else { + m = rxb->tb_m; + rxb->tb_m = NULL; + m->m_pkthdr.len = m->m_len = len; - ml_enqueue(&ml, m); + ml_enqueue(&ml, m); + } put++; if (sc->sc_rx_cons == (DWGE_NRXDESC - 1))
Re: __predict_{true,false} is this right?
> lines 195 and 196. Now my question, does this not sorta look wrong? > > Shouldn't these values be a little more unique? As in not the same? No, these are correct. These lines are used when the compiler does not support __predict_false and __predict_true, so __predict_whaterver(x) has to behave as a boolean evaluation of (x). Miod
Re: [PATCH] Support PS2 keyboard on chrromebook
> CC'ed back the mailing list. Oops, I thought I had replied to the list as well, my bad. > Tested your patch. It works on my Chromebook. Excellent. It's in! Thanks, Miod
Re: Diff for evaluation (WACOM tablet driver)
> On Sat, Aug 12, 2023 at 02:27:13PM +0000, Miod Vallat wrote: > > Third time's (hopefully) the charm. How about that diff? Too much things > > have been removed in uwacom. > > partial success! The wacom driver is recognized, no panics this time. But > the input is all over the place when I try to draw anything in gimp. It opens > windows and stuff that I didn't open. I think it was a mistake to try and have the wacom interrupt code cover the "new" models as well as the existing ones, so I've split it in two flavours. New diff below. Index: dev/hid/hid.c === RCS file: /OpenBSD/src/sys/dev/hid/hid.c,v retrieving revision 1.5 diff -u -p -r1.5 hid.c --- dev/hid/hid.c 20 May 2022 05:03:45 - 1.5 +++ dev/hid/hid.c 12 Aug 2023 15:51:13 - @@ -657,3 +657,52 @@ hid_is_collection(const void *desc, int hid_end_parse(hd); return (0); } + +struct hid_data * +hid_get_collection_data(const void *desc, int size, int32_t usage, +uint32_t collection) +{ + struct hid_data *hd; + struct hid_item hi; + + hd = hid_start_parse(desc, size, hid_all); + + DPRINTF("%s: usage=0x%x\n", __func__, usage); + while (hid_get_item(hd, &hi)) { + DPRINTF("%s: kind=%d id=%d usage=0x%x(0x%x)\n", __func__, + hi.kind, hi.report_ID, hi.usage, usage); + if (hi.kind == hid_collection && + hi.collection == collection && hi.usage == usage) { + DPRINTF("%s: found\n", __func__); + return hd; + } + } + DPRINTF("%s: not found\n", __func__); + hid_end_parse(hd); + return NULL; +} + +int +hid_get_id_of_collection(const void *desc, int size, int32_t usage, +uint32_t collection) +{ + struct hid_data *hd; + struct hid_item hi; + + hd = hid_start_parse(desc, size, hid_all); + + DPRINTF("%s: id=%d usage=0x%x\n", __func__, id, usage); + while (hid_get_item(hd, &hi)) { + DPRINTF("%s: kind=%d id=%d usage=0x%x(0x%x)\n", __func__, + hi.kind, hi.report_ID, hi.usage, usage); + if (hi.kind == hid_collection && + hi.collection == collection && hi.usage == usage) { + DPRINTF("%s: found\n", __func__); + hid_end_parse(hd); + return hi.report_ID; + } + } + DPRINTF("%s: not found\n", __func__); + hid_end_parse(hd); + return -1; +} Index: dev/hid/hid.h === RCS file: /OpenBSD/src/sys/dev/hid/hid.h,v retrieving revision 1.10 diff -u -p -r1.10 hid.h --- dev/hid/hid.h 20 May 2022 05:03:45 - 1.10 +++ dev/hid/hid.h 12 Aug 2023 15:51:13 - @@ -93,6 +93,10 @@ int hid_locate(const void *, int, int32_ int32_thid_get_data(const uint8_t *buf, int, struct hid_location *); uint32_t hid_get_udata(const uint8_t *buf, int, struct hid_location *); inthid_is_collection(const void *, int, uint8_t, int32_t); +struct hid_data * hid_get_collection_data(const void *, int, int32_t, + uint32_t); +inthid_get_id_of_collection(const void *desc, int size, int32_t usage, + uint32_t collection); #endif /* _KERNEL */ @@ -353,6 +357,7 @@ int hid_is_collection(const void *, int, #define HUD_TOUCHSCREEN0x0004 #define HUD_TOUCHPAD 0x0005 #define HUD_CONFIG 0x000e +#define HUD_STYLUS 0x0020 #define HUD_FINGER 0x0022 #define HUD_TIP_PRESSURE 0x0030 #define HUD_BARREL_PRESSURE0x0031 @@ -387,6 +392,12 @@ inthid_is_collection(const void *, int, #define HUD_CONTACT_MAX0x0055 #define HUD_SCAN_TIME 0x0056 #define HUD_BUTTON_TYPE0x0059 +#define HUD_SECONDARY_BARREL_SWITCH0x005A +#define HUD_WACOM_X0x0130 +#define HUD_WACOM_Y0x0131 +#define HUD_WACOM_DISTANCE 0x0132 +#define HUD_WACOM_PAD_BUTTONS000x0910 +#define HUD_WACOM_BATTERY 0x1013 /* Usages, LED */ #define HUL_NUM_LOCK 0x0001 Index: dev/hid/hidms.c === RCS file: /OpenBSD/src/sys/dev/hid/hidms.c,v retrieving revision 1.9 diff -u -p -r1.9 hidms.c --- dev/hid/hidms.c 16 Jun 2022 20:52:38 - 1.9 +++ dev/hid/hidms.c 12 Aug 2023 15:51:13 - @@ -61,6 +61,188 @@ int hidmsdebug = 0; #define MOUSE_FLAGS_MASK (HIO_CONST | HIO_RELATIVE) #define NOTMOUSE(f)(((f) & MOUSE_FLAGS_MASK) != HIO_RELATIVE) +void +hidms_stylus_hid_parse(struct hidms *ms, str
Re: Diff for evaluation (WACOM tablet driver)
Third time's (hopefully) the charm. How about that diff? Too much things have been removed in uwacom. Index: dev/hid/hid.c === RCS file: /OpenBSD/src/sys/dev/hid/hid.c,v retrieving revision 1.5 diff -u -p -r1.5 hid.c --- dev/hid/hid.c 20 May 2022 05:03:45 - 1.5 +++ dev/hid/hid.c 12 Aug 2023 14:24:53 - @@ -657,3 +657,52 @@ hid_is_collection(const void *desc, int hid_end_parse(hd); return (0); } + +struct hid_data * +hid_get_collection_data(const void *desc, int size, int32_t usage, +uint32_t collection) +{ + struct hid_data *hd; + struct hid_item hi; + + hd = hid_start_parse(desc, size, hid_all); + + DPRINTF("%s: usage=0x%x\n", __func__, usage); + while (hid_get_item(hd, &hi)) { + DPRINTF("%s: kind=%d id=%d usage=0x%x(0x%x)\n", __func__, + hi.kind, hi.report_ID, hi.usage, usage); + if (hi.kind == hid_collection && + hi.collection == collection && hi.usage == usage) { + DPRINTF("%s: found\n", __func__); + return hd; + } + } + DPRINTF("%s: not found\n", __func__); + hid_end_parse(hd); + return NULL; +} + +int +hid_get_id_of_collection(const void *desc, int size, int32_t usage, +uint32_t collection) +{ + struct hid_data *hd; + struct hid_item hi; + + hd = hid_start_parse(desc, size, hid_all); + + DPRINTF("%s: id=%d usage=0x%x\n", __func__, id, usage); + while (hid_get_item(hd, &hi)) { + DPRINTF("%s: kind=%d id=%d usage=0x%x(0x%x)\n", __func__, + hi.kind, hi.report_ID, hi.usage, usage); + if (hi.kind == hid_collection && + hi.collection == collection && hi.usage == usage) { + DPRINTF("%s: found\n", __func__); + hid_end_parse(hd); + return hi.report_ID; + } + } + DPRINTF("%s: not found\n", __func__); + hid_end_parse(hd); + return 0; +} Index: dev/hid/hid.h === RCS file: /OpenBSD/src/sys/dev/hid/hid.h,v retrieving revision 1.10 diff -u -p -r1.10 hid.h --- dev/hid/hid.h 20 May 2022 05:03:45 - 1.10 +++ dev/hid/hid.h 12 Aug 2023 14:24:53 - @@ -93,6 +93,10 @@ int hid_locate(const void *, int, int32_ int32_thid_get_data(const uint8_t *buf, int, struct hid_location *); uint32_t hid_get_udata(const uint8_t *buf, int, struct hid_location *); inthid_is_collection(const void *, int, uint8_t, int32_t); +struct hid_data * hid_get_collection_data(const void *, int, int32_t, + uint32_t); +inthid_get_id_of_collection(const void *desc, int size, int32_t usage, + uint32_t collection); #endif /* _KERNEL */ @@ -353,6 +357,7 @@ int hid_is_collection(const void *, int, #define HUD_TOUCHSCREEN0x0004 #define HUD_TOUCHPAD 0x0005 #define HUD_CONFIG 0x000e +#define HUD_STYLUS 0x0020 #define HUD_FINGER 0x0022 #define HUD_TIP_PRESSURE 0x0030 #define HUD_BARREL_PRESSURE0x0031 @@ -387,6 +392,12 @@ inthid_is_collection(const void *, int, #define HUD_CONTACT_MAX0x0055 #define HUD_SCAN_TIME 0x0056 #define HUD_BUTTON_TYPE0x0059 +#define HUD_SECONDARY_BARREL_SWITCH0x005A +#define HUD_WACOM_X0x0130 +#define HUD_WACOM_Y0x0131 +#define HUD_WACOM_DISTANCE 0x0132 +#define HUD_WACOM_PAD_BUTTONS000x0910 +#define HUD_WACOM_BATTERY 0x1013 /* Usages, LED */ #define HUL_NUM_LOCK 0x0001 Index: dev/hid/hidms.c === RCS file: /OpenBSD/src/sys/dev/hid/hidms.c,v retrieving revision 1.9 diff -u -p -r1.9 hidms.c --- dev/hid/hidms.c 16 Jun 2022 20:52:38 - 1.9 +++ dev/hid/hidms.c 12 Aug 2023 14:24:53 - @@ -61,6 +61,188 @@ int hidmsdebug = 0; #define MOUSE_FLAGS_MASK (HIO_CONST | HIO_RELATIVE) #define NOTMOUSE(f)(((f) & MOUSE_FLAGS_MASK) != HIO_RELATIVE) +void +hidms_stylus_hid_parse(struct hidms *ms, struct hid_data *d, +struct hid_location *loc_stylus_btn) +{ + struct hid_item h; + + while (hid_get_item(d, &h)) { + if (h.kind == hid_endcollection) + break; + if (h.kind != hid_input || (h.flags & HIO_CONST) != 0) + continue; + /* All the possible stylus reported usages go here */ +#ifdef HIDMS_DEBUG + printf("stylus usage: 0x%x\n", h.usage); +#endif + switch (h.usage) { + /* Buttons */ + case HID_USAGE2(HUP_WACOM | HUP_DIGITIZERS, HUD_TIP_SWITCH): +
Re: Diff for evaluation (WACOM tablet driver)
> On Sat, Aug 12, 2023 at 08:00:48AM +0000, Miod Vallat wrote: > > I have had a look at your diff and I think it's decent enough to go in > > after some polishing. > > > > Can Wacom tablet users try this cleaned up diff? > > Hi, > > My WACOM tablet stopped working with this, here is a dmesg with the patch and > usbdevs -v output. Let me know if there is any new patches I can test. > > As you can see it doesn't even attach like it should (from the dmesg). Thanks for reporting this. The changes in uhidev have been a bit too aggressive indeed. Does this new version of the diff help? Only uhidev.c differs. Index: dev/hid/hid.c === RCS file: /OpenBSD/src/sys/dev/hid/hid.c,v retrieving revision 1.5 diff -u -p -r1.5 hid.c --- dev/hid/hid.c 20 May 2022 05:03:45 - 1.5 +++ dev/hid/hid.c 12 Aug 2023 13:11:22 - @@ -657,3 +657,52 @@ hid_is_collection(const void *desc, int hid_end_parse(hd); return (0); } + +struct hid_data * +hid_get_collection_data(const void *desc, int size, int32_t usage, +uint32_t collection) +{ + struct hid_data *hd; + struct hid_item hi; + + hd = hid_start_parse(desc, size, hid_all); + + DPRINTF("%s: usage=0x%x\n", __func__, usage); + while (hid_get_item(hd, &hi)) { + DPRINTF("%s: kind=%d id=%d usage=0x%x(0x%x)\n", __func__, + hi.kind, hi.report_ID, hi.usage, usage); + if (hi.kind == hid_collection && + hi.collection == collection && hi.usage == usage) { + DPRINTF("%s: found\n", __func__); + return hd; + } + } + DPRINTF("%s: not found\n", __func__); + hid_end_parse(hd); + return NULL; +} + +int +hid_get_id_of_collection(const void *desc, int size, int32_t usage, +uint32_t collection) +{ + struct hid_data *hd; + struct hid_item hi; + + hd = hid_start_parse(desc, size, hid_all); + + DPRINTF("%s: id=%d usage=0x%x\n", __func__, id, usage); + while (hid_get_item(hd, &hi)) { + DPRINTF("%s: kind=%d id=%d usage=0x%x(0x%x)\n", __func__, + hi.kind, hi.report_ID, hi.usage, usage); + if (hi.kind == hid_collection && + hi.collection == collection && hi.usage == usage) { + DPRINTF("%s: found\n", __func__); + hid_end_parse(hd); + return hi.report_ID; + } + } + DPRINTF("%s: not found\n", __func__); + hid_end_parse(hd); + return 0; +} Index: dev/hid/hid.h === RCS file: /OpenBSD/src/sys/dev/hid/hid.h,v retrieving revision 1.10 diff -u -p -r1.10 hid.h --- dev/hid/hid.h 20 May 2022 05:03:45 - 1.10 +++ dev/hid/hid.h 12 Aug 2023 13:11:22 - @@ -93,6 +93,10 @@ int hid_locate(const void *, int, int32_ int32_thid_get_data(const uint8_t *buf, int, struct hid_location *); uint32_t hid_get_udata(const uint8_t *buf, int, struct hid_location *); inthid_is_collection(const void *, int, uint8_t, int32_t); +struct hid_data * hid_get_collection_data(const void *, int, int32_t, + uint32_t); +inthid_get_id_of_collection(const void *desc, int size, int32_t usage, + uint32_t collection); #endif /* _KERNEL */ @@ -353,6 +357,7 @@ int hid_is_collection(const void *, int, #define HUD_TOUCHSCREEN0x0004 #define HUD_TOUCHPAD 0x0005 #define HUD_CONFIG 0x000e +#define HUD_STYLUS 0x0020 #define HUD_FINGER 0x0022 #define HUD_TIP_PRESSURE 0x0030 #define HUD_BARREL_PRESSURE0x0031 @@ -387,6 +392,12 @@ inthid_is_collection(const void *, int, #define HUD_CONTACT_MAX0x0055 #define HUD_SCAN_TIME 0x0056 #define HUD_BUTTON_TYPE0x0059 +#define HUD_SECONDARY_BARREL_SWITCH0x005A +#define HUD_WACOM_X0x0130 +#define HUD_WACOM_Y0x0131 +#define HUD_WACOM_DISTANCE 0x0132 +#define HUD_WACOM_PAD_BUTTONS000x0910 +#define HUD_WACOM_BATTERY 0x1013 /* Usages, LED */ #define HUL_NUM_LOCK 0x0001 Index: dev/hid/hidms.c === RCS file: /OpenBSD/src/sys/dev/hid/hidms.c,v retrieving revision 1.9 diff -u -p -r1.9 hidms.c --- dev/hid/hidms.c 16 Jun 2022 20:52:38 - 1.9 +++ dev/hid/hidms.c 12 Aug 2023 13:11:22 - @@ -61,6 +61,188 @@ int hidmsdebug = 0; #define MOUSE_FLAGS_MASK (HIO_CONST | HIO_RELATIVE) #define NOTMOUSE(f)(((f) & MOUSE_FLAG
Re: Diff for evaluation (WACOM tablet driver)
I have had a look at your diff and I think it's decent enough to go in after some polishing. Can Wacom tablet users try this cleaned up diff? Index: dev/hid/hid.c === RCS file: /OpenBSD/src/sys/dev/hid/hid.c,v retrieving revision 1.5 diff -u -p -r1.5 hid.c --- dev/hid/hid.c 20 May 2022 05:03:45 - 1.5 +++ dev/hid/hid.c 12 Aug 2023 07:59:14 - @@ -657,3 +657,52 @@ hid_is_collection(const void *desc, int hid_end_parse(hd); return (0); } + +struct hid_data * +hid_get_collection_data(const void *desc, int size, int32_t usage, +uint32_t collection) +{ + struct hid_data *hd; + struct hid_item hi; + + hd = hid_start_parse(desc, size, hid_all); + + DPRINTF("%s: usage=0x%x\n", __func__, usage); + while (hid_get_item(hd, &hi)) { + DPRINTF("%s: kind=%d id=%d usage=0x%x(0x%x)\n", __func__, + hi.kind, hi.report_ID, hi.usage, usage); + if (hi.kind == hid_collection && + hi.collection == collection && hi.usage == usage) { + DPRINTF("%s: found\n", __func__); + return hd; + } + } + DPRINTF("%s: not found\n", __func__); + hid_end_parse(hd); + return NULL; +} + +int +hid_get_id_of_collection(const void *desc, int size, int32_t usage, +uint32_t collection) +{ + struct hid_data *hd; + struct hid_item hi; + + hd = hid_start_parse(desc, size, hid_all); + + DPRINTF("%s: id=%d usage=0x%x\n", __func__, id, usage); + while (hid_get_item(hd, &hi)) { + DPRINTF("%s: kind=%d id=%d usage=0x%x(0x%x)\n", __func__, + hi.kind, hi.report_ID, hi.usage, usage); + if (hi.kind == hid_collection && + hi.collection == collection && hi.usage == usage) { + DPRINTF("%s: found\n", __func__); + hid_end_parse(hd); + return hi.report_ID; + } + } + DPRINTF("%s: not found\n", __func__); + hid_end_parse(hd); + return 0; +} Index: dev/hid/hid.h === RCS file: /OpenBSD/src/sys/dev/hid/hid.h,v retrieving revision 1.10 diff -u -p -r1.10 hid.h --- dev/hid/hid.h 20 May 2022 05:03:45 - 1.10 +++ dev/hid/hid.h 12 Aug 2023 07:59:14 - @@ -93,6 +93,10 @@ int hid_locate(const void *, int, int32_ int32_thid_get_data(const uint8_t *buf, int, struct hid_location *); uint32_t hid_get_udata(const uint8_t *buf, int, struct hid_location *); inthid_is_collection(const void *, int, uint8_t, int32_t); +struct hid_data * hid_get_collection_data(const void *, int, int32_t, + uint32_t); +inthid_get_id_of_collection(const void *desc, int size, int32_t usage, + uint32_t collection); #endif /* _KERNEL */ @@ -353,6 +357,7 @@ int hid_is_collection(const void *, int, #define HUD_TOUCHSCREEN0x0004 #define HUD_TOUCHPAD 0x0005 #define HUD_CONFIG 0x000e +#define HUD_STYLUS 0x0020 #define HUD_FINGER 0x0022 #define HUD_TIP_PRESSURE 0x0030 #define HUD_BARREL_PRESSURE0x0031 @@ -387,6 +392,12 @@ inthid_is_collection(const void *, int, #define HUD_CONTACT_MAX0x0055 #define HUD_SCAN_TIME 0x0056 #define HUD_BUTTON_TYPE0x0059 +#define HUD_SECONDARY_BARREL_SWITCH0x005A +#define HUD_WACOM_X0x0130 +#define HUD_WACOM_Y0x0131 +#define HUD_WACOM_DISTANCE 0x0132 +#define HUD_WACOM_PAD_BUTTONS000x0910 +#define HUD_WACOM_BATTERY 0x1013 /* Usages, LED */ #define HUL_NUM_LOCK 0x0001 Index: dev/hid/hidms.c === RCS file: /OpenBSD/src/sys/dev/hid/hidms.c,v retrieving revision 1.9 diff -u -p -r1.9 hidms.c --- dev/hid/hidms.c 16 Jun 2022 20:52:38 - 1.9 +++ dev/hid/hidms.c 12 Aug 2023 07:59:14 - @@ -61,6 +61,188 @@ int hidmsdebug = 0; #define MOUSE_FLAGS_MASK (HIO_CONST | HIO_RELATIVE) #define NOTMOUSE(f)(((f) & MOUSE_FLAGS_MASK) != HIO_RELATIVE) +void +hidms_stylus_hid_parse(struct hidms *ms, struct hid_data *d, +struct hid_location *loc_stylus_btn) +{ + struct hid_item h; + + while (hid_get_item(d, &h)) { + if (h.kind == hid_endcollection) + break; + if (h.kind != hid_input || (h.flags & HIO_CONST) != 0) + continue; + /* All the possible stylus reported usages go here */ +#ifdef HIDMS_DEBUG + printf("stylus usage: 0x%x\n", h.usage); +#endif + switch (h.usage) { + /* Buttons */ + case HID_USAGE2(HUP_WACOM | HUP_DIGIT
Re: [PATCH] Support PS2 keyboard on chrromebook
> On, at least, some Chromebook PS/2 protocol is implemented by EC rather > than a real PS/2 controller. It works fine except for 2 things: > * Unusual layout like multimedia keys instead of F* > * Reset command returns garbage (usually last key) > This patch attempts to handle later as it stops keyboard from being > recognized at all. It works by checking getid if reset fails. I was not aware of the reset behaviour. I suppose your logic makes sense. However, only Chromebook or other crap hardware would hit that "send a getid command" path, so I think we should only check for a 0xab/0x83 answer to that command, rather than six possible values for the first byte and ignoring the second byte. Have you checked that the Chromebook EC 8042 emulation returns 0xab/0x83 to the 0xf2 command? Miod
Re: m2: add suspend keyboard shortcut
> Now that we have request_sleep() we can add a new internal KS_Cmd_Sleep > keycode, map it into the macbook keyboard, catch in wskbd and go to sleep. > > ok? > --- sys/dev/usb/ukbdmap.c > +++ sys/dev/usb/ukbdmap.c > @@ -176,6 +176,7 @@ static const keysym_t ukbd_keydesc_us[] = { > KC(127), KS_AudioMute, > KC(128), KS_AudioRaise, > KC(129), KS_AudioLower, > +KC(130), KS_Cmd_Sleep, > KC(224), KS_Cmd1,KS_Control_L, > KC(225), KS_Shift_L, > KC(226), KS_Cmd2,KS_Alt_L, This file is generated, so the changes would be lost eventually. You should add this in makemap.awk in the block starting at line 330. Also, that block mentions the use of keysym 102 for suspend, rather than 130 (which you probably picked randomly), so I would prefer if you would use 102, this would allow this feature to also work on more systems. > --- sys/dev/wscons/wskbd.c > +++ sys/dev/wscons/wskbd.c > @@ -1513,6 +1513,11 @@ internal_command(struct wskbd_softc *sc, u_int *type, > if (*type != WSCONS_EVENT_KEY_DOWN) > return (0); > > +#ifdef SUSPEND > + if (ksym == KS_Cmd_Sleep) > + return request_sleep(SLEEP_SUSPEND); > +#endif I think you should return 1 regardless of the result of request_sleep().
Re: [patch] Discontinued Toshiba dynadock lines for usbdevs and udl driver
> Good Day, > > https://uk.dynabook.com/discontinued-products/pa3542e-2prp/ > > one more device with old (probably DL-160, but unsure so leaving > DLUNK) DisplayLink chip. works ok. Patch applied, thanks! Miod
acpithinkpad: do not report fans running at 65535 rpm
After suspending a machine with acpithinkpad(4) and resuming, the fan senors report a value of 65535 (i.e. 0x) for a few seconds, and then start reporting correct values. The following diff marks the sensor as invalid when such a value is read. Index: acpithinkpad.c === RCS file: /OpenBSD/src/sys/dev/acpi/acpithinkpad.c,v retrieving revision 1.71 diff -u -p -r1.71 acpithinkpad.c --- acpithinkpad.c 9 Apr 2023 17:50:02 - 1.71 +++ acpithinkpad.c 24 Apr 2023 14:05:18 - @@ -287,7 +287,12 @@ thinkpad_sensor_refresh(void *arg) /* Read fan RPM */ acpiec_read(sc->sc_ec, THINKPAD_ECOFFSET_FANLO, 1, &lo); acpiec_read(sc->sc_ec, THINKPAD_ECOFFSET_FANHI, 1, &hi); - sc->sc_sens[THINKPAD_SENSOR_FANRPM].value = ((hi << 8L) + lo); + if (hi == 0xff && lo == 0xff) { + sc->sc_sens[THINKPAD_SENSOR_FANRPM].flags = SENSOR_FINVALID; + } else { + sc->sc_sens[THINKPAD_SENSOR_FANRPM].value = ((hi << 8L) + lo); + sc->sc_sens[THINKPAD_SENSOR_FANRPM].flags = 0; + } } void
Re: get rid of pmap_copy()
> I'm fine with removing this. Just wonder if this was ever implemented > for one of the architectures that we no longer support and whether > there was any effect on performance. Nope, never implemented anywhere. If you want to see a pmap_copy() implementation, look at FreeBSD.
get rid of pmap_copy()
pmap_copy() is an optional pmap interface which has never been implemented. In pure Mary Kondo style, we should thank it for the joy it brought to CSRG people, and move it to the recycling bin - it's not going to be implemented anytime soon. Index: share/man/man9/pmap.9 === RCS file: /OpenBSD/src/share/man/man9/pmap.9,v retrieving revision 1.19 diff -u -p -r1.19 pmap.9 --- share/man/man9/pmap.9 16 Dec 2019 10:34:04 - 1.19 +++ share/man/man9/pmap.9 2 Apr 2023 19:23:11 - @@ -49,8 +49,7 @@ .Nm pmap_growkernel , .Nm pmap_update , .Nm pmap_collect , -.Nm pmap_virtual_space , -.Nm pmap_copy +.Nm pmap_virtual_space .Nd machine dependent interface to the MMU .Sh SYNOPSIS .In machine/pmap.h @@ -366,9 +365,6 @@ it contains no valid mappings. .Fn pmap_collect "pmap_t pmap" .Ft void .Fn pmap_virtual_space "vaddr_t *vstartp" "vaddr_t *vendp" -.Ft void -.Fn pmap_copy "pmap_t dst_pmap" "pmap_t src_pmap" "vaddr_t dst_addr" \ - "vsize_t len" "vaddr_t src_addr" .nr nS 0 .Pp Wired memory allocation before the virtual memory system is bootstrapped @@ -398,26 +394,6 @@ is not expected to be used for some time module a chance to prioritize. The initial bounds of the kernel virtual address space are returned by .Fn pmap_virtual_space . -.Pp -The -.Fn pmap_copy -function copies the range specified by -.Fa src_addr -and -.Fa src_len -from -.Fa src_pmap -to the range described by -.Fa dst_addr -and -.Fa dst_len -in -.Fa dst_map . -.Fn pmap_copy -is called during a -.Xr fork 2 -operation to give the child process an initial set of low-level -mappings. .Sh SEE ALSO .Xr fork 2 , .Xr uvm_init 9 Index: sys/arch/alpha/alpha/pmap.c === RCS file: /OpenBSD/src/sys/arch/alpha/alpha/pmap.c,v retrieving revision 1.89 diff -u -p -r1.89 pmap.c --- sys/arch/alpha/alpha/pmap.c 6 Feb 2023 11:16:22 - 1.89 +++ sys/arch/alpha/alpha/pmap.c 2 Apr 2023 19:23:11 - @@ -2017,17 +2017,6 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa } /* - * pmap_copy: [ INTERFACE ] - * - * Copy the mapping range specified by src_addr/len - * from the source map to the range dst_addr/len - * in the destination map. - * - * This routine is only advisory and need not do anything. - */ -/* call deleted in */ - -/* * pmap_collect: [ INTERFACE ] * * Garbage collects the physical map system for pages which are no Index: sys/arch/alpha/include/pmap.h === RCS file: /OpenBSD/src/sys/arch/alpha/include/pmap.h,v retrieving revision 1.44 diff -u -p -r1.44 pmap.h --- sys/arch/alpha/include/pmap.h 6 Feb 2023 11:16:22 - 1.44 +++ sys/arch/alpha/include/pmap.h 2 Apr 2023 19:23:11 - @@ -155,7 +155,6 @@ voidpmap_do_tlb_shootdown(struct cpu_in #definepmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) #definepmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) -#define pmap_copy(dp, sp, da, l, sa) /* nothing */ #define pmap_update(pmap) /* nothing (yet) */ #define pmap_proc_iflush(p, va, len) /* nothing */ Index: sys/arch/amd64/amd64/pmap.c === RCS file: /OpenBSD/src/sys/arch/amd64/amd64/pmap.c,v retrieving revision 1.162 diff -u -p -r1.162 pmap.c --- sys/arch/amd64/amd64/pmap.c 30 Jan 2023 11:21:26 - 1.162 +++ sys/arch/amd64/amd64/pmap.c 2 Apr 2023 19:23:11 - @@ -2257,17 +2257,6 @@ pmap_collect(struct pmap *pmap) } #endif -/* - * pmap_copy: copy mappings from one pmap to another - * - * => optional function - * void pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) - */ - -/* - * defined as macro in pmap.h - */ - void pmap_enter_special(vaddr_t va, paddr_t pa, vm_prot_t prot) { Index: sys/arch/amd64/include/pmap.h === RCS file: /OpenBSD/src/sys/arch/amd64/include/pmap.h,v retrieving revision 1.85 diff -u -p -r1.85 pmap.h --- sys/arch/amd64/include/pmap.h 31 Jan 2023 15:18:54 - 1.85 +++ sys/arch/amd64/include/pmap.h 2 Apr 2023 19:23:11 - @@ -369,7 +369,6 @@ extern const long nbpd[], nkptpmax[]; #define pmap_clear_modify(pg) pmap_clear_attrs(pg, PG_M) #define pmap_clear_reference(pg) pmap_clear_attrs(pg, PG_U) -#define pmap_copy(DP,SP,D,L,S) #define pmap_is_modified(pg) pmap_test_attrs(pg, PG_M) #define pmap_is_referenced(pg) pmap_test_attrs(pg, PG_U) #define pmap_move(DP,SP,D,L,S) Index: sys/arch/arm/include/pmap.h === RCS file: /OpenBSD/src/sys/arch/arm/include/pmap.h,v retrieving revision 1.53 diff -u -p -r1.53 pmap.h --- sys/arch/arm/include/pmap.h 31 Jan 2023 15:18:54 - 1.53 +++ sys/arch/arm
remove pci_{io,mem}_find
pci_{io,mem}_find() have intentionally been left undocumented, developers being (rightfully) advised to use pci_mapreg_info() instead. The following diff removes these undocumented functions and converts their last few users. Bonus changes introduced while looking into this: - correctly cope with 64-bit memory bars in ppb, should there ever exist (I honestly believe that, should that be the case, this would have been noticed with failures to detect or attach devices in the past). - do not hardcode memory type for rtsx (although the fact the driver works implies that this isn't likely to ever be an I/O bar). Index: share/man/man9/pci_mapreg_map.9 === RCS file: /cvs/src/share/man/man9/pci_mapreg_map.9,v retrieving revision 1.1 diff -u -p -u -p -r1.1 pci_mapreg_map.9 --- share/man/man9/pci_mapreg_map.9 23 Feb 2019 04:54:25 - 1.1 +++ share/man/man9/pci_mapreg_map.9 1 Apr 2023 17:15:36 - @@ -23,8 +23,6 @@ .Nm pci_mapreg_info , .Nm pci_mapreg_probe , .Nm pci_mapreg_type -.\" .Nm pci_mem_find , -.\" .Nm pci_io_find .Nd PCI register mappings .Sh SYNOPSIS .In dev/pci/pcivar.h @@ -63,24 +61,6 @@ .Fa "pcitag_t tag" .Fa "int reg" .Fc -.\" .Ft int -.\" .Fo pci_mem_find -.\" .Fa "pci_chipset_tag_t pc" -.\" .Fa "pcitag_t pcitag" -.\" .Fa "int reg" -.\" .Fa "bus_addr_t *basep" -.\" .Fa "bus_size_t *sizep" -.\" .Fa "int *cacheablep" -.\" .Fc -.\" .Ft int -.\" .Fo pci_io_find -.\" .Fa "pci_chipset_tag_t pc" -.\" .Fa "pcitag_t pcitag" -.\" .Fa "int reg" -.\" .Fa "bus_addr_t *basep" -.\" .Fa "bus_size_t *sizep" -.\" .Fa "int *cacheablep" -.\" .Fc .Sh DESCRIPTION These functions provide wrappers and helpers around .Xr bus_space 9 Index: sys/arch/hppa/dev/sti_pci_machdep.c === RCS file: /cvs/src/sys/arch/hppa/dev/sti_pci_machdep.c,v retrieving revision 1.2 diff -u -p -u -p -r1.2 sti_pci_machdep.c --- sys/arch/hppa/dev/sti_pci_machdep.c 10 Apr 2009 17:11:27 - 1.2 +++ sys/arch/hppa/dev/sti_pci_machdep.c 1 Apr 2023 17:15:37 - @@ -51,22 +51,13 @@ sti_pci_is_console(struct pci_attach_arg * matches what PAGE0 says, then we are the console, and it * doesn't matter which BAR matched. */ - for (bar = PCI_MAPREG_START; bar <= PCI_MAPREG_PPB_END; ) { + for (bar = PCI_MAPREG_START; bar <= PCI_MAPREG_PPB_END; bar += 4) { cf = pci_conf_read(paa->pa_pc, paa->pa_tag, bar); - - if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_IO) { - rc = pci_io_find(paa->pa_pc, paa->pa_tag, bar, &addr, - NULL); + rc = pci_mapreg_info(paa->pa_pc, paa->pa_tag, bar, + _PCI_MAPREG_TYPEBITS(cf), &addr, NULL, NULL); + if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_MEM && + PCI_MAPREG_MEM_TYPE(cf) == PCI_MAPREG_MEM_TYPE_64BIT) bar += 4; - } else { - rc = pci_mem_find(paa->pa_pc, paa->pa_tag, bar, &addr, - NULL, NULL); - if (PCI_MAPREG_MEM_TYPE(cf) == - PCI_MAPREG_MEM_TYPE_64BIT) - bar += 8; - else - bar += 4; - } if (rc == 0 && (hppa_hpa_t)addr == (hppa_hpa_t)PAGE0->mem_cons.pz_hpa) Index: sys/arch/macppc/pci/vgafb.c === RCS file: /cvs/src/sys/arch/macppc/pci/vgafb.c,v retrieving revision 1.64 diff -u -p -u -p -r1.64 vgafb.c --- sys/arch/macppc/pci/vgafb.c 31 Dec 2022 05:06:18 - 1.64 +++ sys/arch/macppc/pci/vgafb.c 1 Apr 2023 17:15:37 - @@ -508,7 +508,7 @@ vgafb_mapregs(struct vgafb_softc *sc, st bus_addr_t ba; bus_size_t bs; int hasmem = 0, hasmmio = 0; - uint32_t i, cf; + uint32_t bar, cf; int rv; /* @@ -517,12 +517,12 @@ vgafb_mapregs(struct vgafb_softc *sc, st * For nvidia, this finds mmio 0x10 and frame memory 0x14. * Some nvidias have a 3rd mem region 0x18, which we ignore. */ - for (i = PCI_MAPREG_START; i <= PCI_MAPREG_PPB_END; i += 4) { - cf = pci_conf_read(pa->pa_pc, pa->pa_tag, i); + for (bar = PCI_MAPREG_START; bar <= PCI_MAPREG_PPB_END; bar += 4) { + cf = pci_conf_read(pa->pa_pc, pa->pa_tag, bar); if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_MEM) { /* Memory mapping... frame memory or mmio? */ - rv = pci_mem_find(pa->pa_pc, pa->pa_tag, i, - &ba, &bs, NULL); + rv = pci_mapreg_info(pa->pa_pc, pa->pa_tag, bar, + _PCI_MAPREG_TYPEBITS(cf), &ba, &bs, NULL); if (rv != 0)
Re: atactl: Update common SMART attribute names
> The last times the attribute names were updated were 14 and 21 years ago. > Modern drives, especially SSDs, get a lot of Unknown columns from the > 'readattr' command. > > Attributes were coalesced from smartmontools, NetBSD's atactl, and > Wikipedia's citations. Manufacturer-specific attributes and overrides were > not attempted, as that's an imprecise art probably better left to > smartmontools. Applied, thanks! Miod
Re: Fix broken UTF-8 decoding
> Currently it is not possible to use unicode codepoints > 0xFF on the console, > because our UTF-8 decoding logic is badly broken. > > The code in question is in wsemul_subr.c, wsemul_getchar(). > > The problem is that we calculate the number of bytes in a multi-byte > sequence by just looking at the high bits in turn: > > if (frag & 0x20) { > frag &= ~0x20; > mbleft++; > } > if (frag & 0x10) { > frag &= ~0x10; > mbleft++; > } > if (frag & 0x08) { > frag &= ~0x08; > mbleft++; > } > if (frag & 0x04) { > frag &= ~0x04; > mbleft++; > } > > This is wrong, for several reasons. Doh! Thanks for noticing this. I have replaced that code with something much saner now. Miod
Re: format strings in libexpat
> Does this actually change something on any of our architectures? This gets rid of warnings such as: /usr/src/lib/libexpat/lib/xmlparse.c: In function 'accountingReportDiff': /usr/src/lib/libexpat/lib/xmlparse.c:7704: warning: format '%6d' expects type 'int', but argument 3 has type 'ptrdiff_t' but otherwise won't change anything. > If not, I would prefer to stick to upstream #ifdef hell. This > avoids possible merge errors in every expat release. Sure.
format strings in libexpat
libexpat assumes the compiler might not know of the C99 format specifiers for ptrdiff_t and size_t, and tries to guess alternative format strings. The following diff relieves it of this misery (but can't be sent upѕtream, as it is too aggressive). Index: lib/internal.h === RCS file: /OpenBSD/src/lib/libexpat/lib/internal.h,v retrieving revision 1.10 diff -u -p -r1.10 internal.h --- lib/internal.h 20 Sep 2022 23:00:53 - 1.10 +++ lib/internal.h 18 Feb 2023 08:16:19 - @@ -105,31 +105,9 @@ # endif #endif -#include // ULONG_MAX - -#if defined(_WIN32) \ -&& (! defined(__USE_MINGW_ANSI_STDIO) \ -|| (1 - __USE_MINGW_ANSI_STDIO - 1 == 0)) -# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u" -# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW -#define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d" -#define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u" -# else -#define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d" -#define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u" -# endif -#else -# define EXPAT_FMT_ULL(midpart) "%" midpart "llu" -# if ! defined(ULONG_MAX) -#error Compiler did not define ULONG_MAX for us -# elif ULONG_MAX == 18446744073709551615u // 2^64-1 -#define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld" -#define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu" -# else -#define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d" -#define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u" -# endif -#endif +#define EXPAT_FMT_ULL(midpart) "%" midpart "llu" +#define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "td" +#define EXPAT_FMT_SIZE_T(midpart) "%" midpart "zu" #ifndef UNUSED_P # define UNUSED_P(p) (void)p
Re: [trivial patch] KASSERT within DIAGNOSTIC
> Here are a few more instances of KASSERT being placed in an #ifdef DIAGNOSTIC > block. This is redundant, as KASSERT is already a nop if DIAGNOSTIC is not > defined. Yes and no. You are right that KASSERT is a nop on non-DIAGNOSTIC kernels, but there are sometimes good reasons to keep a single KASSERT (or a set of KASSERTs) wrapped within #ifdef DIAGNOSTIC. > Index: crypto/blake2s.c In this case, the removal is valid and worth doing (in blake2s.h too). > Index: dev/ic/ahci.c > === > RCS file: /cvs/src/sys/dev/ic/ahci.c,v > retrieving revision 1.38 > diff -u -p -r1.38 ahci.c > --- dev/ic/ahci.c 9 Apr 2022 20:10:26 - 1.38 > +++ dev/ic/ahci.c 19 Jan 2023 13:30:37 - > @@ -2472,19 +2472,16 @@ ahci_put_err_ccb(struct ahci_ccb *ccb) > > splassert(IPL_BIO); > > -#ifdef DIAGNOSTIC > KASSERT(ap->ap_err_busy); > -#endif > + In this case, I would keep the #ifdef because this field only exists #ifdef DIAGNOSTIC, so all the code operating on it should have such guards for consistency. > /* No commands may be active on the chip */ > sact = ahci_pread(ap, AHCI_PREG_SACT); > if (sact != 0) > printf("ahci_put_err_ccb but SACT %08x != 0?\n", sact); > KASSERT(ahci_pread(ap, AHCI_PREG_CI) == 0); > > -#ifdef DIAGNOSTIC > /* Done with the CCB */ > KASSERT(ccb == ap->ap_ccb_err); > -#endif In this case, on the other hand, the #ifdef can be removed. > Index: dev/wscons/wsemul_sun.c > === > RCS file: /cvs/src/sys/dev/wscons/wsemul_sun.c,v > retrieving revision 1.34 > diff -u -p -r1.34 wsemul_sun.c > --- dev/wscons/wsemul_sun.c 25 May 2020 09:55:49 - 1.34 > +++ dev/wscons/wsemul_sun.c 19 Jan 2023 13:30:38 - > @@ -242,9 +242,9 @@ wsemul_sun_attach(int console, const str > > if (console) { > edp = &wsemul_sun_console_emuldata; > -#ifdef DIAGNOSTIC > + > KASSERT(edp->console == 1); > -#endif > + Same as for ahci: The `console' field only exists #ifdef DIAGNOSTIC, so the guards must remain (and in that respect, wsemul_vt100.c r1.40 was a mistake). > Index: net/wg_noise.c The removal is valid here.
sparc64: normalize prom mappings
tl;dr: if you have a sparc64 machine, please try this diff and report if your system no longer works with it. On sparc64, the kernel keeps the existing OpenFirmware memory mappings into the kernel pmap, so as to be able to use ofw routines and walk the device tree. However, these translation table entries have a few, software-defined, bits, which matter to the OpenBSD kernel and may or may not matter to the PROM. Recent experiments have shown that, on at least one sparc64 system, one of these software bits is set in the translations inherited from OpenFirmware, and this could be misleading. A quick examination of property dumps (eeprom -p, "translations" property) collected from various sparc64 systems shows that apparently most, if not all, systems with UltraSPARC I/II/IIi/IIe processors have TTE values with unwanted bits set. The following diff normalizes these values by clearing all software-defined bits, when adding them to the kernel pmap. It needs to be tested on as many systems as possible - if they still boot multiuser, and can reboot without problems, then everything's fine. I'd like to hear about systems no longer working correctly with this diff, should there be any. Miod Index: sys/arch/sparc64/sparc64/pmap.c === RCS file: /OpenBSD/src/sys/arch/sparc64/sparc64/pmap.c,v retrieving revision 1.106 diff -u -p -r1.106 pmap.c --- sys/arch/sparc64/sparc64/pmap.c 10 Sep 2022 20:35:29 - 1.106 +++ sys/arch/sparc64/sparc64/pmap.c 5 Jan 2023 19:48:09 - @@ -1074,6 +1074,7 @@ remap_data: if (prom_map[i].vstart && ((prom_map[i].vstart>>32) == 0)) { for (j = 0; j < prom_map[i].vsize; j += NBPG) { int k; + uint64_t tte; for (k = 0; page_size_map[k].mask; k++) { if (((prom_map[i].vstart | @@ -1084,9 +1085,14 @@ remap_data: break; } /* Enter PROM map into pmap_kernel() */ + tte = prom_map[i].tte; + if (CPU_ISSUN4V) + tte &= ~SUN4V_TLB_SOFT_MASK; + else + tte &= ~(SUN4U_TLB_SOFT2_MASK | + SUN4U_TLB_SOFT_MASK); pmap_enter_kpage(prom_map[i].vstart + j, - (prom_map[i].tte + j)|data| - page_size_map[k].code); + (tte + j) | data | page_size_map[k].code); } } }
Re: crunchgen and llvm 15
> I'm not sure which way to go: either sprinkle some -fno-common between > crunchgen and distrib/special/Makefile.inc, or drop -dc on lld archs > only. What would you folks prefer? I'd rather have the same behaviour for all platforms, but I need to test a few more gcc platforms first.
Re: crunchgen and llvm 15
You need this extra chunk for your diff to work. With that, the built instbin binary appears to behave as expected on hppa. Index: distrib/special/Makefile.inc === RCS file: /OpenBSD/src/distrib/special/Makefile.inc,v retrieving revision 1.9 diff -u -p -u -p -r1.9 Makefile.inc --- distrib/special/Makefile.inc10 Mar 2021 22:52:28 - 1.9 +++ distrib/special/Makefile.inc30 Dec 2022 06:14:37 - @@ -1,7 +1,7 @@ # options for all the directories below COPTS+=-Oz -fno-stack-protector -COPTS+=-fno-unwind-tables -fno-asynchronous-unwind-tables +COPTS+=-fno-unwind-tables -fno-asynchronous-unwind-tables -fno-common MAN= LDSTATIC=-static NOPIE=
Re: crunchgen and llvm 15
> IIUC this ld(1) behavior is somewhat similar to -fno-common for cc(1). > base-clang already does -fno-common by default, base-gcc does not. The > diff below replaces ld -dc by cc -fno-common, but TBF I'm not sure what > we're trying to achieve (avoid?) here. A test (make build + release) on > a base-gcc arch would be welcome. An hppa snap with this diff builds without problems, but the resulting binary in bsd.rd does not run correctly: ... root on rd0a swap on rd0b dump on rd0b panic: init died (signal 0, exit 11) I will investigate further.
Re: copystr(9) vs strlcpy
> > In other words, > > copystr(src, dst, dstsiz, len) > > is equivalent to: > > if (strlcpy(dst, src, dstsiz) >= dstsiz) > > return ENAMETOOLONG; > > if (len != NULL) > > *len = strlen(dst); > > This should be *len = strlen(dst)+1 as copystr includes the terminating 0x00 > in the length count. > > It doesn't matter for the current diff, but it will matter if you replace the > last remaining use of copystr which does use the returned length value. Indeed! So the third copystr() call could be replaced with this: Index: sys/kern/vfs_lookup.c === RCS file: /OpenBSD/src/sys/kern/vfs_lookup.c,v retrieving revision 1.87 diff -u -p -r1.87 vfs_lookup.c --- sys/kern/vfs_lookup.c 14 Aug 2022 01:58:28 - 1.87 +++ sys/kern/vfs_lookup.c 25 Dec 2022 20:06:27 - @@ -143,10 +143,16 @@ namei(struct nameidata *ndp) */ if ((cnp->cn_flags & HASBUF) == 0) cnp->cn_pnbuf = pool_get(&namei_pool, PR_WAITOK); - if (ndp->ni_segflg == UIO_SYSSPACE) - error = copystr(ndp->ni_dirp, cnp->cn_pnbuf, - MAXPATHLEN, &ndp->ni_pathlen); - else + if (ndp->ni_segflg == UIO_SYSSPACE) { + ndp->ni_pathlen = strlcpy(cnp->cn_pnbuf, ndp->ni_dirp, + MAXPATHLEN); + if (ndp->ni_pathlen >= MAXPATHLEN) { + error = ENAMETOOLONG; + } else { + error = 0; + ndp->ni_pathlen++; /* ni_pathlen includes NUL */ + } + } else error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf, MAXPATHLEN, &ndp->ni_pathlen);
PMAP_PREFER dead code
With the introduction of the PMAP_PREFER_{ALIGN,OFFSET} macros a long time ago, there are actually no more uses of the PMAP_PREFER macro left in the kernel. The following diff removes PMAP_PREFER() but keeps a simple #define for it to let uvm knows the PMAP_PREFER_{ALIGN,OFFSET} macros are available. It might be worth renaming that enabling macro to __HAVE_PMAP_PREFER to mimic existing macros such as __HAVE_PMAP_{COLLECT,DIRECT}... but then PMAP_GROWKERNEL does not start with __HAVE so there is already a lack of consistency in this area. Note that this diff actually removes PMAP_PREFER on armv7, since none of the targeted v7 platforms actually end up having virtual aliasing. Tested on all affected PMAP_DIRECT platforms (and armv7 which is no longer part of the club). Miod Index: sys/arch/arm/arm/pmap7.c === RCS file: /OpenBSD/src/sys/arch/arm/arm/pmap7.c,v retrieving revision 1.65 diff -u -p -u -p -r1.65 pmap7.c --- sys/arch/arm/arm/pmap7.c12 Sep 2022 19:28:19 - 1.65 +++ sys/arch/arm/arm/pmap7.c25 Dec 2022 16:53:14 - @@ -2848,20 +2848,3 @@ pmap_pte_init_armv7(void) if ((id_mmfr3 & 0x00f0) == 0x0010) pmap_needs_pte_sync = 0; } - -uint32_t pmap_alias_dist; -uint32_t pmap_alias_bits; - -vaddr_t -pmap_prefer(vaddr_t foff, vaddr_t va) -{ - long d, m; - - m = pmap_alias_dist; - if (m == 0) /* m=0 => no cache aliasing */ - return va; - - d = foff - va; - d &= (m - 1); - return va + d; -} Index: sys/arch/arm/include/pmap.h === RCS file: /OpenBSD/src/sys/arch/arm/include/pmap.h,v retrieving revision 1.51 diff -u -p -u -p -r1.51 pmap.h --- sys/arch/arm/include/pmap.h 12 Sep 2022 19:28:19 - 1.51 +++ sys/arch/arm/include/pmap.h 25 Dec 2022 16:53:14 - @@ -613,23 +613,6 @@ l2pte_is_writeable(pt_entry_t pte, struc #defineL2_L_MAPPABLE_P(va, pa, size) \ va) | (pa)) & L2_L_OFFSET) == 0 && (size) >= L2_L_SIZE) -#ifndef _LOCORE -/* pmap_prefer bits for VIPT ARMv7 */ -#define PMAP_PREFER(fo, ap)pmap_prefer((fo), (ap)) -vaddr_tpmap_prefer(vaddr_t, vaddr_t); - -extern uint32_t pmap_alias_dist; -extern uint32_t pmap_alias_bits; - -/* pmap prefer alias alignment. */ -#define PMAP_PREFER_ALIGN()(pmap_alias_dist) -/* pmap prefer offset withing alignment. */ -#define PMAP_PREFER_OFFSET(of) \ -(PMAP_PREFER_ALIGN() == 0 ? 0 : ((of) & (PMAP_PREFER_ALIGN() - 1))) - - -#endif /* _LOCORE */ - #endif /* _KERNEL */ #ifndef _LOCORE Index: sys/arch/hppa/include/cpu.h === RCS file: /OpenBSD/src/sys/arch/hppa/include/cpu.h,v retrieving revision 1.97 diff -u -p -u -p -r1.97 cpu.h --- sys/arch/hppa/include/cpu.h 6 Dec 2022 00:40:09 - 1.97 +++ sys/arch/hppa/include/cpu.h 25 Dec 2022 16:53:14 - @@ -191,7 +191,6 @@ extern int cpu_hvers; */ #defineHPPA_PGALIAS0x0040 -#defineHPPA_PGAMASK0xffc0 #defineHPPA_PGAOFF 0x003f #defineHPPA_IOBEGIN0xf000 Index: sys/arch/hppa/include/pmap.h === RCS file: /OpenBSD/src/sys/arch/hppa/include/pmap.h,v retrieving revision 1.52 diff -u -p -u -p -r1.52 pmap.h --- sys/arch/hppa/include/pmap.h25 Oct 2022 18:44:36 - 1.52 +++ sys/arch/hppa/include/pmap.h25 Dec 2022 16:53:14 - @@ -91,16 +91,7 @@ struct vm_page *pmap_unmap_direct(vaddr_ * according to the parisc manual aliased va's should be * different by high 12 bits only. */ -#definePMAP_PREFER(o,h)pmap_prefer(o, h) -static __inline__ vaddr_t -pmap_prefer(vaddr_t offs, vaddr_t hint) -{ - vaddr_t pmap_prefer_hint = (hint & HPPA_PGAMASK) | (offs & HPPA_PGAOFF); - if (pmap_prefer_hint < hint) - pmap_prefer_hint += HPPA_PGALIAS; - return pmap_prefer_hint; -} - +#definePMAP_PREFER /* pmap prefer alignment */ #define PMAP_PREFER_ALIGN()(HPPA_PGALIAS) /* pmap prefer offset within alignment */ Index: sys/arch/mips64/include/pmap.h === RCS file: /OpenBSD/src/sys/arch/mips64/include/pmap.h,v retrieving revision 1.50 diff -u -p -u -p -r1.50 pmap.h --- sys/arch/mips64/include/pmap.h 10 Sep 2022 20:35:28 - 1.50 +++ sys/arch/mips64/include/pmap.h 25 Dec 2022 16:53:14 - @@ -149,8 +149,7 @@ extern struct pmap *const kernel_pmap_pt #definePMAP_STEAL_MEMORY /* Enable 'stealing' during boot */ -#definePMAP_PREFER(pa, va) pmap_prefer(pa, va) - +#definePMAP_PREFER extern vaddr_t pmap_prefer_mask; /* pmap prefer alignment */ #definePMAP_PREFER_ALIGN()
copystr(9) vs strlcpy
Ho ho ho, copystr(9) is a very old and seldom used kernel function, which performs a bounded string copy and optionally returns the length of the copied string. In other words, copystr(src, dst, dstsiz, len) is equivalent to: if (strlcpy(dst, src, dstsiz) >= dstsiz) return ENAMETOOLONG; if (len != NULL) *len = strlen(dst); return 0; since, unlike all the other copy*(9) functions, this one doesn't have to check for faults since it copies from (supposedly) valid kernel memory to (supposedly) valid kernel memory. But strlcpy() didn't exist at the time copystr() was introduced. Now, there are three uses of copystr() left in the kernel, and two of them ignore the return value of copystr(), and do not need the length of the result to be returned. These two can be trivially replaced with strlcpy() calls. How about this diff? Miod Index: sys/kern/vfs_subr.c === RCS file: /OpenBSD/src/sys/kern/vfs_subr.c,v retrieving revision 1.317 diff -u -p -u -p -r1.317 vfs_subr.c --- sys/kern/vfs_subr.c 14 Aug 2022 01:58:28 - 1.317 +++ sys/kern/vfs_subr.c 25 Dec 2022 16:57:42 - @@ -270,8 +270,8 @@ vfs_rootmountalloc(char *fstypename, cha mp = vfs_mount_alloc(NULLVP, vfsp); mp->mnt_flag |= MNT_RDONLY; mp->mnt_stat.f_mntonname[0] = '/'; - copystr(devname, mp->mnt_stat.f_mntfromname, MNAMELEN, NULL); - copystr(devname, mp->mnt_stat.f_mntfromspec, MNAMELEN, NULL); + strlcpy(mp->mnt_stat.f_mntfromname, devname, MNAMELEN); + strlcpy(mp->mnt_stat.f_mntfromspec, devname, MNAMELEN); *mpp = mp; return (0); }
Re: Get rid of UVM_VNODE_CANPERSIST
> Here is a diff. Maybe bluhm@ can try this on the macppc machine that > triggered the original "vref used where vget required" problem? On a similar machine it panics after a few hours with: panic: uvn_flush: PGO_SYNCIO return 'try again' error (impossible) The trace (transcribed by hand) is uvn_flush+0x820 uvm_vnp_terminate+0x79 vclean+0xdc vgonel+0x70 getnewvnode+0x240 ffs_vget+0xcc ffs_inode_alloc+0x13c ufs_makeinode+0x94 ufs_create+0x58 VOP_CREATE+0x48 vn_open+0x188 doopenat+0x1b4
Re: lladdr support for netstart/hostname.if (was: Re: Locking network card configuration)
I'm a bit late to the thread, but whatever its outcome, things have to work correctly on older sparc64 hardware, where the default behaviour for on-board and Sun-branded expansion card interfaces is to use the same MAC address. This hints that hostname. should have priority over hoshname. for the latter will be ambiguous on these systems.
Re: arm64 pwmbl(4): simplify ramp case
> This actually breaks my machine. malloc() is saying allocation too > large. OF_getproplen will return -1 on that. Is it possible that > len is treated as uint64_t as it is an int and sizeof is effectively > uint64_t? Ah, yes; size_t is unsigned and wider than int on 64-bit platforms, therefore int is converted to unsigned for the comparison. Casting sizeof to int will do. > Might be easier to have a check like: > > if (sc->sc_channels == NULL) > return level < sc->sc_nlevels ? level : sc->sc_nlevels - 1; > > Then you don't need to indent the whole block. Makes the diff smaller > and a bit easier to understand? Sure; what about this new version, then? Index: pwmbl.c === RCS file: /OpenBSD/src/sys/dev/fdt/pwmbl.c,v retrieving revision 1.6 diff -u -p -r1.6 pwmbl.c --- pwmbl.c 24 Oct 2021 17:52:26 - 1.6 +++ pwmbl.c 11 Nov 2022 06:46:41 - @@ -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 >= (int)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"); @@ -143,6 +139,9 @@ pwmbl_find_brightness(struct pwmbl_softc { uint32_t mid; int i; + + if (sc->sc_levels == NULL) + return level < sc->sc_nlevels ? level : sc->sc_nlevels - 1; for (i = 0; i < sc->sc_nlevels - 1; i++) { mid = (sc->sc_levels[i] + sc->sc_levels[i + 1]) / 2;
remove eeprom(8) sun4 leftovers
The following diff removes the last mentions of the sun4 old style eeprom behaviour in the eeprom(8) manual page, as well as options specific to it. Index: eeprom.8 === RCS file: /OpenBSD/src/usr.sbin/eeprom/eeprom.8,v retrieving revision 1.22 diff -u -p -r1.22 eeprom.8 --- eeprom.88 Jan 2020 14:45:36 - 1.22 +++ eeprom.88 Nov 2022 15:42:12 - @@ -33,12 +33,11 @@ .Os .Sh NAME .Nm eeprom -.Nd display or modify contents of the EEPROM or OpenPROM +.Nd display or modify contents of the OpenPROM .Sh SYNOPSIS .Nm eeprom -.Op Fl cipv +.Op Fl pv .Op Fl f Ar device -.Op Fl N Ar system .Oo .Ar field Ns Op = Ns Ar value .Ar ... @@ -46,7 +45,7 @@ .Sh DESCRIPTION .Nm eeprom provides an interface for displaying and changing the contents of the -EEPROM or OpenPROM. +OpenPROM. Without any arguments, .Nm eeprom will list all of the known fields and their corresponding values. @@ -55,145 +54,26 @@ When given the name of a specific field, will display that value or set it if the field name is followed by .Sq = and a value. -Only the superuser may modify the contents of the EEPROM or OpenPROM. +Only the superuser may modify the contents of the OpenPROM. .Pp The options are as follows: .Bl -tag -width Ds .It Fl Commands are taken from stdin and displayed on stdout. -.It Fl c -.Nm eeprom -will fix incorrect checksum values and exit. -This flag is quietly ignored on systems with an OpenPROM. .It Fl f Ar device -On systems with an EEPROM, use -.Ar device -instead of the default -.Pa /dev/eeprom . -On systems with an OpenPROM, use +Use .Ar device instead of the default .Pa /dev/openprom . -.It Fl i -If checksum values are incorrect, -.Nm eeprom -will ignore them and continue after displaying a warning. -This flag is quietly ignored on systems with an OpenPROM. -.It Fl N Ar system -Use the system image -.Ar system -instead of the default -.Pa /bsd . .It Fl p -On systems with an OpenPROM, display the tree derived from it and exit. -This flag is quietly ignored on systems with an EEPROM. +Display the tree derived from the OpenPROM and exit. .It Fl v -On systems with an OpenPROM, be verbose when setting a value. -Systems with an EEPROM are always verbose. +Be verbose when setting a value. .El .Sh FIELDS AND VALUES -The following fields and values are for systems with an EEPROM: -.Bl -tag -width "watchdog_reboot " -.It Ar hwupdate -A valid date, such as -.Dq 7/12/95 . -The strings -.Dq today -and -.Dq now -are also acceptable. -.It Ar memsize -How much memory, in megabytes, is installed in the system. -.It Ar memtest -How much memory, in megabytes, is to be tested upon power-up. -.It Ar scrsize -The size of the screen. -Acceptable values are -.Dq 1024x1024 , -.Dq 1152x900 , -.Dq 1600x1280 , -and -.Dq 1440x1440 . -.It Ar watchdog_reboot -If true, the system will reboot upon reset. -Otherwise, the system will fall into the monitor. -.It Ar default_boot -If true, the system will use the boot device stored in -.Ar bootdev . -.It Ar bootdev -Specifies the default boot device in the form cc(x,x,x), where -.Dq cc -is a combination of two letters such as -.Dq sd -or -.Dq le -and each -.Dq x -is a hexadecimal number between 0 and ff, less the prepending -.Dq 0x . -.It Ar kbdtype -This value is -.Dq 0 -for all Sun keyboards. -.It Ar console -Specifies the console type. -Valid values are -.Dq b&w , -.Dq ttya , -.Dq ttyb , -.Dq color , -and -.Dq p4opt . -.It Ar keyclick -If true, the keys click annoyingly. -.It Ar diagdev -This is a string very similar to that used by -.Ar bootdev . -It specifies the default boot device when the diagnostic switch is -turned on. -.It Ar diagpath -A 40-character, NULL-terminated string specifying the kernel or stand-alone -program to load when the diagnostic switch is turned on. -.It Ar columns -An 8-bit integer specifying the number of columns on the console. -.It Ar rows -An 8-bit integer specifying the number of rows on the console. -.It Ar ttya_use_baud -Use the baud rate stored in -.Ar ttya_baud -instead of the default 9600. -.It Ar ttya_baud -A 16-bit integer specifying the baud rate to use on ttya. -.It Ar ttya_no_rtsdtr -If true, disables RTS/DTR. -.It Ar ttyb_use_baud -Similar to -.Ar ttya_use_baud , -but for ttyb. -.It Ar ttyb_baud -Similar to -.Ar ttya_baud , -but for ttyb. -.It Ar ttyb_no_rtsdtr -Similar to -.Ar ttya_no_rtsdtr , -but for ttyb. -.It Ar banner -An 80-character, NULL-terminated string to use at power-up instead -of the default Sun banner. -.El -.Pp -Note that the -.Ar secure , -.Ar bad_login , -and -.Ar password -fields are not currently supported. -.Pp Since the OpenPROM is designed such that the field names are arbitrary, explaining them here is dubious. -Below are field names and values that -one is likely to see on a system with an OpenPROM. +Below are field names and values that one is likely to see. NOTE: this list may be incomplete or incorrect due to differences b
Re: sparc64: switch to clockintr(9)
> This patch switches sparc64 to clockintr(9). [...] > Testing on the UltraSPARC IIe ("Hummingbird") would also be helpful. > Apparently it has %SYS_TICK and %SYS_TICK_COMPARE, but in an unusual > hardware configuration. I imagine this machine is a bit rare, though. All Sun Blade 100 and 150 are IIe, so they're actually quite common. Fixed diff which compiles below. Index: include/_types.h === RCS file: /OpenBSD/src/sys/arch/sparc64/include/_types.h,v retrieving revision 1.23 diff -u -p -r1.23 _types.h --- include/_types.h5 Mar 2018 01:15:25 - 1.23 +++ include/_types.h7 Nov 2022 16:10:08 - @@ -35,6 +35,8 @@ #ifndef _MACHINE__TYPES_H_ #define _MACHINE__TYPES_H_ +#define__HAVE_CLOCKINTR + #if defined(_KERNEL) typedef struct label_t { long val[2]; Index: include/cpu.h === RCS file: /OpenBSD/src/sys/arch/sparc64/include/cpu.h,v retrieving revision 1.100 diff -u -p -r1.100 cpu.h --- include/cpu.h 22 Oct 2022 20:09:41 - 1.100 +++ include/cpu.h 7 Nov 2022 16:10:08 - @@ -78,6 +78,7 @@ #include #include +#include #include #include @@ -129,7 +130,7 @@ struct cpu_info { int ci_want_resched; int ci_handled_intr_level; void*ci_intrpending[16][8]; - u_int64_t ci_tick; + struct clockintr_queue ci_queue; struct intrhand ci_tickintr; volatile intci_ddb_paused; Index: sparc64/clock.c === RCS file: /OpenBSD/src/sys/arch/sparc64/sparc64/clock.c,v retrieving revision 1.71 diff -u -p -r1.71 clock.c --- sparc64/clock.c 24 Oct 2021 17:05:04 - 1.71 +++ sparc64/clock.c 7 Nov 2022 16:10:08 - @@ -65,6 +65,7 @@ #include #include +#include #include #include #include @@ -74,6 +75,7 @@ #include #endif #include +#include #include #include @@ -132,19 +134,35 @@ struct timecounter sys_tick_timecounter .tc_user = TC_SYS_TICK, }; -/* - * Statistics clock interval and variance, in usec. Variance must be a - * power of two. Since this gives us an even number, not an odd number, - * we discard one case and compensate. That is, a variance of 1024 would - * give us offsets in [0..1023]. Instead, we take offsets in [1..1023]. - * This is symmetric about the point 512, or statvar/2, and thus averages - * to that value (assuming uniform random numbers). - */ -/* XXX fix comment to match value */ -int statvar = 8192; -int statmin; /* statclock interval - 1/2*variance */ +uint64_t tick_nsec_cycle_ratio; +uint64_t tick_nsec_max; + +void tick_rearm(void *, uint64_t); +void tick_trigger(void *); + +const struct intrclock tick_intrclock = { + .ic_rearm = tick_rearm, + .ic_trigger = tick_trigger +}; + +uint64_t sys_tick_nsec_cycle_ratio; +uint64_t sys_tick_nsec_max; -static long tick_increment; +void sys_tick_rearm(void *, uint64_t); +void sys_tick_trigger(void *); + +const struct intrclock sys_tick_intrclock = { + .ic_rearm = sys_tick_rearm, + .ic_trigger = sys_tick_trigger +}; + +void stick_rearm(void *, uint64_t); +void stick_trigger(void *); + +const struct intrclock stick_intrclock = { + .ic_rearm = stick_rearm, + .ic_trigger = stick_trigger +}; void tick_start(void); void sys_tick_start(void); @@ -153,12 +171,8 @@ void stick_start(void); inttickintr(void *); intsys_tickintr(void *); intstickintr(void *); -intschedintr(void *); -static struct intrhand level10 = { clockintr }; static struct intrhand level0 = { tickintr }; -static struct intrhand level14 = { statintr }; -static struct intrhand schedint = { schedintr }; /* * clock (eeprom) attaches at the sbus or the ebus (PCI) @@ -473,21 +487,7 @@ timerattach(struct device *parent, struc timerreg_4u.t_clrintr = (int64_t *)(u_long)va[1]; timerreg_4u.t_mapintr = (int64_t *)(u_long)va[2]; - /* Install the appropriate interrupt vector here */ - level10.ih_number = INTVEC(ma->ma_interrupts[0]); - level10.ih_clr = (void *)&timerreg_4u.t_clrintr[0]; - level10.ih_map = (void *)&timerreg_4u.t_mapintr[0]; - strlcpy(level10.ih_name, "clock", sizeof(level10.ih_name)); - intr_establish(10, &level10); - - level14.ih_number = INTVEC(ma->ma_interrupts[1]); - level14.ih_clr = (void *)&timerreg_4u.t_clrintr[1]; - level14.ih_map = (void *)&timerreg_4u.t_mapintr[1]; - strlcpy(level14.ih_name, "prof", sizeof(level14.ih_name)); - intr_establish(14, &level14); - - printf(" ivec 0x%llx, 0x%llx\n", INTVEC(level10.ih_number), - INTVEC(level14.ih_number)); + printf(" ivec (none)\n"); } void @@ -538,7 +538,7 @@ myetheraddr(u_char *cp) void cpu_i
Re: fix libz regress on gcc archs
> +.if (${COMPILER_VERSION:L} != "clang" && ! exists(/usr/local/bin/eg++)) > +regress: > + @echo 'Run "pkg_add g++" to run unittests on GCC architectures' > + @echo SKIPPED Or the C++ test could be downgraded to C++98 so that it may be used on all supported platforms: Index: utils_unittest.cc === RCS file: /OpenBSD/src/regress/lib/libz/utils_unittest.cc,v retrieving revision 1.3 diff -u -p -r1.3 utils_unittest.cc --- utils_unittest.cc 4 Apr 2022 11:42:12 - 1.3 +++ utils_unittest.cc 31 Oct 2022 07:44:08 - @@ -108,7 +108,7 @@ TEST(ZlibTest, CRCHashBitsCollision) { // of hash bits must be set higher, regardless of the memlevel parameter, when // using CRC32c hashing for string matching. See https://crbug.com/1113596 - std::vector src = { + const uint8_t srcdata[] = { // Random byte; zlib doesn't match at offset 0. 123, @@ -131,10 +131,13 @@ TEST(ZlibTest, CRCHashBitsCollision) { 0x14, 0x15, }; + std::vector src; + for (int i = 0; i < sizeof(srcdata) / sizeof(srcdata[0]); ++i) +src.push_back(srcdata[i]); z_stream stream; - stream.zalloc = nullptr; - stream.zfree = nullptr; + stream.zalloc = Z_NULL; + stream.zfree = Z_NULL; // Using a low memlevel to try to reduce the number of hash bits. Negative // windowbits means raw deflate, i.e. without the zlib header. @@ -174,7 +177,7 @@ TEST(ZlibTest, CRCHashAssert) { // other four bytes also mismatch. This tests that zlib's assert handles this // case. - std::vector src = { + const uint8_t srcdata[] = { // Random byte; zlib doesn't match at offset 0. 123, @@ -202,10 +205,13 @@ TEST(ZlibTest, CRCHashAssert) { 0x12, 0x34, }; + std::vector src; + for (int i = 0; i < sizeof(srcdata) / sizeof(srcdata[0]); ++i) +src.push_back(srcdata[i]); z_stream stream; - stream.zalloc = nullptr; - stream.zfree = nullptr; + stream.zalloc = Z_NULL; + stream.zfree = Z_NULL; int ret = deflateInit2(&stream, /*comp level*/ 5, /*method*/ Z_DEFLATED, /*windowbits*/ -15, /*memlevel*/ 8, @@ -331,8 +337,8 @@ static const uint8_t checkMatchCrashData TEST(ZlibTest, CheckMatchCrash) { // See https://crbug.com/1113142. z_stream stream; - stream.zalloc = nullptr; - stream.zfree = nullptr; + stream.zalloc = Z_NULL; + stream.zfree = Z_NULL; // Low windowbits to hit window sliding also with a relatively small input. int ret = deflateInit2(&stream, /*comp level*/ 5, /*method*/ Z_DEFLATED, @@ -352,7 +358,7 @@ TEST(ZlibTest, CheckMatchCrash) { ASSERT_EQ(ret, Z_OK); } - stream.next_in = nullptr; + stream.next_in = NULL; stream.avail_in = 0; ASSERT_GT(stream.avail_out, 0U); ret = deflate(&stream, Z_FINISH); @@ -385,7 +391,7 @@ TEST(ZlibTest, DeflateRLEUninitUse) { int windowBits = 9; int memLevel = 8; int strategy = Z_RLE; - const std::vector src{ + const uint8_t srcdata[] = { 0x31, 0x64, 0x38, 0x32, 0x30, 0x32, 0x30, 0x36, 0x65, 0x35, 0x38, 0x35, 0x32, 0x61, 0x30, 0x36, 0x65, 0x35, 0x32, 0x66, 0x30, 0x34, 0x38, 0x37, 0x61, 0x31, 0x38, 0x36, 0x37, 0x37, 0x31, 0x39, 0x0a, 0x65, 0x62, 0x00, @@ -451,6 +457,9 @@ TEST(ZlibTest, DeflateRLEUninitUse) { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, }; + std::vector src; + for (int i = 0; i < sizeof(srcdata) / sizeof(srcdata[0]); ++i) +src.push_back(srcdata[i]); z_stream stream; stream.zalloc = Z_NULL; @@ -463,7 +472,8 @@ TEST(ZlibTest, DeflateRLEUninitUse) { std::vector compressed(src.size() * 2 + 1000); stream.next_out = compressed.data(); stream.avail_out = compressed.size(); - for (uint8_t b : src) { + for (std::vector::size_type i = 0; i < src.size(); ++i) { +uint8_t b = src[i]; stream.next_in = &b; stream.avail_in = 1; ret = deflate(&stream, Z_NO_FLUSH);
Re: Fwd: ukbd.c diff
> Found that the reason is that 'sc_apple_fn' inside 'ukbd_softc' is not > being assigned to > newly created 'sc_fn' inside 'hidkbd' Argh, sorry about that. Does the following diff fix the problem on your machine? Index: ukbd.c === RCS file: /OpenBSD/src/sys/dev/usb/ukbd.c,v retrieving revision 1.87 diff -u -p -r1.87 ukbd.c --- ukbd.c 16 Sep 2022 16:30:10 - 1.87 +++ ukbd.c 4 Oct 2022 18:27:49 - @@ -131,7 +131,6 @@ struct ukbd_softc { struct hidkbd sc_kbd; int sc_spl; - struct hid_location sc_apple_fn; #ifdef DDB struct timeout sc_ddb; /* for entering DDB */ @@ -242,7 +241,7 @@ ukbd_attach(struct device *parent, struc if (uha->uaa->vendor == USB_VENDOR_APPLE) { if (hid_locate(desc, dlen, HID_USAGE2(HUP_APPLE, HUG_FN_KEY), - uha->reportid, hid_input, &sc->sc_apple_fn, &qflags)) { + uha->reportid, hid_input, &kbd->sc_fn, &qflags)) { if (qflags & HIO_VARIABLE) { switch (uha->uaa->product) { case USB_PRODUCT_APPLE_FOUNTAIN_ISO:
Re: apldckbd(4): add fn key combose for Page Up/Down
> I've also removed the hidkbd_apple_mba_iso_munge() function as it is > the same as hidkbd_apple_iso_munge() so this also cleans up the switch > in ukbd.c Oh no, it isn't. See, you are in a maze of twisty little functions, all alike. The current state of ukbd has four apple munge routines: - "apple": invoke hid_get_data to get extra keys, then applies table - "apple_mba": invoke hid_get_data to get extra keys, then applies a different table - "apple_iso": applies small iso table, then invokes "apple" munge - "apple_iso_mba": applies small iso table, then invokes "apple_mba" munge. Because the tables used by "apple" and "apple_mba" differ, their iso flavours need to be kept separate.
Re: apldckbd(4): add fn key combose for Page Up/Down
> rev3: Almost there! Minor nits below, then ok. > Index: dev/hid/hidkbd.c > +static const struct hidkbd_translation apple_iso_trans[] = { > + { 53, 100 },/* less -> grave */ > + { 100, 53 } > +}; > + > +static const struct hidkbd_translation apple_iso_mba_trans[] = { > + { 53, 100 },/* less -> grave */ > + { 100, 53 } > +}; No need for two copies of that table. Keep the first one (shortest name) and update hidkbd_apple_mba_munge() accordingly. > Index: dev/hid/hidkbdsc.h > @@ -67,6 +67,7 @@ struct hidkbd { > struct hid_location sc_capsloc; > struct hid_location sc_scroloc; > struct hid_location sc_compose; > + struct hid_location sc_fn; Since the name is generic, consider adding a comment, for example /* optional extra input source used by sc_munge below */
Re: apldckbd(4): add fn key combose for Page Up/Down
> On 16/09/22 12:20 +0000, Miod Vallat wrote: > > > Index: dev/hid/hidkbdtrans.h > > > > > +static const struct hidkbd_translation apple_fn_trans[] = { > > > > No effing way. Every file including this header will embed its own copy > > of these tables. > > > > Better keep the tables in their original locations. The munge interfaces > > already take a pointer to a table and its number of elements, there is > > no need to gather all these tables in one particular location. > > yeah was quiet stupid of me.. new diff here. i've also put the whole > thing inside !SMALL_KERNEL That's better. However: - I see no reason for this to be wrapped within !SMALL_KERNEL, having a working keyboard within the installer is always a good thing. - there is also no reason to move the Gdium-specific (loongson) bits away from ukbd.c. They will never appear on any other kind of keyboard. As long as there is a prototype for hidkbd_translate() somewhere, it will keep working.
Re: apldckbd(4): add fn key combose for Page Up/Down
> Index: dev/hid/hidkbdtrans.h > +static const struct hidkbd_translation apple_fn_trans[] = { No effing way. Every file including this header will embed its own copy of these tables. Better keep the tables in their original locations. The munge interfaces already take a pointer to a table and its number of elements, there is no need to gather all these tables in one particular location.
Re: apldckbd(4): add fn key combose for Page Up/Down
> Hey, > > the diff below adds FN key combos for Page Up, Page Down and some more > on the M2 keyboard. Most of the logic was copied from ukbd. This means most of the munging logic should move from ukbd into hidkbd, but that can be done later. If you don't want to do this yet, you need to address two points: - the result of the hid_locate() call should be checked. - because of this, invocation of apldckbd_munge() should only happen if that call had succeeded.
pmap_collect and the page daemon
When the kernel is low on memory, the pagedaemon thread will try various strategies to free memory. One of those is to ask the pmap layer to free some memory. This is done in uvm_swapout_threads(), which is roughly a wrapper around the invocation of pmap_collect() on behalf of all processes. However, most pmap layers do not implement pmap_collect() and only provide a stub which does nothing. It doesn't make much sense to iterate over the process list, only to invoke a function which does absolutely nothing. The following diff makes pmap_collect() an optional interface, with pmaps implementing it defining __HAVE_PMAP_COLLECT. This feature macro is used to completely omit uvm_swapout_threads() when pmap_collect() is not available. Index: arch/alpha/include/pmap.h === RCS file: /OpenBSD/src/sys/arch/alpha/include/pmap.h,v retrieving revision 1.40 diff -u -p -r1.40 pmap.h --- arch/alpha/include/pmap.h 20 Apr 2016 05:24:18 - 1.40 +++ arch/alpha/include/pmap.h 10 Sep 2022 08:00:10 - @@ -197,6 +197,8 @@ extern pt_entry_t *VPT;/* Virtual Page paddr_t vtophys(vaddr_t); +#define__HAVE_PMAP_COLLECT + /* Machine-specific functions. */ void pmap_bootstrap(paddr_t ptaddr, u_int maxasn, u_long ncpuids); intpmap_emulate_reference(struct proc *p, vaddr_t v, int user, int type); Index: arch/amd64/amd64/pmap.c === RCS file: /OpenBSD/src/sys/arch/amd64/amd64/pmap.c,v retrieving revision 1.153 diff -u -p -r1.153 pmap.c --- arch/amd64/amd64/pmap.c 30 Jun 2022 13:51:24 - 1.153 +++ arch/amd64/amd64/pmap.c 10 Sep 2022 08:00:10 - @@ -2206,6 +2206,7 @@ pmap_unwire(struct pmap *pmap, vaddr_t v #endif } +#if 0 /* * pmap_collect: free resources held by a pmap * @@ -2221,10 +,10 @@ pmap_collect(struct pmap *pmap) * for its entire address space. */ -/* pmap_do_remove(pmap, VM_MIN_ADDRESS, VM_MAX_ADDRESS, + pmap_do_remove(pmap, VM_MIN_ADDRESS, VM_MAX_ADDRESS, PMAP_REMOVE_SKIPWIRED); -*/ } +#endif /* * pmap_copy: copy mappings from one pmap to another Index: arch/arm/arm/pmap7.c === RCS file: /OpenBSD/src/sys/arch/arm/arm/pmap7.c,v retrieving revision 1.63 diff -u -p -r1.63 pmap7.c --- arch/arm/arm/pmap7.c21 Feb 2022 19:15:58 - 1.63 +++ arch/arm/arm/pmap7.c10 Sep 2022 08:00:10 - @@ -1743,21 +1743,6 @@ dab_access(trapframe_t *tf, u_int fsr, u } /* - * pmap_collect: free resources held by a pmap - * - * => optional function. - * => called when a process is swapped out to free memory. - */ -void -pmap_collect(pmap_t pm) -{ - /* -* Nothing to do. -* We don't even need to free-up the process' L1. -*/ -} - -/* * Routine:pmap_proc_iflush * * Function: Index: arch/arm64/arm64/pmap.c === RCS file: /OpenBSD/src/sys/arch/arm64/arm64/pmap.c,v retrieving revision 1.84 diff -u -p -r1.84 pmap.c --- arch/arm64/arm64/pmap.c 10 Jan 2022 09:20:27 - 1.84 +++ arch/arm64/arm64/pmap.c 10 Sep 2022 08:00:10 - @@ -856,24 +856,6 @@ pmap_fill_pte(pmap_t pm, vaddr_t va, pad } /* - * Garbage collects the physical map system for pages which are - * no longer used. Success need not be guaranteed -- that is, there - * may well be pages which are not referenced, but others may be collected - * Called by the pageout daemon when pages are scarce. - */ -void -pmap_collect(pmap_t pm) -{ - /* This could return unused v->p table layers which -* are empty. -* could malicious programs allocate memory and eat -* these wired pages? These are allocated via pool. -* Are there pool functions which could be called -* to lower the pool usage here? -*/ -} - -/* * Fill the given physical page with zeros. */ void Index: arch/hppa/hppa/pmap.c === RCS file: /OpenBSD/src/sys/arch/hppa/hppa/pmap.c,v retrieving revision 1.177 diff -u -p -r1.177 pmap.c --- arch/hppa/hppa/pmap.c 14 Sep 2021 16:16:51 - 1.177 +++ arch/hppa/hppa/pmap.c 10 Sep 2022 08:00:10 - @@ -734,13 +734,6 @@ pmap_reference(struct pmap *pmap) atomic_inc_int(&pmap->pm_obj.uo_refs); } -void -pmap_collect(struct pmap *pmap) -{ - DPRINTF(PDB_FOLLOW|PDB_PMAP, ("pmap_collect(%p)\n", pmap)); - /* nothing yet */ -} - int pmap_enter(struct pmap *pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) { Index: arch/hppa/include/param.h === RCS file: /OpenBSD/src/sys/arch/hppa/include/param.h,v retrieving revision 1.47 diff -u -p -r1.47 param.h --- arch/hppa/include/param.h 14 Sep 2018 13:58:20 - 1.47 +++
some more kernel const
Constify nam2blk[] and chrtoblktbl[], these are never modified at runtime. Plus an octeon bonus: devmap[]. Index: sys/arch/alpha/alpha/autoconf.c === RCS file: /OpenBSD/src/sys/arch/alpha/alpha/autoconf.c,v retrieving revision 1.38 diff -u -p -u -p -r1.38 autoconf.c --- sys/arch/alpha/alpha/autoconf.c 27 Jan 2018 22:55:23 - 1.38 +++ sys/arch/alpha/alpha/autoconf.c 2 Sep 2022 14:39:45 - @@ -220,7 +220,7 @@ device_register(dev, aux) (*platform.device_register)(dev, aux); } -struct nam2blk nam2blk[] = { +const struct nam2blk nam2blk[] = { { "wd", 0 }, { "cd", 3 }, { "fd", 4 }, Index: sys/arch/alpha/alpha/conf.c === RCS file: /OpenBSD/src/sys/arch/alpha/alpha/conf.c,v retrieving revision 1.90 diff -u -p -u -p -r1.90 conf.c --- sys/arch/alpha/alpha/conf.c 11 Nov 2021 10:03:08 - 1.90 +++ sys/arch/alpha/alpha/conf.c 2 Sep 2022 14:39:45 - @@ -252,7 +252,7 @@ getnulldev() return makedev(mem_no, 2); } -int chrtoblktbl[] = { +const int chrtoblktbl[] = { /*VCHR*//*VBLK*/ /* 0 */NODEV, /* 1 */NODEV, @@ -293,4 +293,4 @@ int chrtoblktbl[] = { /* 36 */0, /* 37 */4, /* fd */ }; -int nchrtoblktbl = nitems(chrtoblktbl); +const int nchrtoblktbl = nitems(chrtoblktbl); Index: sys/arch/amd64/amd64/autoconf.c === RCS file: /OpenBSD/src/sys/arch/amd64/amd64/autoconf.c,v retrieving revision 1.53 diff -u -p -u -p -r1.53 autoconf.c --- sys/arch/amd64/amd64/autoconf.c 11 Jan 2019 06:25:06 - 1.53 +++ sys/arch/amd64/amd64/autoconf.c 2 Sep 2022 14:39:45 - @@ -223,7 +223,7 @@ diskconf(void) #endif /* HIBERNATE */ } -struct nam2blk nam2blk[] = { +const struct nam2blk nam2blk[] = { { "wd", 0 }, { "fd", 2 }, { "sd", 4 }, Index: sys/arch/amd64/amd64/conf.c === RCS file: /OpenBSD/src/sys/arch/amd64/amd64/conf.c,v retrieving revision 1.75 diff -u -p -u -p -r1.75 conf.c --- sys/arch/amd64/amd64/conf.c 28 Jun 2022 14:43:50 - 1.75 +++ sys/arch/amd64/amd64/conf.c 2 Sep 2022 14:39:45 - @@ -331,7 +331,7 @@ getnulldev(void) return makedev(mem_no, 2); } -int chrtoblktbl[] = { +const int chrtoblktbl[] = { /*VCHR*//*VBLK*/ /* 0 */NODEV, /* 1 */NODEV, @@ -383,7 +383,7 @@ int chrtoblktbl[] = { /* 47 */17, /* rd */ }; -int nchrtoblktbl = nitems(chrtoblktbl); +const int nchrtoblktbl = nitems(chrtoblktbl); /* * In order to map BSD bdev numbers of disks to their BIOS equivalents Index: sys/arch/arm/arm/conf.c === RCS file: /OpenBSD/src/sys/arch/arm/arm/conf.c,v retrieving revision 1.58 diff -u -p -u -p -r1.58 conf.c --- sys/arch/arm/arm/conf.c 11 Nov 2021 10:03:08 - 1.58 +++ sys/arch/arm/arm/conf.c 2 Sep 2022 14:39:45 - @@ -415,7 +415,7 @@ iszerodev(dev_t dev) } -int chrtoblktbl[] = { +const int chrtoblktbl[] = { /*VCHR*//*VBLK*/ /* 0 */NODEV, /* 1 */NODEV, @@ -445,7 +445,7 @@ int chrtoblktbl[] = { /* 25 */NODEV, /* 26 */26,/* cd */ }; -int nchrtoblktbl = nitems(chrtoblktbl); +const int nchrtoblktbl = nitems(chrtoblktbl); dev_t getnulldev(void) Index: sys/arch/arm64/arm64/autoconf.c === RCS file: /OpenBSD/src/sys/arch/arm64/arm64/autoconf.c,v retrieving revision 1.12 diff -u -p -u -p -r1.12 autoconf.c --- sys/arch/arm64/arm64/autoconf.c 21 Feb 2021 14:55:16 - 1.12 +++ sys/arch/arm64/arm64/autoconf.c 2 Sep 2022 14:39:45 - @@ -109,7 +109,7 @@ device_register(struct device *dev, void { } -struct nam2blk nam2blk[] = { +const struct nam2blk nam2blk[] = { { "wd", 0 }, { "sd", 4 }, { "cd", 6 }, Index: sys/arch/arm64/arm64/conf.c === RCS file: /OpenBSD/src/sys/arch/arm64/arm64/conf.c,v retrieving revision 1.19 diff -u -p -u -p -r1.19 conf.c --- sys/arch/arm64/arm64/conf.c 11 Nov 2021 10:03:08 - 1.19 +++ sys/arch/arm64/arm64/conf.c 2 Sep 2022 14:39:45 - @@ -273,7 +273,7 @@ getnulldev(void) return makedev(CMAJ_MM, 2); } -int chrtoblktbl[] = { +const int chrtoblktbl[] = { /*VCHR*//*VBLK*/ /* 0 */NODEV, /* 1 */NODEV, @@ -325,7 +325,7 @@ int chrtoblktbl[] = { /* 47 */17, /* rd */ }; -int nchrtoblktbl = nitems(chrtoblktbl); +const int nchrtoblktbl = nitems(chrt
libelf: disable ident strings
The general policy in OpenBSD is to not embed ident(1) strings in libraries. However, libelf is currently compiled with ident strings, and thus /usr/lib/libelf* are the only files in /usr/lib sporting ident strings. The following diff disables them. Index: _elftc.h === RCS file: /OpenBSD/src/lib/libelf/_elftc.h,v retrieving revision 1.2 diff -u -p -r1.2 _elftc.h --- _elftc.h2 Sep 2021 21:12:09 - 1.2 +++ _elftc.h31 Aug 2022 18:55:31 - @@ -316,11 +316,7 @@ struct name { \ #endif #if defined(__OpenBSD__) -#if defined(__GNUC__) -#defineELFTC_VCSID(ID) __asm__(".ident\t\"" ID "\"") -#else -#defineELFTC_VCSID(ID) /**/ -#endif /* __GNUC__ */ +#defineELFTC_VCSID(ID) /* intentionally disabled */ #endif #endif /* ELFTC_VCSID */
Re: all architectures: put clockframe definition in frame.h?
> So we would get rid of all the 32-bit compat stuff from arch/sparc64? Yes, but this has never been used, so no worries about it. > Index: include/cpu.h > === > RCS file: /cvs/src/sys/arch/sparc64/include/cpu.h,v > retrieving revision 1.98 > diff -u -p -r1.98 cpu.h > --- include/cpu.h 6 Jul 2021 09:34:07 - 1.98 > +++ include/cpu.h 29 Aug 2022 18:44:50 - > @@ -144,7 +144,7 @@ struct cpu_info { > paddr_t ci_paddr; /* Phys addr of this structure. > */ > > #ifdef SUN4V > - struct rwindow64ci_rw; > + struct rwindow ci_rw; Note that struct rwindow* used to be defined in ; if you move it to then cpu.h needs to include it now. And since also gets included from assembler code, the struct definitions you have moved there need to be protected with #ifndef _LOCORE. > Index: sparc64/machdep.c > @@ -872,36 +872,24 @@ trapdump(tf) > void > stackdump(void) > { > - struct frame32 *fp = (struct frame32 *)getfp(), *sfp; > - struct frame64 *fp64; > + struct frame *fp64 = getfp(), *sfp; > > - sfp = fp; > - printf("Frame pointer is at %p\n", fp); > + sfp = fp64; > + printf("Frame pointer is at %p\n", fp64); > printf("Call traceback:\n"); > - while (fp && ((u_long)fp >> PGSHIFT) == ((u_long)sfp >> PGSHIFT)) { > - if( ((long)fp) & 1 ) { > - fp64 = (struct frame64*)(((char *)fp)+BIAS); > - /* 64-bit frame */ > - printf("%llx(%llx, %llx, %llx, %llx, %llx, %llx, %llx) " > - "fp = %llx\n", > -(unsigned long long)fp64->fr_pc, > -(unsigned long long)fp64->fr_arg[0], > -(unsigned long long)fp64->fr_arg[1], > -(unsigned long long)fp64->fr_arg[2], > -(unsigned long long)fp64->fr_arg[3], > -(unsigned long long)fp64->fr_arg[4], > -(unsigned long long)fp64->fr_arg[5], > -(unsigned long long)fp64->fr_arg[6], > -(unsigned long long)fp64->fr_fp); > - fp = (struct frame32 *)(u_long)fp64->fr_fp; > - } else { > - /* 32-bit frame */ > - printf(" pc = %x args = (%x, %x, %x, %x, %x, %x) " > - "fp = %x\n", fp->fr_pc, fp->fr_arg[0], > - fp->fr_arg[1], fp->fr_arg[2], fp->fr_arg[3], > - fp->fr_arg[4], fp->fr_arg[5], fp->fr_fp); > - fp = (struct frame32*)(u_long)(u_short)fp->fr_fp; > - } > + while (fp64 && ((u_long)fp64 >> PGSHIFT) == ((u_long)sfp >> PGSHIFT)) { > + printf("%llx(%llx, %llx, %llx, %llx, %llx, %llx, %llx) " > + "fp = %llx\n", > +(unsigned long long)fp64->fr_pc, > +(unsigned long long)fp64->fr_arg[0], > +(unsigned long long)fp64->fr_arg[1], > +(unsigned long long)fp64->fr_arg[2], > +(unsigned long long)fp64->fr_arg[3], > +(unsigned long long)fp64->fr_arg[4], > +(unsigned long long)fp64->fr_arg[5], > +(unsigned long long)fp64->fr_arg[6], > +(unsigned long long)fp64->fr_fp); > + fp64 = v9next_frame(fp64); This chunk is wrong. The 64-bit stack pointer is always odd (biased by BIAS), so you need add something similar to fp64 = (struct frame*)(((char *)fp64) + BIAS); prior to the printf call. Also the next statement is incorrectly indented. Last, the removal of CCFSZ exposes a bug in locore.S where it is still used instead of CC64FSZ (in an "everything went wrong" shouldn't-happen scenario), so it should be replaced in there.
Re: Race in disk_attach_callback?
> What's the status on this diff? I'm waiting for review from at least one of the softraid suspects prior to putting this in, in case there are further cinematics to address.
Re: installer: zap fdisk.8.gz and disklabel.8.gz
> > The ability to be able to read the manual pages from the binaries > > themselves, when running is interactive mode, is an intentional feature > > and the reason they embed a gzipped version of the formatted manpage. > > Even in the installer? Especially in the installer, because you might not have another machine nearby to access documentation. (and there were no smartphones when this was introduced close to 25 years ago) > The manual feature is handy, but I don't think it's worth having in > install media. This feature is *especially* intended for installation media.
Re: installer: zap fdisk.8.gz and disklabel.8.gz
> Well, something tells me the inclusion of the manual pages for fdisk > and disklabel is deliberate. Makes some sense as these are complex > utilities and their interactive use is documented in those pages. The ability to be able to read the manual pages from the binaries themselves, when running is interactive mode, is an intentional feature and the reason they embed a gzipped version of the formatted manpage.
Re: mips64: trigger deferred timer interrupt from splx(9)
> After about 92 hours, one machine showed cp0_raise_calls=622486 and > another 695892. cp0_raise_miss was zero on both of them. On two other > machines I had forgotten to allow ddb access from console and could > not check the values. Put kern.allowkmem=1 in /etc/sysctl.conf, and then you can do fetch the values with pstat -d.
Re: Race in disk_attach_callback?
> What is the result if root runs disklabel, and forces it to all zeros? If the root duid is all zeroes, then the only way to refer to the root disk is to use its /dev/{s,w}d* device name, as zero duids are ignored. If you set a zero duid in disklabel(8), setdisklabel() in the kernel will compute a new, non-zero value.
Re: Race in disk_attach_callback?
Come to think further about it, I think it is better for diskmap to always trust disk drivers to either : - not have any label (dk_label == NULL, or points to zeroed memory) or - have a valid label (duid is not zeroes). The following diff thus relaxes the logic to always trust dk_label->d_uid, unless it is zero. This passes the vnd test I mailed yesterday, without the need for a dev/vnd.c change. Index: sys/dev/softraid.c === RCS file: /OpenBSD/src/sys/dev/softraid.c,v retrieving revision 1.425 diff -u -p -u -p -r1.425 softraid.c --- sys/dev/softraid.c 16 Apr 2022 19:19:58 - 1.425 +++ sys/dev/softraid.c 17 Aug 2022 05:20:51 - @@ -3685,13 +3685,11 @@ sr_ioctl_installboot(struct sr_softc *sc } } - bzero(duid, sizeof(duid)); TAILQ_FOREACH(dk, &disklist, dk_link) if (!strncmp(dk->dk_name, bb->bb_dev, sizeof(bb->bb_dev))) break; if (dk == NULL || dk->dk_label == NULL || - (dk->dk_flags & DKF_LABELVALID) == 0 || - bcmp(dk->dk_label->d_uid, &duid, sizeof(duid)) == 0) { + duid_iszero(dk->dk_label->d_uid)) { sr_error(sc, "failed to get DUID for softraid volume"); goto done; } Index: sys/kern/subr_disk.c === RCS file: /OpenBSD/src/sys/kern/subr_disk.c,v retrieving revision 1.253 diff -u -p -u -p -r1.253 subr_disk.c --- sys/kern/subr_disk.c14 Aug 2022 01:58:27 - 1.253 +++ sys/kern/subr_disk.c17 Aug 2022 05:20:51 - @@ -1121,7 +1121,6 @@ disk_attach_callback(void *xdat) /* Read disklabel. */ if (disk_readlabel(&dl, dk->dk_devno, errbuf, sizeof(errbuf)) == NULL) { enqueue_randomness(dl.d_checksum); - dk->dk_flags |= DKF_LABELVALID; } done: @@ -1440,14 +1439,14 @@ setroot(struct device *bootdv, int part, TAILQ_FOREACH(dk, &disklist, dk_link) if (dk->dk_device == bootdv) break; - if (dk && (dk->dk_flags & DKF_LABELVALID)) + if (dk) bcopy(dk->dk_label->d_uid, bootduid, sizeof(bootduid)); } else if (bootdv == NULL) { /* Locate boot disk based on the provided DUID. */ TAILQ_FOREACH(dk, &disklist, dk_link) if (duid_equal(dk->dk_label->d_uid, bootduid)) break; - if (dk && (dk->dk_flags & DKF_LABELVALID)) + if (dk) bootdv = dk->dk_device; } bcopy(bootduid, rootduid, sizeof(rootduid)); @@ -1561,8 +1560,7 @@ gotswap: if (bootdv->dv_class == DV_DISK) { if (!duid_iszero(rootduid)) { TAILQ_FOREACH(dk, &disklist, dk_link) - if ((dk->dk_flags & DKF_LABELVALID) && - dk->dk_label && duid_equal( + if (dk->dk_label && duid_equal( dk->dk_label->d_uid, rootduid)) break; if (dk == NULL) @@ -1788,7 +1786,8 @@ disk_map(char *path, char *mappath, int mdk = NULL; TAILQ_FOREACH(dk, &disklist, dk_link) { - if ((dk->dk_flags & DKF_LABELVALID) && dk->dk_label && + if (dk->dk_label && + !duid_iszero(dk->dk_label->d_uid) && memcmp(dk->dk_label->d_uid, uid, sizeof(dk->dk_label->d_uid)) == 0) { /* Fail if there are duplicate UIDs! */ Index: sys/sys/disk.h === RCS file: /OpenBSD/src/sys/sys/disk.h,v retrieving revision 1.36 diff -u -p -u -p -r1.36 disk.h --- sys/sys/disk.h 4 May 2017 22:47:27 - 1.36 +++ sys/sys/disk.h 17 Aug 2022 05:20:51 - @@ -83,7 +83,6 @@ struct disk { #define DKF_CONSTRUCTED0x0001 #define DKF_OPENED 0x0002 #define DKF_NOLABELREAD0x0004 -#define DKF_LABELVALID 0x0008 /* * Metrics data; note that some metrics may have no meaning
Re: Race in disk_attach_callback?
> after a prompt from stsp@ and florian@, reporting that newfs_msdos > fails when given an $duid.i argument, I set down to see what could be > going on. My test using an USB stick failed to reprdouce the problem. > Then I started using a vnd, and that shows the issue (once in a > while). The feeling is that any disk devcied created on the fly might > show this issue. Moments ago kn@ stumbled upon this as well. It turns out that, at least in the vnd case, there is indeed a race between the scheduling of the task running disk_attach_callback and the first access to the vnd device, which will cause the label to get read. While vnd(4) has logic to read a label on-demand, disk_attach_callback assumes it runs at a point where the label can safely be obtained, and will not retry (because it sets DKF_OPENED, which never gets unset). The following shell script will demonstrate the issue: cat << EOF > test.sh #! /bin/sh set -e dd if=/dev/zero of=img.bin bs=1m count=4 >/dev/null iter=1 while [ $iter -lt 1000 ]; do vnconfig vnd0 img.bin fdisk -iy vnd0 > /dev/null disklabel -Aw vnd0 > /dev/null duid=$(sysctl hw.disknames|sed 's,.*vnd0:,,') disklabel $duid > /dev/null vnconfig -u vnd0 iter=$((iter + 1)) done EOF (don't forget to vnconfig -u vnd0 if it fails). The following diff makes vnd attempt to read a label as soon as the VNDIOCSET ioctl is issued. However it will not fix softraid if it has a similar problem, so a rework of the disk_attach operation might be a better idea. Index: vnd.c === RCS file: /OpenBSD/src/sys/dev/vnd.c,v retrieving revision 1.177 diff -u -p -r1.177 vnd.c --- vnd.c 23 Dec 2021 10:09:16 - 1.177 +++ vnd.c 16 Aug 2022 21:02:23 - @@ -536,6 +536,9 @@ fail: sc->sc_dk.dk_name = sc->sc_dev.dv_xname; disk_attach(&sc->sc_dev, &sc->sc_dk); + sc->sc_flags |= VNF_HAVELABEL; + vndgetdisklabel(dev, sc, sc->sc_dk.dk_label, 0); + disk_unlock(&sc->sc_dk); break;
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, - &alpha_unaligned_print)); - - case CPU_UNALIGNED_FIX: - return (sysctl_int(oldp, oldlenp, newp, newlen, - &alpha_unaligned_fix)); - - case CPU_UNALIGNED_SIGBUS: - return (sysctl_int(oldp, oldlenp, newp, newlen, - &alpha_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 :\ &(p)->p_m
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(&trapcode, (void *)exc, (size_t)&trapsize); @@ -212,7 +212,7 @@ initppc(u_int startkernel, u_int endkern } /* Grr, ALTIVEC_UNAVAIL is a vector not ~0xff aligned: 0x0f20 */ - bcopy(&trapcode, (void *)0xf20, (size_t)&trapsize); + bcopy(&trapcode, (void *)EXC_VEC, (size_t)&trapsize); /* * 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 @@
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(&trapcode, (void *)exc, (size_t)&trapsize); @@ -212,7 +212,7 @@ initppc(u_int startkernel, u_int endkern } /* Grr, ALTIVEC_UNAVAIL is a vector not ~0xff aligned: 0x0f20 */ - bcopy(&trapcode, (void *)0xf20, (size_t)&trapsize); + bcopy(&trapcode, (void *)EXC_VEC, (size_t)&trapsize); /* * 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)&fp->sf_sc ^ p->p_p->ps_sigcookie; if (copyout(&frame, 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 f
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 = &sf->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("&sp", " ", $f) - gsub("&tab", "\t", $f) - gsub("&nl", "\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 = &sc->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(&ipov, 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) &ipov, sizeof(ipov)); + /* first 8 bytes are zeroes */ + sum += in_cksumdata((caddr_t) &ipov + 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(&ipov, 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 *)&ipov; - /* 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(&u.ipov, 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];
Re: in4_cksum changes, step 1
> > - sum += in_cksumdata((caddr_t) &ipov, sizeof(ipov)); > > + sum += in_cksumdata((caddr_t) &ipov + 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), "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3) > > - : "0" (sum), "r" (w)); > > + : "0" (sum), "r" (&ipov)); > > 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(&ipov, 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) &ipov, sizeof(ipov)); + /* first 8 bytes are zeroes */ + sum += in_cksumdata((caddr_t) &ipov + 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(&ipov, 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 *)&ipov; - /* 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
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(&ipov, 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) &ipov, sizeof(ipov)); + sum += in_cksumdata((caddr_t) &ipov + 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(&ipov, 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 *)&ipov; - /* 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(&u.ipov, 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: /OpenBSD/src/sys/arch/sgi/conf/G
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 = strlcpy(err