Skip to content

Commit 0398498

Browse files
chejianjjren1
authored andcommitted
dm/VBS-U: implement virtio_dev_error
When the device has experienced an error from which it cannot re-cover, DEVICE_NEEDS_RESET is set to the device status register and a config change intr is sent to the guest driver. Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com> Reviewed-by: Hao Li <hao.l.li@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent ce09826 commit 0398498

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

devicemodel/hw/pci/virtio/virtio.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,19 @@ virtio_set_modern_bar(struct virtio_base *base, bool use_notify_pio)
10081008
return rc;
10091009
}
10101010

1011+
void
1012+
virtio_dev_error(struct virtio_base *base)
1013+
{
1014+
if (base->negotiated_caps & VIRTIO_F_VERSION_1) {
1015+
/* see 2.1.2. if DRIVER_OK is set, need to send
1016+
* a device configuration change notification to the driver
1017+
*/
1018+
base->status |= VIRTIO_CR_STATUS_NEEDS_RESET;
1019+
if (base->status & VIRTIO_CR_STATUS_DRIVER_OK)
1020+
virtio_config_changed(base);
1021+
}
1022+
}
1023+
10111024
static struct cap_region {
10121025
uint64_t cap_offset; /* offset of capability region */
10131026
int cap_size; /* size of capability region */

devicemodel/include/virtio.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,19 @@ uint64_t virtio_pci_read(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
841841
void virtio_pci_write(struct vmctx *ctx, int vcpu, struct pci_vdev *dev,
842842
int baridx, uint64_t offset, int size, uint64_t value);
843843

844+
/**
845+
* @brief Indicate the device has experienced an error.
846+
*
847+
* This is called when the device has experienced an error from which it
848+
* cannot re-cover. DEVICE_NEEDS_RESET is set to the device status register
849+
* and a config change intr is sent to the guest driver.
850+
*
851+
* @param base Pointer to struct virtio_base.
852+
*
853+
* @return N/A
854+
*/
855+
void virtio_dev_error(struct virtio_base *base);
856+
844857
/**
845858
* @brief Set modern BAR (usually 4) to map PCI config registers.
846859
*

0 commit comments

Comments
 (0)