mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
VFIO updates:
- Conversion to tracepoints (Eric Auger) - Fix memory listener address space (Frank Blaschka) - Move to hw/vfio/ and split common vs pci (Eric Auger & Kim Phillips) - Trivial error_report() fixes (Alex Williamson) In addition to enabling S390 with the address space fix and updating to use tracepoints rather than compile time debug, this set of patches moves hw/misc/vfio.c to hw/vfio/ and paves the way for vfio-platform support by splitting common functionality from PCI specific code. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJUmHzfAAoJECObm247sIsiZwwP/1vaePjmppn2iQkaS/eKssYc aHNlQ+zteML0/MMGUsp2d76HinZTStGRAm0yHGQ46Z2XQ+4DT9iARzkferhJKfb9 jPblAg/ek08WqPvv3epXU81qj/sp0n9MjCz7PJPzSXpKngOaBS5vZp4HJt37+2Kk 4I3TzKGEaEoAk84Ba8AKp3xG3TcOdnIsg5Ht2cT20QmrGh0R8tXreGavC+ERpJ5/ 59yIewpxxVNDYttD4bqRwyVPup1rpw/qK824cYFz3PWeFzix4rYg8aujr5BxqC5S BL6WxHbNC75e8vNZ/toEZX41Dj3jRtXVP3ARCbU0h/5oboUZ+j94eVmRejeCkIor G0uJjOT0NTILeq5ZrhGVl7/4reSFyO4EvhF6RDm/913iYJ9xwR1usHyTT3VbUwMh 3xnCHbGskxVrtdOLHd80o6uEycr4goQip8HP6Xg5YLWauoXHi5oAaOSIeyoHR7JH CjnkdmgpSbqBijL+sgAHoRh4hh7hS1sXR4kqeXEdwqZj8be/5v3gb7R/yLlQZYvs zAcE16a7CkTvki0f9uKsU2ZGhDE4AQaofB3EnKGSHvmMtGw6PoEDlZFcxtEjbfkl RUW6FLxXDVp16wTQCckyT9XPAjsqSFXdiqOf25StR9iwiHDB29hK5JNzM9vTUv06 AiNWMlxwEYuHu09FKSYi =CRNj -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20141222.0' into staging VFIO updates: - Conversion to tracepoints (Eric Auger) - Fix memory listener address space (Frank Blaschka) - Move to hw/vfio/ and split common vs pci (Eric Auger & Kim Phillips) - Trivial error_report() fixes (Alex Williamson) In addition to enabling S390 with the address space fix and updating to use tracepoints rather than compile time debug, this set of patches moves hw/misc/vfio.c to hw/vfio/ and paves the way for vfio-platform support by splitting common functionality from PCI specific code. # gpg: Signature made Mon 22 Dec 2014 20:19:43 GMT using RSA key ID 3BB08B22 # gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>" # gpg: aka "Alex Williamson <alex@shazbot.org>" # gpg: aka "Alex Williamson <alwillia@redhat.com>" # gpg: aka "Alex Williamson <alex.l.williamson@gmail.com>" * remotes/awilliam/tags/vfio-update-20141222.0: vfio: Cleanup error_report()s hw/vfio: create common module hw/vfio/pci: use name field in format strings hw/vfio/pci: rename group_list into vfio_group_list hw/vfio/pci: split vfio_get_device hw/vfio/pci: Introduce VFIORegion hw/vfio/pci: handle reset at VFIODevice hw/vfio/pci: add type, name and group fields in VFIODevice hw/vfio/pci: introduce minimalist VFIODevice with fd hw/vfio/pci: generalize mask/unmask to any IRQ index hw/vfio/pci: Rename VFIODevice into VFIOPCIDevice vfio: move hw/misc/vfio.c to hw/vfio/pci.c Move vfio.h into include/hw/vfio vfio: fix adding memory listener to the right address space vfio: migration to trace points Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
03de06dde5
11 changed files with 1547 additions and 1381 deletions
151
include/hw/vfio/vfio-common.h
Normal file
151
include/hw/vfio/vfio-common.h
Normal file
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* common header for vfio based device assignment support
|
||||
*
|
||||
* Copyright Red Hat, Inc. 2012
|
||||
*
|
||||
* Authors:
|
||||
* Alex Williamson <alex.williamson@redhat.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2. See
|
||||
* the COPYING file in the top-level directory.
|
||||
*
|
||||
* Based on qemu-kvm device-assignment:
|
||||
* Adapted for KVM by Qumranet.
|
||||
* Copyright (c) 2007, Neocleus, Alex Novik (alex@neocleus.com)
|
||||
* Copyright (c) 2007, Neocleus, Guy Zana (guy@neocleus.com)
|
||||
* Copyright (C) 2008, Qumranet, Amit Shah (amit.shah@qumranet.com)
|
||||
* Copyright (C) 2008, Red Hat, Amit Shah (amit.shah@redhat.com)
|
||||
* Copyright (C) 2008, IBM, Muli Ben-Yehuda (muli@il.ibm.com)
|
||||
*/
|
||||
#ifndef HW_VFIO_VFIO_COMMON_H
|
||||
#define HW_VFIO_VFIO_COMMON_H
|
||||
|
||||
#include "qemu-common.h"
|
||||
#include "exec/address-spaces.h"
|
||||
#include "exec/memory.h"
|
||||
#include "qemu/queue.h"
|
||||
#include "qemu/notify.h"
|
||||
|
||||
/*#define DEBUG_VFIO*/
|
||||
#ifdef DEBUG_VFIO
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { fprintf(stderr, "vfio: " fmt, ## __VA_ARGS__); } while (0)
|
||||
#else
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { } while (0)
|
||||
#endif
|
||||
|
||||
/* Extra debugging, trap acceleration paths for more logging */
|
||||
#define VFIO_ALLOW_MMAP 1
|
||||
#define VFIO_ALLOW_KVM_INTX 1
|
||||
#define VFIO_ALLOW_KVM_MSI 1
|
||||
#define VFIO_ALLOW_KVM_MSIX 1
|
||||
|
||||
enum {
|
||||
VFIO_DEVICE_TYPE_PCI = 0,
|
||||
};
|
||||
|
||||
typedef struct VFIORegion {
|
||||
struct VFIODevice *vbasedev;
|
||||
off_t fd_offset; /* offset of region within device fd */
|
||||
MemoryRegion mem; /* slow, read/write access */
|
||||
MemoryRegion mmap_mem; /* direct mapped access */
|
||||
void *mmap;
|
||||
size_t size;
|
||||
uint32_t flags; /* VFIO region flags (rd/wr/mmap) */
|
||||
uint8_t nr; /* cache the region number for debug */
|
||||
} VFIORegion;
|
||||
|
||||
typedef struct VFIOAddressSpace {
|
||||
AddressSpace *as;
|
||||
QLIST_HEAD(, VFIOContainer) containers;
|
||||
QLIST_ENTRY(VFIOAddressSpace) list;
|
||||
} VFIOAddressSpace;
|
||||
|
||||
struct VFIOGroup;
|
||||
|
||||
typedef struct VFIOType1 {
|
||||
MemoryListener listener;
|
||||
int error;
|
||||
bool initialized;
|
||||
} VFIOType1;
|
||||
|
||||
typedef struct VFIOContainer {
|
||||
VFIOAddressSpace *space;
|
||||
int fd; /* /dev/vfio/vfio, empowered by the attached groups */
|
||||
struct {
|
||||
/* enable abstraction to support various iommu backends */
|
||||
union {
|
||||
VFIOType1 type1;
|
||||
};
|
||||
void (*release)(struct VFIOContainer *);
|
||||
} iommu_data;
|
||||
QLIST_HEAD(, VFIOGuestIOMMU) giommu_list;
|
||||
QLIST_HEAD(, VFIOGroup) group_list;
|
||||
QLIST_ENTRY(VFIOContainer) next;
|
||||
} VFIOContainer;
|
||||
|
||||
typedef struct VFIOGuestIOMMU {
|
||||
VFIOContainer *container;
|
||||
MemoryRegion *iommu;
|
||||
Notifier n;
|
||||
QLIST_ENTRY(VFIOGuestIOMMU) giommu_next;
|
||||
} VFIOGuestIOMMU;
|
||||
|
||||
typedef struct VFIODeviceOps VFIODeviceOps;
|
||||
|
||||
typedef struct VFIODevice {
|
||||
QLIST_ENTRY(VFIODevice) next;
|
||||
struct VFIOGroup *group;
|
||||
char *name;
|
||||
int fd;
|
||||
int type;
|
||||
bool reset_works;
|
||||
bool needs_reset;
|
||||
VFIODeviceOps *ops;
|
||||
unsigned int num_irqs;
|
||||
unsigned int num_regions;
|
||||
unsigned int flags;
|
||||
} VFIODevice;
|
||||
|
||||
struct VFIODeviceOps {
|
||||
void (*vfio_compute_needs_reset)(VFIODevice *vdev);
|
||||
int (*vfio_hot_reset_multi)(VFIODevice *vdev);
|
||||
void (*vfio_eoi)(VFIODevice *vdev);
|
||||
int (*vfio_populate_device)(VFIODevice *vdev);
|
||||
};
|
||||
|
||||
typedef struct VFIOGroup {
|
||||
int fd;
|
||||
int groupid;
|
||||
VFIOContainer *container;
|
||||
QLIST_HEAD(, VFIODevice) device_list;
|
||||
QLIST_ENTRY(VFIOGroup) next;
|
||||
QLIST_ENTRY(VFIOGroup) container_next;
|
||||
} VFIOGroup;
|
||||
|
||||
void vfio_put_base_device(VFIODevice *vbasedev);
|
||||
void vfio_disable_irqindex(VFIODevice *vbasedev, int index);
|
||||
void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index);
|
||||
void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index);
|
||||
void vfio_region_write(void *opaque, hwaddr addr,
|
||||
uint64_t data, unsigned size);
|
||||
uint64_t vfio_region_read(void *opaque,
|
||||
hwaddr addr, unsigned size);
|
||||
void vfio_listener_release(VFIOContainer *container);
|
||||
int vfio_mmap_region(Object *vdev, VFIORegion *region,
|
||||
MemoryRegion *mem, MemoryRegion *submem,
|
||||
void **map, size_t size, off_t offset,
|
||||
const char *name);
|
||||
void vfio_reset_handler(void *opaque);
|
||||
VFIOGroup *vfio_get_group(int groupid, AddressSpace *as);
|
||||
void vfio_put_group(VFIOGroup *group);
|
||||
int vfio_get_device(VFIOGroup *group, const char *name,
|
||||
VFIODevice *vbasedev);
|
||||
|
||||
extern const MemoryRegionOps vfio_region_ops;
|
||||
extern const MemoryListener vfio_memory_listener;
|
||||
extern QLIST_HEAD(vfio_group_head, VFIOGroup) vfio_group_list;
|
||||
extern QLIST_HEAD(vfio_as_head, VFIOAddressSpace) vfio_address_spaces;
|
||||
|
||||
#endif /* !HW_VFIO_VFIO_COMMON_H */
|
Loading…
Add table
Add a link
Reference in a new issue