[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH qemu v15 10/17] memory: Add reporting of supported
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH qemu v15 10/17] memory: Add reporting of supported page sizes |
Date: |
Wed, 6 Apr 2016 15:52:11 +1000 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Mon, Apr 04, 2016 at 07:33:39PM +1000, Alexey Kardashevskiy wrote:
> Every IOMMU has some granularity which MemoryRegionIOMMUOps::translate
> uses when translating, however this information is not available outside
> the translate context for various checks.
>
> This adds a get_page_sizes callback to MemoryRegionIOMMUOps and
> a wrapper for it so IOMMU users (such as VFIO) can know the actual
> page size(s) used by an IOMMU.
>
> As IOMMU MR represents a guest IOMMU, this uses TARGET_PAGE_SIZE
> as fallback.
>
> This removes vfio_container_granularity() and uses new callback in
> memory_region_iommu_replay() when replaying IOMMU mappings on added
> IOMMU memory region.
>
> Signed-off-by: Alexey Kardashevskiy <address@hidden>
Reviewed-by: David Gibson <address@hidden>
.. with the exception of one nit:
[snip]
> diff --git a/memory.c b/memory.c
> index 95f7209..c37dbc9 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1512,12 +1512,14 @@ void
> memory_region_register_iommu_notifier(MemoryRegion *mr, Notifier *n)
> notifier_list_add(&mr->iommu_notify, n);
> }
>
> -void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n,
> - hwaddr granularity, bool is_write)
> +void memory_region_iommu_replay(MemoryRegion *mr, Notifier *n, bool is_write)
> {
> - hwaddr addr;
> + hwaddr addr, granularity;
> IOMMUTLBEntry iotlb;
>
> + g_assert(mr->iommu_ops && mr->iommu_ops->get_page_sizes);
> + granularity = (hwaddr)1 << ctz64(mr->iommu_ops->get_page_sizes(mr));
So here, replay requires that the get_page_sizes() callback be
populated. However, if you move memory_region_iommu_get_page_sizes()
just above this, you can use that and have the replay fall back to
TARGET_PAGE_SIZE as well.
> for (addr = 0; addr < memory_region_size(mr); addr += granularity) {
> iotlb = mr->iommu_ops->translate(mr, addr, is_write);
> if (iotlb.perm != IOMMU_NONE) {
> @@ -1544,6 +1546,15 @@ void memory_region_notify_iommu(MemoryRegion *mr,
> notifier_list_notify(&mr->iommu_notify, &entry);
> }
>
> +uint64_t memory_region_iommu_get_page_sizes(MemoryRegion *mr)
> +{
> + assert(memory_region_is_iommu(mr));
> + if (mr->iommu_ops && mr->iommu_ops->get_page_sizes) {
> + return mr->iommu_ops->get_page_sizes(mr);
> + }
> + return TARGET_PAGE_SIZE;
> +}
> +
> void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client)
> {
> uint8_t mask = 1 << client;
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature
- [Qemu-ppc] [PATCH qemu v15 00/17] spapr: vfio: Enable Dynamic DMA windows (DDW), Alexey Kardashevskiy, 2016/04/04
- [Qemu-ppc] [PATCH qemu v15 03/17] vfio: Check that IOMMU MR translates to system address space, Alexey Kardashevskiy, 2016/04/04
- [Qemu-ppc] [PATCH qemu v15 01/17] memory: Fix IOMMU replay base address, Alexey Kardashevskiy, 2016/04/04
- [Qemu-ppc] [PATCH qemu v15 11/17] vfio: spapr: Add SPAPR IOMMU v2 support (DMA memory preregistering), Alexey Kardashevskiy, 2016/04/04
- [Qemu-ppc] [PATCH qemu v15 02/17] vmstate: Define VARRAY with VMS_ALLOC, Alexey Kardashevskiy, 2016/04/04
- [Qemu-ppc] [PATCH qemu v15 10/17] memory: Add reporting of supported page sizes, Alexey Kardashevskiy, 2016/04/04
- Re: [Qemu-ppc] [PATCH qemu v15 10/17] memory: Add reporting of supported page sizes,
David Gibson <=
- [Qemu-ppc] [PATCH qemu v15 06/17] spapr_iommu: Finish renaming vfio_accel to need_vfio, Alexey Kardashevskiy, 2016/04/04
- [Qemu-ppc] [PATCH qemu v15 12/17] spapr_pci: Add and export DMA resetting helper, Alexey Kardashevskiy, 2016/04/04
- [Qemu-ppc] [PATCH qemu v15 15/17] spapr_pci: Get rid of dma_loibn, Alexey Kardashevskiy, 2016/04/04
- [Qemu-ppc] [PATCH qemu v15 05/17] spapr_iommu: Introduce "enabled" state for TCE table, Alexey Kardashevskiy, 2016/04/04
- [Qemu-ppc] [PATCH qemu v15 09/17] spapr_pci: Reset DMA config on PHB reset, Alexey Kardashevskiy, 2016/04/04
- [Qemu-ppc] [PATCH qemu v15 07/17] spapr_iommu: Migrate full state, Alexey Kardashevskiy, 2016/04/04