Home | History | Annotate | Download | only in hyperv
History log of /src/sys/dev/hyperv/if_hvn.c
RevisionDateAuthorComments
 1.30  17-Feb-2025  joe copy dhost and shost without flagging overflow
 1.29  16-Feb-2025  joe avoid buffer overflow when copying the ether header host into the ether vland header host
on hyper-v
 1.28  05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.27  09-Feb-2024  andvar branches: 1.27.2;
fix spelling mistakes, mainly in comments and log messages.
 1.26  20-Dec-2023  skrll Remove unnecssary #include
 1.25  08-Dec-2023  andvar fix triple s typos in comments.
 1.24  18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.23  29-May-2022  rin Audit unload/unmap v.s. free against DMA buffer for sys/dev;
make sure that bus_dmamap_unload(9) [or bus_dmamap_destroy(9)] or
bus_dmamem_unmap(9) are preceding to freeing DMA buffer, if it is
loaded or mapped, respectively.

This is mandatory for some archs. See, e.g.:

http://www.nerv.org/netbsd/?q=id:20210511T013030Z.013443cc790088147e4beed43f53dedabeaf9312
http://www.nerv.org/netbsd/?q=id:20220511T172220Z.561179f0b6fcc5b9cd73e274f69d74e2ce9e4c93

For some drivers, resource leaks for error paths are fixed at
the same time.

XXX XXX XXX
Compile test only (at least one arch per driver).
 1.22  20-May-2022  nonaka 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.
 1.21  16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.20  29-Jan-2021  nonaka branches: 1.20.4;
hvn(4): Don't wait forever.
 1.19  11-Dec-2020  nonaka hvn(4): fix unable to ifconfig up/down.
 1.18  24-May-2020  nonaka branches: 1.18.2;
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.
 1.17  04-Feb-2020  thorpej Use ifmedia_fini().
 1.16  29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.15  27-Dec-2019  nonaka branches: 1.15.2;
hvn(4): Handle CFI field of VLAN.
 1.14  27-Dec-2019  nonaka hvn(4): Use vlan_{get,set,has}_tag().
 1.13  10-Dec-2019  nonaka hvn(4) can be added and deleted dynamically.
 1.12  10-Dec-2019  nonaka hvn(4): Handle VMBUS_CHANPKT_TYPE_INBAND packet type.
 1.11  26-Nov-2019  nonaka hvn(4): Fix incorrect ident when waiting for NVS command response.
 1.10  25-Nov-2019  nonaka hvs(4), hvn(4): Set correct size for bus_dmamap_sync(9).
 1.9  22-Nov-2019  nonaka hvn(4), hvkbd(4): Only need to poll when cold.
 1.8  22-Nov-2019  nonaka vmbus(4), hvn(4), hvkbd(4): Fixed wait time for tsleep(9).
 1.7  18-Nov-2019  nonaka Fixed incorrect m_defrag return value check.
 1.6  15-Nov-2019  nonaka hvn(4), hvkbd(4): No need to call vmbus_channel_setdeferred().

These devices do not perform batch reading.
 1.5  01-Oct-2019  chs in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
 1.4  09-Jul-2019  msaitoh branches: 1.4.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.3  29-May-2019  msaitoh branches: 1.3.2;
Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.2  05-Mar-2019  msaitoh branches: 1.2.2;
Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.1  15-Feb-2019  nonaka Added Microsoft Hyper-V support. It ported from OpenBSD and FreeBSD.

graphical console is not work on Gen.2 VM yet. To use the serial console,
enter "consdev com,0x3f8,115200" on efiboot.
 1.2.2.9  29-Jan-2021  martin Pull up following revision(s) (requested by nonaka in ticket #1647):

sys/dev/hyperv/if_hvn.c: revision 1.20 (via patch)
sys/dev/hyperv/hvkbd.c: revision 1.7 (via patch)
sys/dev/hyperv/vmbus.c: revision 1.12 (via patch)

hvkbd(4): Don't wait forever.
vmbus(4): Don't wait forever.
hvn(4): Don't wait forever.
 1.2.2.8  11-Dec-2020  martin Pull up following revision(s) (requested by nonaka in ticket #1635):

sys/dev/hyperv/if_hvn.c: revision 1.19 (via patch)

hvn(4): fix unable to ifconfig up/down.
 1.2.2.7  26-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1460):

sys/dev/hyperv/if_hvn.c: revision 1.11

hvn(4): Fix incorrect ident when waiting for NVS command response.
 1.2.2.6  25-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1458):

sys/dev/hyperv/hvs.c: revision 1.3
sys/dev/hyperv/if_hvn.c: revision 1.10

hvs(4), hvn(4): Set correct size for bus_dmamap_sync(9).
 1.2.2.5  24-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1455):

sys/dev/hyperv/if_hvn.c: revision 1.8
sys/dev/hyperv/if_hvn.c: revision 1.9
sys/dev/hyperv/hvkbd.c: revision 1.5
sys/dev/hyperv/hvkbd.c: revision 1.6
sys/dev/hyperv/vmbus.c: revision 1.5

vmbus(4), hvn(4), hvkbd(4): Fixed wait time for tsleep(9).
hvn(4), hvkbd(4): Only need to poll when cold.
 1.2.2.4  18-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1447):

sys/dev/hyperv/if_hvn.c: revision 1.7

Fixed incorrect m_defrag return value check.
 1.2.2.3  16-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1441):

sys/dev/hyperv/if_hvn.c: revision 1.6
sys/dev/hyperv/hvkbd.c: revision 1.4

hvn(4), hvkbd(4): No need to call vmbus_channel_setdeferred().

These devices do not perform batch reading.
 1.2.2.2  09-Mar-2019  martin Pull up following revision(s) via patch (requested by nonaka in ticket #1210):

sys/dev/hyperv/vmbusvar.h: revision 1.1
sys/dev/hyperv/hvs.c: revision 1.1
sys/dev/hyperv/if_hvn.c: revision 1.1
sys/dev/hyperv/vmbusic.c: revision 1.1
sys/arch/x86/x86/lapic.c: revision 1.69
sys/arch/x86/isa/clock.c: revision 1.34
sys/arch/x86/include/intrdefs.h: revision 1.22
sys/arch/i386/conf/GENERIC: revision 1.1201
sys/arch/x86/x86/hyperv.c: revision 1.1
sys/arch/x86/include/cpu.h: revision 1.105
sys/arch/x86/x86/x86_machdep.c: revision 1.124
sys/arch/i386/conf/GENERIC: revision 1.1203
sys/arch/amd64/amd64/genassym.cf: revision 1.74
sys/arch/i386/conf/GENERIC: revision 1.1204
sys/arch/amd64/conf/GENERIC: revision 1.520
sys/arch/x86/x86/hypervreg.h: revision 1.1
sys/arch/amd64/amd64/vector.S: revision 1.69
sys/dev/hyperv/hvshutdown.c: revision 1.1
sys/dev/hyperv/hvshutdown.c: revision 1.2
sys/dev/usb/if_urndisreg.h: file removal
sys/arch/x86/x86/cpu.c: revision 1.167
sys/arch/x86/conf/files.x86: revision 1.107
sys/dev/usb/if_urndis.c: revision 1.20
sys/dev/hyperv/vmbusicreg.h: revision 1.1
sys/dev/hyperv/hvheartbeat.c: revision 1.1
sys/dev/hyperv/vmbusicreg.h: revision 1.2
sys/dev/hyperv/hvheartbeat.c: revision 1.2
sys/dev/hyperv/files.hyperv: revision 1.1
sys/dev/ic/rndisreg.h: revision 1.1
sys/arch/i386/i386/genassym.cf: revision 1.111
sys/dev/ic/rndisreg.h: revision 1.2
sys/dev/hyperv/hyperv_common.c: revision 1.1
sys/dev/hyperv/hvtimesync.c: revision 1.1
sys/dev/hyperv/hypervreg.h: revision 1.1
sys/dev/hyperv/hvtimesync.c: revision 1.2
sys/dev/hyperv/vmbusicvar.h: revision 1.1
sys/dev/hyperv/if_hvnreg.h: revision 1.1
sys/arch/x86/x86/lapic.c: revision 1.70
sys/arch/amd64/amd64/vector.S: revision 1.70
sys/dev/ic/ndisreg.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.516
sys/dev/hyperv/hypervvar.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.518
sys/arch/amd64/conf/GENERIC: revision 1.519
sys/arch/i386/conf/files.i386: revision 1.400
sys/dev/acpi/vmbus_acpi.c: revision 1.1
sys/dev/hyperv/vmbus.c: revision 1.1
sys/dev/hyperv/vmbus.c: revision 1.2
sys/arch/x86/x86/intr.c: revision 1.144
sys/arch/i386/i386/vector.S: revision 1.83
sys/arch/amd64/conf/files.amd64: revision 1.112

separate RNDIS definitions from urndis(4) for use with Hyper-V NetVSC.

-

Added Microsoft Hyper-V support. It ported from OpenBSD and FreeBSD.
graphical console is not work on Gen.2 VM yet. To use the serial console,
enter "consdev com,0x3f8,115200" on efiboot.

-

Add __diagused.

-

PR/53984: Partial revert of modify lapic_calibrate_timer() in lapic.c r1.69.

-

Update Hyper-V related drivers description.

-

Remove unused definition.

-

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.
NFCI intended.

-

commented out hvkvp entry.

-

fix typo. pointed out by pgoyette@n.o.

-

Use IDTVEC instead of NENTRY for handle_hyperv_hypercall.

-

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.
 1.2.2.1  05-Mar-2019  martin file if_hvn.c was added on branch netbsd-8 on 2019-03-09 17:10:19 +0000
 1.3.2.4  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.2.3  08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.2.2  10-Jun-2019  christos Sync with HEAD
 1.3.2.1  29-May-2019  christos file if_hvn.c was added on branch phil-wifi on 2019-06-10 22:07:09 +0000
 1.4.2.7  04-Feb-2021  martin Pull up following revision(s) (requested by nonaka in ticket #1192):

sys/dev/hyperv/if_hvn.c: revision 1.20 (via patch)
sys/dev/hyperv/hvkbd.c: revision 1.7 (via patch)
sys/dev/hyperv/vmbus.c: revision 1.12 (via patch)

hvkbd(4): Don't wait forever.
vmbus(4): Don't wait forever.
hvn(4): Don't wait forever.
 1.4.2.6  11-Dec-2020  martin Pull up following revision(s) (requested by nonaka in ticket #1146):

sys/dev/hyperv/if_hvn.c: revision 1.19

hvn(4): fix unable to ifconfig up/down.
 1.4.2.5  26-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #484):

sys/dev/hyperv/if_hvn.c: revision 1.11

hvn(4): Fix incorrect ident when waiting for NVS command response.
 1.4.2.4  25-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #480):

sys/dev/hyperv/hvs.c: revision 1.3
sys/dev/hyperv/if_hvn.c: revision 1.10

hvs(4), hvn(4): Set correct size for bus_dmamap_sync(9).
 1.4.2.3  24-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #464):

sys/dev/hyperv/if_hvn.c: revision 1.8
sys/dev/hyperv/if_hvn.c: revision 1.9
sys/dev/hyperv/hvkbd.c: revision 1.5
sys/dev/hyperv/hvkbd.c: revision 1.6
sys/dev/hyperv/vmbus.c: revision 1.5

vmbus(4), hvn(4), hvkbd(4): Fixed wait time for tsleep(9).
hvn(4), hvkbd(4): Only need to poll when cold.
 1.4.2.2  18-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #441):

sys/dev/hyperv/if_hvn.c: revision 1.7
sys/dev/pci/if_mcx.c: revision 1.6

Fixed incorrect m_defrag return value check.
 1.4.2.1  16-Nov-2019  martin Pull up following revision(s) (requested by nonaka in ticket #428):

sys/dev/hyperv/if_hvn.c: revision 1.6
sys/dev/hyperv/hvkbd.c: revision 1.4

hvn(4), hvkbd(4): No need to call vmbus_channel_setdeferred().

These devices do not perform batch reading.
 1.15.2.1  29-Feb-2020  ad Sync with head.
 1.18.2.2  03-Apr-2021  thorpej Sync with HEAD.
 1.18.2.1  14-Dec-2020  thorpej Sync w/ HEAD.
 1.20.4.1  17-Jun-2021  thorpej Sync w/ HEAD.
 1.27.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed