qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
	peter.maydell@linaro.org, shannon.zhaosl@gmail.com,
	mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com,
	peterx@redhat.com
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, jgg@nvidia.com,
	shameerali.kolothum.thodi@huawei.com, jasowang@redhat.com
Subject: Re: [PATCH RFCv1 02/10] hw/arm/virt: Add iommufd link to virt-machine
Date: Tue, 9 Jul 2024 11:11:56 +0200	[thread overview]
Message-ID: <efec2974-ce96-4cb1-a00c-30fe93c5fa7b@redhat.com> (raw)
In-Reply-To: <df22fcd43e201fea97da8862b61614a2986ffa5e.1719361174.git.nicolinc@nvidia.com>

Hi Nicolin,

On 6/26/24 02:28, Nicolin Chen wrote:
> A nested SMMU must use iommufd ioctls to communicate with the host-level
> SMMU instance for 2-stage translation support. Add an iommufd link to the
> ARM virt-machine, allowing QEMU command to pass in an iommufd object.
If I am not wrong vfio devices are allowed to use different iommufd's
(although there is no real benefice). So this command line wouldn't
match with that option.
Also while reading the commit msg it is not clear with the iommufd is
needed in the machine whereas the vfio iommufd BE generally calls those
ioctls.

Thanks

Eric
>
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
>  hw/arm/virt.c         | 14 ++++++++++++++
>  include/hw/arm/virt.h |  2 ++
>  2 files changed, 16 insertions(+)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 78af2d2195..71093d7c60 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -1404,6 +1404,13 @@ static void create_smmu(const VirtMachineState *vms,
>  
>      object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
>                               &error_abort);
> +
> +    if (vms->iommu == VIRT_IOMMU_NESTED_SMMUV3) {
> +        g_assert(vms->iommufd);
> +        object_property_set_link(OBJECT(dev), "iommufd", OBJECT(vms->iommufd),
> +                                 &error_abort);
> +        object_property_set_bool(OBJECT(dev), "nested", true, &error_abort);

> +    }
>      sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
>      sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
>      for (i = 0; i < NUM_SMMU_IRQS; i++) {
> @@ -3114,6 +3121,13 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
>                                            "Set GIC version. "
>                                            "Valid values are 2, 3, 4, host and max");
>  
> +    object_class_property_add_link(oc, "iommufd", TYPE_IOMMUFD_BACKEND,
> +                                   offsetof(VirtMachineState, iommufd),
> +                                   object_property_allow_set_link,
> +                                   OBJ_PROP_LINK_STRONG);
> +    object_class_property_set_description(oc, "iommufd",
> +                                          "Set the IOMMUFD handler from \"-iommufd\"");
> +
>      object_class_property_add_str(oc, "iommu", virt_get_iommu, virt_set_iommu);
>      object_class_property_set_description(oc, "iommu",
>                                            "Set the IOMMU type. "
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index 7df0813e28..d5cbce1a30 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -36,6 +36,7 @@
>  #include "hw/arm/boot.h"
>  #include "hw/arm/bsa.h"
>  #include "hw/block/flash.h"
> +#include "sysemu/iommufd.h"
>  #include "sysemu/kvm.h"
>  #include "hw/intc/arm_gicv3_common.h"
>  #include "qom/object.h"
> @@ -154,6 +155,7 @@ struct VirtMachineState {
>      bool dtb_randomness;
>      OnOffAuto acpi;
>      VirtGICType gic_version;
> +    IOMMUFDBackend *iommufd;
>      VirtIOMMUType iommu;
>      bool default_bus_bypass_iommu;
>      VirtMSIControllerType msi_controller;



  reply	other threads:[~2024-07-09  9:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26  0:28 [PATCH RFCv1 00/10] hw/arm/virt: Add multiple nested SMMUs Nicolin Chen
2024-06-26  0:28 ` [PATCH RFCv1 01/10] hw/arm/virt-acpi-build: Add IORT RMR regions to handle MSI nested binding Nicolin Chen
2024-06-26  0:28 ` [PATCH RFCv1 02/10] hw/arm/virt: Add iommufd link to virt-machine Nicolin Chen
2024-07-09  9:11   ` Eric Auger [this message]
2024-07-09 16:59     ` Nicolin Chen
2024-07-09 17:06       ` Eric Auger
2024-07-09 17:18         ` Nicolin Chen
2024-07-10  2:32           ` Duan, Zhenzhong
2024-06-26  0:28 ` [PATCH RFCv1 03/10] hw/arm/virt: Get the number of host-level SMMUv3 instances Nicolin Chen
2024-07-09  9:20   ` Eric Auger
2024-07-09 17:11     ` Nicolin Chen
2024-07-09 17:22       ` Eric Auger
2024-07-09 18:02         ` Nicolin Chen
2024-06-26  0:28 ` [PATCH RFCv1 04/10] hw/arm/virt: Add an SMMU_IO_LEN macro Nicolin Chen
2024-06-26  0:28 ` [PATCH RFCv1 05/10] hw/arm/virt: Add VIRT_NESTED_SMMU Nicolin Chen
2024-07-09 13:26   ` Eric Auger
2024-07-09 17:59     ` Nicolin Chen
2024-07-11 15:48       ` Andrea Bolognani
2024-07-11 17:57         ` Jason Gunthorpe
2024-06-26  0:28 ` [PATCH RFCv1 06/10] hw/arm/virt: Assign vfio-pci devices to nested SMMUs Nicolin Chen
2024-07-09 13:32   ` Eric Auger
2024-06-26  0:28 ` [PATCH RFCv1 07/10] hw/arm/virt: Bypass iommu for default PCI bus Nicolin Chen
2024-06-26  0:28 ` [PATCH RFCv1 08/10] hw/arm/virt-acpi-build: Handle reserved bus number of pxb buses Nicolin Chen
2024-06-26  0:28 ` [PATCH RFCv1 09/10] hw/arm/virt-acpi-build: Build IORT with multiple SMMU nodes Nicolin Chen
2024-06-26  0:28 ` [PATCH RFCv1 10/10] hw/arm/virt-acpi-build: Enable ATS for nested SMMUv3 Nicolin Chen

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=efec2974-ce96-4cb1-a00c-30fe93c5fa7b@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=anisinha@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=mst@redhat.com \
    --cc=nicolinc@nvidia.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=shannon.zhaosl@gmail.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).