summaryrefslogtreecommitdiff
path: root/sys/dev/pv
AgeCommit message (Collapse)Author
2024-05-17vio: Fix signal handling and locking in sysctl pathStefan Fritsch
Commits f0b002d01d5 "Release the netlock when sleeping for control messages in in vioioctl()" and 126b881f71 "Insert a workaround for per-ifp ioctl being called w/o NET_LOCK()." in vio(4) fixed a deadlock but may cause a crash with a protection fault trap if addresses are added/removed concurrently. The actual issue is that signals are not handled correctly while sleeping. After a signal, there is a race condition where sc_ctrl_inuse is first set to FREE and then the interrupt handler sets it to DONE, causing a hang in the next vio_wait_ctrl() call. To fix it: * Revert the NET_LOCK unlocking work-around. * Remove PCATCH from the sleep call when we wait for control queue, avoiding the race with vio_ctrleof(). To ensure that we don't hang forever, use a 5 second timeout. * If the timeout is hit, or if the hypervisor has set the DEVICE_NEEDS_RESET status bit, do not try to use the control queue until the next ifconfig down/up which resets the device. * In order to allow reading the device status from device drivers, add a new interface to the virtio transport drivers. * Avoid a crash if there is outgoing traffic while doing ifconfig down. OK bluhm@
2024-05-14remove prototypes with no matching functionJonathan Gray
2024-05-13remove prototypes with no matching functionJonathan Gray
ok mpi@
2024-05-07Additional check for TSO packets with 0 MSS.Jan Klemkow
Tested by bluhm ok bluhm@
2024-04-10Implement TCP Segmentation Offload for vio(4)Jan Klemkow
Tested by Brian Conway and bluhm With tweaks from bluhm ok bluhm
2024-02-14Check IP length in ether_extract_headers().Alexander Bluhm
For LRO with ix(4) it is necessary to detect ethernet padding. Extract ip_len and ip6_plen from the mbuf and provide it to the drivers. Add extended sanitity checks, like IP packet is shorter than TCP header. This prevents offloading to network hardware with bougus packets. Also iphlen of extracted headers contains header length for IPv4 and IPv6, to make code in drivers simpler. OK mglocker@
2024-02-13Analyse header layout in ether_extract_headers().Alexander Bluhm
Several drivers need IPv4 header length and TCP offset for checksum offload, TSO and LRO. Accessing these fields directly caused crashes on sparc64 due to misaligned access. It cannot be guaranteed that IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1 assumes that bit fields can be accessed with 32 bit load instructions. Use memcpy() in ether_extract_headers() to get the bits from IPv4 and TCP header and store the header length in struct ether_extracted. From there network drivers can esily use it without caring about alignment and bit shift. Do some sanity checks with the length values to prevent that invalid values from evil packets get stored into hardware registers. If check fails, clear the pointer to the header to hide it from the driver. Add debug prints that help to figure out the reason for bad packets and provide information when debugging drivers. OK mglocker@
2024-01-04Revert previous. splx(9) can call kvp_get_ip_info() from any place withVitaliy Makkoveev
netlock held and cause recursive lock acquisition issue.
2023-12-20vio(4): checksum offloading for TCP/UDP in IPv6 PacketsJan Klemkow
ok sf@
2023-12-11vio(4): simplify mbuf parsing with ether_extract_headers()Jan Klemkow
ok sf@
2023-12-09vio(4) add recv TCP/UDP checksum offloadingJan Klemkow
tested on Linux/KVM tested on proxmox and vultr by florian ok florian
2023-12-02virtio: Fix handling of feature bits >= 32Stefan Fritsch
Fix handling of feature bits >= 32. This does not yet affect any driver as no high feature bit besides VERSION_1 is used, and that one has special handling. Also, with VIRTIO_DEBUG, simply walk through all transport and device feature names, so that we don't need to adjust the if clause whenever the standard introduces new transport features. ok jan@ bluhm@
2023-11-10Make ifq and ifiq interface MP safe.Alexander Bluhm
Rename ifq_set_maxlen() to ifq_init_maxlen(). This function neither uses WRITE_ONCE() nor a mutex and is called before the ifq mutex is initialized. The new name expresses that it should be used only during interface attach when there is no concurrency. Protect ifq_len(), ifq_empty(), ifiq_len(), and ifiq_empty() with READ_ONCE(). They can be used without lock as they only read a single integer. OK dlg@
2023-11-08Allow Xen to use backing store devices with 4K-byte sectors.Kenneth R Westerback
Problem reported and much testing by Christian Kujau. Thanks! Roughly equivalent to bouyer@NetBSD changes prompted by Christian. ok mlarkin@ dlg@
2023-09-26Use shared netlock to protect ifnet data within vmt_tclo_broadcastip().Vitaliy Makkoveev
Execute vmt_tclo_tick() timeout handler in process context to allow context switch within vmt_tclo_broadcastip(). ok yasuoka
2023-09-23Use shared netlock to protect if_list and ifa_list walkthrough and ifnetVitaliy Makkoveev
data access within kvp_get_ip_info(). ok bluhm
2023-07-28Initialize handlers with NULL, not 0.Dave Voutila
2023-07-07The per-VQ MSI-X interrupt handler needs to sync DMA mappings in thePatrick Wildt
same way that the shared interrupt handler does. This is one of the requirements of virtio_dequeue(), as specified in its comment above. Without the DMA sync, it will not see a new entry on the ring and return. Since the interrupt is edge-triggered there won't be another one and we'll get stuck. ok dv@
2023-07-05The hypercall page populated with instructions by the hypervisor is not IBTAnton Lindqvist
compatible due to lack of endbr64. Replace the indirect call with a new hv_hypercall_trampoline() routine which jumps to the hypercall page without any indirection. Allows me to boot OpenBSD using Hyper-V on Windows 11 again. ok guenther@
2023-07-03typofix lladdr in function names; OK deraadt janKlemens Nanni
2023-05-29virtio: Set DRIVER_OK earlierStefan Fritsch
The DRIVER_OK bit must be set before using any virt-queues. To allow virtio device drivers to use the virt-queues in their attach functions, set the bit there and not in the virtio transport attach function. Only vioscsi and viogpu really need this, but let's only have one standard way to do this. Noticed because of hangs with vioscsi on qemu/windows and in the Oracle cloud. With much debugging help by Aaron Mason. Also revert vioscsi.c 1.31 "Temporarily workaround double calls into vioscsi_req_done()" ok krw@
2023-04-27Temporarily workaround double calls into vioscsi_req_done()Kenneth R Westerback
causing NULL de-reference. Reported, initial patch and tests by Antun Matanovic. Thanks! ok miod@
2023-04-23Stop setting ri->ri_bs to prevent a panic caused by rasops accessing itsPatrick Wildt
uninitialized content. When we rasops_init() with RI_VCONS, a new screen is allocated. If ri->ri_bs is set, this will be copied. Otherwise a new one will be allocated and filled with ASCII spaces. Copying the ri->ri_bs is useful in case we have an early console which contents we want to keep. As we do not have an early console here, there's no point in setting it at the moment. With this my Hetzner arm64 VM doesn't panic anymore. ok jcs@ kettenis@
2023-04-20add viogpu, a VirtIO GPU driverJoshua Stein
works enough to get a console on qemu with more work to come from others feedback from miod ok patrick
2023-04-11fix double words in commentsJonathan Gray
feedback and ok jmc@ miod, ok millert@
2023-02-04timecounting: remove incomplete PPS supportScott Soule Cheloha
The timecounting code has had stubs for pulse-per-second (PPS) polling since it was imported in 2004. At this point it seems unlikely that anyone is going to finish adding PPS support, so let's remove the stubs: - Delete the dead tc_poll_pps() call from tc_windup(). - Remove all tc_poll_pps symbols from the kernel. Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2 ok miod@
2023-01-07The maximum length of the value is extended to 64k bytes.ASOU Masato
ok yasuoka
2022-12-28Change space character to TAB.ASOU Masato
ok tb mlarkin giovanni
2022-12-26Add close vmt.ASOU Masato
2022-12-08Fix pvbus to specify M_ZERO properly.YASUOKA Masahiko
ok kn mvs mlarkin asou deraadt
2022-12-03Modify vmt to use the buffer allocated in pvbus directly instead ofYASUOKA Masahiko
the buffer in the vmt softc when doing RPC for PVBUSIOC_KV{READ|WRITE} ioctl. ok asou
2022-11-10Return error number instead of call panic().ASOU Masato
ok mpi@
2022-09-08Rename global ifnet TAILQKlemens Nanni
Naming the list like the struct itself makes for awful grepping. Call the global variable "ifnetlist" from now on. There used to be kvm(3) consumers in base picking up this symbol, but those have long been converted to other interfaces. A few potential ports users remain, same deal as sys/net/if_var.h r1.116 "Remove struct ifnet's unused if_switchport member": they get bumped. Previous users pointed out by deraadt OK bluhm
2022-08-29use ansi volatile keyword, not __volatile__Jonathan Gray
ok miod@ guenther@
2022-08-25amd64, i386: use delay_init() instead of writing delay_func by handScott Soule Cheloha
Now that we have delay_init(), use it in all the places where we currently set delay_func by hand. lapic_delay() is great: 3000. hv_delay() is needed before we set up lapic_delay() on Hyper-V guests: 4000. tsc_delay() is better than lapic_delay() and (probably?) hv_delay(): 5000. We may bump hv_delay's quality value up over that of tsc_delay() in a future patch. It's a little ambiguous whether hv_delay() causes a VM exit. Idea and patch from jsg@. With tons of input, research and advice from jsg@. Link: https://marc.info/?l=openbsd-tech&m=166053729104923&w=2 ok mlarkin@ jsg@
2022-04-16constify SCSI adapter entry pointsChristian Weisgerber
ok krw@
2022-03-23KASSERT() that an id read from a descriptor is valid before using itJonathan Gray
as an index into an array. Reported by Demi Marie Obenour of Invisible Things Lab. feedback and ok jmatthew@
2022-03-07vio(4): use NULL instead of 0 with sc_{rx,tx}_mbuf pointer array.Dave Voutila
ok millert@, deraadt@
2022-01-09spellingJonathan Gray
feedback and ok tb@ jmc@ ok ratchov@
2021-11-05Constify struct cfattach.Martin Pieuchot
2021-10-24pretty & normalize the cfdriver declTheo de Raadt
2021-08-31When running on Hyper-V, make use of its timecounter as delay func in casePatrick Wildt
we're still using the i8254 for that. On Hyper-V Gen 2 VMs there is no i8254 we can trust, so we need some kind of fallback, especially if there is no TSC either. Discussed with the hackroom ok kettenis@
2021-07-26fix an mbuf leak with m_len 0 mbufsJonathan Gray
from niklas@ via mikeb@
2021-07-26Add mtx_enter/mtx_leave in kvp_pool_keys().asou
ok mikeb
2021-06-11Drop received packets unless IFF_RUNNING is set. When hvn(4) attachesPatrick Wildt
it sends commands and waits for replies to come back in. The receive pipe seems to contain both command completions and data packets. When waiting for command completion during hvn(4) attach, it's possible for packets to show up as well. We shouldn't call if_input() if hvn(4) is not set up, so drop them when we're not running. ok mikeb@
2021-05-16panic does not require a \n at the end. When one is provided, it looks wrong.Theo de Raadt
2021-02-23timecounting: use C99-style initialization for all timecounter structscheloha
The timecounter struct is large and I think it may change in the future. Changing it later will be easier if we use C99-style initialization for all timecounter structs. It also makes reading the code a bit easier. For reasons I cannot explain, switching to C99-style initialization sometimes changes the hash of the resulting object file, even though the resulting struct should be the same. So there is a binary change here, but only sometimes. No behavior should change in either case. I can't compile-test this everywhere but I have been staring at the diff for days now and I'm relatively confident this will not break compilation. Fingers crossed. ok gnezdo@
2021-02-11Initialize var since it's used in a condition a little bit afterwards.Ricardo Mestre
CID 1501713 ok jmatthew@
2021-01-15Report full IP address information to the host. Contrary to what I wroteJonathan Matthew
here 10 years ago, xdr isn't scary at all. ok dlg@
2021-01-13Make vm_rpc_send_rpci_tx_buf() use the buffer passed in, not the bufferJonathan Matthew
allocated as part of the softc, though it's always been the same buffer so far. ok dlg@