Skip to content
  • Jean-Philippe Brucker's avatar
    virtio: Support drivers that don't negotiate VIRTIO_RING_F_EVENT_IDX · b7af514c
    Jean-Philippe Brucker authored
    Bad things happen when the VIRTIO_RING_F_EVENT_IDX feature isn't
    negotiated and we try to write the avail_event anyway. SeaBIOS, for
    example, stores internal data where avail_event should be [1].
    
    Technically the Virtio specification doesn't forbid the device from
    writing the avail_event, and it's up to the driver to reserve space for it
    ("the transitional driver [...] MUST allocate the total number of bytes
    for the virtqueue according to [formula containing the avail event]").
    
    But it doesn't hurt us to avoid writing avail_event, and kvmtool needs
    changes for interrupt suppression anyway, in order to comply with the
    spec. Indeed Virtio 1.0 cs04 says, in 2.4.7.2 Device Requirements:
    Virtqueue Interrupt Suppression:
    """
    If the VIRTIO_F_EVENT_IDX feature bit is not negotiated:
    * The device MUST ignore the used_event value.
    * After the device writes a descriptor index into the used ring:
      - If flags is 1, the device SHOULD NOT send an interrupt.
    """
    
    So let's do that.
    
    [1] https://patchwork.kernel.org/patch/10038931/
    
    
    
    Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    b7af514c