CVS commit: src/sys/dev/pci
Module Name:src Committed By: nonaka Date: Wed Dec 21 05:19:15 UTC 2022 Modified Files: src/sys/dev/pci: if_rge.c if_rgereg.h Log Message: Update the Rx descriptor based on the vendor driver for Linux. This fixes a panic on RTL8125. Patch from OpenBSD if_rge.c r1.20, if_rgereg.h r1.8. Tested by msaitoh@n.o. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/if_rge.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/if_rgereg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_rge.c diff -u src/sys/dev/pci/if_rge.c:1.24 src/sys/dev/pci/if_rge.c:1.25 --- src/sys/dev/pci/if_rge.c:1.24 Sat Sep 24 18:12:42 2022 +++ src/sys/dev/pci/if_rge.c Wed Dec 21 05:19:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_rge.c,v 1.24 2022/09/24 18:12:42 thorpej Exp $ */ +/* $NetBSD: if_rge.c,v 1.25 2022/12/21 05:19:15 nonaka Exp $ */ /* $OpenBSD: if_rge.c,v 1.9 2020/12/12 11:48:53 jan Exp $ */ /* @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_rge.c,v 1.24 2022/09/24 18:12:42 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_rge.c,v 1.25 2022/12/21 05:19:15 nonaka Exp $"); #include @@ -1132,22 +1132,16 @@ rge_newbuf(struct rge_softc *sc, int idx /* Map the segments into RX descriptors. */ r = >rge_ldata.rge_rx_list[idx]; - if (RGE_OWN(r)) { - device_printf(sc->sc_dev, "tried to map busy RX descriptor\n"); - goto out; - } - rxq->rxq_mbuf = m; - r->rge_extsts = 0; - r->rge_addrlo = htole32(RGE_ADDR_LO(rxmap->dm_segs[0].ds_addr)); - r->rge_addrhi = htole32(RGE_ADDR_HI(rxmap->dm_segs[0].ds_addr)); + r->hi_qword1.rx_qword4.rge_extsts = 0; + r->hi_qword0.rge_addr = htole64(rxmap->dm_segs[0].ds_addr); - r->rge_cmdsts = htole32(rxmap->dm_segs[0].ds_len); + r->hi_qword1.rx_qword4.rge_cmdsts = htole32(rxmap->dm_segs[0].ds_len); if (idx == RGE_RX_LIST_CNT - 1) - r->rge_cmdsts |= htole32(RGE_RDCMDSTS_EOR); + r->hi_qword1.rx_qword4.rge_cmdsts |= htole32(RGE_RDCMDSTS_EOR); - r->rge_cmdsts |= htole32(RGE_RDCMDSTS_OWN); + r->hi_qword1.rx_qword4.rge_cmdsts |= htole32(RGE_RDCMDSTS_OWN); bus_dmamap_sync(sc->sc_dmat, sc->rge_ldata.rge_rx_list_map, idx * sizeof(struct rge_rx_desc), sizeof(struct rge_rx_desc), @@ -1167,11 +1161,11 @@ rge_discard_rxbuf(struct rge_softc *sc, r = >rge_ldata.rge_rx_list[idx]; - r->rge_cmdsts = htole32(RGE_JUMBO_FRAMELEN); - r->rge_extsts = 0; + r->hi_qword1.rx_qword4.rge_cmdsts = htole32(RGE_JUMBO_FRAMELEN); + r->hi_qword1.rx_qword4.rge_extsts = 0; if (idx == RGE_RX_LIST_CNT - 1) - r->rge_cmdsts |= htole32(RGE_RDCMDSTS_EOR); - r->rge_cmdsts |= htole32(RGE_RDCMDSTS_OWN); + r->hi_qword1.rx_qword4.rge_cmdsts |= htole32(RGE_RDCMDSTS_EOR); + r->hi_qword1.rx_qword4.rge_cmdsts |= htole32(RGE_RDCMDSTS_OWN); bus_dmamap_sync(sc->sc_dmat, sc->rge_ldata.rge_rx_list_map, idx * sizeof(struct rge_rx_desc), sizeof(struct rge_rx_desc), @@ -1235,8 +1229,8 @@ rge_rxeof(struct rge_softc *sc) if (RGE_OWN(cur_rx)) break; - rxstat = letoh32(cur_rx->rge_cmdsts); - extsts = letoh32(cur_rx->rge_extsts); + rxstat = letoh32(cur_rx->hi_qword1.rx_qword4.rge_cmdsts); + extsts = letoh32(cur_rx->hi_qword1.rx_qword4.rge_extsts); total_len = RGE_RXBYTES(cur_rx); rxq = >rge_ldata.rge_rxq[i]; @@ -1317,16 +1311,16 @@ rge_rxeof(struct rge_softc *sc) #if notyet /* Check IP header checksum. */ - if (!(rxstat & RGE_RDCMDSTS_IPCSUMERR) && + if (!(extsts & RGE_RDEXTSTS_IPCSUMERR) && (extsts & RGE_RDEXTSTS_IPV4)) m->m_pkthdr.csum_flags |= M_IPV4_CSUM_IN_OK; /* Check TCP/UDP checksum. */ if ((extsts & (RGE_RDEXTSTS_IPV4 | RGE_RDEXTSTS_IPV6)) && - (((rxstat & RGE_RDCMDSTS_TCPPKT) && - !(rxstat & RGE_RDCMDSTS_TCPCSUMERR)) || - ((rxstat & RGE_RDCMDSTS_UDPPKT) && - !(rxstat & RGE_RDCMDSTS_UDPCSUMERR + (((extsts & RGE_RDEXTSTS_TCPPKT) && + !(extsts & RGE_RDEXTSTS_TCPCSUMERR)) || + ((extsts & RGE_RDEXTSTS_UDPPKT) && + !(extsts & RGE_RDEXTSTS_UDPCSUMERR m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK; #endif Index: src/sys/dev/pci/if_rgereg.h diff -u src/sys/dev/pci/if_rgereg.h:1.6 src/sys/dev/pci/if_rgereg.h:1.7 --- src/sys/dev/pci/if_rgereg.h:1.6 Sun Aug 28 07:44:23 2022 +++ src/sys/dev/pci/if_rgereg.h Wed Dec 21 05:19:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_rgereg.h,v 1.6 2022/08/28 07:44:23 skrll Exp $ */ +/* $NetBSD: if_rgereg.h,v 1.7 2022/12/21 05:19:15 nonaka Exp $ */ /* $OpenBSD: if_rgereg.h,v 1.6 2020/12/24 01:00:00 kevlo Exp $ */ /* @@ -188,9 +188,10 @@ #define RGE_NEXT_RX_DESC(x) (((x) + 1) % RGE_RX_LIST_CNT) #define RGE_ADDR_LO(y) ((uint64_t) (y) & 0x) #define RGE_ADDR_HI(y) ((uint64_t) (y) >> 32) -#define RGE_OWN(x) (letoh32((x)->rge_cmdsts) & RGE_RDCMDSTS_OWN) -#define RGE_RXBYTES(x) (letoh32((x)->rge_cmdsts) & \ -RGE_RDCMDSTS_FRAGLEN) +#define RGE_OWN(x) \ +
CVS commit: src/sys/dev/pci
Module Name:src Committed By: nonaka Date: Wed Dec 21 05:19:15 UTC 2022 Modified Files: src/sys/dev/pci: if_rge.c if_rgereg.h Log Message: Update the Rx descriptor based on the vendor driver for Linux. This fixes a panic on RTL8125. Patch from OpenBSD if_rge.c r1.20, if_rgereg.h r1.8. Tested by msaitoh@n.o. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/if_rge.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/if_rgereg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/landisk/stand/boot
Module Name:src Committed By: nonaka Date: Wed Aug 24 14:22:36 UTC 2022 Modified Files: src/sys/arch/landisk/stand/boot: getsecs.c Log Message: Added missing copyright and license notice. Pointed out by miod@o.o., Thanks. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/landisk/stand/boot/getsecs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/landisk/stand/boot
Module Name:src Committed By: nonaka Date: Wed Aug 24 14:22:36 UTC 2022 Modified Files: src/sys/arch/landisk/stand/boot: getsecs.c Log Message: Added missing copyright and license notice. Pointed out by miod@o.o., Thanks. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/landisk/stand/boot/getsecs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/landisk/stand/boot/getsecs.c diff -u src/sys/arch/landisk/stand/boot/getsecs.c:1.3 src/sys/arch/landisk/stand/boot/getsecs.c:1.4 --- src/sys/arch/landisk/stand/boot/getsecs.c:1.3 Mon Jan 12 11:32:44 2009 +++ src/sys/arch/landisk/stand/boot/getsecs.c Wed Aug 24 14:22:35 2022 @@ -1,4 +1,30 @@ -/* $NetBSD: getsecs.c,v 1.3 2009/01/12 11:32:44 tsutsui Exp $ */ +/* $NetBSD: getsecs.c,v 1.4 2022/08/24 14:22:35 nonaka Exp $ */ + +/*- + * Copyright (c) 2005 NONAKA Kimihiro + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ #include #include
CVS commit: src/sys
Module Name:src Committed By: nonaka Date: Fri May 20 13:55:17 UTC 2022 Modified Files: src/sys/arch/x86/x86: hyperv.c src/sys/dev/hyperv: files.hyperv hyperv_common.c hypervreg.h hypervvar.h if_hvn.c if_hvnreg.h vmbus.c vmbusvar.h Log Message: Improve Hyper-V support. vmbus(4): - Added support for multichannel. hvn(4): - Added support for multichannel. - Added support for change MTU. - Added support for TX aggregation. - Improve VLAN support. - Improve checksum offload support. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/x86/hyperv.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hyperv/files.hyperv \ src/sys/dev/hyperv/if_hvnreg.h cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/hyperv_common.c \ src/sys/dev/hyperv/hypervvar.h cvs rdiff -u -r1.1 -r1.2 src/sys/dev/hyperv/hypervreg.h cvs rdiff -u -r1.21 -r1.22 src/sys/dev/hyperv/if_hvn.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/hyperv/vmbus.c cvs rdiff -u -r1.6 -r1.7 src/sys/dev/hyperv/vmbusvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/isa
Module Name:src Committed By: nonaka Date: Sat Jul 3 04:44:16 UTC 2021 Modified Files: src/sys/dev/isa: itesio_isa.c itesio_isavar.h Log Message: itesio(4): Added IT8625E support. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/dev/isa/itesio_isa.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/isa/itesio_isavar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/isa
Module Name:src Committed By: nonaka Date: Sat Jul 3 04:44:16 UTC 2021 Modified Files: src/sys/dev/isa: itesio_isa.c itesio_isavar.h Log Message: itesio(4): Added IT8625E support. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/dev/isa/itesio_isa.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/isa/itesio_isavar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/isa/itesio_isa.c diff -u src/sys/dev/isa/itesio_isa.c:1.28 src/sys/dev/isa/itesio_isa.c:1.29 --- src/sys/dev/isa/itesio_isa.c:1.28 Tue Jul 23 09:38:53 2019 +++ src/sys/dev/isa/itesio_isa.c Sat Jul 3 04:44:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: itesio_isa.c,v 1.28 2019/07/23 09:38:53 msaitoh Exp $ */ +/* $NetBSD: itesio_isa.c,v 1.29 2021/07/03 04:44:16 nonaka Exp $ */ /* Derived from $OpenBSD: it.c,v 1.19 2006/04/10 00:57:54 deraadt Exp $ */ /* @@ -34,13 +34,14 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: itesio_isa.c,v 1.28 2019/07/23 09:38:53 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: itesio_isa.c,v 1.29 2021/07/03 04:44:16 nonaka Exp $"); #include #include #include #include #include +#include #include #include @@ -52,6 +53,11 @@ __KERNEL_RCSID(0, "$NetBSD: itesio_isa.c #define IT_VOLTSTART_IDX 3 /* voltage start index */ #define IT_FANSTART_IDX 12 /* fan start index */ +/* IT8625: 3 temps, 10 volts, 6 fans */ +#define IT8625_NUM_SENSORS 19 +#define IT8625_VOLTSTART_IDX 3 /* voltage start index */ +#define IT8625_FANSTART_IDX 13 /* fan start index */ + #if defined(ITESIO_DEBUG) #define DPRINTF(x) do { printf x; } while (0) #else @@ -90,6 +96,13 @@ static void itesio_refresh_temp(struct i static void itesio_refresh_volts(struct itesio_softc *, envsys_data_t *); static void itesio_refresh_fans(struct itesio_softc *, envsys_data_t *); static void itesio_refresh(struct sysmon_envsys *, envsys_data_t *); +static void itesio_refresh_it8705_fans(struct itesio_softc *, + envsys_data_t *); +static void itesio_setup_it8625_sensors(struct itesio_softc *); +static void itesio_refresh_it8625_volts(struct itesio_softc *, + envsys_data_t *); +static void itesio_refresh_it8625_fans(struct itesio_softc *, + envsys_data_t *); /* sysmon_wdog glue */ static bool itesio_wdt_suspend(device_t, const pmf_qual_t *); @@ -109,11 +122,58 @@ static const int itesio_vrfact[] = { RFACT_NONE /* VBAT */ }; +static const struct itesio_config itesio_config[] = { + { + .chipid = ITESIO_ID8625, + .no_wdt = true, + .num_sensors = IT8625_NUM_SENSORS, + .voltstart_idx = IT8625_VOLTSTART_IDX, + .fanstart_idx = IT8625_FANSTART_IDX, + .setup_sensors = itesio_setup_it8625_sensors, + .refresh_volts = itesio_refresh_it8625_volts, + .refresh_fans = itesio_refresh_it8625_fans, + }, + { .chipid = ITESIO_ID8628, }, + { .chipid = ITESIO_ID8655, }, + { + .chipid = ITESIO_ID8705, + .no_wdt = true, + .refresh_fans = itesio_refresh_it8705_fans, + }, + { + .chipid = ITESIO_ID8712, + .refresh_fans = itesio_refresh_it8705_fans, + }, + { .chipid = ITESIO_ID8716, }, + { .chipid = ITESIO_ID8718, }, + { .chipid = ITESIO_ID8720, }, + { .chipid = ITESIO_ID8721, }, + { .chipid = ITESIO_ID8726, }, + { .chipid = ITESIO_ID8728, }, + { .chipid = ITESIO_ID8771, }, + { .chipid = ITESIO_ID8772, }, +}; + +static const struct itesio_config * +itesio_isa_find_config(uint16_t chipid) +{ + const struct itesio_config *ic; + size_t i; + + for (i = 0; i < __arraycount(itesio_config); i++) { + ic = _config[i]; + if (chipid == ic->chipid) + return ic; + } + return NULL; +} + static int itesio_isa_match(device_t parent, cfdata_t match, void *aux) { struct isa_attach_args *ia = aux; bus_space_handle_t ioh; + const struct itesio_config *ic; uint16_t cr; /* Must supply an address */ @@ -135,28 +195,16 @@ itesio_isa_match(device_t parent, cfdata itesio_exit(ia->ia_iot, ioh); bus_space_unmap(ia->ia_iot, ioh, 2); - switch (cr) { - case ITESIO_ID8628: - case ITESIO_ID8655: - case ITESIO_ID8705: - case ITESIO_ID8712: - case ITESIO_ID8716: - case ITESIO_ID8718: - case ITESIO_ID8720: - case ITESIO_ID8721: - case ITESIO_ID8726: - case ITESIO_ID8728: - case ITESIO_ID8771: - case ITESIO_ID8772: - ia->ia_nio = 1; - ia->ia_io[0].ir_size = 2; - ia->ia_niomem = 0; - ia->ia_nirq = 0; - ia->ia_ndrq = 0; - return 1; - default: + ic = itesio_isa_find_config(cr); + if (ic == NULL) return 0; - } + + ia->ia_nio = 1; + ia->ia_io[0].ir_size = 2; + ia->ia_niomem = 0; + ia->ia_nirq = 0; + ia->ia_ndrq = 0; + return 1; } static void @@ -164,7 +212,9 @@ itesio_isa_attach(device_t parent, devic { struct itesio_softc *sc = device_private(self); struct isa_attach_args *ia = aux; - int i; + const struct itesio_config *ic; + uint32_t i; + int error; uint8_t cr; sc->sc_iot = ia->ia_iot; @@ -205,6 +255,27 @@ itesio_isa_attach(device_t parent, devic */ itesio_exit(sc->sc_iot,
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Thu Jun 10 07:48:01 UTC 2021 Modified Files: src/sys/dev/hyperv: hvs.c Log Message: hvs(4): Pass correct pointer of scsibus device to scsi_probe_bus(). To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/hvs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/hvs.c diff -u src/sys/dev/hyperv/hvs.c:1.5 src/sys/dev/hyperv/hvs.c:1.6 --- src/sys/dev/hyperv/hvs.c:1.5 Sat Apr 24 23:36:54 2021 +++ src/sys/dev/hyperv/hvs.c Thu Jun 10 07:48:00 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: hvs.c,v 1.5 2021/04/24 23:36:54 thorpej Exp $ */ +/* $NetBSD: hvs.c,v 1.6 2021/06/10 07:48:00 nonaka Exp $ */ /* $OpenBSD: hvs.c,v 1.17 2017/08/10 17:22:48 mikeb Exp $ */ /*- @@ -37,7 +37,7 @@ /* #define HVS_DEBUG_IO */ #include -__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.5 2021/04/24 23:36:54 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.6 2021/06/10 07:48:00 nonaka Exp $"); #include #include @@ -833,7 +833,7 @@ hvs_scsi_probe(void *arg) struct hvs_softc *sc = arg; if (sc->sc_scsibus != NULL) - scsi_probe_bus((void *)sc->sc_scsibus, -1, -1); + scsi_probe_bus(device_private(sc->sc_scsibus), -1, -1); } static void
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Thu Jun 10 07:48:01 UTC 2021 Modified Files: src/sys/dev/hyperv: hvs.c Log Message: hvs(4): Pass correct pointer of scsibus device to scsi_probe_bus(). To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/hvs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/pci
Module Name:src Committed By: nonaka Date: Sun Jun 6 11:35:22 UTC 2021 Modified Files: src/sys/arch/x86/pci: amdzentemp.c Log Message: Fix build failure on i386. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/pci/amdzentemp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/pci/amdzentemp.c diff -u src/sys/arch/x86/pci/amdzentemp.c:1.13 src/sys/arch/x86/pci/amdzentemp.c:1.14 --- src/sys/arch/x86/pci/amdzentemp.c:1.13 Sun Jun 6 08:45:18 2021 +++ src/sys/arch/x86/pci/amdzentemp.c Sun Jun 6 11:35:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka Exp $ */ +/* $NetBSD: amdzentemp.c,v 1.14 2021/06/06 11:35:22 nonaka Exp $ */ /* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ /* @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka Exp $ "); +__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.14 2021/06/06 11:35:22 nonaka Exp $ "); #include #include @@ -431,8 +431,9 @@ static void amdzentemp_setup_ccd_sensors(struct amdzentemp_softc *sc) { envsys_data_t *edata; + size_t i; uint32_t temp; - int i, error; + int error; for (i = 0; i < sc->sc_numsensors - 1; i++) { error = amdsmn_read(sc->sc_smn, @@ -446,7 +447,7 @@ amdzentemp_setup_ccd_sensors(struct amdz edata->flags = ENVSYS_FHAS_ENTROPY; edata->private = CCD_BASE + i; snprintf(edata->desc, sizeof(edata->desc), - "cpu%u ccd%u temperature", device_unit(sc->sc_dev), i); + "cpu%u ccd%zu temperature", device_unit(sc->sc_dev), i); } }
CVS commit: src/sys/arch/x86/pci
Module Name:src Committed By: nonaka Date: Sun Jun 6 11:35:22 UTC 2021 Modified Files: src/sys/arch/x86/pci: amdzentemp.c Log Message: Fix build failure on i386. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/pci/amdzentemp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/pci
Module Name:src Committed By: nonaka Date: Sun Jun 6 08:45:18 UTC 2021 Modified Files: src/sys/arch/x86/pci: amdzentemp.c Log Message: amdzentemp(4): Add support for per CCD temperature sensor from FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/pci/amdzentemp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/pci/amdzentemp.c diff -u src/sys/arch/x86/pci/amdzentemp.c:1.12 src/sys/arch/x86/pci/amdzentemp.c:1.13 --- src/sys/arch/x86/pci/amdzentemp.c:1.12 Sat Jun 5 01:38:22 2021 +++ src/sys/arch/x86/pci/amdzentemp.c Sun Jun 6 08:45:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka Exp $ */ +/* $NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka Exp $ */ /* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ /* @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka Exp $ "); +__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka Exp $ "); #include #include @@ -76,6 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdzentemp.c #define AMD_CURTMP_RANGE_ADJUST 4900 /* in microKelvins (ie, 49C) */ #define AMD_CURTMP_RANGE_CHECK __BIT(19) #define F10_TEMP_CURTMP __BITS(31,21) /* XXX same as amdtemp.c */ +#define F10_TEMP_CURTMP_MASK 0x7ff #define F15M60_CURTMP_TJSEL __BITS(17,16) /* @@ -96,7 +97,17 @@ __KERNEL_RCSID(0, "$NetBSD: amdzentemp.c */ #define AMD_17H_CUR_TMP 0x59800 +/* + * The following register set was discovered experimentally by Ondrej Čerman + * and collaborators, but is not (yet) documented in a PPR/OSRR (other than + * the M70H PPR SMN memory map showing [0x59800, +0x314] as allocated to + * SMU::THM). It seems plausible and the Linux sensor folks have adopted it. + */ +#define AMD_17H_CCD_TMP_BASE 0x59954 +#define AMD_17H_CCD_TMP_VALID __BIT(11) + struct amdzentemp_softc { + device_t sc_dev; struct sysmon_envsys *sc_sme; device_t sc_smn; envsys_data_t *sc_sensor; @@ -105,15 +116,33 @@ struct amdzentemp_softc { int32_t sc_offset; }; +enum { + NOSENSOR = 0, + CORE0_SENSOR0, + CCD_BASE, + CCD0 = CCD_BASE, + CCD1, + CCD2, + CCD3, + CCD4, + CCD5, + CCD6, + CCD7, + CCD_MAX, + NUM_CCDS = CCD_MAX - CCD_BASE +}; + static int amdzentemp_match(device_t, cfdata_t, void *); static void amdzentemp_attach(device_t, device_t, void *); static int amdzentemp_detach(device_t, int); -static void amdzentemp_init(struct amdzentemp_softc *); -static void amdzentemp_setup_sensors(struct amdzentemp_softc *, int); +static void amdzentemp_init(struct amdzentemp_softc *, int, int); +static void amdzentemp_setup_sensors(struct amdzentemp_softc *); static void amdzentemp_family15_refresh(struct sysmon_envsys *, envsys_data_t *); static void amdzentemp_family17_refresh(struct sysmon_envsys *, envsys_data_t *); +static int amdzentemp_probe_ccd_sensors(struct amdzentemp_softc *, int, int); +static void amdzentemp_setup_ccd_sensors(struct amdzentemp_softc *); CFATTACH_DECL_NEW(amdzentemp, sizeof(struct amdzentemp_softc), amdzentemp_match, amdzentemp_attach, amdzentemp_detach, NULL); @@ -124,9 +153,9 @@ amdzentemp_match(device_t parent, cfdata struct pci_attach_args *pa __diagused = aux; KASSERT(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD); - + cfdata_t parent_cfdata = device_cfdata(parent); - + /* Got AMD family 17h system management network */ return parent_cfdata->cf_name && memcmp(parent_cfdata->cf_name, "amdsmn", 6) == 0; @@ -137,18 +166,20 @@ amdzentemp_attach(device_t parent, devic { struct amdzentemp_softc *sc = device_private(self); struct cpu_info *ci = curcpu(); - int family; + int family, model; int error; size_t i; + sc->sc_dev = self; + family = CPUID_TO_FAMILY(ci->ci_signature); + model = CPUID_TO_MODEL(ci->ci_signature); aprint_naive("\n"); - aprint_normal(": AMD CPU Temperature Sensors (Family%xh)", - family); + aprint_normal(": AMD CPU Temperature Sensors (Family%xh)", family); sc->sc_smn = parent; - amdzentemp_init(sc); + amdzentemp_init(sc, family, model); aprint_normal("\n"); @@ -156,12 +187,14 @@ amdzentemp_attach(device_t parent, devic sc->sc_sensor_len = sizeof(envsys_data_t) * sc->sc_numsensors; sc->sc_sensor = kmem_zalloc(sc->sc_sensor_len, KM_SLEEP); - amdzentemp_setup_sensors(sc, device_unit(self)); + amdzentemp_setup_sensors(sc); /* * Set properties in sensors. */ for (i = 0; i < sc->sc_numsensors; i++) { + if (sc->sc_sensor[i].private == NOSENSOR) + continue; if (sysmon_envsys_sensor_attach(sc->sc_sme, >sc_sensor[i])) goto bad; } @@ -223,10 +256,10 @@ amdzentemp_detach(device_t self, int fla static void -amdzentemp_init(struct amdzentemp_softc *sc) +amdzentemp_init(struct amdzentemp_softc *sc, int family, int model) { - sc->sc_numsensors = 1; +
CVS commit: src/sys/arch/x86/pci
Module Name:src Committed By: nonaka Date: Sun Jun 6 08:45:18 UTC 2021 Modified Files: src/sys/arch/x86/pci: amdzentemp.c Log Message: amdzentemp(4): Add support for per CCD temperature sensor from FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/pci/amdzentemp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/isa
Module Name:src Committed By: nonaka Date: Sat Jun 5 01:40:53 UTC 2021 Modified Files: src/sys/dev/isa: itesio_isavar.h Log Message: Add IT8625 chip id. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/isa/itesio_isavar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/isa/itesio_isavar.h diff -u src/sys/dev/isa/itesio_isavar.h:1.12 src/sys/dev/isa/itesio_isavar.h:1.13 --- src/sys/dev/isa/itesio_isavar.h:1.12 Tue Jul 23 09:38:53 2019 +++ src/sys/dev/isa/itesio_isavar.h Sat Jun 5 01:40:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: itesio_isavar.h,v 1.12 2019/07/23 09:38:53 msaitoh Exp $ */ +/* $NetBSD: itesio_isavar.h,v 1.13 2021/06/05 01:40:53 nonaka Exp $ */ /* $OpenBSD: itvar.h,v 1.2 2003/11/05 20:57:10 grange Exp $ */ /* @@ -57,6 +57,7 @@ #define ITESIO_CHIPID2 0x21 /* Chip ID 2 */ #define ITESIO_DEVREV 0x22 /* Device Revision */ +#define ITESIO_ID8625 0x8625 #define ITESIO_ID8628 0x8628 #define ITESIO_ID8655 0x8655 #define ITESIO_ID8705 0x8705
CVS commit: src/sys/dev/isa
Module Name:src Committed By: nonaka Date: Sat Jun 5 01:40:53 UTC 2021 Modified Files: src/sys/dev/isa: itesio_isavar.h Log Message: Add IT8625 chip id. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/isa/itesio_isavar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/pci
Module Name:src Committed By: nonaka Date: Sat Jun 5 01:38:22 UTC 2021 Modified Files: src/sys/arch/x86/pci: amdzentemp.c Log Message: amdzentemp(4): Add Zen 3 support. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x86/pci/amdzentemp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/pci/amdzentemp.c diff -u src/sys/arch/x86/pci/amdzentemp.c:1.11 src/sys/arch/x86/pci/amdzentemp.c:1.12 --- src/sys/arch/x86/pci/amdzentemp.c:1.11 Sat Apr 25 15:26:18 2020 +++ src/sys/arch/x86/pci/amdzentemp.c Sat Jun 5 01:38:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: amdzentemp.c,v 1.11 2020/04/25 15:26:18 bouyer Exp $ */ +/* $NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka Exp $ */ /* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ /* @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.11 2020/04/25 15:26:18 bouyer Exp $ "); +__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka Exp $ "); #include #include @@ -177,6 +177,7 @@ amdzentemp_attach(device_t parent, devic sc->sc_sme->sme_refresh = amdzentemp_family15_refresh; break; case 0x17: + case 0x19: sc->sc_sme->sme_refresh = amdzentemp_family17_refresh; break; default:
CVS commit: src/sys/arch/x86/pci
Module Name:src Committed By: nonaka Date: Sat Jun 5 01:38:22 UTC 2021 Modified Files: src/sys/arch/x86/pci: amdzentemp.c Log Message: amdzentemp(4): Add Zen 3 support. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x86/pci/amdzentemp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/include
Module Name:src Committed By: nonaka Date: Thu Mar 18 01:50:12 UTC 2021 Modified Files: src/sys/arch/x86/include: intrdefs.h Log Message: LIR_HV priority should be lower than softint. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x86/include/intrdefs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/intrdefs.h diff -u src/sys/arch/x86/include/intrdefs.h:1.24 src/sys/arch/x86/include/intrdefs.h:1.25 --- src/sys/arch/x86/include/intrdefs.h:1.24 Sat Apr 25 15:26:18 2020 +++ src/sys/arch/x86/include/intrdefs.h Thu Mar 18 01:50:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: intrdefs.h,v 1.24 2020/04/25 15:26:18 bouyer Exp $ */ +/* $NetBSD: intrdefs.h,v 1.25 2021/03/18 01:50:12 nonaka Exp $ */ #ifndef _X86_INTRDEFS_H_ #define _X86_INTRDEFS_H_ @@ -27,7 +27,6 @@ */ #define LIR_IPI 31 #define LIR_TIMER 30 -#define LIR_HV 29 /* * XXX These should be lowest numbered, but right now would @@ -35,11 +34,12 @@ * means that soft interrupt take priority over hardware * interrupts when lowering the priority level! */ -#define SIR_SERIAL 28 -#define SIR_NET 27 -#define SIR_BIO 26 -#define SIR_CLOCK 25 -#define SIR_PREEMPT 24 +#define SIR_SERIAL 29 +#define SIR_NET 28 +#define SIR_BIO 27 +#define SIR_CLOCK 26 +#define SIR_PREEMPT 25 +#define LIR_HV 24 #define SIR_XENIPL_HIGH 23 #define SIR_XENIPL_SCHED 22 #define SIR_XENIPL_VM 21
CVS commit: src/sys/arch/x86/include
Module Name:src Committed By: nonaka Date: Thu Mar 18 01:50:12 UTC 2021 Modified Files: src/sys/arch/x86/include: intrdefs.h Log Message: LIR_HV priority should be lower than softint. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x86/include/intrdefs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Jan 29 04:38:49 UTC 2021 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Don't wait forever. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.19 src/sys/dev/hyperv/if_hvn.c:1.20 --- src/sys/dev/hyperv/if_hvn.c:1.19 Fri Dec 11 08:13:08 2020 +++ src/sys/dev/hyperv/if_hvn.c Fri Jan 29 04:38:49 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.19 2020/12/11 08:13:08 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.20 2021/01/29 04:38:49 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.19 2020/12/11 08:13:08 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.20 2021/01/29 04:38:49 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1070,7 +1070,8 @@ hvn_nvs_cmd(struct hvn_softc *sc, void * if (cold) delay(1000); else -tsleep(cmd, PRIBIO, "nvsout", mstohz(1)); +tsleep(cmd, PRIBIO, "nvsout", +uimax(1, mstohz(1))); } else if (rv) { DPRINTF("%s: NVSP operation %u send error %d\n", device_xname(sc->sc_dev), hdr->nvs_type, rv); @@ -1095,7 +1096,7 @@ hvn_nvs_cmd(struct hvn_softc *sc, void * splx(s); } else tsleep(sc->sc_nvsrsp, PRIBIO | PCATCH, "nvscmd", - mstohz(1)); + uimax(1, mstohz(1))); } while (--timo > 0 && sc->sc_nvsdone != 1); if (timo == 0 && sc->sc_nvsdone != 1) { @@ -1393,7 +1394,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru if (cold) delay(1000); else -tsleep(rc, PRIBIO, "rndisout", mstohz(1)); +tsleep(rc, PRIBIO, "rndisout", +uimax(1, mstohz(1))); } else if (rv) { DPRINTF("%s: RNDIS operation %u send error %d\n", device_xname(sc->sc_dev), hdr->rm_type, rv); @@ -1422,7 +1424,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru hvn_nvs_intr(sc); splx(s); } else - tsleep(rc, PRIBIO | PCATCH, "rndiscmd", mstohz(1)); + tsleep(rc, PRIBIO | PCATCH, "rndiscmd", + uimax(1, mstohz(1))); } while (--timo > 0 && rc->rc_done != 1); bus_dmamap_sync(sc->sc_dmat, rc->rc_dmap, 0, PAGE_SIZE,
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Jan 29 04:38:49 UTC 2021 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Don't wait forever. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Jan 29 04:38:34 UTC 2021 Modified Files: src/sys/dev/hyperv: vmbus.c Log Message: vmbus(4): Don't wait forever. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/vmbus.c diff -u src/sys/dev/hyperv/vmbus.c:1.11 src/sys/dev/hyperv/vmbus.c:1.12 --- src/sys/dev/hyperv/vmbus.c:1.11 Tue May 26 16:08:55 2020 +++ src/sys/dev/hyperv/vmbus.c Fri Jan 29 04:38:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vmbus.c,v 1.11 2020/05/26 16:08:55 nonaka Exp $ */ +/* $NetBSD: vmbus.c,v 1.12 2021/01/29 04:38:34 nonaka Exp $ */ /* $OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.11 2020/05/26 16:08:55 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.12 2021/01/29 04:38:34 nonaka Exp $"); #include #include @@ -608,7 +608,8 @@ vmbus_start(struct vmbus_softc *sc, stru hyperv_intr(); splx(s); } else - tsleep(wchan, PRIBIO, wchan, mstohz(delays[i])); + tsleep(wchan, PRIBIO, wchan, + uimax(1, mstohz(delays[i] / 1000))); } if (status != HYPERCALL_STATUS_SUCCESS) { device_printf(sc->sc_dev,
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Jan 29 04:38:34 UTC 2021 Modified Files: src/sys/dev/hyperv: vmbus.c Log Message: vmbus(4): Don't wait forever. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Jan 29 04:38:18 UTC 2021 Modified Files: src/sys/dev/hyperv: hvkbd.c Log Message: hvkbd(4): Don't wait forever. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/hyperv/hvkbd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/hvkbd.c diff -u src/sys/dev/hyperv/hvkbd.c:1.6 src/sys/dev/hyperv/hvkbd.c:1.7 --- src/sys/dev/hyperv/hvkbd.c:1.6 Fri Nov 22 12:40:07 2019 +++ src/sys/dev/hyperv/hvkbd.c Fri Jan 29 04:38:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: hvkbd.c,v 1.6 2019/11/22 12:40:07 nonaka Exp $ */ +/* $NetBSD: hvkbd.c,v 1.7 2021/01/29 04:38:18 nonaka Exp $ */ /*- * Copyright (c) 2017 Microsoft Corp. @@ -36,7 +36,7 @@ #endif /* _KERNEL_OPT */ #include -__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.6 2019/11/22 12:40:07 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.7 2021/01/29 04:38:18 nonaka Exp $"); #include #include @@ -350,7 +350,8 @@ hvkbd_connect(struct hvkbd_softc *sc) hvkbd_intr(sc); splx(s); } else - tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", mstohz(1)); + tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", + uimax(1, mstohz(1))); } while (--timo > 0 && sc->sc_connected == 0); if (timo == 0 && sc->sc_connected == 0) {
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Jan 29 04:38:18 UTC 2021 Modified Files: src/sys/dev/hyperv: hvkbd.c Log Message: hvkbd(4): Don't wait forever. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/hyperv/hvkbd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Dec 11 08:13:08 UTC 2020 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): fix unable to ifconfig up/down. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.18 src/sys/dev/hyperv/if_hvn.c:1.19 --- src/sys/dev/hyperv/if_hvn.c:1.18 Sun May 24 10:31:59 2020 +++ src/sys/dev/hyperv/if_hvn.c Fri Dec 11 08:13:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.18 2020/05/24 10:31:59 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.19 2020/12/11 08:13:08 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.18 2020/05/24 10:31:59 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.19 2020/12/11 08:13:08 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -387,26 +387,7 @@ hvn_ioctl(struct ifnet *ifp, u_long comm s = splnet(); - switch (command) { - case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) { - if (ifp->if_flags & IFF_RUNNING) -error = ENETRESET; - else { -error = hvn_init(ifp); -if (error) - ifp->if_flags &= ~IFF_UP; - } - } else { - if (ifp->if_flags & IFF_RUNNING) -hvn_stop(ifp, 1); - } - break; - default: - error = ether_ioctl(ifp, command, data); - break; - } - + error = ether_ioctl(ifp, command, data); if (error == ENETRESET) { if (ifp->if_flags & IFF_RUNNING) hvn_iff(sc);
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Dec 11 08:13:08 UTC 2020 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): fix unable to ifconfig up/down. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev
Module Name:src Committed By: nonaka Date: Mon Aug 17 08:34:36 UTC 2020 Modified Files: src/sys/dev: ipmi.c Log Message: ipmi(4): Fixed a bug that incorrect condition is notified. When the value obtained from the sensor is below the lower limit of the critical threshold, it is notified that the value is below the lower limit of the warning threshold. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ipmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ipmi.c diff -u src/sys/dev/ipmi.c:1.4 src/sys/dev/ipmi.c:1.5 --- src/sys/dev/ipmi.c:1.4 Sat May 18 08:38:00 2019 +++ src/sys/dev/ipmi.c Mon Aug 17 08:34:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ipmi.c,v 1.4 2019/05/18 08:38:00 mlelstv Exp $ */ +/* $NetBSD: ipmi.c,v 1.5 2020/08/17 08:34:36 nonaka Exp $ */ /* * Copyright (c) 2019 Michael van Elst @@ -76,7 +76,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4 2019/05/18 08:38:00 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.5 2020/08/17 08:34:36 nonaka Exp $"); #include #include @@ -1632,14 +1632,14 @@ ipmi_sensor_status(struct ipmi_softc *sc edata->value_cur > psensor->i_limits.sel_warnmax) return ENVSYS_SWARNOVER; - if (psensor->i_props & PROP_WARNMIN && - edata->value_cur < psensor->i_limits.sel_warnmin) - return ENVSYS_SWARNUNDER; - if (psensor->i_props & PROP_CRITMIN && edata->value_cur < psensor->i_limits.sel_critmin) return ENVSYS_SCRITUNDER; + if (psensor->i_props & PROP_WARNMIN && + edata->value_cur < psensor->i_limits.sel_warnmin) + return ENVSYS_SWARNUNDER; + break; case IPMI_SENSOR_TYPE_INTRUSION:
CVS commit: src/sys/dev
Module Name:src Committed By: nonaka Date: Mon Aug 17 08:34:36 UTC 2020 Modified Files: src/sys/dev: ipmi.c Log Message: ipmi(4): Fixed a bug that incorrect condition is notified. When the value obtained from the sensor is below the lower limit of the critical threshold, it is notified that the value is below the lower limit of the warning threshold. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ipmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Tue May 26 16:08:55 UTC 2020 Modified Files: src/sys/dev/hyperv: vmbus.c vmbusvar.h Log Message: vmbus(4): Do not call hyperv_dma_alloc() in interrupt context. The channel offer and rescind process is performed on another context. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/hyperv/vmbus.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hyperv/vmbusvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Tue May 26 16:08:55 UTC 2020 Modified Files: src/sys/dev/hyperv: vmbus.c vmbusvar.h Log Message: vmbus(4): Do not call hyperv_dma_alloc() in interrupt context. The channel offer and rescind process is performed on another context. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/hyperv/vmbus.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hyperv/vmbusvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/vmbus.c diff -u src/sys/dev/hyperv/vmbus.c:1.10 src/sys/dev/hyperv/vmbus.c:1.11 --- src/sys/dev/hyperv/vmbus.c:1.10 Tue May 26 16:00:06 2020 +++ src/sys/dev/hyperv/vmbus.c Tue May 26 16:08:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vmbus.c,v 1.10 2020/05/26 16:00:06 nonaka Exp $ */ +/* $NetBSD: vmbus.c,v 1.11 2020/05/26 16:08:55 nonaka Exp $ */ /* $OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.10 2020/05/26 16:00:06 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.11 2020/05/26 16:08:55 nonaka Exp $"); #include #include @@ -103,10 +103,14 @@ static void vmbus_channel_detach(struct static void vmbus_channel_pause(struct vmbus_channel *); static uint32_t vmbus_channel_unpause(struct vmbus_channel *); static uint32_t vmbus_channel_ready(struct vmbus_channel *); +static void vmbus_chevq_enqueue(struct vmbus_softc *, int, void *); +static void vmbus_process_chevq(void *); +static void vmbus_chevq_thread(void *); static void vmbus_devq_enqueue(struct vmbus_softc *, int, struct vmbus_channel *); static void vmbus_process_devq(void *); static void vmbus_devq_thread(void *); +static void vmbus_subchannel_devq_thread(void *); static struct vmbus_softc *vmbus_sc; @@ -841,15 +845,33 @@ vmbus_channel_response(struct vmbus_soft static void vmbus_channel_offer(struct vmbus_softc *sc, struct vmbus_chanmsg_hdr *hdr) { + struct vmbus_chanmsg_choffer *co; - vmbus_process_offer(sc, (struct vmbus_chanmsg_choffer *)hdr); + co = kmem_intr_alloc(sizeof(*co), KM_NOSLEEP); + if (co == NULL) { + device_printf(sc->sc_dev, + "failed to allocate an offer object\n"); + return; + } + + memcpy(co, hdr, sizeof(*co)); + vmbus_chevq_enqueue(sc, VMBUS_CHEV_TYPE_OFFER, co); } static void vmbus_channel_rescind(struct vmbus_softc *sc, struct vmbus_chanmsg_hdr *hdr) { + struct vmbus_chanmsg_chrescind *cr; + + cr = kmem_intr_alloc(sizeof(*cr), KM_NOSLEEP); + if (cr == NULL) { + device_printf(sc->sc_dev, + "failed to allocate an rescind object\n"); + return; + } - vmbus_process_rescind(sc, (struct vmbus_chanmsg_chrescind *)hdr); + memcpy(cr, hdr, sizeof(*cr)); + vmbus_chevq_enqueue(sc, VMBUS_CHEV_TYPE_RESCIND, cr); } static void @@ -906,16 +928,48 @@ vmbus_channel_scan(struct vmbus_softc *s struct vmbus_chanmsg_hdr hdr; struct vmbus_chanmsg_choffer rsp; + TAILQ_INIT(>sc_prichans); + mutex_init(>sc_prichan_lock, MUTEX_DEFAULT, IPL_NET); TAILQ_INIT(>sc_channels); mutex_init(>sc_channel_lock, MUTEX_DEFAULT, IPL_NET); + /* + * This queue serializes vmbus channel offer and rescind messages. + */ + SIMPLEQ_INIT(>sc_chevq); + mutex_init(>sc_chevq_lock, MUTEX_DEFAULT, IPL_NET); + cv_init(>sc_chevq_cv, "hvchevcv"); + if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, + vmbus_chevq_thread, sc, NULL, "hvchevq") != 0) { + DPRINTF("%s: failed to create prich chevq thread\n", + device_xname(sc->sc_dev)); + return -1; + } + + /* + * This queue serializes vmbus devices' attach and detach + * for channel offer and rescind messages. + */ SIMPLEQ_INIT(>sc_devq); mutex_init(>sc_devq_lock, MUTEX_DEFAULT, IPL_NET); cv_init(>sc_devq_cv, "hvdevqcv"); + if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, + vmbus_devq_thread, sc, NULL, "hvdevq") != 0) { + DPRINTF("%s: failed to create prich devq thread\n", + device_xname(sc->sc_dev)); + return -1; + } + /* + * This queue handles sub-channel detach, so that vmbus + * device's detach running in sc_devq can drain its sub-channels. + */ + SIMPLEQ_INIT(>sc_subch_devq); + mutex_init(>sc_subch_devq_lock, MUTEX_DEFAULT, IPL_NET); + cv_init(>sc_subch_devq_cv, "hvsdvqcv"); if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL, - vmbus_devq_thread, sc, NULL, "hvoffer") != 0) { - DPRINTF("%s: failed to create offer thread\n", + vmbus_subchannel_devq_thread, sc, NULL, "hvsdevq") != 0) { + DPRINTF("%s: failed to create subch devq thread\n", device_xname(sc->sc_dev)); return -1; } @@ -932,6 +986,9 @@ vmbus_channel_scan(struct vmbus_softc *s while (!ISSET(sc->sc_flags, VMBUS_SCFLAG_OFFERS_DELIVERED)) tsleep(>sc_devq, PRIBIO, "hvscan", 1); + mutex_enter(>sc_chevq_lock); + vmbus_process_chevq(sc); + mutex_exit(>sc_chevq_lock); mutex_enter(>sc_devq_lock); vmbus_process_devq(sc); mutex_exit(>sc_devq_lock); @@
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Tue May 26 16:00:06 UTC 2020 Modified Files: src/sys/dev/hyperv: vmbus.c Log Message: vmbus(4): Fixed incorrect use of vmbus_wait() in vmbus_channel_scan(). Found by kUBSan. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/vmbus.c diff -u src/sys/dev/hyperv/vmbus.c:1.9 src/sys/dev/hyperv/vmbus.c:1.10 --- src/sys/dev/hyperv/vmbus.c:1.9 Mon May 25 10:14:58 2020 +++ src/sys/dev/hyperv/vmbus.c Tue May 26 16:00:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vmbus.c,v 1.9 2020/05/25 10:14:58 nonaka Exp $ */ +/* $NetBSD: vmbus.c,v 1.10 2020/05/26 16:00:06 nonaka Exp $ */ /* $OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.9 2020/05/25 10:14:58 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.10 2020/05/26 16:00:06 nonaka Exp $"); #include #include @@ -76,9 +76,6 @@ static int vmbus_cmd(struct vmbus_softc int); static int vmbus_start(struct vmbus_softc *, struct vmbus_msg *, paddr_t); static int vmbus_reply(struct vmbus_softc *, struct vmbus_msg *); -static void vmbus_wait(struct vmbus_softc *, - int (*done)(struct vmbus_softc *, struct vmbus_msg *), - struct vmbus_msg *, void *, const char *); static uint16_t vmbus_intr_signal(struct vmbus_softc *, paddr_t); static void vmbus_event_proc(void *, struct cpu_info *); static void vmbus_event_proc_compat(void *, struct cpu_info *); @@ -642,36 +639,26 @@ vmbus_reply_done(struct vmbus_softc *sc, static int vmbus_reply(struct vmbus_softc *sc, struct vmbus_msg *msg) { + int s; if (msg->msg_flags & MSGF_NOQUEUE) return 0; - vmbus_wait(sc, vmbus_reply_done, msg, msg, "hvreply"); - - mutex_enter(>sc_rsp_lock); - TAILQ_REMOVE(>sc_rsps, msg, msg_entry); - mutex_exit(>sc_rsp_lock); - - return 0; -} - -static void -vmbus_wait(struct vmbus_softc *sc, -int (*cond)(struct vmbus_softc *, struct vmbus_msg *), -struct vmbus_msg *msg, void *wchan, const char *wmsg) -{ - int s; - - while (!cond(sc, msg)) { + while (!vmbus_reply_done(sc, msg)) { if (msg->msg_flags & MSGF_NOSLEEP) { delay(1000); s = splnet(); hyperv_intr(); splx(s); } else - tsleep(wchan, PRIBIO, wmsg ? wmsg : "hvwait", - mstohz(1)); + tsleep(msg, PRIBIO, "hvreply", 1); } + + mutex_enter(>sc_rsp_lock); + TAILQ_REMOVE(>sc_rsps, msg, msg_entry); + mutex_exit(>sc_rsp_lock); + + return 0; } static uint16_t @@ -914,13 +901,6 @@ hyperv_guid_sprint(struct hyperv_guid *g } static int -vmbus_channel_scan_done(struct vmbus_softc *sc, struct vmbus_msg *msg __unused) -{ - - return ISSET(sc->sc_flags, VMBUS_SCFLAG_OFFERS_DELIVERED); -} - -static int vmbus_channel_scan(struct vmbus_softc *sc) { struct vmbus_chanmsg_hdr hdr; @@ -949,8 +929,8 @@ vmbus_channel_scan(struct vmbus_softc *s return -1; } - vmbus_wait(sc, vmbus_channel_scan_done, (struct vmbus_msg *), - >sc_devq, "hvscan"); + while (!ISSET(sc->sc_flags, VMBUS_SCFLAG_OFFERS_DELIVERED)) + tsleep(>sc_devq, PRIBIO, "hvscan", 1); mutex_enter(>sc_devq_lock); vmbus_process_devq(sc);
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Tue May 26 16:00:06 UTC 2020 Modified Files: src/sys/dev/hyperv: vmbus.c Log Message: vmbus(4): Fixed incorrect use of vmbus_wait() in vmbus_channel_scan(). Found by kUBSan. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Mon May 25 10:14:58 UTC 2020 Modified Files: src/sys/dev/hyperv: hvs.c vmbus.c Log Message: Use howmany() macro. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hvs.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Mon May 25 10:14:58 UTC 2020 Modified Files: src/sys/dev/hyperv: hvs.c vmbus.c Log Message: Use howmany() macro. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hvs.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/hvs.c diff -u src/sys/dev/hyperv/hvs.c:1.3 src/sys/dev/hyperv/hvs.c:1.4 --- src/sys/dev/hyperv/hvs.c:1.3 Mon Nov 25 08:53:39 2019 +++ src/sys/dev/hyperv/hvs.c Mon May 25 10:14:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hvs.c,v 1.3 2019/11/25 08:53:39 nonaka Exp $ */ +/* $NetBSD: hvs.c,v 1.4 2020/05/25 10:14:58 nonaka Exp $ */ /* $OpenBSD: hvs.c,v 1.17 2017/08/10 17:22:48 mikeb Exp $ */ /*- @@ -37,7 +37,7 @@ /* #define HVS_DEBUG_IO */ #include -__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.3 2019/11/25 08:53:39 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.4 2020/05/25 10:14:58 nonaka Exp $"); #include #include @@ -180,7 +180,7 @@ union hvs_cmd { #define HVS_RING_SIZE (20 * PAGE_SIZE) #define HVS_MAX_CCB 128 -#define HVS_MAX_SGE (MAXPHYS / PAGE_SIZE + 1) +#define HVS_MAX_SGE (howmany(MAXPHYS, PAGE_SIZE) + 1) struct hvs_softc; Index: src/sys/dev/hyperv/vmbus.c diff -u src/sys/dev/hyperv/vmbus.c:1.8 src/sys/dev/hyperv/vmbus.c:1.9 --- src/sys/dev/hyperv/vmbus.c:1.8 Tue Dec 10 12:20:20 2019 +++ src/sys/dev/hyperv/vmbus.c Mon May 25 10:14:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vmbus.c,v 1.8 2019/12/10 12:20:20 nonaka Exp $ */ +/* $NetBSD: vmbus.c,v 1.9 2020/05/25 10:14:58 nonaka Exp $ */ /* $OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.8 2019/12/10 12:20:20 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.9 2020/05/25 10:14:58 nonaka Exp $"); #include #include @@ -1911,7 +1911,7 @@ vmbus_handle_alloc(struct vmbus_channel /* Allocate additional gpadl_body structures if required */ if (left > 0) { - ncmds = MAX(1, left / VMBUS_NPFNBODY + left % VMBUS_NPFNBODY); + ncmds = howmany(left, VMBUS_NPFNBODY); bodylen = ncmds * VMBUS_MSG_DSIZE_MAX; body = kmem_zalloc(bodylen, kmemflags); if (body == NULL) {
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Sun May 24 10:32:00 UTC 2020 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Prevent from occur panic when acquiring the media status. hvn(4) sleeps during hvn_media_status(), and thus requires an adaptive mutex for the media lock. Taken from recent iwm(4) change. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.17 src/sys/dev/hyperv/if_hvn.c:1.18 --- src/sys/dev/hyperv/if_hvn.c:1.17 Tue Feb 4 05:25:38 2020 +++ src/sys/dev/hyperv/if_hvn.c Sun May 24 10:31:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.17 2020/02/04 05:25:38 thorpej Exp $ */ +/* $NetBSD: if_hvn.c,v 1.18 2020/05/24 10:31:59 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.17 2020/02/04 05:25:38 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.18 2020/05/24 10:31:59 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -133,6 +133,7 @@ struct hvn_softc { struct ethercom sc_ec; struct ifmedia sc_media; + kmutex_t sc_media_lock; /* XXX */ struct if_percpuq *sc_ipq; intsc_link_state; intsc_promisc; @@ -294,8 +295,10 @@ hvn_attach(device_t parent, device_t sel /* Initialize ifmedia structures. */ sc->sc_ec.ec_ifmedia = >sc_media; - ifmedia_init(>sc_media, IFM_IMASK, hvn_media_change, - hvn_media_status); + /* XXX media locking needs revisiting */ + mutex_init(>sc_media_lock, MUTEX_DEFAULT, IPL_SOFTNET); + ifmedia_init_with_lock(>sc_media, IFM_IMASK, + hvn_media_change, hvn_media_status, >sc_media_lock); ifmedia_add(>sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL); ifmedia_set(>sc_media, IFM_ETHER | IFM_MANUAL); @@ -341,7 +344,9 @@ hvn_attach(device_t parent, device_t sel fail4: hvn_rndis_detach(sc); if_percpuq_destroy(sc->sc_ipq); -fail3: hvn_tx_ring_destroy(sc); +fail3: ifmedia_fini(>sc_media); + mutex_destroy(>sc_media_lock); + hvn_tx_ring_destroy(sc); fail2: hvn_rx_ring_destroy(sc); fail1: hvn_nvs_detach(sc); } @@ -363,6 +368,7 @@ hvn_detach(device_t self, int flags) ether_ifdetach(ifp); if_detach(ifp); ifmedia_fini(>sc_media); + mutex_destroy(>sc_media_lock); if_percpuq_destroy(sc->sc_ipq); hvn_rndis_detach(sc);
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Sun May 24 10:32:00 UTC 2020 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Prevent from occur panic when acquiring the media status. hvn(4) sleeps during hvn_media_status(), and thus requires an adaptive mutex for the media lock. Taken from recent iwm(4) change. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: nonaka Date: Sun May 17 11:54:40 UTC 2020 Modified Files: src/sys/arch/x86/x86: hyperv.c Log Message: Fixed a problem that caused a page fault when attaching vmbus(4). Dynamically allocate a page of memory with uvm_km_alloc(kernel_map, ...) for Hyper-V hypercall. However, this method can no longer be used to make an executable page. So we prevent it by using statically allocated memory for text segment. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/x86/hyperv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/hyperv.c diff -u src/sys/arch/x86/x86/hyperv.c:1.8 src/sys/arch/x86/x86/hyperv.c:1.9 --- src/sys/arch/x86/x86/hyperv.c:1.8 Sat Apr 25 15:26:18 2020 +++ src/sys/arch/x86/x86/hyperv.c Sun May 17 11:54:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hyperv.c,v 1.8 2020/04/25 15:26:18 bouyer Exp $ */ +/* $NetBSD: hyperv.c,v 1.9 2020/05/17 11:54:39 nonaka Exp $ */ /*- * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. @@ -33,7 +33,7 @@ */ #include #ifdef __KERNEL_RCSID -__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.8 2020/04/25 15:26:18 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.9 2020/05/17 11:54:39 nonaka Exp $"); #endif #ifdef __FBSDID __FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hyperv.c 331757 2018-03-30 02:25:12Z emaste $"); @@ -97,6 +97,9 @@ struct hyperv_hypercall_ctx { static struct hyperv_hypercall_ctx hyperv_hypercall_ctx; +static char hyperv_hypercall_page[PAGE_SIZE] +__section(".text") __aligned(PAGE_SIZE) = { 0xcc }; + static u_int hyperv_get_timecount(struct timecounter *); static u_int hyperv_ver_major; @@ -703,11 +706,7 @@ static void hyperv_hypercall_memfree(void) { - if (hyperv_hypercall_ctx.hc_addr != NULL) { - uvm_km_free(kernel_map, (vaddr_t)hyperv_hypercall_ctx.hc_addr, - PAGE_SIZE, UVM_KMF_WIRED); - hyperv_hypercall_ctx.hc_addr = NULL; - } + hyperv_hypercall_ctx.hc_addr = NULL; } static bool @@ -715,30 +714,9 @@ hyperv_init_hypercall(void) { uint64_t hc, hc_orig; - hyperv_hypercall_ctx.hc_addr = (void *)uvm_km_alloc(kernel_map, - PAGE_SIZE, PAGE_SIZE, - UVM_KMF_WIRED | UVM_KMF_EXEC | (cold ? UVM_KMF_NOWAIT : 0)); - if (hyperv_hypercall_ctx.hc_addr == NULL) { - aprint_error("Hyper-V: Hypercall page allocation failed\n"); - return false; - } - - memset(hyperv_hypercall_ctx.hc_addr, 0xcc, PAGE_SIZE); - wbinvd(); - x86_flush(); - - /* The hypercall page must be both readable and executable */ - uvm_km_protect(kernel_map, (vaddr_t)hyperv_hypercall_ctx.hc_addr, - PAGE_SIZE, VM_PROT_READ | VM_PROT_EXECUTE); - - if (!pmap_extract(pmap_kernel(), (vaddr_t)hyperv_hypercall_ctx.hc_addr, - _hypercall_ctx.hc_paddr)) { - aprint_error("Hyper-V: Hypercall page setup failed\n"); - hyperv_hypercall_memfree(); - /* Can't perform any Hyper-V specific actions */ - vm_guest = VM_GUEST_VM; - return false; - } + hyperv_hypercall_ctx.hc_addr = hyperv_hypercall_page; + hyperv_hypercall_ctx.hc_paddr = vtophys((vaddr_t)hyperv_hypercall_page); + KASSERT(hyperv_hypercall_ctx.hc_paddr != 0); /* Get the 'reserved' bits, which requires preservation. */ hc_orig = rdmsr(MSR_HV_HYPERCALL);
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: nonaka Date: Sun May 17 11:54:40 UTC 2020 Modified Files: src/sys/arch/x86/x86: hyperv.c Log Message: Fixed a problem that caused a page fault when attaching vmbus(4). Dynamically allocate a page of memory with uvm_km_alloc(kernel_map, ...) for Hyper-V hypercall. However, this method can no longer be used to make an executable page. So we prevent it by using statically allocated memory for text segment. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/x86/hyperv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Sat Jan 18 19:25:58 UTC 2020 Modified Files: src/sys/arch/i386/stand/efiboot: devopen.c Log Message: x86 efiboot: Fixed the problem that /EFI/NetBSD/boot.cfg could not be loaded. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/devopen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/devopen.c diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.10 src/sys/arch/i386/stand/efiboot/devopen.c:1.11 --- src/sys/arch/i386/stand/efiboot/devopen.c:1.10 Sat Jan 18 19:20:23 2020 +++ src/sys/arch/i386/stand/efiboot/devopen.c Sat Jan 18 19:25:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: devopen.c,v 1.10 2020/01/18 19:20:23 nonaka Exp $ */ +/* $NetBSD: devopen.c,v 1.11 2020/01/18 19:25:58 nonaka Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -100,7 +100,7 @@ bios2dev(int biosdev, daddr_t sector, ch *devname = "hd"; (void)biosdisk_findpartition(biosdev, sector, partition, part_name); - if (*part_name != NULL) { + if (part_name != NULL && *part_name != NULL) { snprintf(savedevname, sizeof(savedevname), "NAME=%s", *part_name); *devname = savedevname;
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Sat Jan 18 19:25:58 UTC 2020 Modified Files: src/sys/arch/i386/stand/efiboot: devopen.c Log Message: x86 efiboot: Fixed the problem that /EFI/NetBSD/boot.cfg could not be loaded. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/devopen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Sat Jan 18 19:20:23 UTC 2020 Modified Files: src/sys/arch/i386/stand/efiboot: devopen.c Log Message: fix indent. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/devopen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Sat Jan 18 19:20:23 UTC 2020 Modified Files: src/sys/arch/i386/stand/efiboot: devopen.c Log Message: fix indent. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/devopen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/devopen.c diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.9 src/sys/arch/i386/stand/efiboot/devopen.c:1.10 --- src/sys/arch/i386/stand/efiboot/devopen.c:1.9 Tue Dec 10 02:02:47 2019 +++ src/sys/arch/i386/stand/efiboot/devopen.c Sat Jan 18 19:20:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: devopen.c,v 1.9 2019/12/10 02:02:47 manu Exp $ */ +/* $NetBSD: devopen.c,v 1.10 2020/01/18 19:20:23 nonaka Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -103,7 +103,7 @@ bios2dev(int biosdev, daddr_t sector, ch if (*part_name != NULL) { snprintf(savedevname, sizeof(savedevname), "NAME=%s", *part_name); - *devname = savedevname; + *devname = savedevname; } }
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Wed Jan 8 04:53:38 UTC 2020 Modified Files: src/sys/dev/ic: rndisreg.h Log Message: Added some RNDIS status definitions from FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/rndisreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Wed Jan 8 04:53:38 UTC 2020 Modified Files: src/sys/dev/ic: rndisreg.h Log Message: Added some RNDIS status definitions from FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/rndisreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/rndisreg.h diff -u src/sys/dev/ic/rndisreg.h:1.4 src/sys/dev/ic/rndisreg.h:1.5 --- src/sys/dev/ic/rndisreg.h:1.4 Fri Dec 6 12:41:17 2019 +++ src/sys/dev/ic/rndisreg.h Wed Jan 8 04:53:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rndisreg.h,v 1.4 2019/12/06 12:41:17 nonaka Exp $ */ +/* $NetBSD: rndisreg.h,v 1.5 2020/01/08 04:53:38 nonaka Exp $ */ /* NetBSD: if_urndisreg.h,v 1.4 2018/11/09 21:57:09 maya Exp */ /* $OpenBSD: if_urndisreg.h,v 1.14 2010/07/08 18:22:01 ckuethe Exp $ */ @@ -32,6 +32,8 @@ #define RNDIS_STATUS_PENDING 0x0103L #define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BL #define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CL +#define RNDIS_STATUS_LINK_SPEED_CHANGE 0x40010013L +#define RNDIS_STATUS_NETWORK_CHANGE 0x40010018L #define RNDIS_STATUS_OFFLOAD_CURRENT_CONFIG 0x40020006 #define RNDIS_STATUS_BUFFER_OVERFLOW 0x8005L #define RNDIS_STATUS_FAILURE 0xC001L
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Dec 27 05:59:53 UTC 2019 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Handle CFI field of VLAN. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Dec 27 05:59:53 UTC 2019 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Handle CFI field of VLAN. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.14 src/sys/dev/hyperv/if_hvn.c:1.15 --- src/sys/dev/hyperv/if_hvn.c:1.14 Fri Dec 27 05:56:42 2019 +++ src/sys/dev/hyperv/if_hvn.c Fri Dec 27 05:59:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.14 2019/12/27 05:56:42 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.15 2019/12/27 05:59:53 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.14 2019/12/27 05:56:42 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.15 2019/12/27 05:59:53 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -67,6 +67,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1 #ifndef EVL_PRIO_BITS #define EVL_PRIO_BITS 13 #endif +#ifndef EVL_CFI_BITS +#define EVL_CFI_BITS 12 +#endif #define HVN_NVS_MSGSIZE 32 #define HVN_NVS_BUFSIZE PAGE_SIZE @@ -584,7 +587,7 @@ hvn_encap(struct hvn_softc *sc, struct m tag = vlan_get_tag(m); vlan = NDIS_VLAN_INFO_MAKE(EVL_VLANOFTAG(tag), - EVL_PRIOFTAG(tag), 0); + EVL_PRIOFTAG(tag), EVL_CFIOFTAG(tag)); cp = hvn_rndis_pktinfo_append(pkt, HVN_RNDIS_PKT_LEN, NDIS_VLAN_INFO_SIZE, NDIS_PKTINFO_TYPE_VLAN); memcpy(cp, , NDIS_VLAN_INFO_SIZE); @@ -1593,6 +1596,7 @@ hvn_rxeof(struct hvn_softc *sc, uint8_t if (vlan != 0x) { uint16_t t = NDIS_VLAN_INFO_ID(vlan); t |= NDIS_VLAN_INFO_PRI(vlan) << EVL_PRIO_BITS; +t |= NDIS_VLAN_INFO_CFI(vlan) << EVL_CFI_BITS; vlan_set_tag(m, t); } break;
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Dec 27 05:56:42 UTC 2019 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Use vlan_{get,set,has}_tag(). To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.13 src/sys/dev/hyperv/if_hvn.c:1.14 --- src/sys/dev/hyperv/if_hvn.c:1.13 Tue Dec 10 12:20:20 2019 +++ src/sys/dev/hyperv/if_hvn.c Fri Dec 27 05:56:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.13 2019/12/10 12:20:20 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.14 2019/12/27 05:56:42 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.13 2019/12/10 12:20:20 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.14 2019/12/27 05:56:42 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -577,13 +577,14 @@ hvn_encap(struct hvn_softc *sc, struct m } txd->txd_buf = m; - if (m->m_flags & M_VLANTAG) { + if (vlan_has_tag(m)) { uint32_t vlan; char *cp; + uint16_t tag; - vlan = NDIS_VLAN_INFO_MAKE( - EVL_VLANOFTAG(m->m_pkthdr.ether_vtag), - EVL_PRIOFTAG(m->m_pkthdr.ether_vtag), 0); + tag = vlan_get_tag(m); + vlan = NDIS_VLAN_INFO_MAKE(EVL_VLANOFTAG(tag), + EVL_PRIOFTAG(tag), 0); cp = hvn_rndis_pktinfo_append(pkt, HVN_RNDIS_PKT_LEN, NDIS_VLAN_INFO_SIZE, NDIS_PKTINFO_TYPE_VLAN); memcpy(cp, , NDIS_VLAN_INFO_SIZE); @@ -1590,10 +1591,9 @@ hvn_rxeof(struct hvn_softc *sc, uint8_t case NDIS_PKTINFO_TYPE_VLAN: memcpy(, pi->rm_data, sizeof(vlan)); if (vlan != 0x) { -m->m_pkthdr.ether_vtag = -NDIS_VLAN_INFO_ID(vlan) | -(NDIS_VLAN_INFO_PRI(vlan) << EVL_PRIO_BITS); -m->m_flags |= M_VLANTAG; +uint16_t t = NDIS_VLAN_INFO_ID(vlan); +t |= NDIS_VLAN_INFO_PRI(vlan) << EVL_PRIO_BITS; +vlan_set_tag(m, t); } break; default:
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Dec 27 05:56:42 UTC 2019 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Use vlan_{get,set,has}_tag(). To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Tue Dec 10 12:20:20 UTC 2019 Modified Files: src/sys/dev/hyperv: hyperv_common.c hypervvar.h if_hvn.c vmbus.c vmbusvar.h Log Message: hvn(4) can be added and deleted dynamically. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hyperv/hyperv_common.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hypervvar.h \ src/sys/dev/hyperv/vmbusvar.h cvs rdiff -u -r1.12 -r1.13 src/sys/dev/hyperv/if_hvn.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/hyperv_common.c diff -u src/sys/dev/hyperv/hyperv_common.c:1.4 src/sys/dev/hyperv/hyperv_common.c:1.5 --- src/sys/dev/hyperv/hyperv_common.c:1.4 Sat Dec 7 11:45:45 2019 +++ src/sys/dev/hyperv/hyperv_common.c Tue Dec 10 12:20:20 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hyperv_common.c,v 1.4 2019/12/07 11:45:45 nonaka Exp $ */ +/* $NetBSD: hyperv_common.c,v 1.5 2019/12/10 12:20:20 nonaka Exp $ */ /*- * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.4 2019/12/07 11:45:45 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.5 2019/12/10 12:20:20 nonaka Exp $"); #include "hyperv.h" @@ -111,17 +111,18 @@ hyperv_guid2str(const struct hyperv_guid */ void * hyperv_dma_alloc(bus_dma_tag_t dmat, struct hyperv_dma *dma, bus_size_t size, -bus_size_t alignment, bus_size_t boundary, int nsegs) +bus_size_t alignment, bus_size_t boundary, int nsegs, int flags) { - const int kmemflags = cold ? KM_NOSLEEP : KM_SLEEP; - const int dmaflags = cold ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK; + const int waitok = (flags & HYPERV_DMA_NOSLEEP) != HYPERV_DMA_NOSLEEP; + const int kmemflags = waitok ? KM_SLEEP: KM_NOSLEEP; + const int dmaflags = waitok ? BUS_DMA_WAITOK : BUS_DMA_NOWAIT; int rseg, error; KASSERT(dma != NULL); KASSERT(dma->segs == NULL); KASSERT(nsegs > 0); - dma->segs = kmem_zalloc(sizeof(*dma->segs) * nsegs, kmemflags); + dma->segs = kmem_intr_zalloc(sizeof(*dma->segs) * nsegs, kmemflags); if (dma->segs == NULL) return NULL; Index: src/sys/dev/hyperv/hypervvar.h diff -u src/sys/dev/hyperv/hypervvar.h:1.3 src/sys/dev/hyperv/hypervvar.h:1.4 --- src/sys/dev/hyperv/hypervvar.h:1.3 Sat Dec 7 11:45:45 2019 +++ src/sys/dev/hyperv/hypervvar.h Tue Dec 10 12:20:20 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervvar.h,v 1.3 2019/12/07 11:45:45 nonaka Exp $ */ +/* $NetBSD: hypervvar.h,v 1.4 2019/12/10 12:20:20 nonaka Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -108,8 +108,10 @@ hyperv_dma_get_paddr(struct hyperv_dma * return dma->map->dm_segs[0].ds_addr; } +#define HYPERV_DMA_SLEEPOK 0 +#define HYPERV_DMA_NOSLEEP __BIT(0) void *hyperv_dma_alloc(bus_dma_tag_t, struct hyperv_dma *, bus_size_t, -bus_size_t, bus_size_t, int); +bus_size_t, bus_size_t, int, int); void hyperv_dma_free(bus_dma_tag_t, struct hyperv_dma *); #endif /* _KERNEL */ Index: src/sys/dev/hyperv/vmbusvar.h diff -u src/sys/dev/hyperv/vmbusvar.h:1.3 src/sys/dev/hyperv/vmbusvar.h:1.4 --- src/sys/dev/hyperv/vmbusvar.h:1.3 Sat Dec 7 11:45:45 2019 +++ src/sys/dev/hyperv/vmbusvar.h Tue Dec 10 12:20:20 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: vmbusvar.h,v 1.3 2019/12/07 11:45:45 nonaka Exp $ */ +/* $NetBSD: vmbusvar.h,v 1.4 2019/12/10 12:20:20 nonaka Exp $ */ /* $OpenBSD: hypervvar.h,v 1.13 2017/06/23 19:05:42 mikeb Exp $ */ /* @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,7 @@ typedef void (*vmbus_channel_callback_t)(void *); struct vmbus_softc; +struct vmbus_channel; struct vmbus_msg { uint64_t msg_flags; @@ -57,11 +59,14 @@ struct vmbus_msg { __CTASSERT((offsetof(struct vmbus_msg, msg_req) % 8) == 0); TAILQ_HEAD(vmbus_queue, vmbus_msg); -struct vmbus_offer { - struct vmbus_chanmsg_choffer co_chan; - SIMPLEQ_ENTRY(vmbus_offer) co_entry; +struct vmbus_dev { + int vd_type; +#define VMBUS_DEV_TYPE_ATTACH 0 +#define VMBUS_DEV_TYPE_DETACH 1 + struct vmbus_channel *vd_chan; + SIMPLEQ_ENTRY(vmbus_dev) vd_entry; }; -SIMPLEQ_HEAD(vmbus_offers, vmbus_offer); +SIMPLEQ_HEAD(vmbus_devq, vmbus_dev); struct vmbus_ring_data { struct vmbus_bufring *rd_ring; @@ -72,7 +77,6 @@ struct vmbus_ring_data { uint32_t rd_dsize; }; -struct vmbus_channel; TAILQ_HEAD(vmbus_channels, vmbus_channel); struct vmbus_channel { @@ -111,6 +115,7 @@ struct vmbus_channel { uint32_t ch_flags; #define CHF_BATCHED __BIT(0) #define CHF_MONITOR __BIT(1) +#define CHF_REVOKED __BIT(2) uint8_tch_mgroup; uint8_tch_mindex; @@ -137,12 +142,6 @@ struct vmbus_attach_args { bus_space_tag_t aa_memt; }; -struct vmbus_dev { - struct vmbus_attach_args dv_aa; - SLIST_ENTRY(vmbus_dev) dv_entry; -}; -SLIST_HEAD(vmbus_devices,
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Tue Dec 10 12:20:20 UTC 2019 Modified Files: src/sys/dev/hyperv: hyperv_common.c hypervvar.h if_hvn.c vmbus.c vmbusvar.h Log Message: hvn(4) can be added and deleted dynamically. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hyperv/hyperv_common.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hypervvar.h \ src/sys/dev/hyperv/vmbusvar.h cvs rdiff -u -r1.12 -r1.13 src/sys/dev/hyperv/if_hvn.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Tue Dec 10 11:19:25 UTC 2019 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Handle VMBUS_CHANPKT_TYPE_INBAND packet type. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Tue Dec 10 11:19:25 UTC 2019 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Handle VMBUS_CHANPKT_TYPE_INBAND packet type. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.11 src/sys/dev/hyperv/if_hvn.c:1.12 --- src/sys/dev/hyperv/if_hvn.c:1.11 Tue Nov 26 01:46:31 2019 +++ src/sys/dev/hyperv/if_hvn.c Tue Dec 10 11:19:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.11 2019/11/26 01:46:31 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.12 2019/12/10 11:19:25 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.11 2019/11/26 01:46:31 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.12 2019/12/10 11:19:25 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1040,6 +1040,16 @@ hvn_nvs_intr(void *arg) "on receive\n", nvs->nvs_type); break; } + } else if (cph->cph_type == VMBUS_CHANPKT_TYPE_INBAND) { + switch (nvs->nvs_type) { + case HVN_NVS_TYPE_TXTBL_NOTE: +/* Useless; ignore */ +break; + default: +device_printf(sc->sc_dev, +"got notify, nvs type %u\n", nvs->nvs_type); +break; + } } else device_printf(sc->sc_dev, "unknown NVSP packet type %u\n", cph->cph_type);
CVS commit: src/sys
Module Name:src Committed By: nonaka Date: Sat Dec 7 11:45:45 UTC 2019 Modified Files: src/sys/arch/x86/x86: cpu.c hyperv.c hypervvar.h src/sys/dev/hyperv: hyperv_common.c hypervvar.h vmbus.c vmbusvar.h Log Message: Get a Hyper-V virtual processor id in cpu_hatch(). Currently, it is got in config_interrupts context. However, since it is required when attaching a device, it is got earlier than now. To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/sys/arch/x86/x86/cpu.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/x86/hyperv.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/x86/hypervvar.h cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hyperv_common.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hyperv/hypervvar.h \ src/sys/dev/hyperv/vmbusvar.h cvs rdiff -u -r1.6 -r1.7 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/cpu.c diff -u src/sys/arch/x86/x86/cpu.c:1.177 src/sys/arch/x86/x86/cpu.c:1.178 --- src/sys/arch/x86/x86/cpu.c:1.177 Wed Nov 27 06:24:33 2019 +++ src/sys/arch/x86/x86/cpu.c Sat Dec 7 11:45:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.177 2019/11/27 06:24:33 maxv Exp $ */ +/* $NetBSD: cpu.c,v 1.178 2019/12/07 11:45:45 nonaka Exp $ */ /* * Copyright (c) 2000-2012 NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.177 2019/11/27 06:24:33 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.178 2019/12/07 11:45:45 nonaka Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -118,6 +118,13 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.17 #include "tsc.h" +#ifndef XEN +#include "hyperv.h" +#if NHYPERV > 0 +#include +#endif +#endif + static int cpu_match(device_t, cfdata_t, void *); static void cpu_attach(device_t, device_t, void *); static void cpu_defer(device_t); @@ -863,6 +870,9 @@ cpu_hatch(void *v) cpu_init_msrs(ci, true); cpu_probe(ci); cpu_speculation_init(ci); +#if NHYPERV > 0 + hyperv_init_cpu(ci); +#endif ci->ci_data.cpu_cc_freq = cpu_info_primary.ci_data.cpu_cc_freq; /* cpu_get_tsc_freq(ci); */ Index: src/sys/arch/x86/x86/hyperv.c diff -u src/sys/arch/x86/x86/hyperv.c:1.5 src/sys/arch/x86/x86/hyperv.c:1.6 --- src/sys/arch/x86/x86/hyperv.c:1.5 Sat Nov 30 05:28:28 2019 +++ src/sys/arch/x86/x86/hyperv.c Sat Dec 7 11:45:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hyperv.c,v 1.5 2019/11/30 05:28:28 nonaka Exp $ */ +/* $NetBSD: hyperv.c,v 1.6 2019/12/07 11:45:45 nonaka Exp $ */ /*- * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. @@ -33,7 +33,7 @@ */ #include #ifdef __KERNEL_RCSID -__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.5 2019/11/30 05:28:28 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.6 2019/12/07 11:45:45 nonaka Exp $"); #endif #ifdef __FBSDID __FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hyperv.c 331757 2018-03-30 02:25:12Z emaste $"); @@ -113,6 +113,8 @@ static char hyperv_features3_str[256]; static int hyperv_idtvec; +uint32_t hyperv_vcpuid[MAXCPUS]; + static struct timecounter hyperv_timecounter = { .tc_get_timecount = hyperv_get_timecount, .tc_counter_mask = 0x, @@ -495,12 +497,45 @@ hyperv_early_init(void) { u_int features, pm_features, features3; u_int maxleaf; + int i; if (!hyperv_probe(, , _features, )) return; if (features & CPUID_HV_MSR_TIME_REFCNT) x86_delay = delay_func = delay_msr; + + if (features & CPUID_HV_MSR_VP_INDEX) { + /* Save virtual processor id. */ + hyperv_vcpuid[0] = rdmsr(MSR_HV_VP_INDEX); + } else { + /* Set virtual processor id to 0 for compatibility. */ + hyperv_vcpuid[0] = 0; + } + for (i = 1; i < MAXCPUS; i++) + hyperv_vcpuid[i] = hyperv_vcpuid[0]; +} + +void +hyperv_init_cpu(struct cpu_info *ci) +{ + u_int features, pm_features, features3; + u_int maxleaf; + + if (!hyperv_probe(, , _features, )) + return; + + if (features & CPUID_HV_MSR_VP_INDEX) + hyperv_vcpuid[ci->ci_index] = rdmsr(MSR_HV_VP_INDEX); +} + +uint32_t +hyperv_get_vcpuid(cpuid_t cpu) +{ + + if (cpu < MAXCPUS) + return hyperv_vcpuid[cpu]; + return 0; } static bool @@ -798,14 +833,6 @@ vmbus_init_synic_md(struct vmbus_softc * pd = >sc_percpu[cpu]; - if (hyperv_features & CPUID_HV_MSR_VP_INDEX) { - /* Save virtual processor id. */ - pd->vcpuid = rdmsr(MSR_HV_VP_INDEX); - } else { - /* Set virtual processor id to 0 for compatibility. */ - pd->vcpuid = 0; - } - /* * Setup the SynIC message. */ Index: src/sys/arch/x86/x86/hypervvar.h diff -u src/sys/arch/x86/x86/hypervvar.h:1.1 src/sys/arch/x86/x86/hypervvar.h:1.2 --- src/sys/arch/x86/x86/hypervvar.h:1.1 Fri May 24 14:28:48 2019 +++ src/sys/arch/x86/x86/hypervvar.h Sat Dec 7 11:45:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervvar.h,v 1.1 2019/05/24 14:28:48 nonaka Exp $ */ +/* $NetBSD: hypervvar.h,v 1.2 2019/12/07 11:45:45 nonaka Exp $ */ /*- * Copyright (c) 2009-2012,2016 Microsoft
CVS commit: src/sys
Module Name:src Committed By: nonaka Date: Sat Dec 7 11:45:45 UTC 2019 Modified Files: src/sys/arch/x86/x86: cpu.c hyperv.c hypervvar.h src/sys/dev/hyperv: hyperv_common.c hypervvar.h vmbus.c vmbusvar.h Log Message: Get a Hyper-V virtual processor id in cpu_hatch(). Currently, it is got in config_interrupts context. However, since it is required when attaching a device, it is got earlier than now. To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/sys/arch/x86/x86/cpu.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/x86/hyperv.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/x86/hypervvar.h cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hyperv_common.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hyperv/hypervvar.h \ src/sys/dev/hyperv/vmbusvar.h cvs rdiff -u -r1.6 -r1.7 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Dec 6 12:46:06 UTC 2019 Modified Files: src/sys/dev/hyperv: hyperv_common.c vmbus.c Log Message: Clear the allocated memory in hyperv_dma_alloc(). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hyperv/hyperv_common.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/hyperv_common.c diff -u src/sys/dev/hyperv/hyperv_common.c:1.2 src/sys/dev/hyperv/hyperv_common.c:1.3 --- src/sys/dev/hyperv/hyperv_common.c:1.2 Fri May 31 04:23:19 2019 +++ src/sys/dev/hyperv/hyperv_common.c Fri Dec 6 12:46:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hyperv_common.c,v 1.2 2019/05/31 04:23:19 nonaka Exp $ */ +/* $NetBSD: hyperv_common.c,v 1.3 2019/12/06 12:46:06 nonaka Exp $ */ /*- * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.2 2019/05/31 04:23:19 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.3 2019/12/06 12:46:06 nonaka Exp $"); #include "hyperv.h" @@ -155,6 +155,10 @@ hyperv_dma_alloc(bus_dma_tag_t dmat, str goto fail4; } + memset(dma->addr, 0, dma->map->dm_mapsize); + bus_dmamap_sync(dmat, dma->map, 0, dma->map->dm_mapsize, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + return dma->addr; fail4: bus_dmamap_destroy(dmat, dma->map); Index: src/sys/dev/hyperv/vmbus.c diff -u src/sys/dev/hyperv/vmbus.c:1.5 src/sys/dev/hyperv/vmbus.c:1.6 --- src/sys/dev/hyperv/vmbus.c:1.5 Fri Nov 22 12:30:32 2019 +++ src/sys/dev/hyperv/vmbus.c Fri Dec 6 12:46:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: vmbus.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $ */ +/* $NetBSD: vmbus.c,v 1.6 2019/12/06 12:46:06 nonaka Exp $ */ /* $OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.6 2019/12/06 12:46:06 nonaka Exp $"); #include #include @@ -985,7 +985,6 @@ vmbus_channel_alloc(struct vmbus_softc * kmem_free(ch, sizeof(*ch)); return NULL; } - memset(ch->ch_monprm, 0, sizeof(*ch->ch_monprm)); ch->ch_refs = 1; ch->ch_sc = sc; @@ -1264,7 +1263,6 @@ vmbus_channel_ring_create(struct vmbus_c "failed to allocate channel ring\n"); return ENOMEM; } - memset(ch->ch_ring, 0, ch->ch_ring_size); memset(>ch_wrd, 0, sizeof(ch->ch_wrd)); ch->ch_wrd.rd_ring = (struct vmbus_bufring *)ch->ch_ring;
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Dec 6 12:46:06 UTC 2019 Modified Files: src/sys/dev/hyperv: hyperv_common.c vmbus.c Log Message: Clear the allocated memory in hyperv_dma_alloc(). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hyperv/hyperv_common.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/vmbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Fri Dec 6 12:41:17 UTC 2019 Modified Files: src/sys/dev/ic: rndisreg.h Log Message: Added RNDIS RSS and TCP offload related definitions. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/rndisreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Fri Dec 6 12:41:17 UTC 2019 Modified Files: src/sys/dev/ic: rndisreg.h Log Message: Added RNDIS RSS and TCP offload related definitions. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/rndisreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/rndisreg.h diff -u src/sys/dev/ic/rndisreg.h:1.3 src/sys/dev/ic/rndisreg.h:1.4 --- src/sys/dev/ic/rndisreg.h:1.3 Thu Aug 8 06:16:39 2019 +++ src/sys/dev/ic/rndisreg.h Fri Dec 6 12:41:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rndisreg.h,v 1.3 2019/08/08 06:16:39 maya Exp $ */ +/* $NetBSD: rndisreg.h,v 1.4 2019/12/06 12:41:17 nonaka Exp $ */ /* NetBSD: if_urndisreg.h,v 1.4 2018/11/09 21:57:09 maya Exp */ /* $OpenBSD: if_urndisreg.h,v 1.14 2010/07/08 18:22:01 ckuethe Exp $ */ @@ -64,6 +64,8 @@ #define OID_GEN_SUPPORTED_GUIDS 0x00010117 #define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118 #define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119 +#define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203 +#define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204 #define OID_GEN_MACHINE_NAME 0x0001021A #define OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B #define OID_GEN_VLAN_ID 0x0001021C @@ -85,6 +87,7 @@ #define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C +#define OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020D #define RNDIS_MEDIUM_802_3 0x
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Fri Dec 6 12:39:51 UTC 2019 Modified Files: src/sys/dev/ic: ndisreg.h Log Message: Added NDIS ver.6.20 definition. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/ndisreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/ndisreg.h diff -u src/sys/dev/ic/ndisreg.h:1.1 src/sys/dev/ic/ndisreg.h:1.2 --- src/sys/dev/ic/ndisreg.h:1.1 Fri Feb 15 08:54:02 2019 +++ src/sys/dev/ic/ndisreg.h Fri Dec 6 12:39:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ndisreg.h,v 1.1 2019/02/15 08:54:02 nonaka Exp $ */ +/* $NetBSD: ndisreg.h,v 1.2 2019/12/06 12:39:51 nonaka Exp $ */ /* $OpenBSD: ndis.h,v 1.2 2016/09/23 11:32:13 mikeb Exp $ */ /*- @@ -39,6 +39,7 @@ #define NDIS_VERSION_5_1 0x00050001 #define NDIS_VERSION_6_0 0x0006 #define NDIS_VERSION_6_1 0x00060001 +#define NDIS_VERSION_6_20 0x00060014 #define NDIS_VERSION_6_30 0x0006001e #define NDIS_MEDIA_STATE_CONNECTED 0
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Fri Dec 6 12:39:51 UTC 2019 Modified Files: src/sys/dev/ic: ndisreg.h Log Message: Added NDIS ver.6.20 definition. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/ndisreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/x86
Module Name:src Committed By: nonaka Date: Sat Nov 30 05:28:28 UTC 2019 Modified Files: src/sys/arch/x86/include: genfb_machdep.h src/sys/arch/x86/x86: genfb_machdep.c hyperv.c Log Message: Prevent panic when attaching genfb if using a serial console with Hyper-V Gen.2. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/include/genfb_machdep.h cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/x86/genfb_machdep.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/x86/hyperv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/include/genfb_machdep.h diff -u src/sys/arch/x86/include/genfb_machdep.h:1.3 src/sys/arch/x86/include/genfb_machdep.h:1.4 --- src/sys/arch/x86/include/genfb_machdep.h:1.3 Wed Feb 9 13:24:23 2011 +++ src/sys/arch/x86/include/genfb_machdep.h Sat Nov 30 05:28:28 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: genfb_machdep.h,v 1.3 2011/02/09 13:24:23 jmcneill Exp $ */ +/* $NetBSD: genfb_machdep.h,v 1.4 2019/11/30 05:28:28 nonaka Exp $ */ /*- * Copyright (c) 2009 Jared D. McNeill @@ -29,6 +29,7 @@ #ifndef _X86_GENFB_MACHDEP_H #define _X86_GENFB_MACHDEP_H +int x86_genfb_init(void); int x86_genfb_cnattach(void); void x86_genfb_mtrr_init(uint64_t, uint32_t); void x86_genfb_set_console_dev(device_t); Index: src/sys/arch/x86/x86/genfb_machdep.c diff -u src/sys/arch/x86/x86/genfb_machdep.c:1.14 src/sys/arch/x86/x86/genfb_machdep.c:1.15 --- src/sys/arch/x86/x86/genfb_machdep.c:1.14 Tue Oct 1 18:00:08 2019 +++ src/sys/arch/x86/x86/genfb_machdep.c Sat Nov 30 05:28:28 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: genfb_machdep.c,v 1.14 2019/10/01 18:00:08 chs Exp $ */ +/* $NetBSD: genfb_machdep.c,v 1.15 2019/11/30 05:28:28 nonaka Exp $ */ /*- * Copyright (c) 2009 Jared D. McNeill @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.14 2019/10/01 18:00:08 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.15 2019/11/30 05:28:28 nonaka Exp $"); #include "opt_mtrr.h" @@ -136,23 +136,19 @@ x86_genfb_mtrr_init(uint64_t physaddr, u } int -x86_genfb_cnattach(void) +x86_genfb_init(void) { - static int ncalls = 0; + static int inited, attached; struct rasops_info *ri = _genfb_console_screen.scr_ri; const struct btinfo_framebuffer *fbinfo; bus_space_tag_t t = x86_bus_space_mem; bus_space_handle_t h; void *bits; - long defattr; int err; - /* XXX jmcneill - * Defer console initialization until UVM is initialized - */ - ++ncalls; - if (ncalls < 3) - return -1; + if (inited) + return attached; + inited = 1; memset(_genfb_console_screen, 0, sizeof(x86_genfb_console_screen)); @@ -202,6 +198,27 @@ x86_genfb_cnattach(void) x86_genfb_stdscreen.textops = >ri_ops; x86_genfb_stdscreen.capabilities = ri->ri_caps; + attached = 1; + return 1; +} + +int +x86_genfb_cnattach(void) +{ + static int ncalls = 0; + struct rasops_info *ri = _genfb_console_screen.scr_ri; + long defattr; + + /* XXX jmcneill + * Defer console initialization until UVM is initialized + */ + ++ncalls; + if (ncalls < 3) + return -1; + + if (!x86_genfb_init()) + return 0; + ri->ri_ops.allocattr(ri, 0, 0, 0, ); wsdisplay_preattach(_genfb_stdscreen, ri, 0, 0, defattr); @@ -209,6 +226,12 @@ x86_genfb_cnattach(void) } #else /* NWSDISPLAY > 0 && NGENFB > 0 */ int +x86_genfb_init(void) +{ + return 0; +} + +int x86_genfb_cnattach(void) { return 0; Index: src/sys/arch/x86/x86/hyperv.c diff -u src/sys/arch/x86/x86/hyperv.c:1.4 src/sys/arch/x86/x86/hyperv.c:1.5 --- src/sys/arch/x86/x86/hyperv.c:1.4 Mon Jun 3 09:51:04 2019 +++ src/sys/arch/x86/x86/hyperv.c Sat Nov 30 05:28:28 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hyperv.c,v 1.4 2019/06/03 09:51:04 nonaka Exp $ */ +/* $NetBSD: hyperv.c,v 1.5 2019/11/30 05:28:28 nonaka Exp $ */ /*- * Copyright (c) 2009-2012,2016-2017 Microsoft Corp. @@ -33,7 +33,7 @@ */ #include #ifdef __KERNEL_RCSID -__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.4 2019/06/03 09:51:04 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.5 2019/11/30 05:28:28 nonaka Exp $"); #endif #ifdef __FBSDID __FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hyperv.c 331757 2018-03-30 02:25:12Z emaste $"); @@ -70,7 +70,7 @@ __FBSDID("$FreeBSD: head/sys/dev/hyperv/ #include #include -#include +#include #include #include @@ -1103,6 +1103,9 @@ device_hyperv_register(device_t dev, voi sizeof(*aa->aa_type)) == 0) { prop_dictionary_t dict = device_properties(dev); + /* Initialize genfb for serial console */ + x86_genfb_init(); + /* * framebuffer drivers other than genfb can work * without the address property
CVS commit: src/sys/arch/x86
Module Name:src Committed By: nonaka Date: Sat Nov 30 05:28:28 UTC 2019 Modified Files: src/sys/arch/x86/include: genfb_machdep.h src/sys/arch/x86/x86: genfb_machdep.c hyperv.c Log Message: Prevent panic when attaching genfb if using a serial console with Hyper-V Gen.2. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/include/genfb_machdep.h cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/x86/genfb_machdep.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/x86/hyperv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Tue Nov 26 01:46:32 UTC 2019 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Fix incorrect ident when waiting for NVS command response. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.10 src/sys/dev/hyperv/if_hvn.c:1.11 --- src/sys/dev/hyperv/if_hvn.c:1.10 Mon Nov 25 08:53:39 2019 +++ src/sys/dev/hyperv/if_hvn.c Tue Nov 26 01:46:31 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.10 2019/11/25 08:53:39 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.11 2019/11/26 01:46:31 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.10 2019/11/25 08:53:39 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.11 2019/11/26 01:46:31 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1091,7 +1091,8 @@ hvn_nvs_cmd(struct hvn_softc *sc, void * hvn_nvs_intr(sc); splx(s); } else - tsleep(sc, PRIBIO | PCATCH, "nvscmd", mstohz(1)); + tsleep(sc->sc_nvsrsp, PRIBIO | PCATCH, "nvscmd", + mstohz(1)); } while (--timo > 0 && sc->sc_nvsdone != 1); if (timo == 0 && sc->sc_nvsdone != 1) {
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Tue Nov 26 01:46:32 UTC 2019 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: hvn(4): Fix incorrect ident when waiting for NVS command response. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Mon Nov 25 08:53:39 UTC 2019 Modified Files: src/sys/dev/hyperv: hvs.c if_hvn.c Log Message: hvs(4), hvn(4): Set correct size for bus_dmamap_sync(9). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hyperv/hvs.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Mon Nov 25 08:53:39 UTC 2019 Modified Files: src/sys/dev/hyperv: hvs.c if_hvn.c Log Message: hvs(4), hvn(4): Set correct size for bus_dmamap_sync(9). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hyperv/hvs.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/hvs.c diff -u src/sys/dev/hyperv/hvs.c:1.2 src/sys/dev/hyperv/hvs.c:1.3 --- src/sys/dev/hyperv/hvs.c:1.2 Tue Oct 1 18:00:08 2019 +++ src/sys/dev/hyperv/hvs.c Mon Nov 25 08:53:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hvs.c,v 1.2 2019/10/01 18:00:08 chs Exp $ */ +/* $NetBSD: hvs.c,v 1.3 2019/11/25 08:53:39 nonaka Exp $ */ /* $OpenBSD: hvs.c,v 1.17 2017/08/10 17:22:48 mikeb Exp $ */ /*- @@ -37,7 +37,7 @@ /* #define HVS_DEBUG_IO */ #include -__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.2 2019/10/01 18:00:08 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.3 2019/11/25 08:53:39 nonaka Exp $"); #include #include @@ -1084,7 +1084,8 @@ hvs_free_ccbs(struct hvs_softc *sc) if (ccb->ccb_dmap == NULL) continue; - bus_dmamap_sync(sc->sc_dmat, ccb->ccb_dmap, 0, 0, + bus_dmamap_sync(sc->sc_dmat, ccb->ccb_dmap, + 0, ccb->ccb_dmap->dm_mapsize, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->sc_dmat, ccb->ccb_dmap); bus_dmamap_destroy(sc->sc_dmat, ccb->ccb_dmap); Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.9 src/sys/dev/hyperv/if_hvn.c:1.10 --- src/sys/dev/hyperv/if_hvn.c:1.9 Fri Nov 22 12:40:07 2019 +++ src/sys/dev/hyperv/if_hvn.c Mon Nov 25 08:53:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.9 2019/11/22 12:40:07 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.10 2019/11/25 08:53:39 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.9 2019/11/22 12:40:07 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.10 2019/11/25 08:53:39 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -632,7 +632,8 @@ hvn_decap(struct hvn_softc *sc, struct h { struct ifnet *ifp = SC2IFP(sc); - bus_dmamap_sync(sc->sc_dmat, txd->txd_dmap, 0, 0, + bus_dmamap_sync(sc->sc_dmat, txd->txd_dmap, + 0, txd->txd_dmap->dm_mapsize, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->sc_dmat, txd->txd_dmap); txd->txd_buf = NULL; @@ -667,7 +668,8 @@ hvn_txeof(struct hvn_softc *sc, uint64_t } txd->txd_buf = NULL; - bus_dmamap_sync(sc->sc_dmat, txd->txd_dmap, 0, 0, + bus_dmamap_sync(sc->sc_dmat, txd->txd_dmap, + 0, txd->txd_dmap->dm_mapsize, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->sc_dmat, txd->txd_dmap); m_freem(m); @@ -844,7 +846,8 @@ hvn_tx_ring_destroy(struct hvn_softc *sc txd = >sc_tx_desc[i]; if (txd->txd_dmap == NULL) continue; - bus_dmamap_sync(sc->sc_dmat, txd->txd_dmap, 0, 0, + bus_dmamap_sync(sc->sc_dmat, txd->txd_dmap, + 0, txd->txd_dmap->dm_mapsize, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->sc_dmat, txd->txd_dmap); bus_dmamap_destroy(sc->sc_dmat, txd->txd_dmap); @@ -855,7 +858,8 @@ hvn_tx_ring_destroy(struct hvn_softc *sc txd->txd_buf = NULL; } if (sc->sc_tx_rmap) { - bus_dmamap_sync(sc->sc_dmat, sc->sc_tx_rmap, 0, 0, + bus_dmamap_sync(sc->sc_dmat, sc->sc_tx_rmap, + 0, txd->txd_dmap->dm_mapsize, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(sc->sc_dmat, sc->sc_tx_rmap); bus_dmamap_destroy(sc->sc_dmat, sc->sc_tx_rmap);
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Nov 22 12:40:08 UTC 2019 Modified Files: src/sys/dev/hyperv: hvkbd.c if_hvn.c Log Message: hvn(4), hvkbd(4): Only need to poll when cold. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/hvkbd.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Nov 22 12:40:08 UTC 2019 Modified Files: src/sys/dev/hyperv: hvkbd.c if_hvn.c Log Message: hvn(4), hvkbd(4): Only need to poll when cold. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/hvkbd.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/hvkbd.c diff -u src/sys/dev/hyperv/hvkbd.c:1.5 src/sys/dev/hyperv/hvkbd.c:1.6 --- src/sys/dev/hyperv/hvkbd.c:1.5 Fri Nov 22 12:30:32 2019 +++ src/sys/dev/hyperv/hvkbd.c Fri Nov 22 12:40:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hvkbd.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $ */ +/* $NetBSD: hvkbd.c,v 1.6 2019/11/22 12:40:07 nonaka Exp $ */ /*- * Copyright (c) 2017 Microsoft Corp. @@ -36,7 +36,7 @@ #endif /* _KERNEL_OPT */ #include -__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.6 2019/11/22 12:40:07 nonaka Exp $"); #include #include @@ -344,13 +344,13 @@ hvkbd_connect(struct hvkbd_softc *sc) } do { - if (cold) + if (cold) { delay(1000); - else + s = spltty(); + hvkbd_intr(sc); + splx(s); + } else tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", mstohz(1)); - s = spltty(); - hvkbd_intr(sc); - splx(s); } while (--timo > 0 && sc->sc_connected == 0); if (timo == 0 && sc->sc_connected == 0) { Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.8 src/sys/dev/hyperv/if_hvn.c:1.9 --- src/sys/dev/hyperv/if_hvn.c:1.8 Fri Nov 22 12:30:32 2019 +++ src/sys/dev/hyperv/if_hvn.c Fri Nov 22 12:40:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.8 2019/11/22 12:30:32 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.9 2019/11/22 12:40:07 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.8 2019/11/22 12:30:32 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.9 2019/11/22 12:40:07 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1081,13 +1081,13 @@ hvn_nvs_cmd(struct hvn_softc *sc, void * return 0; do { - if (cold) + if (cold) { delay(1000); - else + s = splnet(); + hvn_nvs_intr(sc); + splx(s); + } else tsleep(sc, PRIBIO | PCATCH, "nvscmd", mstohz(1)); - s = splnet(); - hvn_nvs_intr(sc); - splx(s); } while (--timo > 0 && sc->sc_nvsdone != 1); if (timo == 0 && sc->sc_nvsdone != 1) { @@ -1404,13 +1404,13 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru BUS_DMASYNC_POSTWRITE); do { - if (cold) + if (cold) { delay(1000); - else + s = splnet(); + hvn_nvs_intr(sc); + splx(s); + } else tsleep(rc, PRIBIO | PCATCH, "rndiscmd", mstohz(1)); - s = splnet(); - hvn_nvs_intr(sc); - splx(s); } while (--timo > 0 && rc->rc_done != 1); bus_dmamap_sync(sc->sc_dmat, rc->rc_dmap, 0, PAGE_SIZE,
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Nov 22 12:30:32 UTC 2019 Modified Files: src/sys/dev/hyperv: hvkbd.c if_hvn.c vmbus.c Log Message: vmbus(4), hvn(4), hvkbd(4): Fixed wait time for tsleep(9). To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hyperv/hvkbd.c \ src/sys/dev/hyperv/vmbus.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Nov 22 12:30:32 UTC 2019 Modified Files: src/sys/dev/hyperv: hvkbd.c if_hvn.c vmbus.c Log Message: vmbus(4), hvn(4), hvkbd(4): Fixed wait time for tsleep(9). To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hyperv/hvkbd.c \ src/sys/dev/hyperv/vmbus.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/hvkbd.c diff -u src/sys/dev/hyperv/hvkbd.c:1.4 src/sys/dev/hyperv/hvkbd.c:1.5 --- src/sys/dev/hyperv/hvkbd.c:1.4 Fri Nov 15 08:51:27 2019 +++ src/sys/dev/hyperv/hvkbd.c Fri Nov 22 12:30:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hvkbd.c,v 1.4 2019/11/15 08:51:27 nonaka Exp $ */ +/* $NetBSD: hvkbd.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $ */ /*- * Copyright (c) 2017 Microsoft Corp. @@ -36,7 +36,7 @@ #endif /* _KERNEL_OPT */ #include -__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.4 2019/11/15 08:51:27 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $"); #include #include @@ -347,7 +347,7 @@ hvkbd_connect(struct hvkbd_softc *sc) if (cold) delay(1000); else - tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", 1); + tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", mstohz(1)); s = spltty(); hvkbd_intr(sc); splx(s); Index: src/sys/dev/hyperv/vmbus.c diff -u src/sys/dev/hyperv/vmbus.c:1.4 src/sys/dev/hyperv/vmbus.c:1.5 --- src/sys/dev/hyperv/vmbus.c:1.4 Tue Jul 9 10:07:11 2019 +++ src/sys/dev/hyperv/vmbus.c Fri Nov 22 12:30:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: vmbus.c,v 1.4 2019/07/09 10:07:11 nakayama Exp $ */ +/* $NetBSD: vmbus.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $ */ /* $OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.4 2019/07/09 10:07:11 nakayama Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $"); #include #include @@ -604,7 +604,7 @@ vmbus_start(struct vmbus_softc *sc, stru hyperv_intr(); splx(s); } else - tsleep(wchan, PRIBIO, wchan, 1); + tsleep(wchan, PRIBIO, wchan, mstohz(delays[i])); } if (status != HYPERCALL_STATUS_SUCCESS) { device_printf(sc->sc_dev, @@ -666,7 +666,8 @@ vmbus_wait(struct vmbus_softc *sc, hyperv_intr(); splx(s); } else - tsleep(wchan, PRIBIO, wmsg ? wmsg : "hvwait", 1); + tsleep(wchan, PRIBIO, wmsg ? wmsg : "hvwait", + mstohz(1)); } } Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.7 src/sys/dev/hyperv/if_hvn.c:1.8 --- src/sys/dev/hyperv/if_hvn.c:1.7 Mon Nov 18 04:38:48 2019 +++ src/sys/dev/hyperv/if_hvn.c Fri Nov 22 12:30:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.7 2019/11/18 04:38:48 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.8 2019/11/22 12:30:32 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.7 2019/11/18 04:38:48 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.8 2019/11/22 12:30:32 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1063,7 +1063,7 @@ hvn_nvs_cmd(struct hvn_softc *sc, void * if (cold) delay(1000); else -tsleep(cmd, PRIBIO, "nvsout", 1); +tsleep(cmd, PRIBIO, "nvsout", mstohz(1)); } else if (rv) { DPRINTF("%s: NVSP operation %u send error %d\n", device_xname(sc->sc_dev), hdr->nvs_type, rv); @@ -1084,7 +1084,7 @@ hvn_nvs_cmd(struct hvn_softc *sc, void * if (cold) delay(1000); else - tsleep(sc, PRIBIO | PCATCH, "nvscmd", 1); + tsleep(sc, PRIBIO | PCATCH, "nvscmd", mstohz(1)); s = splnet(); hvn_nvs_intr(sc); splx(s); @@ -1385,7 +1385,7 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru if (cold) delay(1000); else -tsleep(rc, PRIBIO, "rndisout", 1); +tsleep(rc, PRIBIO, "rndisout", mstohz(1)); } else if (rv) { DPRINTF("%s: RNDIS operation %u send error %d\n", device_xname(sc->sc_dev), hdr->rm_type, rv); @@ -1407,7 +1407,7 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru if (cold) delay(1000); else - tsleep(rc, PRIBIO | PCATCH, "rndiscmd", 1); + tsleep(rc, PRIBIO | PCATCH, "rndiscmd", mstohz(1)); s = splnet(); hvn_nvs_intr(sc); splx(s);
CVS commit: src/sys/dev/pci
Module Name:src Committed By: nonaka Date: Mon Nov 18 04:40:05 UTC 2019 Modified Files: src/sys/dev/pci: if_mcx.c Log Message: Fixed incorrect m_defrag return value check. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/if_mcx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_mcx.c diff -u src/sys/dev/pci/if_mcx.c:1.5 src/sys/dev/pci/if_mcx.c:1.6 --- src/sys/dev/pci/if_mcx.c:1.5 Thu Oct 17 15:57:56 2019 +++ src/sys/dev/pci/if_mcx.c Mon Nov 18 04:40:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_mcx.c,v 1.5 2019/10/17 15:57:56 msaitoh Exp $ */ +/* $NetBSD: if_mcx.c,v 1.6 2019/11/18 04:40:05 nonaka Exp $ */ /* $OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */ /* @@ -6347,7 +6347,7 @@ mcx_load_mbuf(struct mcx_softc *sc, stru break; case EFBIG: - if (m_defrag(m, M_DONTWAIT) == 0 && + if (m_defrag(m, M_DONTWAIT) != NULL && bus_dmamap_load_mbuf(sc->sc_dmat, ms->ms_map, m, BUS_DMA_STREAMING | BUS_DMA_NOWAIT) == 0) break;
CVS commit: src/sys/dev/pci
Module Name:src Committed By: nonaka Date: Mon Nov 18 04:40:05 UTC 2019 Modified Files: src/sys/dev/pci: if_mcx.c Log Message: Fixed incorrect m_defrag return value check. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/if_mcx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Mon Nov 18 04:38:48 UTC 2019 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: Fixed incorrect m_defrag return value check. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.6 src/sys/dev/hyperv/if_hvn.c:1.7 --- src/sys/dev/hyperv/if_hvn.c:1.6 Fri Nov 15 08:51:27 2019 +++ src/sys/dev/hyperv/if_hvn.c Mon Nov 18 04:38:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.6 2019/11/15 08:51:27 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.7 2019/11/18 04:38:48 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.6 2019/11/15 08:51:27 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.7 2019/11/18 04:38:48 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -565,7 +565,7 @@ hvn_encap(struct hvn_softc *sc, struct m case 0: break; case EFBIG: - if (m_defrag(m, M_NOWAIT) == 0 && + if (m_defrag(m, M_NOWAIT) != NULL && bus_dmamap_load_mbuf(sc->sc_dmat, txd->txd_dmap, m, BUS_DMA_READ | BUS_DMA_NOWAIT) == 0) break;
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Mon Nov 18 04:38:48 UTC 2019 Modified Files: src/sys/dev/hyperv: if_hvn.c Log Message: Fixed incorrect m_defrag return value check. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Nov 15 08:51:27 UTC 2019 Modified Files: src/sys/dev/hyperv: hvkbd.c if_hvn.c Log Message: hvn(4), hvkbd(4): No need to call vmbus_channel_setdeferred(). These devices do not perform batch reading. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hvkbd.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hyperv/hvkbd.c diff -u src/sys/dev/hyperv/hvkbd.c:1.3 src/sys/dev/hyperv/hvkbd.c:1.4 --- src/sys/dev/hyperv/hvkbd.c:1.3 Tue Oct 1 18:00:08 2019 +++ src/sys/dev/hyperv/hvkbd.c Fri Nov 15 08:51:27 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: hvkbd.c,v 1.3 2019/10/01 18:00:08 chs Exp $ */ +/* $NetBSD: hvkbd.c,v 1.4 2019/11/15 08:51:27 nonaka Exp $ */ /*- * Copyright (c) 2017 Microsoft Corp. @@ -36,7 +36,7 @@ #endif /* _KERNEL_OPT */ #include -__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.3 2019/10/01 18:00:08 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.4 2019/11/15 08:51:27 nonaka Exp $"); #include #include @@ -210,11 +210,6 @@ hvkbd_attach(device_t parent, device_t s hvkbd_alloc_keybuf(sc); sc->sc_buf = kmem_zalloc(HVKBD_BUFSIZE, KM_SLEEP); - if (vmbus_channel_setdeferred(sc->sc_chan, device_xname(self))) { - aprint_error_dev(self, - "failed to create the interrupt thread\n"); - goto free_buf; - } sc->sc_chan->ch_flags &= ~CHF_BATCHED; if (vmbus_channel_open(sc->sc_chan, Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.5 src/sys/dev/hyperv/if_hvn.c:1.6 --- src/sys/dev/hyperv/if_hvn.c:1.5 Tue Oct 1 18:00:08 2019 +++ src/sys/dev/hyperv/if_hvn.c Fri Nov 15 08:51:27 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.5 2019/10/01 18:00:08 chs Exp $ */ +/* $NetBSD: if_hvn.c,v 1.6 2019/11/15 08:51:27 nonaka Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.5 2019/10/01 18:00:08 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.6 2019/11/15 08:51:27 nonaka Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -922,12 +922,6 @@ hvn_nvs_attach(struct hvn_softc *sc) sc->sc_chan->ch_flags &= ~CHF_BATCHED; - if (vmbus_channel_setdeferred(sc->sc_chan, device_xname(sc->sc_dev))) { - aprint_error_dev(sc->sc_dev, - "failed to create the interrupt thread\n"); - return -1; - } - /* Associate our interrupt handler with the channel */ if (vmbus_channel_open(sc->sc_chan, ringsize, NULL, 0, hvn_nvs_intr, sc)) {
CVS commit: src/sys/dev/hyperv
Module Name:src Committed By: nonaka Date: Fri Nov 15 08:51:27 UTC 2019 Modified Files: src/sys/dev/hyperv: hvkbd.c if_hvn.c Log Message: hvn(4), hvkbd(4): No need to call vmbus_channel_setdeferred(). These devices do not perform batch reading. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/hyperv/hvkbd.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/if_hvn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Mon Nov 11 07:27:49 UTC 2019 Modified Files: src/sys/dev/ic: nvme.c Log Message: nvme(4): Use the SET_FEATURES command to get the number of allocated queues. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/dev/ic/nvme.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/nvme.c diff -u src/sys/dev/ic/nvme.c:1.46 src/sys/dev/ic/nvme.c:1.47 --- src/sys/dev/ic/nvme.c:1.46 Thu Sep 26 11:50:32 2019 +++ src/sys/dev/ic/nvme.c Mon Nov 11 07:27:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvme.c,v 1.46 2019/09/26 11:50:32 nonaka Exp $ */ +/* $NetBSD: nvme.c,v 1.47 2019/11/11 07:27:48 nonaka Exp $ */ /* $OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */ /* @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.46 2019/09/26 11:50:32 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.47 2019/11/11 07:27:48 nonaka Exp $"); #include #include @@ -116,7 +116,8 @@ static void nvme_pt_done(struct nvme_que static int nvme_command_passthrough(struct nvme_softc *, struct nvme_pt_command *, uint16_t, struct lwp *, bool); -static int nvme_get_number_of_queues(struct nvme_softc *, u_int *); +static int nvme_set_number_of_queues(struct nvme_softc *, u_int, u_int *, + u_int *); #define NVME_TIMO_QOP 5 /* queue create and delete timeout */ #define NVME_TIMO_IDENT 10 /* probe identify timeout */ @@ -339,7 +340,7 @@ nvme_attach(struct nvme_softc *sc) uint32_t reg; u_int dstrd; u_int mps = PAGE_SHIFT; - u_int ioq_allocated; + u_int ncq, nsq; uint16_t adminq_entries = nvme_adminq_size; uint16_t ioq_entries = nvme_ioq_size; int i; @@ -413,13 +414,15 @@ nvme_attach(struct nvme_softc *sc) if (sc->sc_use_mq) { /* Limit the number of queues to the number allocated in HW */ - if (nvme_get_number_of_queues(sc, _allocated) != 0) { + if (nvme_set_number_of_queues(sc, sc->sc_nq, , ) != 0) { aprint_error_dev(sc->sc_dev, "unable to get number of queues\n"); goto disable; } - if (sc->sc_nq > ioq_allocated) - sc->sc_nq = ioq_allocated; + if (sc->sc_nq > ncq) + sc->sc_nq = ncq; + if (sc->sc_nq > nsq) + sc->sc_nq = nsq; } sc->sc_q = kmem_zalloc(sizeof(*sc->sc_q) * sc->sc_nq, KM_SLEEP); @@ -1579,20 +1582,21 @@ nvme_fill_identify(struct nvme_queue *q, } static int -nvme_get_number_of_queues(struct nvme_softc *sc, u_int *nqap) +nvme_set_number_of_queues(struct nvme_softc *sc, u_int nq, u_int *ncqa, +u_int *nsqa) { struct nvme_pt_state state; struct nvme_pt_command pt; struct nvme_ccb *ccb; - uint16_t ncqa, nsqa; int rv; ccb = nvme_ccb_get(sc->sc_admin_q, false); KASSERT(ccb != NULL); /* it's a bug if we don't have spare ccb here */ memset(, 0, sizeof(pt)); - pt.cmd.opcode = NVM_ADMIN_GET_FEATURES; - pt.cmd.cdw10 = NVM_FEATURE_NUMBER_OF_QUEUES; + pt.cmd.opcode = NVM_ADMIN_SET_FEATURES; + htolem32(, NVM_FEATURE_NUMBER_OF_QUEUES); + htolem32(, ((nq - 1) << 16) | (nq - 1)); memset(, 0, sizeof(state)); state.pt = @@ -1604,13 +1608,12 @@ nvme_get_number_of_queues(struct nvme_so rv = nvme_poll(sc, sc->sc_admin_q, ccb, nvme_pt_fill, NVME_TIMO_QOP); if (rv != 0) { - *nqap = 0; + *ncqa = *nsqa = 0; return EIO; } - ncqa = pt.cpl.cdw0 >> 16; - nsqa = pt.cpl.cdw0 & 0x; - *nqap = MIN(ncqa, nsqa) + 1; + *ncqa = (pt.cpl.cdw0 >> 16) + 1; + *nsqa = (pt.cpl.cdw0 & 0x) + 1; return 0; }
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Mon Nov 11 07:27:49 UTC 2019 Modified Files: src/sys/dev/ic: nvme.c Log Message: nvme(4): Use the SET_FEATURES command to get the number of allocated queues. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/dev/ic/nvme.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Thu Sep 26 12:21:03 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: boot.c conf.c dev_net.c devopen.c devopen.h Log Message: x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/stand/efiboot/boot.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/conf.c \ src/sys/arch/i386/stand/efiboot/dev_net.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/devopen.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/devopen.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Thu Sep 26 12:21:03 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: boot.c conf.c dev_net.c devopen.c devopen.h Log Message: x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/stand/efiboot/boot.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/conf.c \ src/sys/arch/i386/stand/efiboot/dev_net.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/devopen.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/devopen.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/boot.c diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.16 src/sys/arch/i386/stand/efiboot/boot.c:1.17 --- src/sys/arch/i386/stand/efiboot/boot.c:1.16 Fri Sep 13 02:19:45 2019 +++ src/sys/arch/i386/stand/efiboot/boot.c Thu Sep 26 12:21:03 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.16 2019/09/13 02:19:45 manu Exp $ */ +/* $NetBSD: boot.c,v 1.17 2019/09/26 12:21:03 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -111,6 +111,7 @@ const struct bootblk_command commands[] { NULL, NULL }, }; +static char *default_fsname; static char *default_devname; static int default_unit, default_partition; static const char *default_filename; @@ -125,8 +126,11 @@ parsebootfile(const char *fname, char ** { const char *col; static char savedevname[MAXDEVNAME+1]; +#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP) + const struct netboot_fstab *nf; +#endif - *fsname = "ufs"; + *fsname = default_fsname; if (default_part_name == NULL) { *devname = default_devname; } else { @@ -152,6 +156,7 @@ parsebootfile(const char *fname, char ** if (strstr(fname, "NAME=") == fname) { strlcpy(savedevname, fname, devlen + 1); + *fsname = "ufs"; *devname = savedevname; *unit = -1; *partition = -1; @@ -188,6 +193,13 @@ parsebootfile(const char *fname, char ** if (i != devlen) return ENXIO; +#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP) + nf = netboot_fstab_find(savedevname); + if (nf != NULL) + *fsname = (char *)nf->name; + else +#endif + *fsname = "ufs"; *devname = savedevname; *unit = u; *partition = p; @@ -278,6 +290,9 @@ boot(void) { int currname; int c; +#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP) + const struct netboot_fstab *nf; +#endif boot_modules_enabled = !(boot_params.bp_flags & X86_BP_FLAGS_NOMODULES); @@ -288,6 +303,14 @@ boot(void) /* if the user types "boot" without filename */ default_filename = DEFFILENAME; +#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP) + nf = netboot_fstab_find(default_devname); + if (nf != NULL) + default_fsname = (char *)nf->name; + else +#endif + default_fsname = "ufs"; + if (!(boot_params.bp_flags & X86_BP_FLAGS_NOBOOTCONF)) { #ifdef EFIBOOTCFG_FILENAME int rv = EINVAL; @@ -456,7 +479,7 @@ command_dev(char *arg) { static char savedevname[MAXDEVNAME + 1]; char buf[80]; - char *fsname, *devname; + char *devname; const char *file; /* dummy */ if (*arg == '\0') { @@ -474,7 +497,7 @@ command_dev(char *arg) } if (strchr(arg, ':') == NULL || - parsebootfile(arg, , , _unit, + parsebootfile(arg, _fsname, , _unit, _partition, )) { command_help(NULL); return; Index: src/sys/arch/i386/stand/efiboot/conf.c diff -u src/sys/arch/i386/stand/efiboot/conf.c:1.2 src/sys/arch/i386/stand/efiboot/conf.c:1.3 --- src/sys/arch/i386/stand/efiboot/conf.c:1.2 Wed Apr 11 10:32:09 2018 +++ src/sys/arch/i386/stand/efiboot/conf.c Thu Sep 26 12:21:03 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.2 2018/04/11 10:32:09 nonaka Exp $ */ +/* $NetBSD: conf.c,v 1.3 2019/09/26 12:21:03 nonaka Exp $ */ /* * Copyright (c) 1997 @@ -54,20 +54,23 @@ #endif #endif #include +#include "devopen.h" #include "efinet.h" struct devsw devsw[] = { { "disk", biosdisk_strategy, biosdisk_open, biosdisk_close, biosdisk_ioctl }, +#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP) { "net", net_strategy, net_open, net_close, net_ioctl }, +#endif }; int ndevs = __arraycount(devsw); -#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP) struct netif_driver *netif_drivers[] = { +#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP) , +#endif }; int n_netif_drivers = __arraycount(netif_drivers); -#endif struct fs_ops file_system[] = { #ifdef SUPPORT_CD9660 @@ -113,3 +116,15 @@ struct fs_ops file_system_nfs = FS_OPS(n #ifdef SUPPORT_TFTP struct fs_ops file_system_tftp = FS_OPS(tftp); #endif + +#if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP) +const struct netboot_fstab netboot_fstab[] = { +#ifdef SUPPORT_NFS + { "nfs", _system_nfs }, +#endif +#ifdef SUPPORT_TFTP + { "tftp", _system_tftp }, +#endif +}; +const int nnetboot_fstab = __arraycount(netboot_fstab); +#endif Index:
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Thu Sep 26 11:50:32 UTC 2019 Modified Files: src/sys/dev/ic: nvme.c Log Message: nvme(4): Don't attach the device, if namespace not found. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/dev/ic/nvme.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Thu Sep 26 11:50:32 UTC 2019 Modified Files: src/sys/dev/ic: nvme.c Log Message: nvme(4): Don't attach the device, if namespace not found. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/dev/ic/nvme.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/nvme.c diff -u src/sys/dev/ic/nvme.c:1.45 src/sys/dev/ic/nvme.c:1.46 --- src/sys/dev/ic/nvme.c:1.45 Fri Sep 20 05:32:42 2019 +++ src/sys/dev/ic/nvme.c Thu Sep 26 11:50:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvme.c,v 1.45 2019/09/20 05:32:42 nonaka Exp $ */ +/* $NetBSD: nvme.c,v 1.46 2019/09/26 11:50:32 nonaka Exp $ */ /* $OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */ /* @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.45 2019/09/20 05:32:42 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.46 2019/09/26 11:50:32 nonaka Exp $"); #include #include @@ -399,6 +399,10 @@ nvme_attach(struct nvme_softc *sc) aprint_error_dev(sc->sc_dev, "unable to identify controller\n"); goto disable; } + if (sc->sc_nn == 0) { + aprint_error_dev(sc->sc_dev, "namespace not found\n"); + goto disable; + } /* we know how big things are now */ sc->sc_max_sgl = sc->sc_mdts / sc->sc_mps;
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Fri Sep 20 05:32:42 UTC 2019 Modified Files: src/sys/dev/ic: nvme.c Log Message: Don't set Phase Tag bit of Completion Queue entry at nvme_poll_done(). A new completion queue entry check incorrectly determined that there was a Completion Queue entry for a command that was not submitted. Fix PR kern/54275, PR kern/54503, PR kern/54532. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/dev/ic/nvme.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/nvme.c diff -u src/sys/dev/ic/nvme.c:1.44 src/sys/dev/ic/nvme.c:1.45 --- src/sys/dev/ic/nvme.c:1.44 Fri Jun 28 15:08:47 2019 +++ src/sys/dev/ic/nvme.c Fri Sep 20 05:32:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: nvme.c,v 1.44 2019/06/28 15:08:47 jmcneill Exp $ */ +/* $NetBSD: nvme.c,v 1.45 2019/09/20 05:32:42 nonaka Exp $ */ /* $OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */ /* @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44 2019/06/28 15:08:47 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.45 2019/09/20 05:32:42 nonaka Exp $"); #include #include @@ -1302,8 +1302,8 @@ nvme_poll_done(struct nvme_queue *q, str { struct nvme_poll_state *state = ccb->ccb_cookie; - SET(cqe->flags, htole16(NVME_CQE_PHASE)); state->c = *cqe; + SET(state->c.flags, htole16(NVME_CQE_PHASE)); ccb->ccb_cookie = state->cookie; state->done(q, ccb, >c);
CVS commit: src/sys/dev/ic
Module Name:src Committed By: nonaka Date: Fri Sep 20 05:32:42 UTC 2019 Modified Files: src/sys/dev/ic: nvme.c Log Message: Don't set Phase Tag bit of Completion Queue entry at nvme_poll_done(). A new completion queue entry check incorrectly determined that there was a Completion Queue entry for a command that was not submitted. Fix PR kern/54275, PR kern/54503, PR kern/54532. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/dev/ic/nvme.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/etc/rc.d
Module Name:src Committed By: nonaka Date: Wed Sep 18 05:16:15 UTC 2019 Modified Files: src/etc/rc.d: Makefile Log Message: Moved zfs out of MKX11 block. Fix build failure without X11. To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/etc/rc.d/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/etc/rc.d
Module Name:src Committed By: nonaka Date: Wed Sep 18 05:16:15 UTC 2019 Modified Files: src/etc/rc.d: Makefile Log Message: Moved zfs out of MKX11 block. Fix build failure without X11. To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/etc/rc.d/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/rc.d/Makefile diff -u src/etc/rc.d/Makefile:1.105 src/etc/rc.d/Makefile:1.106 --- src/etc/rc.d/Makefile:1.105 Sun Sep 15 19:38:09 2019 +++ src/etc/rc.d/Makefile Wed Sep 18 05:16:15 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.105 2019/09/15 19:38:09 brad Exp $ +# $NetBSD: Makefile,v 1.106 2019/09/18 05:16:15 nonaka Exp $ .include @@ -54,14 +54,14 @@ FILESBUILD_xdm= yes FILESBUILD_xfs= yes FILESBUILD_fccache= yes -.if ${MKZFS} != "no" -CONFIGFILES+= zfs -.endif - .SUFFIXES: .in .in: ${_MKTARGET_CREATE} ${TOOL_SED} -e 's,@X11ROOTDIR@,${X11ROOTDIR},g' < ${.IMPSRC} > ${.TARGET} .endif +.if ${MKZFS} != "no" +CONFIGFILES+= zfs +.endif + .include
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Sat Aug 3 08:13:36 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: version Log Message: x86 efiboot: version 1.1. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Sat Aug 3 08:13:36 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: version Log Message: x86 efiboot: version 1.1. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/version diff -u src/sys/arch/i386/stand/efiboot/version:1.1 src/sys/arch/i386/stand/efiboot/version:1.2 --- src/sys/arch/i386/stand/efiboot/version:1.1 Tue Jan 24 11:09:14 2017 +++ src/sys/arch/i386/stand/efiboot/version Sat Aug 3 08:13:36 2019 @@ -1,7 +1,8 @@ -$NetBSD: version,v 1.1 2017/01/24 11:09:14 nonaka Exp $ +$NetBSD: version,v 1.2 2019/08/03 08:13:36 nonaka Exp $ NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE. The format of this file is important - make sure the entries are appended on end, last item is taken as the current. 1.0: Initial version. +1.1: Add CD/DVD-ROM, serial, PXE boot and UEFI memory map compaction support.
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Mon Jul 29 12:37:26 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: efiboot.c Log Message: Added missing efi_memory_probe() call. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/efiboot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/efiboot.c diff -u src/sys/arch/i386/stand/efiboot/efiboot.c:1.9 src/sys/arch/i386/stand/efiboot/efiboot.c:1.10 --- src/sys/arch/i386/stand/efiboot/efiboot.c:1.9 Mon Jul 29 11:28:51 2019 +++ src/sys/arch/i386/stand/efiboot/efiboot.c Mon Jul 29 12:37:26 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.c,v 1.9 2019/07/29 11:28:51 nonaka Exp $ */ +/* $NetBSD: efiboot.c,v 1.10 2019/07/29 12:37:26 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -88,6 +88,7 @@ efi_main(EFI_HANDLE imageHandle, EFI_SYS } } + efi_memory_probe(); efi_disk_probe(); efi_pxe_probe(); efi_net_probe();
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Mon Jul 29 12:37:26 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: efiboot.c Log Message: Added missing efi_memory_probe() call. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/efiboot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Mon Jul 29 11:33:07 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: efimemory.c Log Message: Sync the output of memmap command to the output of stand/efiboot mem command. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/efimemory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Mon Jul 29 11:33:07 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: efimemory.c Log Message: Sync the output of memmap command to the output of stand/efiboot mem command. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/efimemory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/efimemory.c diff -u src/sys/arch/i386/stand/efiboot/efimemory.c:1.7 src/sys/arch/i386/stand/efiboot/efimemory.c:1.8 --- src/sys/arch/i386/stand/efiboot/efimemory.c:1.7 Mon Jul 29 11:28:51 2019 +++ src/sys/arch/i386/stand/efiboot/efimemory.c Mon Jul 29 11:33:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efimemory.c,v 1.7 2019/07/29 11:28:51 nonaka Exp $ */ +/* $NetBSD: efimemory.c,v 1.8 2019/07/29 11:33:07 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -30,38 +30,22 @@ #include -static const char *memtypes[] = { - "unknown", - "available", - "reserved", - "ACPI reclaimable", - "ACPI NVS", - "unusable", - "disabled", - "Persistent", - "undefined (8)", - "undefined (9)", - "undefined (10)", - "undefined (11)", - "Persistent (Legacy)" -}; - -static const char *efimemtypes[] = { - "Reserved", - "LoaderCode", - "LoaderData", - "BootServicesCode", - "BootServicesData", - "RuntimeServicesCode", - "RuntimeServicesData", - "ConventionalMemory", - "UnusableMemory", - "ACPIReclaimMemory", - "ACPIMemoryNVS", - "MemoryMappedIO", - "MemoryMappedIOPortSpace", - "PalCode", - "PersistentMemory", +static const char *efi_memory_type[] = { + [EfiReservedMemoryType] = "Reserved Memory Type", + [EfiLoaderCode] = "Loader Code", + [EfiLoaderData] = "Loader Data", + [EfiBootServicesCode] = "Boot Services Code", + [EfiBootServicesData] = "Boot Services Data", + [EfiRuntimeServicesCode] = "Runtime Services Code", + [EfiRuntimeServicesData] = "Runtime Services Data", + [EfiConventionalMemory] = "Conventional Memory", + [EfiUnusableMemory] = "Unusable Memory", + [EfiACPIReclaimMemory] = "ACPI Reclaim Memory", + [EfiACPIMemoryNVS] = "ACPI Memory NVS", + [EfiMemoryMappedIO] = "MMIO", + [EfiMemoryMappedIOPortSpace] = "MMIO (Port Space)", + [EfiPalCode] = "Pal Code", + [EfiPersistentMemory] = "Persistent Memory", }; #ifndef KERN_LOADSPACE_SIZE @@ -355,9 +339,8 @@ efi_memory_show_map(bool sorted, bool co EFI_MEMORY_DESCRIPTOR *mdtop, *md, *next; UINTN i, NoEntries, MapKey, DescriptorSize; UINT32 DescriptorVersion; - char memstr[32], efimemstr[32]; - int memtype; - UINTN cols, rows, row = 0; + char efimemstr[32]; + UINTN cols, rows, row; status = uefi_call_wrapper(ST->ConOut->QueryMode, 4, ST->ConOut, ST->ConOut->Mode->Mode, , ); @@ -371,24 +354,23 @@ efi_memory_show_map(bool sorted, bool co if (compact) efi_memory_compact_map(mdtop, , DescriptorSize); + printf("%-22s %-16s %-16s %-16s\n", "Type", "Start", "End", "Attributes"); + printf("-- \n"); + row = 2; + for (i = 0, md = mdtop; i < NoEntries; i++, md = next) { next = NextMemoryDescriptor(md, DescriptorSize); - memtype = getmemtype(md); - if (memtype >= __arraycount(memtypes)) - snprintf(memstr, sizeof(memstr), "unknown (%d)", - memtype); - if (md->Type >= __arraycount(efimemtypes)) + if (md->Type >= __arraycount(efi_memory_type)) snprintf(efimemstr, sizeof(efimemstr), "unknown (%d)", md->Type); - printf("%016" PRIxMAX "/%016" PRIxMAX ": %s [%s]\n", + printf("%-22s %016" PRIxMAX " %016" PRIxMAX " %016" PRIxMAX "\n", + md->Type >= __arraycount(efi_memory_type) ? + efimemstr : efi_memory_type[md->Type], (uintmax_t)md->PhysicalStart, (uintmax_t)md->PhysicalStart + md->NumberOfPages * EFI_PAGE_SIZE - 1, - memtype >= __arraycount(memtypes) ? - memstr : memtypes[memtype], - md->Type >= __arraycount(efimemtypes) ? - efimemstr : efimemtypes[md->Type]); + (uintmax_t)md->Attribute); if (++row >= rows) { row = 0;
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Mon Jul 29 11:28:51 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: boot.c efiboot.c efiboot.h efimemory.c Log Message: Added BTINFO_EFIMEMMAP compaction support to x86 efiboot. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/i386/stand/efiboot/boot.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/i386/stand/efiboot/efiboot.c \ src/sys/arch/i386/stand/efiboot/efiboot.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/efimemory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/boot.c diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.12 src/sys/arch/i386/stand/efiboot/boot.c:1.13 --- src/sys/arch/i386/stand/efiboot/boot.c:1.12 Fri Jul 26 12:09:48 2019 +++ src/sys/arch/i386/stand/efiboot/boot.c Mon Jul 29 11:28:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.12 2019/07/26 12:09:48 nonaka Exp $ */ +/* $NetBSD: boot.c,v 1.13 2019/07/29 11:28:51 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -351,7 +351,7 @@ command_help(char *arg) #if LIBSA_ENABLE_LS_OP "ls [path]\n" #endif - "memmap [{sorted|unsorted}]\n" + "memmap [{sorted|unsorted|compact}]\n" #ifndef SMALL "menu (reenters boot menu, if defined in boot.cfg)\n" #endif @@ -613,18 +613,21 @@ void command_memmap(char *arg) { bool sorted = true; + bool compact = false; if (*arg == '\0' || strcmp(arg, "sorted") == 0) /* Already sorted is true. */; else if (strcmp(arg, "unsorted") == 0) sorted = false; + else if (strcmp(arg, "compact") == 0) + compact = true; else { printf("invalid flag, " - "must be 'sorted' or 'unsorted'.\n"); + "must be 'sorted', 'unsorted' or 'compact'.\n"); return; } - efi_memory_show_map(sorted); + efi_memory_show_map(sorted, compact); } void Index: src/sys/arch/i386/stand/efiboot/efiboot.c diff -u src/sys/arch/i386/stand/efiboot/efiboot.c:1.8 src/sys/arch/i386/stand/efiboot/efiboot.c:1.9 --- src/sys/arch/i386/stand/efiboot/efiboot.c:1.8 Fri Jun 8 11:52:30 2018 +++ src/sys/arch/i386/stand/efiboot/efiboot.c Mon Jul 29 11:28:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.c,v 1.8 2018/06/08 11:52:30 nonaka Exp $ */ +/* $NetBSD: efiboot.c,v 1.9 2019/07/29 11:28:51 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -134,6 +134,7 @@ efi_cleanup(void) } efi_cleanuped = true; + efi_memory_compact_map(desc, , DescriptorSize); allocsz = sizeof(struct btinfo_efimemmap) - 1 + NoEntries * DescriptorSize; bim = alloc(allocsz); Index: src/sys/arch/i386/stand/efiboot/efiboot.h diff -u src/sys/arch/i386/stand/efiboot/efiboot.h:1.8 src/sys/arch/i386/stand/efiboot/efiboot.h:1.9 --- src/sys/arch/i386/stand/efiboot/efiboot.h:1.8 Wed Apr 11 10:32:09 2018 +++ src/sys/arch/i386/stand/efiboot/efiboot.h Mon Jul 29 11:28:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.h,v 1.8 2018/04/11 10:32:09 nonaka Exp $ */ +/* $NetBSD: efiboot.h,v 1.9 2019/07/29 11:28:51 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -80,9 +80,11 @@ void efi_disk_show(void); /* efimemory.c */ void efi_memory_probe(void); -void efi_memory_show_map(bool); +void efi_memory_show_map(bool, bool); EFI_MEMORY_DESCRIPTOR *efi_memory_get_map(UINTN *, UINTN *, UINTN *, UINT32 *, bool); +EFI_MEMORY_DESCRIPTOR *efi_memory_compact_map(EFI_MEMORY_DESCRIPTOR *, UINTN *, +UINTN); /* efinet.c */ void efi_net_probe(void); Index: src/sys/arch/i386/stand/efiboot/efimemory.c diff -u src/sys/arch/i386/stand/efiboot/efimemory.c:1.6 src/sys/arch/i386/stand/efiboot/efimemory.c:1.7 --- src/sys/arch/i386/stand/efiboot/efimemory.c:1.6 Fri Jul 26 12:09:48 2019 +++ src/sys/arch/i386/stand/efiboot/efimemory.c Mon Jul 29 11:28:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efimemory.c,v 1.6 2019/07/26 12:09:48 nonaka Exp $ */ +/* $NetBSD: efimemory.c,v 1.7 2019/07/29 11:28:51 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -107,7 +107,7 @@ EFI_MEMORY_DESCRIPTOR * efi_memory_get_map(UINTN *NoEntries, UINTN *MapKey, UINTN *DescriptorSize, UINT32 *DescriptorVersion, bool sorted) { - EFI_MEMORY_DESCRIPTOR *desc, *md, *next, *target, tmp; + EFI_MEMORY_DESCRIPTOR *desc, *md, *next, *target, *tmp; UINTN i, j; *NoEntries = 0; @@ -119,17 +119,93 @@ efi_memory_get_map(UINTN *NoEntries, UIN if (!sorted) return desc; + tmp = alloc(*DescriptorSize); + if (tmp == NULL) + return desc; + for (i = 0, md = desc; i < *NoEntries - 1; i++, md = next) { target = next = NextMemoryDescriptor(md, *DescriptorSize); for (j = i + 1; j < *NoEntries; j++) { if (md->PhysicalStart > target->PhysicalStart) { -CopyMem(, md, sizeof(*md)); -CopyMem(md, target, sizeof(*md)); -CopyMem(target, , sizeof(*md)); +CopyMem(tmp, md, *DescriptorSize); +CopyMem(md, target, *DescriptorSize); +CopyMem(target, tmp,
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Mon Jul 29 11:28:51 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: boot.c efiboot.c efiboot.h efimemory.c Log Message: Added BTINFO_EFIMEMMAP compaction support to x86 efiboot. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/i386/stand/efiboot/boot.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/i386/stand/efiboot/efiboot.c \ src/sys/arch/i386/stand/efiboot/efiboot.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/efimemory.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/stand
Module Name:src Committed By: nonaka Date: Fri Jul 26 12:09:48 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: boot.c efimemory.c src/sys/arch/i386/stand/lib: exec.c libi386.h Log Message: Pre-allocate memory for the kernel space at startup. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/efiboot/boot.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/efimemory.c cvs rdiff -u -r1.72 -r1.73 src/sys/arch/i386/stand/lib/exec.c cvs rdiff -u -r1.43 -r1.44 src/sys/arch/i386/stand/lib/libi386.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/boot.c diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.11 src/sys/arch/i386/stand/efiboot/boot.c:1.12 --- src/sys/arch/i386/stand/efiboot/boot.c:1.11 Thu Jun 20 17:33:31 2019 +++ src/sys/arch/i386/stand/efiboot/boot.c Fri Jul 26 12:09:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.11 2019/06/20 17:33:31 maxv Exp $ */ +/* $NetBSD: boot.c,v 1.12 2019/07/26 12:09:48 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -226,40 +226,16 @@ clearit(void) static void bootit(const char *filename, int howto) { - EFI_STATUS status; - EFI_PHYSICAL_ADDRESS bouncebuf; - UINTN npages; - u_long allocsz; if (howto & AB_VERBOSE) printf("booting %s (howto 0x%x)\n", sprint_bootsel(filename), howto); - if (count_netbsd(filename, ) < 0) { - printf("boot: %s: %s\n", sprint_bootsel(filename), - strerror(errno)); - return; - } - - bouncebuf = EFI_ALLOCATE_MAX_ADDRESS; - npages = EFI_SIZE_TO_PAGES(allocsz); - status = uefi_call_wrapper(BS->AllocatePages, 4, AllocateMaxAddress, - EfiLoaderData, npages, ); - if (EFI_ERROR(status)) { - printf("boot: %s: %s\n", sprint_bootsel(filename), - strerror(ENOMEM)); - return; - } - - efi_loadaddr = bouncebuf; - if (exec_netbsd(filename, bouncebuf, howto, 0, efi_cleanup) < 0) + if (exec_netbsd(filename, efi_loadaddr, howto, 0, efi_cleanup) < 0) printf("boot: %s: %s\n", sprint_bootsel(filename), strerror(errno)); else printf("boot returned\n"); - - (void) uefi_call_wrapper(BS->FreePages, 2, bouncebuf, npages); - efi_loadaddr = 0; } void Index: src/sys/arch/i386/stand/efiboot/efimemory.c diff -u src/sys/arch/i386/stand/efiboot/efimemory.c:1.5 src/sys/arch/i386/stand/efiboot/efimemory.c:1.6 --- src/sys/arch/i386/stand/efiboot/efimemory.c:1.5 Tue Mar 27 14:15:05 2018 +++ src/sys/arch/i386/stand/efiboot/efimemory.c Fri Jul 26 12:09:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efimemory.c,v 1.5 2018/03/27 14:15:05 nonaka Exp $ */ +/* $NetBSD: efimemory.c,v 1.6 2019/07/26 12:09:48 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -64,6 +64,10 @@ static const char *efimemtypes[] = { "PersistentMemory", }; +#ifndef KERN_LOADSPACE_SIZE +#define KERN_LOADSPACE_SIZE (128 * 1024 * 1024) /* 128MiB */ +#endif + static int getmemtype(EFI_MEMORY_DESCRIPTOR *md) { @@ -231,13 +235,21 @@ void efi_memory_probe(void) { EFI_MEMORY_DESCRIPTOR *mdtop, *md, *next; + EFI_STATUS status; + EFI_PHYSICAL_ADDRESS bouncebuf; UINTN i, n, NoEntries, MapKey, DescriptorSize, MappingSize; UINT32 DescriptorVersion; int memtype; + bouncebuf = EFI_ALLOCATE_MAX_ADDRESS; + status = uefi_call_wrapper(BS->AllocatePages, 4, AllocateMaxAddress, + EfiLoaderData, EFI_SIZE_TO_PAGES(KERN_LOADSPACE_SIZE), ); + if (EFI_ERROR(status)) + panic("couldn't allocate kernel space."); + efi_loadaddr = bouncebuf; + mdtop = efi_memory_get_map(, , , , false); - printf(" mem["); for (i = 0, n = 0, md = mdtop; i < NoEntries; i++, md = next) { next = NextMemoryDescriptor(md, DescriptorSize); Index: src/sys/arch/i386/stand/lib/exec.c diff -u src/sys/arch/i386/stand/lib/exec.c:1.72 src/sys/arch/i386/stand/lib/exec.c:1.73 --- src/sys/arch/i386/stand/lib/exec.c:1.72 Mon Jun 24 13:58:24 2019 +++ src/sys/arch/i386/stand/lib/exec.c Fri Jul 26 12:09:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.72 2019/06/24 13:58:24 pgoyette Exp $ */ +/* $NetBSD: exec.c,v 1.73 2019/07/26 12:09:48 nonaka Exp $ */ /* * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -573,64 +573,6 @@ out: return -1; } -int -count_netbsd(const char *file, u_long *rsz) -{ - u_long marks[MARK_MAX]; - char kdev[64]; - char base_path[64] = "/"; - struct stat st; - boot_module_t *bm; - u_long sz; - int err, fd; - - if (has_prekern) { - /* - * Hardcoded for now. Need to count both the prekern and the - * kernel. 128MB is enough in all cases, so use that. - */ - *rsz = (128UL << 20); - return 0; - } - - howto = AB_SILENT; - - memset(marks, 0, sizeof(marks)); - if ((fd = loadfile(file, marks, COUNT_KERNEL | LOAD_NOTE)) == -1) - return -1; - close(fd); - marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) & - (-sizeof(int)); - sz = marks[MARK_END]; - - /* The modules must be allocated after the
CVS commit: src/sys/arch/i386/stand
Module Name:src Committed By: nonaka Date: Fri Jul 26 12:09:48 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: boot.c efimemory.c src/sys/arch/i386/stand/lib: exec.c libi386.h Log Message: Pre-allocate memory for the kernel space at startup. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/efiboot/boot.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/efimemory.c cvs rdiff -u -r1.72 -r1.73 src/sys/arch/i386/stand/lib/exec.c cvs rdiff -u -r1.43 -r1.44 src/sys/arch/i386/stand/lib/libi386.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Fri Jul 26 11:30:31 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: Makefile.efiboot dev_net.c Log Message: Added tftp support to x86 efiboot. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/i386/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/dev_net.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/Makefile.efiboot diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.14 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.15 --- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.14 Wed Jul 25 23:45:32 2018 +++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot Fri Jul 26 11:30:31 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.14 2018/07/25 23:45:32 kamil Exp $ +# $NetBSD: Makefile.efiboot,v 1.15 2019/07/26 11:30:31 nonaka Exp $ S= ${.CURDIR}/../../../../.. @@ -18,7 +18,9 @@ SOURCES+= efidisk.c efidisk_ll.c efigets SOURCES+= efinet.c efipxe.c LIBI386SRCS= biosdisk.c bootinfo.c bootinfo_biosgeom.c bootmenu.c LIBI386SRCS+= diskbuf.c exec.c menuutils.c parseutils.c pread.c -SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS} +# use our own nfs implementation +LIBSASRCS+= nfs.c +SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS} ${LIBSASRCS} .include @@ -35,6 +37,7 @@ BINMODE=444 .PATH: ${.CURDIR} ${.CURDIR}/.. .PATH: ${.CURDIR}/../../lib +.PATH: ${.CURDIR}/../../libsa LDSCRIPT?= ${.CURDIR}/ldscript LDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared -nocombreloc @@ -60,7 +63,7 @@ CPPFLAGS+= -DSUPPORT_EXT2FS CPPFLAGS+= -DSUPPORT_BOOTP CPPFLAGS+= -DSUPPORT_DHCP CPPFLAGS+= -DSUPPORT_NFS -#CPPFLAGS+= -DSUPPORT_TFTP +CPPFLAGS+= -DSUPPORT_TFTP CPPFLAGS+= -DPASS_BIOSGEOM CPPFLAGS+= -DBIOSDISK_DEFAULT_SECSIZE=2048 # for bootinfo_biosgeom.c CPPFLAGS+= -DLIBSA_ENABLE_LS_OP Index: src/sys/arch/i386/stand/efiboot/dev_net.c diff -u src/sys/arch/i386/stand/efiboot/dev_net.c:1.1 src/sys/arch/i386/stand/efiboot/dev_net.c:1.2 --- src/sys/arch/i386/stand/efiboot/dev_net.c:1.1 Wed Apr 11 10:32:09 2018 +++ src/sys/arch/i386/stand/efiboot/dev_net.c Fri Jul 26 11:30:31 2019 @@ -1,3 +1,256 @@ -/* $NetBSD: dev_net.c,v 1.1 2018/04/11 10:32:09 nonaka Exp $ */ +/* $NetBSD: dev_net.c,v 1.2 2019/07/26 11:30:31 nonaka Exp $ */ -#include +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library NFS code. This interface + * does not support any "block" access, and exists only for the + * purpose of initializing the network interface, getting boot + * parameters, and performing the NFS mount. + * + * At open time, this does: + * + * find interface - netif_open() + * RARP for IP address - rarp_getipaddress() + * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) + * RPC/mountd - nfs_mount(sock, ip, path) + */ + +#include +#include +#include +#include +#include + +#include + +#include "stand.h" +#include "net.h" +#include "netif.h" +#include "nfs.h" +#include "bootparam.h" +#include "dev_net.h" +#ifdef SUPPORT_BOOTP +#include "bootp.h" +#endif + +static int netdev_sock = -1; +static int netdev_opens; + +static int net_getparams(int); + +/* + * Called by devopen after it sets f->f_dev to our devsw entry. + * This opens the low-level device and sets f->f_devdata. + * This is
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Fri Jul 26 11:30:31 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: Makefile.efiboot dev_net.c Log Message: Added tftp support to x86 efiboot. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/i386/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/dev_net.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/kdump
Module Name:src Committed By: nonaka Date: Tue Jul 23 01:54:51 UTC 2019 Modified Files: src/usr.bin/kdump: kdump.c Log Message: kdump(1): Symbolic printing for MALLOC_OPTIONS="U". To generate a diff of this commit: cvs rdiff -u -r1.131 -r1.132 src/usr.bin/kdump/kdump.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/kdump/kdump.c diff -u src/usr.bin/kdump/kdump.c:1.131 src/usr.bin/kdump/kdump.c:1.132 --- src/usr.bin/kdump/kdump.c:1.131 Mon May 6 19:20:13 2019 +++ src/usr.bin/kdump/kdump.c Tue Jul 23 01:54:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kdump.c,v 1.131 2019/05/06 19:20:13 christos Exp $ */ +/* $NetBSD: kdump.c,v 1.132 2019/07/23 01:54:51 nonaka Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: kdump.c,v 1.131 2019/05/06 19:20:13 christos Exp $"); +__RCSID("$NetBSD: kdump.c,v 1.132 2019/07/23 01:54:51 nonaka Exp $"); #endif #endif /* not lint */ @@ -1143,6 +1143,27 @@ ktruser_control(const char *name, const } static void +ktruser_malloc(const char *name, const void *buf, size_t len) +{ + struct ut { void *p; size_t s; void *r; } m; + + if (len != sizeof(m)) + warnx("%.*s: len %zu != %zu", KTR_USER_MAXIDLEN, name, len, + sizeof(m)); + memcpy(, buf, len < sizeof(m) ? len : sizeof(m)); + if (m.p == NULL && m.s == 0 && m.r == NULL) + printf("%.*s: malloc_init()\n", KTR_USER_MAXIDLEN, name); + else if (m.p != NULL && m.s != 0) + printf("%.*s: %p = realloc(%p, %zu)\n", KTR_USER_MAXIDLEN, name, + m.r, m.p, m.s); + else if (m.s == 0) + printf("%.*s: free(%p)\n", KTR_USER_MAXIDLEN, name, m.p); + else + printf("%.*s: %p = malloc(%zu)\n", KTR_USER_MAXIDLEN, name, + m.r, m.s); +} + +static void ktruser_misc(const char *name, const void *buf, size_t len) { size_t i; @@ -1161,6 +1182,7 @@ static struct { { "msghdr", ktruser_msghdr }, { "mbsoname", ktruser_soname }, { "mbcontrol", ktruser_control }, + { "malloc", ktruser_malloc }, { NULL, ktruser_misc }, };