From: Auger Eric <eric.auger@redhat.com>
To: Shannon Zhao <zhaoshenglong@huawei.com>,
Peter Maydell <peter.maydell@linaro.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
Jean-Philippe Brucker <jean-philippe.brucker@arm.com>,
Tomasz Nowicki <tn@semihalf.com>,
QEMU Developers <qemu-devel@nongnu.org>,
Peter Xu <peterx@redhat.com>,
Shannon Zhao <shannon.zhaosl@gmail.com>,
Alex Williamson <alex.williamson@redhat.com>,
qemu-arm <qemu-arm@nongnu.org>,
Christoffer Dall <christoffer.dall@linaro.org>,
linuc.decode@gmail.com, Bharat Bhushan <bharat.bhushan@nxp.com>,
Prem Mallappa <prem.mallappa@gmail.com>,
Eric Auger <eric.auger.pro@gmail.com>
Subject: Re: [Qemu-arm] [Qemu-devel] [PATCH v9 13/14] hw/arm/virt-acpi-build: Add smmuv3 node in IORT table
Date: Mon, 19 Mar 2018 21:50:35 +0100 [thread overview]
Message-ID: <2908cad5-ffb8-29bd-0f10-a7600622429a@redhat.com> (raw)
In-Reply-To: <5AAFCA19.7020507@huawei.com>
Hi Shannon,
On 19/03/18 15:32, Shannon Zhao wrote:
>
>
> On 2018/3/12 20:48, Peter Maydell wrote:
>> On 17 February 2018 at 18:46, Eric Auger <eric.auger@redhat.com> wrote:
>>> From: Prem Mallappa <prem.mallappa@broadcom.com>
>>>
>>> This patch builds the smmuv3 node in the ACPI IORT table.
>>>
>>> The RID space of the root complex, which spans 0x0-0x10000
>>> maps to streamid space 0x0-0x10000 in smmuv3, which in turn
>>> maps to deviceid space 0x0-0x10000 in the ITS group.
>>>
>>> The guest must feature the IOMMU probe deferral series
>>> (https://lkml.org/lkml/2017/4/10/214) which fixes streamid
>>> multiple lookup. This bug is not related to the SMMU emulation.
>>>
>>> Signed-off-by: Prem Mallappa <prem.mallappa@broadcom.com>
>>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>>>
>>> ---
>>>
>>> v2 -> v3:
>>> - integrate into the existing IORT table made up of ITS, RC nodes
>>> - take into account vms->smmu
>>> - match linux actbl2.h acpi_iort_smmu_v3 field names
>>> ---
>>> hw/arm/virt-acpi-build.c | 56 +++++++++++++++++++++++++++++++++++++++------
>>> include/hw/acpi/acpi-defs.h | 15 ++++++++++++
>>> 2 files changed, 64 insertions(+), 7 deletions(-)
>>
>> Since ACPI is definitely not my area of expertise, I've cc'd
>> Shannon on this patch. Shannon, could you take a look at it, please?
>>
> Sure.
>
>>> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>>> index f7fa795..4b5ad91 100644
>>> --- a/hw/arm/virt-acpi-build.c
>>> +++ b/hw/arm/virt-acpi-build.c
>>> @@ -393,19 +393,26 @@ build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned xsdt_tbl_offset)
>>> }
>>>
>>> static void
>>> -build_iort(GArray *table_data, BIOSLinker *linker)
>>> +build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>>> {
>>> - int iort_start = table_data->len;
>>> + int nb_nodes, iort_start = table_data->len;
>>> AcpiIortIdMapping *idmap;
>>> AcpiIortItsGroup *its;
>>> AcpiIortTable *iort;
>>> - size_t node_size, iort_length;
>>> + AcpiIortSmmu3 *smmu;
>>> + size_t node_size, iort_length, smmu_offset = 0;
>>> AcpiIortRC *rc;
>>>
>>> iort = acpi_data_push(table_data, sizeof(*iort));
>>>
>>> + if (vms->iommu) {
> use if (vms->iommu == VIRT_IOMMU_SMMUV3) ? in case we support other
> types of SMMU.
OK
>
>>> + nb_nodes = 3; /* RC, ITS, SMMUv3 */
>>> + } else {
>>> + nb_nodes = 2; /* RC, ITS */
>>> + }
>>> +
>>> iort_length = sizeof(*iort);
>>> - iort->node_count = cpu_to_le32(2); /* RC and ITS nodes */
>>> + iort->node_count = cpu_to_le32(nb_nodes);
>>> iort->node_offset = cpu_to_le32(sizeof(*iort));
>>>
>>> /* ITS group node */
>>> @@ -418,6 +425,35 @@ build_iort(GArray *table_data, BIOSLinker *linker)
>>> its->its_count = cpu_to_le32(1);
>>> its->identifiers[0] = 0; /* MADT translation_id */
>>>
>>> + if (vms->iommu == VIRT_IOMMU_SMMUV3) {
>>> + int irq = vms->irqmap[VIRT_SMMU];
>>> +
>>> + /* SMMUv3 node */
>>> + smmu_offset = cpu_to_le32(iort->node_offset + node_size);
> no need cpu_to_le32 here.
> Otherwise: Reviewed-by: Shannon Zhao <zhaoshenglong@huawei.com>
OK. Thank you for the review!
Thanks
Eric
>
>>> + node_size = sizeof(*smmu) + sizeof(*idmap);
>>> + iort_length += node_size;
>>> + smmu = acpi_data_push(table_data, node_size);
>>> +
>>> +
>>> + smmu->type = ACPI_IORT_NODE_SMMU_V3;
>>> + smmu->length = cpu_to_le16(node_size);
>>> + smmu->mapping_count = cpu_to_le32(1);
>>> + smmu->mapping_offset = cpu_to_le32(sizeof(*smmu));
>>> + smmu->base_address = cpu_to_le64(vms->memmap[VIRT_SMMU].base);
>>> + smmu->event_gsiv = cpu_to_le32(irq);
>>> + smmu->pri_gsiv = cpu_to_le32(irq + 1);
>>> + smmu->gerr_gsiv = cpu_to_le32(irq + 2);
>>> + smmu->sync_gsiv = cpu_to_le32(irq + 3);
>>> +
>>> + /* Identity RID mapping covering the whole input RID range */
>>> + idmap = &smmu->id_mapping_array[0];
>>> + idmap->input_base = 0;
>>> + idmap->id_count = cpu_to_le32(0xFFFF);
>>> + idmap->output_base = 0;
>>> + /* output IORT node is the ITS group node (the first node) */
>>> + idmap->output_reference = cpu_to_le32(iort->node_offset);
>>> + }
>>> +
>>> /* Root Complex Node */
>>> node_size = sizeof(*rc) + sizeof(*idmap);
>>> iort_length += node_size;
>>> @@ -438,8 +474,14 @@ build_iort(GArray *table_data, BIOSLinker *linker)
>>> idmap->input_base = 0;
>>> idmap->id_count = cpu_to_le32(0xFFFF);
>>> idmap->output_base = 0;
>>> - /* output IORT node is the ITS group node (the first node) */
>>> - idmap->output_reference = cpu_to_le32(iort->node_offset);
>>> +
>>> + if (vms->iommu) {
>>> + /* output IORT node is the smmuv3 node */
>>> + idmap->output_reference = cpu_to_le32(smmu_offset);
>>> + } else {
>>> + /* output IORT node is the ITS group node (the first node) */
>>> + idmap->output_reference = cpu_to_le32(iort->node_offset);
>>> + }
>>>
>>> iort->length = cpu_to_le32(iort_length);
>>>
>>> @@ -786,7 +828,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
>>>
>>> if (its_class_name() && !vmc->no_its) {
>>> acpi_add_table(table_offsets, tables_blob);
>>> - build_iort(tables_blob, tables->linker);
>>> + build_iort(tables_blob, tables->linker, vms);
>>> }
>>>
>>> /* XSDT is pointed to by RSDP */
>>> diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
>>> index 80c8099..068ce28 100644
>>> --- a/include/hw/acpi/acpi-defs.h
>>> +++ b/include/hw/acpi/acpi-defs.h
>>> @@ -700,6 +700,21 @@ struct AcpiIortItsGroup {
>>> } QEMU_PACKED;
>>> typedef struct AcpiIortItsGroup AcpiIortItsGroup;
>>>
>>> +struct AcpiIortSmmu3 {
>>> + ACPI_IORT_NODE_HEADER_DEF
>>> + uint64_t base_address;
>>> + uint32_t flags;
>>> + uint32_t reserved2;
>>> + uint64_t vatos_address;
>>> + uint32_t model;
>>> + uint32_t event_gsiv;
>>> + uint32_t pri_gsiv;
>>> + uint32_t gerr_gsiv;
>>> + uint32_t sync_gsiv;
>>> + AcpiIortIdMapping id_mapping_array[0];
>>> +} QEMU_PACKED;
>>> +typedef struct AcpiIortSmmu3 AcpiIortSmmu3;
>>> +
>>> struct AcpiIortRC {
>>> ACPI_IORT_NODE_HEADER_DEF
>>> AcpiIortMemoryAccess memory_properties;
>>> --
>>> 2.5.5
>>>
>>
>> thanks
>> -- PMM
>>
>>
>> .
>>
>
next prev parent reply other threads:[~2018-03-19 20:51 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-17 18:46 [Qemu-arm] [PATCH v9 00/14] ARM SMMUv3 Emulation Support Eric Auger
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 01/14] hw/arm/smmu-common: smmu base device and datatypes Eric Auger
2018-03-06 12:09 ` Peter Maydell
2018-03-06 15:01 ` [Qemu-arm] [Qemu-devel] " Auger Eric
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 02/14] hw/arm/smmu-common: IOMMU memory region and address space setup Eric Auger
2018-03-06 14:08 ` Peter Maydell
2018-03-06 14:47 ` [Qemu-arm] [Qemu-devel] " Auger Eric
2018-03-06 14:49 ` Peter Maydell
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 03/14] hw/arm/smmu-common: VMSAv8-64 page table walk Eric Auger
2018-03-06 19:43 ` Peter Maydell
2018-03-07 16:23 ` Auger Eric
2018-03-07 16:35 ` Peter Maydell
2018-03-08 18:56 ` Auger Eric
2018-03-08 19:01 ` Peter Maydell
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 04/14] hw/arm/smmuv3: Skeleton Eric Auger
2018-03-08 14:27 ` Peter Maydell
2018-03-09 13:19 ` Auger Eric
2018-03-09 13:37 ` Peter Maydell
2018-03-09 13:49 ` Auger Eric
2018-02-17 18:46 ` [Qemu-devel] [PATCH v9 05/14] hw/arm/smmuv3: Wired IRQ and GERROR helpers Eric Auger
2018-03-08 17:49 ` [Qemu-arm] " Peter Maydell
2018-03-09 14:03 ` Auger Eric
2018-03-09 14:18 ` Peter Maydell
2018-03-09 14:50 ` [Qemu-arm] [Qemu-devel] " Auger Eric
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 06/14] hw/arm/smmuv3: Queue helpers Eric Auger
2018-03-08 18:28 ` Peter Maydell
2018-03-09 16:43 ` Auger Eric
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 07/14] hw/arm/smmuv3: Implement MMIO write operations Eric Auger
2018-03-08 18:37 ` Peter Maydell
2018-03-09 16:42 ` Auger Eric
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 08/14] hw/arm/smmuv3: Event queue recording helper Eric Auger
2018-03-08 18:39 ` Peter Maydell
2018-03-09 17:16 ` Auger Eric
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 09/14] hw/arm/smmuv3: Implement translate callback Eric Auger
2018-03-09 18:46 ` Peter Maydell
2018-03-12 10:38 ` [Qemu-devel] " Eric Auger
2018-02-17 18:46 ` [Qemu-devel] [PATCH v9 10/14] hw/arm/smmuv3: Abort on vfio or vhost case Eric Auger
2018-03-08 19:06 ` Peter Maydell
2018-03-09 17:53 ` [Qemu-arm] " Auger Eric
2018-03-09 17:59 ` Peter Maydell
2018-03-12 10:53 ` Eric Auger
2018-03-12 11:10 ` Peter Maydell
2018-03-12 15:01 ` [Qemu-arm] [Qemu-devel] " Auger Eric
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 11/14] target/arm/kvm: Translate the MSI doorbell in kvm_arch_fixup_msi_route Eric Auger
2018-03-12 11:59 ` Peter Maydell
2018-03-12 15:16 ` Auger Eric
2018-03-13 13:37 ` Paolo Bonzini
2018-03-15 9:45 ` Auger Eric
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 12/14] hw/arm/virt: Add SMMUv3 to the virt board Eric Auger
2018-03-12 12:46 ` Peter Maydell
2018-03-12 15:01 ` [Qemu-arm] [Qemu-devel] " Auger Eric
2018-03-12 15:05 ` Peter Maydell
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 13/14] hw/arm/virt-acpi-build: Add smmuv3 node in IORT table Eric Auger
2018-03-12 12:48 ` Peter Maydell
2018-03-19 14:32 ` [Qemu-arm] [Qemu-devel] " Shannon Zhao
2018-03-19 20:50 ` Auger Eric [this message]
2018-02-17 18:46 ` [Qemu-arm] [PATCH v9 14/14] hw/arm/virt: Handle iommu in 2.12 machine type Eric Auger
2018-03-12 12:56 ` [Qemu-devel] " Peter Maydell
2018-03-12 15:01 ` [Qemu-arm] " Auger Eric
2018-02-27 19:02 ` [Qemu-arm] [PATCH v9 00/14] ARM SMMUv3 Emulation Support Peter Maydell
2018-02-28 8:44 ` [Qemu-arm] [Qemu-devel] " Auger Eric
2018-03-12 12:58 ` Peter Maydell
2018-03-12 15:22 ` Auger Eric
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=2908cad5-ffb8-29bd-0f10-a7600622429a@redhat.com \
--to=eric.auger@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=bharat.bhushan@nxp.com \
--cc=christoffer.dall@linaro.org \
--cc=eric.auger.pro@gmail.com \
--cc=jean-philippe.brucker@arm.com \
--cc=linuc.decode@gmail.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=prem.mallappa@gmail.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shannon.zhaosl@gmail.com \
--cc=tn@semihalf.com \
--cc=zhaoshenglong@huawei.com \
/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).