From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
Michael Roth <mdroth@linux.vnet.ibm.com>,
qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
Paolo Bonzini <pbonzini@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] [RFC PATCH qemu v3 1/4] memory: Add reporting of supported page sizes
Date: Thu, 16 Jul 2015 11:12:29 +1000 [thread overview]
Message-ID: <55A704FD.1070108@ozlabs.ru> (raw)
In-Reply-To: <1436984807.1391.521.camel@redhat.com>
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 <aik@ozlabs.ru>
>> ---
>> 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
next prev parent reply other threads:[~2015-07-16 1:12 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-14 12:21 [Qemu-devel] [RFC PATCH qemu v3 0/4] vfio: SPAPR IOMMU v2 (memory preregistration support) Alexey Kardashevskiy
2015-07-14 12:21 ` [Qemu-devel] [RFC PATCH qemu v3 1/4] memory: Add reporting of supported page sizes Alexey Kardashevskiy
2015-07-15 18:26 ` Alex Williamson
2015-07-16 1:12 ` Alexey Kardashevskiy [this message]
2015-07-14 12:21 ` [Qemu-devel] [RFC PATCH qemu v3 2/4] vfio: Use different page size for different IOMMU types Alexey Kardashevskiy
2015-07-15 18:26 ` Alex Williamson
2015-07-16 1:26 ` Alexey Kardashevskiy
2015-07-16 2:51 ` Alex Williamson
2015-07-16 3:31 ` Alexey Kardashevskiy
2015-07-14 12:21 ` [Qemu-devel] [RFC PATCH qemu v3 3/4] vfio: Store IOMMU type in container Alexey Kardashevskiy
2015-07-15 18:26 ` Alex Williamson
2015-07-14 12:21 ` [Qemu-devel] [RFC PATCH qemu v3 4/4] vfio: spapr: Add SPAPR IOMMU v2 support (DMA memory preregistering) Alexey Kardashevskiy
2015-07-16 5:11 ` David Gibson
2015-07-16 14:44 ` Alex Williamson
2015-07-17 5:20 ` David Gibson
2015-07-17 18:25 ` Alex Williamson
2015-07-18 15:05 ` David Gibson
2015-07-19 15:04 ` Alex Williamson
2015-07-17 7:13 ` Alexey Kardashevskiy
2015-07-17 13:39 ` David Gibson
2015-07-17 15:47 ` Alexey Kardashevskiy
2015-07-18 15:17 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55A704FD.1070108@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).