From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFXjA-0006gt-7f for qemu-devel@nongnu.org; Wed, 15 Jul 2015 21:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFXj4-00062K-M7 for qemu-devel@nongnu.org; Wed, 15 Jul 2015 21:12:44 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:34012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFXj4-00061q-El for qemu-devel@nongnu.org; Wed, 15 Jul 2015 21:12:38 -0400 Received: by pdbep18 with SMTP id ep18so35442229pdb.1 for ; Wed, 15 Jul 2015 18:12:37 -0700 (PDT) References: <1436876514-2946-1-git-send-email-aik@ozlabs.ru> <1436876514-2946-2-git-send-email-aik@ozlabs.ru> <1436984807.1391.521.camel@redhat.com> From: Alexey Kardashevskiy Message-ID: <55A704FD.1070108@ozlabs.ru> Date: Thu, 16 Jul 2015 11:12:29 +1000 MIME-Version: 1.0 In-Reply-To: <1436984807.1391.521.camel@redhat.com> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH qemu v3 1/4] memory: Add reporting of supported page sizes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: Peter Crosthwaite , Michael Roth , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Paolo Bonzini , David Gibson On 07/16/2015 04:26 AM, Alex Williamson wrote: > On Tue, 2015-07-14 at 22:21 +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. >> >> TARGET_PAGE_BITS shift is used as fallback. >> >> Signed-off-by: Alexey Kardashevskiy >> --- >> hw/ppc/spapr_iommu.c | 8 ++++++++ >> include/exec/memory.h | 11 +++++++++++ >> memory.c | 9 +++++++++ >> 3 files changed, 28 insertions(+) >> >> diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c >> index f61504e..a2572c4 100644 >> --- a/hw/ppc/spapr_iommu.c >> +++ b/hw/ppc/spapr_iommu.c >> @@ -104,6 +104,13 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr, >> return ret; >> } >> >> +static uint64_t spapr_tce_get_page_sizes(MemoryRegion *iommu) >> +{ >> + sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu); >> + >> + return 1ULL << tcet->page_shift; >> +} >> + >> static int spapr_tce_table_post_load(void *opaque, int version_id) >> { >> sPAPRTCETable *tcet = SPAPR_TCE_TABLE(opaque); >> @@ -135,6 +142,7 @@ static const VMStateDescription vmstate_spapr_tce_table = { >> >> static MemoryRegionIOMMUOps spapr_iommu_ops = { >> .translate = spapr_tce_translate_iommu, >> + .get_page_sizes = spapr_tce_get_page_sizes, >> }; >> >> static int spapr_tce_table_realize(DeviceState *dev) >> diff --git a/include/exec/memory.h b/include/exec/memory.h >> index 1394715..9ca74e3 100644 >> --- a/include/exec/memory.h >> +++ b/include/exec/memory.h >> @@ -152,6 +152,8 @@ typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps; >> struct MemoryRegionIOMMUOps { >> /* Return a TLB entry that contains a given address. */ >> IOMMUTLBEntry (*translate)(MemoryRegion *iommu, hwaddr addr, bool is_write); >> + /* Returns supported page sizes */ >> + uint64_t (*get_page_sizes)(MemoryRegion *iommu); >> }; >> >> typedef struct CoalescedMemoryRange CoalescedMemoryRange; >> @@ -552,6 +554,15 @@ static inline bool memory_region_is_romd(MemoryRegion *mr) >> bool memory_region_is_iommu(MemoryRegion *mr); >> >> /** >> + * memory_region_iommu_get_page_sizes: get supported page sizes in an iommu >> + * >> + * Returns %bitmap of supported page sizes for an iommu. >> + * >> + * @mr: the memory region being queried >> + */ >> +uint64_t memory_region_iommu_get_page_sizes(MemoryRegion *mr); >> + >> +/** >> * memory_region_notify_iommu: notify a change in an IOMMU translation entry. >> * >> * @mr: the memory region that was changed >> diff --git a/memory.c b/memory.c >> index 5a0cc66..0732763 100644 >> --- a/memory.c >> +++ b/memory.c >> @@ -1413,6 +1413,15 @@ bool memory_region_is_iommu(MemoryRegion *mr) >> return mr->iommu_ops; >> } >> >> +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 1ULL << TARGET_PAGE_BITS; > > At this rate we're adding TARGET_PAGE_foo faster than Peter can remove > them. Well, returning zero is better? Or qemu_real_host_page_size? -- Alexey