VirtualBox

Changeset 98063 in vbox for trunk/src/VBox/Devices/VirtIO


Ignore:
Timestamp:
Jan 12, 2023 3:01:04 PM (2 years ago)
Author:
vboxsync
Message:

Devices/Virtio,Devices/DevVirtioNet_1_0: Additional fixes for the virtio-net device implementation, don't reset the shadow index counters in the virtq structure when it is being attached because the guest might have used the queues before setting the DRIVER_OK flag (FreeBSD's legacy virtio-net driver included up to version 12.3 and pfSense 2.6.0). Also add a device reset callback to properly reset the device state, avoiding the RX code to work on stale data overwriting random guest memory. Some style fixes, ticketref:21201

Location:
trunk/src/VBox/Devices/VirtIO
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VirtIO/VirtioCore.cpp

    r97530 r98063  
    590590    PVIRTQUEUE pVirtq = &pVirtio->aVirtqueues[uVirtq];
    591591    pVirtq->uVirtq = uVirtq;
    592     pVirtq->uAvailIdxShadow = 0;
    593     pVirtq->uUsedIdxShadow  = 0;
    594592    pVirtq->fUsedRingEvent = false;
    595593    pVirtq->fAttached = true;
     
    10141012                    ("Guest driver not in ready state.\n"), VERR_INVALID_STATE);
    10151013
    1016     Log6Func(("    Copying device data to %s, [desc:%u used ring:%u]\n",
     1014    Log6Func(("    Copying device data to %s, [desc:%u -> used ring:%u]\n",
    10171015              VIRTQNAME(pVirtio, uVirtq), pVirtqBuf->uHeadIdx, pVirtq->uUsedIdxShadow));
    10181016
     
    11611159            ("Guest driver not in ready state.\n"), VERR_INVALID_STATE);
    11621160
    1163     Log6Func(("    Sync %s used ring (%u idx)\n",
     1161    Log6Func(("    Sync %s used ring (%u -> idx)\n",
    11641162                        pVirtq->szName, pVirtq->uUsedIdxShadow));
    11651163
     
    13531351    pVirtioCC->pfnStatusChanged(pVirtio, pVirtioCC, 0 /* fDriverOk */);
    13541352    virtioResetDevice(pDevIns, pVirtio);
     1353}
     1354
     1355DECLHIDDEN(void) virtioCoreR3ResetDevice(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC)
     1356{
     1357    virtioGuestR3WasReset(pDevIns, pVirtio, pVirtioCC);
    13551358}
    13561359#endif /* IN_RING3 */
  • trunk/src/VBox/Devices/VirtIO/VirtioCore.h

    r96407 r98063  
    549549
    550550/**
     551 * Resets the device state upon a VM reset for instance.
     552 *
     553 * @returns nothing.
     554 * @param   pVirtio     Pointer to the virtio state.
     555 *
     556 * @note Calls back into the upper device when the status changes.
     557 */
     558DECLHIDDEN(void) virtioCoreR3ResetDevice(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC);
     559
     560/**
    551561 * 'Attaches' host device-specific implementation's queue state to host VirtIO core
    552562 * virtqueue management infrastructure, informing the virtio core of the name of the
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette