Re: [PATCH v8 08/12] hw/arm/virt: Allow user-creatable SMMUv3 dev instantiation

2025-07-18 Thread Nicolin Chen
On Fri, Jul 18, 2025 at 08:22:09AM +, Shameerali Kolothum Thodi wrote: > > So, my question was: where do we set the number of 4 to the sbdev? > > As platform_bus_get_irqn() returned very correctly with 0, 4, 8, > > and so on.. > > See smmu_realize() --> smmu_init_irq() > > And then in virt_ma

Re: [PATCH v8 08/12] hw/arm/virt: Allow user-creatable SMMUv3 dev instantiation

2025-07-18 Thread Nicolin Chen
On Fri, Jul 18, 2025 at 08:01:22AM +, Shameerali Kolothum Thodi wrote: > > > +int irq = platform_bus_get_irqn(pbus, sbdev, 0); > > > +hwaddr base = platform_bus_get_mmio_addr(pbus, sbdev, 0); > > > +MachineState *ms = MACHINE(vms); > > > + > > > +if (!(vms->bootinfo.firmware_loa

Re: [PATCH v8 08/12] hw/arm/virt: Allow user-creatable SMMUv3 dev instantiation

2025-07-17 Thread Nicolin Chen
Hi Shameer, On Fri, Jul 11, 2025 at 09:47:45AM +0100, Shameer Kolothum wrote: > +static void create_smmuv3_dev_dtb(VirtMachineState *vms, > + DeviceState *dev, PCIBus *bus) > +{ > +PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev); > +Sy

Re: [PATCH v8 00/12] hw/arm/virt: Add support for user creatable SMMUv3 device

2025-07-17 Thread Nicolin Chen
x27;ve tested this series using the latest vSMMU RFCv3: https://lore.kernel.org/qemu-devel/20250714155941.22176-1-shameerali.kolothum.th...@huawei.com/ I was able to create four vSMMU instances with four pxb buses, then to pass through four vfio-pci devices to a VM. Tested-by: Nicolin Chen

Re: [RFC PATCH v3 14/15] Read and validate host SMMUv3 feature bits

2025-07-16 Thread Nicolin Chen
On Wed, Jul 16, 2025 at 03:42:39PM -0300, Jason Gunthorpe wrote: > On Wed, Jul 16, 2025 at 11:09:45AM -0700, Nicolin Chen wrote: > > OK. I see your point. That will leads to a very long list of > > parameters. > > I would have some useful prebaked ones. Realistically ther

Re: [RFC PATCH v3 14/15] Read and validate host SMMUv3 feature bits

2025-07-16 Thread Nicolin Chen
On Wed, Jul 16, 2025 at 10:26:21AM +, Shameerali Kolothum Thodi wrote: > > On Mon, Jul 14, 2025 at 04:59:40PM +0100, Shameer Kolothum wrote: > > My vSMMU didn't work until I added entries like SIDSIZE, SSIDSIZE, > > TERM_MODEL, STALL_MODEL, and RIL. > > How come your vSMMU not working? Or you

Re: [RFC PATCH v3 06/15] hw/arm/smmuv3-accel: Restrict accelerated SMMUv3 to vfio-pci endpoints with iommufd

2025-07-16 Thread Nicolin Chen
On Wed, Jul 16, 2025 at 10:51:23AM -0700, Nicolin Chen wrote: > On Wed, Jul 16, 2025 at 09:34:04AM +, Shameerali Kolothum Thodi wrote: > > > >> Seems aggressive for a hotplug, could we fail hotplug instead of kill > > > QEMU? > > > > > > > >H

Re: [RFC PATCH v3 09/15] hw/arm/smmuv3-accel: Support nested STE install/uninstall support

2025-07-16 Thread Nicolin Chen
On Wed, Jul 16, 2025 at 08:36:38AM +, Shameerali Kolothum Thodi wrote: > > > +g_hash_table_foreach(bs->configs, smmuv3_accel_ste_range, range); > > > > This will not work correctly? > > > > The bs->configs is a cache that gets an entry inserted to when a > > config is fetched via smmuv3_g

Re: [RFC PATCH v3 14/15] Read and validate host SMMUv3 feature bits

2025-07-16 Thread Nicolin Chen
On Wed, Jul 16, 2025 at 02:45:06PM -0300, Jason Gunthorpe wrote: > On Wed, Jul 16, 2025 at 10:35:25AM -0700, Nicolin Chen wrote: > > On Wed, Jul 16, 2025 at 08:51:23AM -0300, Jason Gunthorpe wrote: > > > On Tue, Jul 15, 2025 at 07:57:57PM -0700, Nicolin Chen wrote: > > >

Re: [RFC PATCH v3 06/15] hw/arm/smmuv3-accel: Restrict accelerated SMMUv3 to vfio-pci endpoints with iommufd

2025-07-16 Thread Nicolin Chen
On Wed, Jul 16, 2025 at 09:34:04AM +, Shameerali Kolothum Thodi wrote: > > >> Seems aggressive for a hotplug, could we fail hotplug instead of kill > > QEMU? > > > > > >Hotplug will unlikely be supported well, as it would introduce > > >too much complication. > > > > > >With iommufd, a vIOMMU o

Re: [RFC PATCH v3 14/15] Read and validate host SMMUv3 feature bits

2025-07-16 Thread Nicolin Chen
On Wed, Jul 16, 2025 at 08:51:23AM -0300, Jason Gunthorpe wrote: > On Tue, Jul 15, 2025 at 07:57:57PM -0700, Nicolin Chen wrote: > > > +val = FIELD_EX32(s_accel->info.idr[5], IDR5, GRAN4K); > > > +if (val < FIELD_EX32(s->idr[5], IDR5, GRAN4K)) { > > >

Re: [RFC PATCH v3 14/15] Read and validate host SMMUv3 feature bits

2025-07-15 Thread Nicolin Chen via
On Mon, Jul 14, 2025 at 04:59:40PM +0100, Shameer Kolothum wrote: > From: Nicolin Chen > > Not all fields in the SMMU IDR registers are meaningful for userspace. > Only the following fields can be used: > >   - IDR0: ST_LEVEL, TERM_MODEL, STALL_MODEL, TTENDIAN, CD2L, ASID16

Re: [RFC PATCH v3 09/15] hw/arm/smmuv3-accel: Support nested STE install/uninstall support

2025-07-15 Thread Nicolin Chen
On Mon, Jul 14, 2025 at 04:59:35PM +0100, Shameer Kolothum wrote: > +static void > +smmuv3_accel_ste_range(gpointer key, gpointer value, gpointer user_data) > +{ > +SMMUDevice *sdev = (SMMUDevice *)key; > +uint32_t sid = smmu_get_sid(sdev); > +SMMUSIDRange *sid_range = (SMMUSIDRange *)u

Re: [RFC PATCH v3 06/15] hw/arm/smmuv3-accel: Restrict accelerated SMMUv3 to vfio-pci endpoints with iommufd

2025-07-15 Thread Nicolin Chen
On Tue, Jul 15, 2025 at 10:53:50AM +, Duan, Zhenzhong wrote: > > > >-Original Message- > >From: Shameer Kolothum > >Subject: [RFC PATCH v3 06/15] hw/arm/smmuv3-accel: Restrict accelerated > >SMMUv3 to vfio-pci endpoints with iommufd > > > >Accelerated SMMUv3 is only useful when the d

Re: [RFC PATCH v3 05/15] hw/arm/smmuv3-accel: Introduce smmuv3 accel device

2025-07-15 Thread Nicolin Chen
On Tue, Jul 15, 2025 at 10:48:31AM +, Duan, Zhenzhong wrote: > >+static const TypeInfo types[] = { > >+{ > >+.name = TYPE_ARM_SMMUV3_ACCEL, > >+.parent = TYPE_ARM_SMMUV3, > >+.class_init = smmuv3_accel_class_init, > >+} > > In cover-letter, I see "-device arm-sm

Re: [RFC PATCH v3 13/15] hw/arm/smmuv3: Forward invalidation commands to hw

2025-07-15 Thread Nicolin Chen
On Tue, Jul 15, 2025 at 11:46:09AM +0100, Jonathan Cameron wrote: > > SMMUCmdError cmd_error = SMMU_CERROR_NONE; > > SMMUQueue *q = &s->cmdq; > > SMMUCommandType type = 0; > > +SMMUCommandBatch batch = {}; > > +uint32_t ncmds; > > > > if (!smmuv3_cmdq_enabled(s)) { > >

Re: [RFC PATCH v3 12/15] hw/arm/smmuv3-accel: Introduce helpers to batch and issue cache invalidations

2025-07-15 Thread Nicolin Chen
On Tue, Jul 15, 2025 at 11:39:54AM +0100, Jonathan Cameron wrote: > > +/* Update batch->ncmds to the number of execute cmds */ > > Not obvious what the return value here means. Maybe a comment? I think it would be clear once we fix the typo in the current one: s/execute/executed That being said

Re: [RFC PATCH v3 08/15] hw/arm/smmuv3-accel: Add set/unset_iommu_device callback

2025-07-15 Thread Nicolin Chen
On Tue, Jul 15, 2025 at 11:29:41AM +0100, Jonathan Cameron wrote: > > +if (!iommufd_backend_alloc_viommu(idev->iommufd, idev->devid, > > + IOMMU_VIOMMU_TYPE_ARM_SMMUV3, > > + s2_hwpt_id, &viommu_id, errp)) { > > +

Re: [RFC PATCH v3 00/15] hw/arm/virt: Add support for user-creatable accelerated SMMUv3

2025-07-14 Thread Nicolin Chen via
On Mon, Jul 14, 2025 at 09:14:17AM -0700, Nicolin Chen wrote: > Hi Shameer, > > Thank you for sending the v3. > > On Mon, Jul 14, 2025 at 04:59:26PM +0100, Shameer Kolothum wrote: > > Branch for testing: > [...] > > Tested on a HiSilicon platform with multiple S

Re: [RFC PATCH v3 14/15] Read and validate host SMMUv3 feature bits

2025-07-14 Thread Nicolin Chen via
On Mon, Jul 14, 2025 at 01:04:02PM -0700, Nicolin Chen wrote: > On Mon, Jul 14, 2025 at 04:59:40PM +0100, Shameer Kolothum wrote: > > From: Nicolin Chen > > > > Not all fields in the SMMU IDR registers are meaningful for userspace. > > Only the following fields can

Re: [RFC PATCH v3 08/15] hw/arm/smmuv3-accel: Add set/unset_iommu_device callback

2025-07-14 Thread Nicolin Chen
On Mon, Jul 14, 2025 at 04:59:34PM +0100, Shameer Kolothum wrote: > From: Nicolin Chen > > Implement a set_iommu_device callback: > -If found an existing viommu reuse that. >(Devices behind the same physical SMMU should share an S2 HWPT) > -Else, > Allocate a v

Re: [RFC PATCH v3 14/15] Read and validate host SMMUv3 feature bits

2025-07-14 Thread Nicolin Chen via
On Mon, Jul 14, 2025 at 04:59:40PM +0100, Shameer Kolothum wrote: > From: Nicolin Chen > > Not all fields in the SMMU IDR registers are meaningful for userspace. > Only the following fields can be used: > >   - IDR0: ST_LEVEL, TERM_MODEL, STALL_MODEL, TTENDIAN, CD2L, ASID16

Re: [RFC PATCH v3 15/15] hw/arm/smmu-common: Add accel property for SMMU dev

2025-07-14 Thread Nicolin Chen
On Mon, Jul 14, 2025 at 04:59:41PM +0100, Shameer Kolothum wrote: > Now user can set "accel=on". Have fun! > > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen

Re: [RFC PATCH v3 12/15] hw/arm/smmuv3-accel: Introduce helpers to batch and issue cache invalidations

2025-07-14 Thread Nicolin Chen
On Mon, Jul 14, 2025 at 04:59:38PM +0100, Shameer Kolothum wrote: > diff --git a/hw/arm/smmuv3-accel.h b/hw/arm/smmuv3-accel.h > index 21028e60c8..d06c9664ba 100644 > --- a/hw/arm/smmuv3-accel.h > +++ b/hw/arm/smmuv3-accel.h > @@ -13,6 +13,7 @@ > #include "hw/arm/smmu-common.h" > #include "system

Re: [RFC PATCH v3 11/15] hw/pci/pci: Introduce optional get_msi_address_space() callback.

2025-07-14 Thread Nicolin Chen
lems when MSI doorbells need to be translated. > > To fix this, introduce an optional get_msi_address_space() callback. > In the SMMUv3 accelerated case, this callback returns the IOMMU address > space if the guest has set up S1 translations for the vfio-pci device. > Otherwise,

Re: [RFC PATCH v3 10/15] hw/arm/smmuv3-accel: Allocate a vDEVICE object for device

2025-07-14 Thread Nicolin Chen
On Mon, Jul 14, 2025 at 04:59:36PM +0100, Shameer Kolothum wrote: > diff --git a/hw/arm/smmuv3-accel.c b/hw/arm/smmuv3-accel.c > index 74bf20cfaf..f1584dd775 100644 > --- a/hw/arm/smmuv3-accel.c > +++ b/hw/arm/smmuv3-accel.c > @@ -93,6 +93,23 @@ void smmuv3_accel_install_nested_ste(SMMUState *bs,

Re: [RFC PATCH v3 09/15] hw/arm/smmuv3-accel: Support nested STE install/uninstall support

2025-07-14 Thread Nicolin Chen
On Mon, Jul 14, 2025 at 04:59:35PM +0100, Shameer Kolothum wrote: > +static int > +smmuv3_accel_dev_install_nested_ste(SMMUv3AccelDevice *accel_dev, > +uint32_t data_type, uint32_t data_len, > +void *data) > +{ > +SMMUViomm

Re: [RFC PATCH v3 07/15] hw/arm/smmuv3: Implement get_viommu_cap() callback

2025-07-14 Thread Nicolin Chen
ured > in Stage 1 mode, ensure that the 'stage' property is explicitly set to > Stage 1. > > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen > @@ -81,8 +82,22 @@ static AddressSpace *smmuv3_accel_find_add_as(PCIBus *bus, > void *opaque, > } > }

Re: [RFC PATCH v3 06/15] hw/arm/smmuv3-accel: Restrict accelerated SMMUv3 to vfio-pci endpoints with iommufd

2025-07-14 Thread Nicolin Chen
n associated > SID, making it difficult to trace the originating device. If we allowed > emulated endpoint devices, QEMU would have to invalidate both its own > software IOTLB and the host's hardware IOTLB, which could slow things > down. Change looks good to me, Reviewed-by: Nicolin

Re: [RFC PATCH v3 05/15] hw/arm/smmuv3-accel: Introduce smmuv3 accel device

2025-07-14 Thread Nicolin Chen
ot set it at this > point. It will be introduced in a subsequent patch once the necessary > support is in place. > > Signed-off-by: Shameer Kolothum Overall the patch looks good to me, Reviewed-by: Nicolin Chen with some nits: > @@ -61,7 +61,8 @@ arm_common_ss.add(when: 

Re: [RFC PATCH v3 04/15] hw/arm/smmu-common: Introduce smmu_iommu_ops_by_type() helper

2025-07-14 Thread Nicolin Chen via
> No special handling is required for now and returns the default ops > in base SMMU Class. > > No functional changes intended. > > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen > +static const PCIIOMMUOps *smmu_iommu_ops_by_type(SMMUState *s) > +{ >

Re: [RFC PATCH v3 02/15] backends/iommufd: Introduce iommufd_vdev_alloc

2025-07-14 Thread Nicolin Chen
On Mon, Jul 14, 2025 at 04:59:28PM +0100, Shameer Kolothum wrote: > +bool iommufd_backend_alloc_vdev(IOMMUFDBackend *be, uint32_t dev_id, > +uint32_t viommu_id, uint64_t virt_id, > +uint32_t *out_vdev_id, Error **errp) > +{ > +int

Re: [RFC PATCH v3 01/15] backends/iommufd: Introduce iommufd_backend_alloc_viommu

2025-07-14 Thread Nicolin Chen
On Mon, Jul 14, 2025 at 04:59:27PM +0100, Shameer Kolothum wrote: > +bool iommufd_backend_alloc_viommu(IOMMUFDBackend *be, uint32_t dev_id, > + uint32_t viommu_type, uint32_t hwpt_id, > + uint32_t *out_viommu_id, Error **errp) > +{ >

Re: [RFC PATCH v3 00/15] hw/arm/virt: Add support for user-creatable accelerated SMMUv3

2025-07-14 Thread Nicolin Chen via
Hi Shameer, Thank you for sending the v3. On Mon, Jul 14, 2025 at 04:59:26PM +0100, Shameer Kolothum wrote: > Branch for testing: [...] > Tested on a HiSilicon platform with multiple SMMUv3s. > > ./qemu-system-aarch64 \ >   -machine virt,accel=kvm,gic-version=3 \ >   -object iommufd,id=iommufd0

Re: [PATCH v7 00/12] hw/arm/virt: Add support for user creatable SMMUv3 device

2025-07-10 Thread Nicolin Chen
Hi Peter, On Thu, Jul 10, 2025 at 12:48:20PM +0100, Peter Maydell wrote: > On Thu, 10 Jul 2025 at 11:10, Shameerali Kolothum Thodi > > > Changes from v6: > > > https://lore.kernel.org/qemu-devel/20250703084643.85740-1- > > > shameerali.kolothum.th...@huawei.com/ > > > > > > 1. Fixed the warning ca

Re: [PATCH v7 07/12] hw/pci: Introduce pci_setup_iommu_per_bus() for per-bus IOMMU ops retrieval

2025-07-10 Thread Nicolin Chen
r_bus when > determining the correct IOMMU ops, ensuring accurate behavior for > per-bus IOMMUs. > > Reviewed-by: Jonathan Cameron > Reviewed-by: Eric Auger > Tested-by: Nathan Chen > Tested-by: Eric Auger > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen With a

Re: [PATCH v7 07/12] hw/pci: Introduce pci_setup_iommu_per_bus() for per-bus IOMMU ops retrieval

2025-07-10 Thread Nicolin Chen
On Thu, Jul 10, 2025 at 09:40:28PM +, Shameerali Kolothum Thodi wrote: > > So, the logic is trying to avoid: > > "iommu_bus = parent_bus;" > > for a case that parent_bus (pcie.0) having its own IOMMU. > > > > But shouldn't it be just "if (parent_bus->iommu_per_bus)"? > > > > Why does

Re: [PATCH v3 02/20] hw/pci: Introduce pci_device_get_viommu_cap()

2025-07-10 Thread Nicolin Chen
On Thu, Jul 10, 2025 at 01:07:11PM -0400, Donald Dutile wrote: > > > > If not, maybe go a bit further like "VIOMMU_CAP_HW_NESTED_S1"? > > > > > > I am not sure the _S1 part makes much sense in ARM case. It doesn't matter > > > whether the Guest SMMUv3 is configured in s1/s2 or nested for this CAP.

Re: [PATCH v3 02/20] hw/pci: Introduce pci_device_get_viommu_cap()

2025-07-10 Thread Nicolin Chen
On Thu, Jul 10, 2025 at 08:11:28AM +, Shameerali Kolothum Thodi wrote: > > So I suggested: > > /* hardware-accelerated nested stage-1 page table support */ > > VIOMMU_CAP_NESTED_S1 = BIT_ULL(0), > > > > which it should be clear IMHO. > > > > If not, maybe go a bit further like "VIOMM

Re: [PATCH v7 02/12] hw/arm/smmu-common: Check SMMU has PCIe Root Complex association

2025-07-10 Thread Nicolin Chen
s added and validated with SMMUv3. > > Reviewed-by: Jonathan Cameron > Reviewed-by: Eric Auger > Tested-by: Nathan Chen > Tested-by: Eric Auger > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen With a small suggestion for clarification. > +/* > + * We

Re: [PATCH v7 02/12] hw/arm/smmu-common: Check SMMU has PCIe Root Complex association

2025-07-10 Thread Nicolin Chen
On Thu, Jul 10, 2025 at 07:27:10AM +, Shameerali Kolothum Thodi wrote: > > On Wed, Jul 09, 2025 at 08:08:49AM +, Shameerali Kolothum Thodi > > wrote: > > > > On Tue, Jul 08, 2025 at 04:40:45PM +0100, Shameer Kolothum wrote: > > > > > @@ -937,11 +939,32 @@ static void smmu_base_realize(Devic

Re: [PATCH v7 07/12] hw/pci: Introduce pci_setup_iommu_per_bus() for per-bus IOMMU ops retrieval

2025-07-10 Thread Nicolin Chen
On Thu, Jul 10, 2025 at 04:21:41PM +, Shameerali Kolothum Thodi wrote: > > >> On Wed, Jul 09, 2025 at 08:20:35AM +, Shameerali Kolothum Thodi > > >> wrote: > > On Tue, Jul 08, 2025 at 04:40:50PM +0100, Shameer Kolothum wrote: > > > @@ -2909,6 +2909,19 @@ static void > > pci_de

Re: [PATCH v7 07/12] hw/pci: Introduce pci_setup_iommu_per_bus() for per-bus IOMMU ops retrieval

2025-07-09 Thread Nicolin Chen
On Wed, Jul 09, 2025 at 08:20:35AM +, Shameerali Kolothum Thodi wrote: > > On Tue, Jul 08, 2025 at 04:40:50PM +0100, Shameer Kolothum wrote: > > > @@ -2909,6 +2909,19 @@ static void > > pci_device_get_iommu_bus_devfn(PCIDevice *dev, > > > } > > > } > > > > > > +/*

Re: [PATCH v7 02/12] hw/arm/smmu-common: Check SMMU has PCIe Root Complex association

2025-07-09 Thread Nicolin Chen
On Wed, Jul 09, 2025 at 08:08:49AM +, Shameerali Kolothum Thodi wrote: > > On Tue, Jul 08, 2025 at 04:40:45PM +0100, Shameer Kolothum wrote: > > > @@ -937,11 +939,32 @@ static void smmu_base_realize(DeviceState > > *dev, Error **errp) > > > g_free, g_free);

Re: [PATCH v3 02/20] hw/pci: Introduce pci_device_get_viommu_cap()

2025-07-09 Thread Nicolin Chen
On Wed, Jul 09, 2025 at 01:55:46PM -0400, Donald Dutile wrote: > > > +enum { > > > +VIOMMU_CAP_STAGE1 = BIT_ULL(0), /* stage1 page table supported */ > > > +}; > > > > Thanks for this work. I am happy to see that we can share the > > common code that allocates a NESTING_PARENT in the core usi

Re: [PATCH v3 02/20] hw/pci: Introduce pci_device_get_viommu_cap()

2025-07-08 Thread Nicolin Chen
On Wed, Jul 09, 2025 at 03:38:49AM +, Duan, Zhenzhong wrote: > >> +enum { > >> +VIOMMU_CAP_STAGE1 = BIT_ULL(0), /* stage1 page table > >supported */ > >> +}; > > > >Thanks for this work. I am happy to see that we can share the > >common code that allocates a NESTING_PARENT in the core usin

Re: [PATCH v3 02/20] hw/pci: Introduce pci_device_get_viommu_cap()

2025-07-08 Thread Nicolin Chen
On Tue, Jul 08, 2025 at 07:05:43AM -0400, Zhenzhong Duan wrote: > diff --git a/include/hw/iommu.h b/include/hw/iommu.h > new file mode 100644 > index 00..e80aaf4431 > --- /dev/null > +++ b/include/hw/iommu.h > @@ -0,0 +1,16 @@ > +/* > + * General vIOMMU capabilities, flags, etc > + * > + *

Re: [PATCH v7 08/12] hw/arm/virt: Allow user-creatable SMMUv3 dev instantiation

2025-07-08 Thread Nicolin Chen
; limited to cases where it is attached to the default pcie.0 root complex. > > Reviewed-by: Jonathan Cameron > Reviewed-by: Eric Auger > Tested-by: Nathan Chen > Tested-by: Eric Auger > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen

Re: [PATCH v7 07/12] hw/pci: Introduce pci_setup_iommu_per_bus() for per-bus IOMMU ops retrieval

2025-07-08 Thread Nicolin Chen
On Tue, Jul 08, 2025 at 04:40:50PM +0100, Shameer Kolothum wrote: > @@ -2909,6 +2909,19 @@ static void pci_device_get_iommu_bus_devfn(PCIDevice > *dev, > } > } > > +/* > + * When multiple PCI Express Root Buses are defined using pxb-pcie, > + * the I

Re: [PATCH v7 02/12] hw/arm/smmu-common: Check SMMU has PCIe Root Complex association

2025-07-08 Thread Nicolin Chen
On Tue, Jul 08, 2025 at 04:40:45PM +0100, Shameer Kolothum wrote: > @@ -937,11 +939,32 @@ static void smmu_base_realize(DeviceState *dev, Error > **errp) > g_free, g_free); > s->smmu_pcibus_by_busptr = g_hash_table_new(NULL, NULL); Although this is not i

Re: [PATCH v6 00/12] hw/arm/virt: Add support for user creatable SMMUv3 device

2025-07-08 Thread Nicolin Chen
On Tue, Jul 08, 2025 at 08:57:37AM +, Shameerali Kolothum Thodi wrote: > > Thank you for the effort and the work here. > > > > A separate topic: do you have any preparation for the vIOMMU uAPI > > patches (iommufd backends) in QEMU? > > > > I think it should be the next step after this series

Re: [PATCH v6 00/12] hw/arm/virt: Add support for user creatable SMMUv3 device

2025-07-08 Thread Nicolin Chen
On Thu, Jul 03, 2025 at 09:46:31AM +0100, Shameer Kolothum wrote: > 1. Rebased to target-arm.next and resolved conflicts with the series >[PATCH-for-10.1 v6 0/9] hw/arm: GIC 'its=off'. > 2. While at it, noticed an issue with RC id mappings creation >and patch #1 is a fix for that. > 3. Pat

Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to host

2025-06-16 Thread Nicolin Chen
On Mon, Jun 16, 2025 at 08:15:11AM +, Duan, Zhenzhong wrote: > >IIUIC, the guest kernel cmdline can switch the mode between the > >stage1 (nesting) and stage2 (legacy/emulated VT-d), right? > > Right. E.g., kexec from "intel_iommu=on,sm_on" to "intel_iommu=on,sm_off", > Then first kernel will

Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to host

2025-06-16 Thread Nicolin Chen
On Mon, Jun 16, 2025 at 03:38:26PM +0800, Yi Liu wrote: > On 2025/6/16 13:59, Nicolin Chen wrote: > > On Thu, Jun 12, 2025 at 08:53:40PM +0800, Yi Liu wrote: > > > > > That being said, IOMMU_NOTIFIER_IOTLB_EVENTS should not be needed > > > > > for passthro

Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to host

2025-06-16 Thread Nicolin Chen
On Mon, Jun 16, 2025 at 03:24:06AM +, Duan, Zhenzhong wrote: > Hi @Liu, Yi L @Nicolin Chen, for emulated/passthru devices > behind the same pcie-pci bridge, I think of an idea, adding > a new PCI callback: > > AddressSpace * (*get_address_space_extend)(PCIBus *bus, > void

Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to host

2025-06-15 Thread Nicolin Chen
On Thu, Jun 12, 2025 at 02:06:15PM +, Shameerali Kolothum Thodi wrote: > > >> The "switch" in vSMMU model is only needed by KVM for MSI doorbell > > >> translation. By thinking it carefully, maybe it shouldn't switch AS > > >> because VFIO might be confused if it somehow does get_address_space

Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to host

2025-06-15 Thread Nicolin Chen
On Thu, Jun 12, 2025 at 08:53:40PM +0800, Yi Liu wrote: > > > That being said, IOMMU_NOTIFIER_IOTLB_EVENTS should not be needed > > > for passthrough devices, right? > > > > No, even if x-flts=on is configured in QEMU cmdline, that only mean virtual > > vtd > > supports stage-1 translation, guest

Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to host

2025-06-15 Thread Nicolin Chen
Sorry for a late reply. On Wed, May 28, 2025 at 07:12:25AM +, Duan, Zhenzhong wrote: > >Third, the vSMMU model, for invalidation efficiency and HW Queue > >support, isolates all emulated devices out of the nesting-enabled > >vSMMU instance, suggested by Jason. So, only passthrough devices > >w

Re: [PATCH v4 2/7] hw/arm/virt-acpi-build: Re-arrange SMMUv3 IORT build

2025-06-15 Thread Nicolin Chen
l > soon add support for user-creatable SMMUv3 devices. These changes will > be useful to have common code paths when we add that support. > > Tested-by: Nathan Chen > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen > +static void > +populate_smmuv3_legacy_dev(GArray

Re: [PATCH v4 7/7] qemu-options.hx: Document the arm-smmuv3 device

2025-06-15 Thread Nicolin Chen
On Fri, Jun 13, 2025 at 03:44:49PM +0100, Shameer Kolothum wrote: > Now that arm,virt can have user-creatable smmuv3 devices, document it. > > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen

Re: [PATCH v4 6/7] hw/arm/virt: Allow user-creatable SMMUv3 dev instantiation

2025-06-15 Thread Nicolin Chen
he default pcie.0 RC. I forgot the detail for this limitation. Maybe spare a few more words briefly describing why? > Tested-by: Nathan Chen > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen

Re: [PATCH v4 3/7] hw/arm/virt-acpi-build: Update IORT for multiple smmuv3 devices

2025-06-15 Thread Nicolin Chen
| 0x - 0x00FF (from RC0) | > | 0x0100 - 0x01FF (from RC1) | > | 0x0200 - 0x (No SMMU) | > ++ > > Tested-by: Nathan Chen > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen

Re: [PATCH v4 1/7] hw/arm/smmu-common: Check SMMU has PCIe Root Complex association

2025-06-15 Thread Nicolin Chen
olothum Reviewed-by: Nicolin Chen

Re: [PATCH v2 4/4] vfio/iommufd: Save vendor specific device info

2025-05-30 Thread Nicolin Chen
; capability directly. > > Because IOMMU_GET_HW_INFO is only supported in linux, so declare those > capability related structures with CONFIG_LINUX. > > Suggested-by: Eric Auger > Suggested-by: Nicolin Chen > Signed-off-by: Zhenzhong Duan Reviewed-by: Nicolin Chen I like

Re: [PATCH v2 2/4] vfio/iommufd: Add properties and handlers to TYPE_HOST_IOMMU_DEVICE_IOMMUFD

2025-05-30 Thread Nicolin Chen
On Fri, May 30, 2025 at 05:35:10PM +0800, Zhenzhong Duan wrote: > Enhance HostIOMMUDeviceIOMMUFD object with 3 new members, specific > to the iommufd BE + 2 new class functions. > > IOMMUFD BE includes IOMMUFD handle, devid and hwpt_id. IOMMUFD handle > and devid are used to allocate/free ioas and

Re: [PATCH v2 3/4] vfio/iommufd: Implement [at|de]tach_hwpt handlers

2025-05-30 Thread Nicolin Chen via
ater Reviewed-by: Nicolin Chen > +static bool > +host_iommu_device_iommufd_vfio_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev, > + uint32_t hwpt_id, Error **errp) > +{ > +VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent; > + >

Re: [PATCH v1 1/6] backends/iommufd: Add a helper to invalidate user-managed HWPT

2025-05-29 Thread Nicolin Chen
On Thu, May 29, 2025 at 06:46:20AM +, Duan, Zhenzhong wrote: > >Looking at the kernel iommufd_hwpt_invalidate() routine and > >intel_nested_cache_invalidate_user(), it doesn't seem possible to > >return a different number of cache entries. Are you anticipating > >other implementations (sMMU) ?

Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to host

2025-05-26 Thread Nicolin Chen
OK. Let me clarify this at the top as I see the gap here now: First, the vSMMU model is based on Zhenzhong's older series that keeps an ioas_id in the HostIOMMUDeviceIOMMUFD structure, which now it only keeps an hwpt_id in this RFCv3 series. This ioas_id is allocated when a passthrough cdev attach

Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to host

2025-05-23 Thread Nicolin Chen
Nic, > > On 2025/5/22 06:49, Nicolin Chen wrote: > > On Wed, May 21, 2025 at 07:14:45PM +0800, Zhenzhong Duan wrote: > > > +static const MemoryListener iommufd_s2domain_memory_listener = { > > > +.name = "iommufd_s2domain", > >

Re: [PATCH rfcv3 05/21] vfio/iommufd: Save vendor specific device info

2025-05-22 Thread Nicolin Chen
On Thu, May 22, 2025 at 09:21:04AM +, Duan, Zhenzhong wrote: > > > >-Original Message----- > >From: Nicolin Chen > >Subject: Re: [PATCH rfcv3 05/21] vfio/iommufd: Save vendor specific device > >info > > > >On Wed, May 21, 2025 at 07:14:35PM +

Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to host

2025-05-22 Thread Nicolin Chen
On Thu, May 22, 2025 at 06:50:42AM +, Duan, Zhenzhong wrote: > > > >-Original Message----- > >From: Nicolin Chen > >Subject: Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to > >host > > > >On Wed, May 21, 2025 at 07:14:45PM

Re: [PATCH rfcv3 15/21] intel_iommu: Bind/unbind guest page table to host

2025-05-21 Thread Nicolin Chen
On Wed, May 21, 2025 at 07:14:45PM +0800, Zhenzhong Duan wrote: > +static const MemoryListener iommufd_s2domain_memory_listener = { > +.name = "iommufd_s2domain", > +.priority = 1000, > +.region_add = iommufd_listener_region_add_s2domain, > +.region_del = iommufd_listener_region_del

Re: [PATCH rfcv3 05/21] vfio/iommufd: Save vendor specific device info

2025-05-21 Thread Nicolin Chen
On Wed, May 21, 2025 at 07:14:35PM +0800, Zhenzhong Duan wrote: > @@ -852,6 +853,17 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice > *hiod, void *opaque, > caps->type = type; > caps->hw_caps = hw_caps; > > +switch (type) { > +case IOMMU_HW_INFO_TYPE_INTEL_VTD: > +

Re: [PATCH 1/5] vfio/iommufd: Save host iommu capabilities in VFIODevice.caps

2025-05-05 Thread Nicolin Chen
On Mon, May 05, 2025 at 06:38:17PM +0200, Eric Auger wrote: > > +/** > > + * struct HostIOMMUDeviceIOMMUFDCaps - Define host IOMMU device > > capabilities. > > + * > > + * @type: host platform IOMMU type. > > + * > > + * @hw_caps: host platform IOMMU capabilities (e.g. on IOMMUFD this > > represe

Re: [PATCH v2 6/6] hw/arm/smmuv3: Enable smmuv3 device creation

2025-05-02 Thread Nicolin Chen
On Fri, May 02, 2025 at 11:27:07AM +0100, Shameer Kolothum wrote: > Signed-off-by: Shameer Kolothum Though I think the commit log shouldn't be empty, Reviewed-by: Nicolin Chen

Re: [PATCH v2 5/6] hw/arm/virt: Add support for smmuv3 device

2025-05-02 Thread Nicolin Chen
On Fri, May 02, 2025 at 11:27:06AM +0100, Shameer Kolothum wrote: > @@ -2972,6 +3004,21 @@ static void virt_machine_device_plug_cb(HotplugHandler > *hotplug_dev, > virtio_md_pci_plug(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev), errp); > } > > +if (object_dynamic_cast(OBJECT(dev),

Re: [PATCH v2 1/6] hw/arm/smmuv3: Add support to associate a PCIe RC

2025-05-02 Thread Nicolin Chen
On Fri, May 02, 2025 at 11:27:02AM +0100, Shameer Kolothum wrote: > Although this change does not affect functionality at present, it lays > the groundwork for enabling user-created SMMUv3 devices in > future patches > > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen

Re: [PATCH v2 3/6] hw/arm/virt: Factor out common SMMUV3 dt bindings code

2025-05-02 Thread Nicolin Chen
On Fri, May 02, 2025 at 11:27:04AM +0100, Shameer Kolothum wrote: > No functional changes intended. This will be useful when we > add support for user-creatable smmuv3 device. > > Signed-off-by: Shameer Kolothum Reviewed-by: Nicolin Chen

Re: [PATCH v2 2/6] hw/arm/virt-acpi-build: Update IORT for multiple smmuv3 devices

2025-05-02 Thread Nicolin Chen
_base - map_b->input_base; > +} > + > +static void > +get_smmuv3_legacy_dev(VirtMachineState *vms, GArray * smmuv3_devices) GArray *smmuv3_devices Or maybe align with the non-legacy path, i.e. "sdev_blob"? Or the other way around. Otherwise, lgtm Reviewed-by: Nicolin Chen

Re: [RFC PATCH v2 19/20] hw/arm/virt-acpi-build: Update IORT with multiple smmuv3-accel nodes

2025-04-05 Thread Nicolin Chen
On Wed, Mar 26, 2025 at 07:14:31PM +0100, Eric Auger wrote: > > > On 3/11/25 3:10 PM, Shameer Kolothum wrote: > > Now that we can have multiple user-creatable smmuv3-accel devices, > > each associated with different pci buses, update IORT ID mappings > > accordingly. > > > > Signed-off-by: Shamee

Re: [RFC PATCH v2 05/20] hw/arm/smmuv3-accel: Associate a pxb-pcie bus

2025-04-05 Thread Nicolin Chen
On Wed, Mar 19, 2025 at 09:26:29AM +, Shameerali Kolothum Thodi wrote: > Having said that, current code only allows pxb-pcie root complexes avoiding > the pcie.0. The idea behind this was, user can use pcie.0 with a non accel > SMMUv3 > for any emulated devices avoiding the performance bottle

Re: [RFC PATCH v2 18/20] hw/arm/smmu-common: Bypass emulated IOTLB for a accel SMMUv3

2025-03-26 Thread Nicolin Chen
On Wed, Mar 26, 2025 at 06:40:10PM +0100, Eric Auger wrote: > On 3/11/25 3:10 PM, Shameer Kolothum wrote: > > From: Nicolin Chen > > > > If a vSMMU is configured as a accelerated one, HW IOTLB will be used > > and all cache invalidation should be done to the HW IOTLB

Re: [RFC PATCH v2 17/20] hw/arm/smmuv3: Check idr registers for STE_S1CDMAX and STE_S1STALLD

2025-03-26 Thread Nicolin Chen
On Wed, Mar 26, 2025 at 06:18:49PM +0100, Eric Auger wrote: > > @@ -561,6 +561,16 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg > > *cfg, > > > > decode_ste_config(cfg, config); > > > > + /* S1DSS.Terminate is same as Config.abort for default stream */ > > S1DSS. Termination

Re: [RFC PATCH v2 15/20] hw/arm/smmuv3: Forward invalidation commands to hw

2025-03-26 Thread Nicolin Chen
On Wed, Mar 26, 2025 at 03:16:18PM +0100, Eric Auger wrote: > > @@ -1395,6 +1403,13 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) > > > > trace_smmuv3_cmdq_cfgi_cd(sid); > > smmuv3_flush_config(sdev); > > + > > +if (smmuv3_accel_batch_cmds(sdev->smmu, sde

Re: [RFC PATCH v2 13/20] hw/arm/smmuv3-accel: Introduce helpers to batch and issue cache invalidations

2025-03-26 Thread Nicolin Chen
On Wed, Mar 26, 2025 at 02:38:04PM +0100, Eric Auger wrote: > > +/* Update batch->ncmds to the number of execute cmds */ > > +int smmuv3_accel_issue_cmd_batch(SMMUState *bs, SMMUCommandBatch *batch) > > +{ > > +SMMUv3AccelState *s_accel = ARM_SMMUV3_ACCEL(bs); > > +uint32_t total = batch->n

Re: [RFC PATCH v2 10/20] hw/arm/smmuv3-accel: Support nested STE install/uninstall support

2025-03-25 Thread Nicolin Chen
On Tue, Mar 25, 2025 at 07:08:29PM +0100, Eric Auger wrote: > > +static int > > +smmuv3_accel_dev_install_nested_ste(SMMUv3AccelDevice *accel_dev, > > +uint32_t data_type, uint32_t data_len, > > +void *data) > > +{ > > +SMM

Re: [RFC PATCH v2 00/20] hw/arm/virt: Add support for user-creatable accelerated SMMUv3

2025-03-25 Thread Nicolin Chen via
On Tue, Mar 25, 2025 at 03:43:29PM +, Shameerali Kolothum Thodi wrote: > > For the record I tested the series with host VFIO device and a > > virtio-blk-pci device put behind the same pxb-pcie/smmu protection and > > it works just fine > > > > -+-[:0a]-+-01.0-[0b]00.0  Mellanox Technol

Re: [RFC PATCH v2 05/20] hw/arm/smmuv3-accel: Associate a pxb-pcie bus

2025-03-24 Thread Nicolin Chen
On Mon, Mar 24, 2025 at 02:13:20PM +0100, Eric Auger wrote: > >> If VM has an emulated device and a passthrough device: > >> attach the emulated device to PCIE.0 <=> vSMMU bypass (or accel=off?) > >> attach the passthrough device to pxb-pcie <=> vSMMU0 (accel=on) > > This can be other way around

Re: [RFC PATCH v2 05/20] hw/arm/smmuv3-accel: Associate a pxb-pcie bus

2025-03-24 Thread Nicolin Chen
On Mon, Mar 24, 2025 at 08:19:27AM +, Shameerali Kolothum Thodi wrote: > > If VM has an emulated device and a passthrough device: > > attach the emulated device to PCIE.0 <=> vSMMU bypass (or accel=off?) > > attach the passthrough device to pxb-pcie <=> vSMMU0 (accel=on) > > This can be othe

Re: [RFC PATCH v2 03/20] hw/arm/smmuv3-accel: Add initial infrastructure for smmuv3-accel device

2025-03-19 Thread Nicolin Chen
On Wed, Mar 19, 2025 at 07:09:33PM +0100, Eric Auger wrote: > > Option means something like this: > > -device smmuv3,accel=on > > instead of > > -device "smmuv3-accel" > > ? > > > > Yea, I think that's good. > Yeah actually that's a big debate for not much. From an implementation > pov tha

Re: [RFC PATCH v2 03/20] hw/arm/smmuv3-accel: Add initial infrastructure for smmuv3-accel device

2025-03-19 Thread Nicolin Chen
On Wed, Mar 19, 2025 at 05:45:51PM +0100, Eric Auger wrote: > > > > On 3/17/25 8:10 PM, Nicolin Chen wrote: > > On Mon, Mar 17, 2025 at 07:07:52PM +0100, Eric Auger wrote: > >> On 3/17/25 6:54 PM, Nicolin Chen wrote: > >>> On Wed, Mar 12, 2025 at 04:15:10

Re: [RFC PATCH v2 13/20] hw/arm/smmuv3-accel: Introduce helpers to batch and issue cache invalidations

2025-03-19 Thread Nicolin Chen
On Wed, Mar 19, 2025 at 12:24:32PM -0400, Donald Dutile wrote: > > > On 3/11/25 10:10 AM, Shameer Kolothum wrote: > > > > From: Nicolin Chen > > > > > > > > Inroduce an SMMUCommandBatch and some helpers to batch and issue > > > the >

Re: [RFC PATCH v2 03/20] hw/arm/smmuv3-accel: Add initial infrastructure for smmuv3-accel device

2025-03-18 Thread Nicolin Chen
On Tue, Mar 18, 2025 at 09:31:35PM -0300, Jason Gunthorpe wrote: > On Tue, Mar 18, 2025 at 07:31:36PM +0100, Eric Auger wrote: > > Nevertheless I don't think anything prevents the acceleration granted > > device from also working with virtio/vhost devices for instance unless > > you unplug the exis

Re: [RFC PATCH v2 03/20] hw/arm/smmuv3-accel: Add initial infrastructure for smmuv3-accel device

2025-03-18 Thread Nicolin Chen
On Tue, Mar 18, 2025 at 07:31:36PM +0100, Eric Auger wrote: > On 3/17/25 9:19 PM, Nicolin Chen wrote: > > On Mon, Mar 17, 2025 at 04:24:53PM -0300, Jason Gunthorpe wrote: > >> On Mon, Mar 17, 2025 at 12:10:19PM -0700, Nicolin Chen wrote: > >>> Another question: ho

Re: [RFC PATCH v2 03/20] hw/arm/smmuv3-accel: Add initial infrastructure for smmuv3-accel device

2025-03-17 Thread Nicolin Chen
On Mon, Mar 17, 2025 at 04:24:53PM -0300, Jason Gunthorpe wrote: > On Mon, Mar 17, 2025 at 12:10:19PM -0700, Nicolin Chen wrote: > > Another question: how does an emulated device work with a vSMMUv3? > > I could imagine that all the accel steps would be bypassed since > >

Re: [RFC PATCH v2 03/20] hw/arm/smmuv3-accel: Add initial infrastructure for smmuv3-accel device

2025-03-17 Thread Nicolin Chen
On Mon, Mar 17, 2025 at 07:07:52PM +0100, Eric Auger wrote: > On 3/17/25 6:54 PM, Nicolin Chen wrote: > > On Wed, Mar 12, 2025 at 04:15:10PM +0100, Eric Auger wrote: > >> On 3/11/25 3:10 PM, Shameer Kolothum wrote: > >>> Based on SMMUv3 as a parent device, add

Re: [RFC PATCH v2 09/20] hw/arm/smmuv3-accel: Add set/unset_iommu_device callback

2025-03-17 Thread Nicolin Chen
On Mon, Mar 17, 2025 at 08:38:23AM +, Shameerali Kolothum Thodi wrote: > Hi Nicolin, > > > -Original Message- > > From: Nicolin Chen > > Sent: Tuesday, March 11, 2025 9:08 PM > > To: Shameerali Kolothum Thodi > > Cc: qemu-...@nongnu.org

Re: [RFC PATCH v2 03/20] hw/arm/smmuv3-accel: Add initial infrastructure for smmuv3-accel device

2025-03-17 Thread Nicolin Chen
On Wed, Mar 12, 2025 at 04:15:10PM +0100, Eric Auger wrote: > On 3/11/25 3:10 PM, Shameer Kolothum wrote: > > Based on SMMUv3 as a parent device, add a user-creatable smmuv3-accel > > device. In order to support vfio-pci dev assignment with a Guest > guest > > SMMUv3, the physical SMMUv3 has to be

Re: [RFC PATCH v2 09/20] hw/arm/smmuv3-accel: Add set/unset_iommu_device callback

2025-03-11 Thread Nicolin Chen
On Tue, Mar 11, 2025 at 02:10:34PM +, Shameer Kolothum wrote: > @@ -30,6 +32,185 @@ static SMMUv3AccelDevice *smmuv3_accel_get_dev(SMMUState > *s, SMMUPciBus *sbus, > return accel_dev; > } > > +static bool > +smmuv3_accel_dev_attach_viommu(SMMUv3AccelDevice *accel_dev, > +

Re: [RFC PATCH v2 08/20] hw/arm/smmuv3-accel: Provide get_address_space callback

2025-03-11 Thread Nicolin Chen
On Tue, Mar 11, 2025 at 02:10:33PM +, Shameer Kolothum wrote: > diff --git a/include/hw/arm/smmuv3-accel.h b/include/hw/arm/smmuv3-accel.h > index 56fe376bf4..86c0523063 100644 > --- a/include/hw/arm/smmuv3-accel.h > +++ b/include/hw/arm/smmuv3-accel.h > @@ -16,6 +16,10 @@ > #define TYPE_ARM_S

  1   2   >