memory/iommu: Add get_attr()
This adds get_attr() to IOMMUMemoryRegionClass, like iommu_ops::domain_get_attr in the Linux kernel. This defines the first attribute - IOMMU_ATTR_SPAPR_TCE_FD - which will be used between the pSeries machine and VFIO-PCI. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
20e0d439a6
commit
f1334de60b
@ -190,6 +190,10 @@ struct MemoryRegionOps {
|
|||||||
const MemoryRegionMmio old_mmio;
|
const MemoryRegionMmio old_mmio;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum IOMMUMemoryRegionAttr {
|
||||||
|
IOMMU_ATTR_SPAPR_TCE_FD
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct IOMMUMemoryRegionClass {
|
typedef struct IOMMUMemoryRegionClass {
|
||||||
/* private */
|
/* private */
|
||||||
struct DeviceClass parent_class;
|
struct DeviceClass parent_class;
|
||||||
@ -210,6 +214,10 @@ typedef struct IOMMUMemoryRegionClass {
|
|||||||
IOMMUNotifierFlag new_flags);
|
IOMMUNotifierFlag new_flags);
|
||||||
/* Set this up to provide customized IOMMU replay function */
|
/* Set this up to provide customized IOMMU replay function */
|
||||||
void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier);
|
void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier);
|
||||||
|
|
||||||
|
/* Get IOMMU misc attributes */
|
||||||
|
int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr,
|
||||||
|
void *data);
|
||||||
} IOMMUMemoryRegionClass;
|
} IOMMUMemoryRegionClass;
|
||||||
|
|
||||||
typedef struct CoalescedMemoryRange CoalescedMemoryRange;
|
typedef struct CoalescedMemoryRange CoalescedMemoryRange;
|
||||||
@ -926,6 +934,20 @@ void memory_region_iommu_replay_all(IOMMUMemoryRegion *iommu_mr);
|
|||||||
void memory_region_unregister_iommu_notifier(MemoryRegion *mr,
|
void memory_region_unregister_iommu_notifier(MemoryRegion *mr,
|
||||||
IOMMUNotifier *n);
|
IOMMUNotifier *n);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* memory_region_iommu_get_attr: return an IOMMU attr if get_attr() is
|
||||||
|
* defined on the IOMMU.
|
||||||
|
*
|
||||||
|
* Returns 0 if succeded, error code otherwise.
|
||||||
|
*
|
||||||
|
* @iommu_mr: the memory region
|
||||||
|
* @attr: the requested attribute
|
||||||
|
* @data: a pointer to the requested attribute data
|
||||||
|
*/
|
||||||
|
int memory_region_iommu_get_attr(IOMMUMemoryRegion *iommu_mr,
|
||||||
|
enum IOMMUMemoryRegionAttr attr,
|
||||||
|
void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* memory_region_name: get a memory region's name
|
* memory_region_name: get a memory region's name
|
||||||
*
|
*
|
||||||
|
13
memory.c
13
memory.c
@ -1922,6 +1922,19 @@ void memory_region_notify_iommu(IOMMUMemoryRegion *iommu_mr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int memory_region_iommu_get_attr(IOMMUMemoryRegion *iommu_mr,
|
||||||
|
enum IOMMUMemoryRegionAttr attr,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_GET_CLASS(iommu_mr);
|
||||||
|
|
||||||
|
if (!imrc->get_attr) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return imrc->get_attr(iommu_mr, attr, data);
|
||||||
|
}
|
||||||
|
|
||||||
void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client)
|
void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client)
|
||||||
{
|
{
|
||||||
uint8_t mask = 1 << client;
|
uint8_t mask = 1 << client;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user