Page MenuHomeFreeBSD

aokblast (ShengYi Hung)
AoK_Blast

Projects (2)

User Details

User Since
Jun 21 2022, 7:17 PM (230 w, 2 d)

Recent Activity

Sat, Nov 14

aokblast updated the diff for D57364: bhyve: Implement virtio 1.0.

update:

Sat, Nov 14, 9:21 PM
aokblast added a comment to D57364: bhyve: Implement virtio 1.0.

Also, packaed queue is on my stash list but I forget to create diff. I will tidy up the patch and push to phab.

Sat, Nov 14, 9:09 PM
aokblast added a comment to D57364: bhyve: Implement virtio 1.0.

Thanks for working on this. We need virtio 1.0 in bhyve as well: hyperMAC (https://github.com/keelos-dev/hyperMAC), our port of bhyve to macOS's Hypervisor.framework, runs Windows 11 on arm64, whose virtio drivers cannot use the I/O BAR, and it carries a transitional implementation of its own (vm/bhyve/patches/upstream/0018-virtio-modern.patch there). Rather than open a competing review, I tested this stack on top of main (7cb4d4dfd) in a nested FreeBSD host.

To build it on main I needed two small changes, plus a rebase of the virtio-scsi hunk in D57365 (vtscsi_vi_consts moved):

  • pci_emul_alloc_bar() returns void now, so error = pci_emul_alloc_bar(...) in the modern BAR setup no longer compiles (the build failure mentioned above).
  • With WITH_BHYVE_SNAPSHOT the snapshot code saves vq->vq_avail_wrap and vq->vq_used_wrap, which struct vqueue_info does not have. Packed queues are not implemented, so I dropped the two lines.

One real problem: vi_notify_cfg_write() does not check vq_ring_ready() the way the legacy VIRTIO_PCI_QUEUE_NOTIFY path does. A FreeBSD main guest with -s 7,virtio-console kills bhyve with SIGSEGV in pci_vtcon_notify_rx() -> vq_kick_disable() (vq_used is NULL): vtcon notifies its control receive queue during attach, and FreeBSD's modern transport writes queue_enable only later, in vtpci_modern_setup_interrupts(). Since the guest can crash bhyve this way, I think the device has to ignore the notification whatever the driver does:

 		vq = &vs->vs_queues[qidx];
+		if (!vq_ring_ready(vq))
+			return;
 		if (vq->vq_notify != NULL)

With these three changes everything I tried passed:

  • FreeBSD main guest (virtio-blk, virtio-net, virtio-rnd, virtio-console): all four attach as "VirtIO PCI (modern)" with Version1 negotiated; 256 MB written to vtbd0 and read back with the same MD5, 50/50 pings over vtnet0; with MSI-X and with MSI (hw.virtio.pci.disable_msix=1).
  • The same guest with hw.virtio.pci.transitional=0 drives the transitional devices through the legacy interface: same results.
  • Debian 13 (Linux 6.12, UEFI): virtio-pci binds the modern interface for blk and net; 128 MB written to vda and read back with the same MD5, 30/30 pings.
  • WITH_BHYVE_SNAPSHOT: checkpoint of the FreeBSD guest in modern mode, bhyve killed, restored: pings and disk writes work after the restore (virtio-console left out: it has no snapshot support in main).

A question about virtio-net: once VIRTIO_F_VERSION_1 is negotiated the header is always 12 bytes (virtio 1.0 section 5.1.6, num_buffers is present whether or not VIRTIO_NET_F_MRG_RXBUF is), but pci_vtnet_neg_features() still uses 10 bytes when MRG_RXBUF is not negotiated. FreeBSD and Linux always take MRG_RXBUF, so I could not hit it, but EDK2's VirtioNetDxe negotiates VERSION_1 and never MRG_RXBUF (OvmfPkg/VirtioNetDxe/SnpInitialize.c), so UEFI network boot over a modern virtio-net would see misaligned frames. hyperMAC's version does this in pci_vtnet_neg_features():

	if (negotiated_features & VIRTIO_NET_F_MRG_RXBUF) {
		sc->vhdrlen = sizeof(struct virtio_net_rxhdr);
		sc->rx_merge = 1;
-	} else {
+	} else if (negotiated_features & VIRTIO_F_VERSION_1) {
+		sc->vhdrlen = sizeof(struct virtio_net_rxhdr);
+		sc->rx_merge = 0;
+	} else {

plus num_buffers = 1 in the header of each received frame in that case (5.1.6.3.1: without MRG_RXBUF the device MUST set it to 1; with rx_merge == 0 nothing writes it now, so it stays 0 when the backend has no vnet header; hyperMAC misses that part as well). Not tested with EDK2 here.

Sat, Nov 14, 9:08 PM
aokblast requested review of D61582: bhyve/pci_virtio_net: Fix modern virtio header handling.
Sat, Nov 14, 9:07 PM
aokblast updated the diff for D57364: bhyve: Implement virtio 1.0.

Fix build error

Sat, Nov 14, 9:07 PM
aokblast committed rG3b795a9b0be5: xhci: Enlarge total transfer number.
Sat, Nov 14, 8:55 PM
aokblast closed D61246: xhci: Enlarge total transfer number.
Sat, Nov 14, 8:55 PM
aokblast committed rGf8a67d6ff5e7: xhci: Map stream id to occupied slot.
Sat, Nov 14, 8:55 PM
aokblast closed D61247: xhci: Map stream id to occupied slot.
Sat, Nov 14, 8:55 PM
Herald added a reviewer for D55592: acpi: Add acpi_fan: olce.

cc @seuros

Sat, Nov 14, 6:40 PM

Mon, Nov 9

aokblast accepted D61253: Implement pthread_mutex_clocklock(3) and pthread_rwlock_clock{wr,rd}lock(3) from POSIX 2024.
Mon, Nov 9, 8:04 PM
aokblast accepted D61343: explain bumping locklevel in pshared locks.
Mon, Nov 9, 8:03 PM
aokblast abandoned D61215: libthr: Guard every key insertion on pshared cache bump.

If we all agree that pshare can be relaxed to not async signal safe. Let's drop his patch now!

Mon, Nov 9, 8:02 PM
aokblast added inline comments to D61253: Implement pthread_mutex_clocklock(3) and pthread_rwlock_clock{wr,rd}lock(3) from POSIX 2024.
Mon, Nov 9, 12:54 AM
aokblast added inline comments to D61253: Implement pthread_mutex_clocklock(3) and pthread_rwlock_clock{wr,rd}lock(3) from POSIX 2024.
Mon, Nov 9, 12:54 AM
aokblast added a comment to D61215: libthr: Guard every key insertion on pshared cache bump.
In D61215#1404928, @kib wrote:

Using pthread locking primitives in signal handler is UB for very good reason. We do not block signals around locks. Then, signal delivery might interrupt either locked region (causing app to recurse on its locks) or the locking code itself (causing libthr to operate on the inconsistent lock state). The pshared component is just a part of the lock state, and it is not async signal safe.

So trying to add the safety for single bit of it does not seem useful.

Mon, Nov 9, 12:46 AM

Sat, Nov 7

aokblast added a comment to D61215: libthr: Guard every key insertion on pshared cache bump.
In D61215#1404148, @kib wrote:
In D61215#1403613, @kib wrote:

Why do we need this? Is there a function that uses pshared and required to be async signal safe?

If indeed we need this (I doubt), then it is better to use THR_CRITICAL_ENTER() around.

This is found by @markj's AI bot. And yes, we need to be signal safe I think. A signal can contend with process itself over pshared_cache_insert.

Still, why is it needed? What are the async-signal-safe functions that could call into pshared?

Sat, Nov 7, 4:51 AM
aokblast updated the diff for D61215: libthr: Guard every key insertion on pshared cache bump.
  • add test
Sat, Nov 7, 4:48 AM
aokblast accepted D61278: xhci: only set the slot context parent hub fields on xHCI 1.2.
Sat, Nov 7, 4:29 AM · drivers, USB
aokblast added a comment to D61253: Implement pthread_mutex_clocklock(3) and pthread_rwlock_clock{wr,rd}lock(3) from POSIX 2024.

I wonder if we need the same check on Linux side (futex) for umtx_abs_timeout_init.

Sat, Nov 7, 4:28 AM

Thu, Nov 5

aokblast added a reviewer for D61247: xhci: Map stream id to occupied slot: USB.
Thu, Nov 5, 11:56 PM
aokblast added a reviewer for D61246: xhci: Enlarge total transfer number: USB.
Thu, Nov 5, 11:56 PM
aokblast requested review of D61247: xhci: Map stream id to occupied slot.
Thu, Nov 5, 11:55 PM
aokblast requested review of D61246: xhci: Enlarge total transfer number.
Thu, Nov 5, 11:55 PM
aokblast committed rG44eaf36072b7: libc/locale: Check EILSEQ return.
Thu, Nov 5, 11:02 PM
aokblast added a comment to D61215: libthr: Guard every key insertion on pshared cache bump.
In D61215#1403613, @kib wrote:

Why do we need this? Is there a function that uses pshared and required to be async signal safe?

If indeed we need this (I doubt), then it is better to use THR_CRITICAL_ENTER() around.

Thu, Nov 5, 8:15 PM
aokblast abandoned D60282: devel/mold: Bump version to 2.42.1.
Thu, Nov 5, 6:05 PM
aokblast committed rG2734bbbcba3c: libthr: Create landing pad in thr_once in C++ exception.
Thu, Nov 5, 4:03 PM
aokblast closed D61212: libthr: Create landingpad and call dtor in thr_once in C++ exception.
Thu, Nov 5, 4:03 PM
aokblast committed rG71937d8e11a6: libthr: Predict libthr is initialized in _thr_check_init.
Thu, Nov 5, 4:01 PM
aokblast committed rG1e1ce1f6f97b: libthr: Fix whitespace in thr_once.c.
Thu, Nov 5, 4:01 PM
aokblast closed D61213: libthr: Early return in thr_once.
Thu, Nov 5, 4:01 PM
aokblast added a comment to D61212: libthr: Create landingpad and call dtor in thr_once in C++ exception.
In D61212#1403439, @kib wrote:

Does this need to be conditional on _PTHREAD_FORCED_UNWIND (I am not sure)?

Thu, Nov 5, 4:34 AM
aokblast added inline comments to D61213: libthr: Early return in thr_once.
Thu, Nov 5, 4:18 AM
aokblast updated the diff for D61213: libthr: Early return in thr_once.

Reflect kib@'s comment

Thu, Nov 5, 4:14 AM
aokblast requested review of D61215: libthr: Guard every key insertion on pshared cache bump.
Thu, Nov 5, 4:11 AM
aokblast retitled D61212: libthr: Create landingpad and call dtor in thr_once in C++ exception from libthr: Call dtor in thr_once in C++ exception
Thu, Nov 5, 12:36 AM
aokblast added inline comments to D61213: libthr: Early return in thr_once.
Thu, Nov 5, 12:13 AM
aokblast requested review of D61213: libthr: Early return in thr_once.
Thu, Nov 5, 12:13 AM
aokblast requested review of D61212: libthr: Create landingpad and call dtor in thr_once in C++ exception.
Thu, Nov 5, 12:06 AM

Wed, Nov 4

aokblast committed rG7806832f23fb: libthr: Cache recent pshared_key.
Wed, Nov 4, 11:42 PM
aokblast closed D60957: libthr: Cache recent pshared_key.
Wed, Nov 4, 11:42 PM
aokblast added a comment to D60960: libthr: Robust rwlock destory.
In D60960#1402833, @kib wrote:

So what are the benefits of the change?

It does not guarantee that EBUSY is returned, so consumers cannot rely on it (lets ignore portability aspects).
If code is not accurate to not destroy locked rwlock, then perhaps it is also not accurate to check the result of _destroy(). And then the result is a memory leak instead of potential fault on unlock.

I do not object, but also I do not see much benefits.

Wed, Nov 4, 11:14 PM
aokblast updated the diff for D60957: libthr: Cache recent pshared_key.

reflect kib@'s comment

Wed, Nov 4, 11:04 PM
aokblast added a comment to D57322: ls: Support dired mode.
In D57322#1388427, @jrm wrote:

@aokblast Gentle ping. Do you plan to commit this?

Wed, Nov 4, 4:53 AM
aokblast added inline comments to D60957: libthr: Cache recent pshared_key.
Wed, Nov 4, 4:52 AM
aokblast updated the diff for D60957: libthr: Cache recent pshared_key.

Update

Wed, Nov 4, 4:51 AM
aokblast added inline comments to D60960: libthr: Robust rwlock destory.
Wed, Nov 4, 4:33 AM
aokblast updated the diff for D60960: libthr: Robust rwlock destory.

Reflect markj@'s commnent

Wed, Nov 4, 4:32 AM
aokblast committed rGb138d017c704: libc/locale: Check EILSEQ return.
Wed, Nov 4, 4:10 AM
aokblast closed D61151: libc/locale: Check EILSEQ return.
Wed, Nov 4, 4:10 AM

Tue, Nov 3

aokblast committed rG6071292d39ab: libthr: Return EDEADLK if it is held by ourself.
Tue, Nov 3, 6:52 AM
aokblast closed D60959: libthr: Return EDEADLK if it is held by ourself.
Tue, Nov 3, 6:52 AM
aokblast requested review of D61153: libiconv/gbk2k: Handle GB18030SUPP correctly..
Tue, Nov 3, 6:39 AM
aokblast requested review of D61152: libiconv: Respect RFC 3629.
Tue, Nov 3, 6:06 AM
aokblast requested review of D61151: libc/locale: Check EILSEQ return.
Tue, Nov 3, 5:59 AM
aokblast accepted D61127: uchcom(4): validate baud rate in uchcom_pre_param.

Check uchcom code again. I think it is the correct way to detect 0 divident. pre_param is the verifier. So LGTM to me!

Tue, Nov 3, 4:14 AM

Mon, Nov 2

aokblast committed R11:20023fac845f: devel/bear: Update to 4.2.4.
Mon, Nov 2, 4:58 AM
aokblast committed rG5cc08734add2: __FreeBSD_version: Bump for USB 3.1 and 3.2 changes.
Mon, Nov 2, 3:54 AM
aokblast committed rG20b19982545e: usb: support SSP and SSPx2 xHCI.
Mon, Nov 2, 3:03 AM
aokblast committed rGfb470e8f1c58: usb: Add support for SSP and SSPx2 hubs.
Mon, Nov 2, 3:03 AM
aokblast committed rG23ef0bdb48f3: usb: Add SSPlus device capability descriptor.
Mon, Nov 2, 3:03 AM
aokblast committed rG2f79adc28976: usb: Implement usbd_req_get_bos_descriptor helper.
Mon, Nov 2, 3:03 AM
aokblast committed rG1928debe1a47: usb: Add get_ext_port_status helper function.
Mon, Nov 2, 3:03 AM
aokblast committed rGab18352d8f9d: usb: Add usbd_bos_foreach helper.
Mon, Nov 2, 3:03 AM
aokblast closed D52347: usb: support SSP and SSPx2 xHCI.
Mon, Nov 2, 3:03 AM · USB
aokblast committed rG1fe552b036a5: usb: Add extended port status struct.
Mon, Nov 2, 3:03 AM
aokblast closed D57204: usb: Add support for SSP and SSPx2 hubs.
Mon, Nov 2, 3:03 AM · USB
aokblast committed rG85c3bd4595ba: usb: support SSP/SSPx2 devices in all-speed consumers.
Mon, Nov 2, 3:03 AM
aokblast closed D57203: usb: Add SSPlus device capability descriptor.
Mon, Nov 2, 3:03 AM · USB
aokblast closed D57202: usb: Implement usbd_req_get_bos_descriptor helper.
Mon, Nov 2, 3:03 AM · USB
aokblast committed rG65346af4961e: usbdump: Support SSP and SSPx2 speed display.
Mon, Nov 2, 3:03 AM
aokblast closed D57201: usb: Add get_ext_port_status helper function.
Mon, Nov 2, 3:03 AM · USB
aokblast committed rG2802f8d4a0c2: usbconfig: Add SSPx2 support.
Mon, Nov 2, 3:03 AM
aokblast closed D57200: usb: Add extended port status struct.
Mon, Nov 2, 3:03 AM · USB
aokblast closed D57199: usb: Add usb_bos_foreach helper.
Mon, Nov 2, 3:03 AM · USB
aokblast closed D57198: usb: support SSP/SSPx2 devices in all-speed consumers.
Mon, Nov 2, 3:03 AM · USB
aokblast committed rG1a382091363f: libusb: Add SSP and SSPx2 enum support.
Mon, Nov 2, 3:03 AM
aokblast closed D57197: usbdump: Support SSP and SSPx2 speed display.
Mon, Nov 2, 3:03 AM · USB
aokblast closed D57196: usbconfig: Add SSPx2 support.
Mon, Nov 2, 3:03 AM · USB
aokblast committed rG6e575d08a5f5: usb: Add SSP and SSPx2 speed and move USB_*_MAX into enum.
Mon, Nov 2, 3:03 AM
aokblast closed D57195: libusb: Add SSP and SSPx2 enum support.
Mon, Nov 2, 3:03 AM · USB
aokblast closed D57194: usb: Add SSP and SSPx2 speed and move USB_*_MAX into enum.
Mon, Nov 2, 3:03 AM · USB

Sun, Nov 1

aokblast closed D60832: libthr: Robust tryjoin test.

Merged

Sun, Nov 1, 10:16 PM
aokblast committed rGc334757cb920: libthr: Remove deadcode in join_common.
Sun, Nov 1, 10:10 PM
aokblast committed rG8b3f74c15296: libthr: Fix LIBPTHREAD_QUEUE_FIFO range.
Sun, Nov 1, 10:10 PM
aokblast committed rGe3e0f6e7a517: linux: cap mount id to INT_MAX.
Sun, Nov 1, 10:10 PM
aokblast committed rG15ba44617d18: hyperv: Fix single page invalidation path.
Sun, Nov 1, 10:09 PM
aokblast committed rGb2e37d027f10: libthr: Fix some bugs in trylock.
Sun, Nov 1, 10:09 PM
aokblast committed rGb00382555656: libthr: reject count < 0.
Sun, Nov 1, 10:09 PM
aokblast committed rG28093296d9e4: libthr: Do not rely on UB in counter.
Sun, Nov 1, 10:09 PM
aokblast committed rGbd5aaf84d2e6: libthr: Consume error in check_and_init_mutex.
Sun, Nov 1, 10:09 PM
aokblast committed rG6b597a9470ad: uchcom: Set rate to 1 if 0.
Sun, Nov 1, 10:08 PM
aokblast added inline comments to D60957: libthr: Cache recent pshared_key.
Sun, Nov 1, 9:57 PM
aokblast added inline comments to D60960: libthr: Robust rwlock destory.
Sun, Nov 1, 9:40 PM
aokblast added inline comments to D60959: libthr: Return EDEADLK if it is held by ourself.
Sun, Nov 1, 9:36 PM
aokblast updated the diff for D60959: libthr: Return EDEADLK if it is held by ourself.

Reflect markj@'s comment

Sun, Nov 1, 9:35 PM

Thu, Oct 29

aokblast updated the diff for D60959: libthr: Return EDEADLK if it is held by ourself.

Reflect @markj's comment

Thu, Oct 29, 10:24 PM
aokblast added a comment to D57364: bhyve: Implement virtio 1.0.

@andy_omniosce.org Hi. I am wondering whether you are preparing to upstream your 1.0 implementation? If this happens after few years. I think I might want to merge my implementation first. Thanks!

Thu, Oct 29, 8:09 PM
aokblast committed rG6a65632e1a6a: libthr: Add missing include header.
Thu, Oct 29, 7:17 PM