mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-14 21:52:18 -06:00

The vring.c code currently assumes that guest and host endianness match, which is not true for a number of cases: - emulating targets with a different endianness than the host - bi-endian targets, where the correct endianness depends on the virtio device - upcoming support for the virtio-1 standard mandates little-endian accesses even for big-endian targets and hosts Make sure to use accessors that depend on the virtio device. Note that dataplane now needs to be built per-target. Cc: Stefan Hajnoczi <stefanha@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Fam Zheng <famz@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Tested-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1422289602-17874-2-git-send-email-cornelia.huck@de.ibm.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
49 lines
1.7 KiB
C
49 lines
1.7 KiB
C
/* Copyright 2012 Red Hat, Inc. and/or its affiliates
|
|
* Copyright IBM, Corp. 2012
|
|
*
|
|
* Based on Linux 2.6.39 vhost code:
|
|
* Copyright (C) 2009 Red Hat, Inc.
|
|
* Copyright (C) 2006 Rusty Russell IBM Corporation
|
|
*
|
|
* Author: Michael S. Tsirkin <mst@redhat.com>
|
|
* Stefan Hajnoczi <stefanha@redhat.com>
|
|
*
|
|
* Inspiration, some code, and most witty comments come from
|
|
* Documentation/virtual/lguest/lguest.c, by Rusty Russell
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2.
|
|
*/
|
|
|
|
#ifndef VRING_H
|
|
#define VRING_H
|
|
|
|
#include "qemu-common.h"
|
|
#include "hw/virtio/virtio_ring.h"
|
|
#include "hw/virtio/virtio.h"
|
|
|
|
typedef struct {
|
|
MemoryRegion *mr; /* memory region containing the vring */
|
|
struct vring vr; /* virtqueue vring mapped to host memory */
|
|
uint16_t last_avail_idx; /* last processed avail ring index */
|
|
uint16_t last_used_idx; /* last processed used ring index */
|
|
uint16_t signalled_used; /* EVENT_IDX state */
|
|
bool signalled_used_valid;
|
|
bool broken; /* was there a fatal error? */
|
|
} Vring;
|
|
|
|
/* Fail future vring_pop() and vring_push() calls until reset */
|
|
static inline void vring_set_broken(Vring *vring)
|
|
{
|
|
vring->broken = true;
|
|
}
|
|
|
|
bool vring_setup(Vring *vring, VirtIODevice *vdev, int n);
|
|
void vring_teardown(Vring *vring, VirtIODevice *vdev, int n);
|
|
void vring_disable_notification(VirtIODevice *vdev, Vring *vring);
|
|
bool vring_enable_notification(VirtIODevice *vdev, Vring *vring);
|
|
bool vring_should_notify(VirtIODevice *vdev, Vring *vring);
|
|
int vring_pop(VirtIODevice *vdev, Vring *vring, VirtQueueElement *elem);
|
|
void vring_push(VirtIODevice *vdev, Vring *vring, VirtQueueElement *elem,
|
|
int len);
|
|
|
|
#endif /* VRING_H */
|