Re: [PATCH] iommu/vt-d: Increase DMAR_UNITS_SUPPORTED

2022-05-05 Thread Baolu Lu
On 2022/5/6 03:46, Steve Wahl wrote: Increase DMAR_UNITS_SUPPORTED to support 64 sockets with 10 DMAR units each, for a total of 640. If the available hardware exceeds DMAR_UNITS_SUPPORTED (previously set to MAX_IO_APICS, or 128), it causes these messages: "DMAR: Failed to allocate seq_id",

Re: [PATCH v5 10/12] iommu: Prepare IOMMU domain for IOPF

2022-05-05 Thread Baolu Lu
On 2022/5/5 21:38, Jean-Philippe Brucker wrote: Hi Baolu, On Thu, May 05, 2022 at 04:31:38PM +0800, Baolu Lu wrote: On 2022/5/4 02:20, Jean-Philippe Brucker wrote: diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 7cae631c1baa..33449523afbe 100644 --- a/drivers/iommu/iommu.c

Re: [PATCH v3] iommu/mediatek: Fix NULL pointer dereference when printing dev_name

2022-05-05 Thread Yong Wu via iommu
On Thu, 2022-05-05 at 21:27 +0800, Miles Chen wrote: > When larbdev is NULL (in the case I hit, the node is incorrectly set > iommus = < NUM>), it will cause device_link_add() fail and > kernel crashes when we try to print dev_name(larbdev). > > Let's fail the probe if a larbdev is NULL to avoid

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-05-05 Thread Baolu Lu
On 2022/5/3 15:49, Jean-Philippe Brucker wrote: On Sat, Apr 30, 2022 at 03:33:17PM +0800, Baolu Lu wrote: Jean, another quick question about the iommu_sva_bind_device() /** * iommu_sva_bind_device() - Bind a process address space to a device * @dev: the device * @mm: the mm to bind,

[PATCH v3 4/4] iommu/vt-d: Remove hard coding PGSNP bit in PASID entries

2022-05-05 Thread Lu Baolu
As enforce_cache_coherency has been introduced into the iommu_domain_ops, the kernel component which owns the iommu domain is able to opt-in its requirement for force snooping support. The iommu driver has no need to hard code the page snoop control bit in the PASID table entries anymore.

[PATCH v3 3/4] iommu/vt-d: Remove domain_update_iommu_snooping()

2022-05-05 Thread Lu Baolu
The IOMMU force snooping capability is not required to be consistent among all the IOMMUs anymore. Remove force snooping capability check in the IOMMU hot-add path and domain_update_iommu_snooping() becomes a dead code now. Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin

[PATCH v3 2/4] iommu/vt-d: Check domain force_snooping against attached devices

2022-05-05 Thread Lu Baolu
As domain->force_snooping only impacts the devices attached with the domain, there's no need to check against all IOMMU units. On the other hand, force_snooping could be set on a domain no matter whether it has been attached or not, and once set it is an immutable flag. If no device attached, the

[PATCH v3 1/4] iommu/vt-d: Block force-snoop domain attaching if no SC support

2022-05-05 Thread Lu Baolu
In the attach_dev callback of the default domain ops, if the domain has been set force_snooping, but the iommu hardware of the device does not support SC(Snoop Control) capability, the callback should block it and return a corresponding error code. Signed-off-by: Lu Baolu Reviewed-by: Jason

[PATCH v3 0/4] iommu/vt-d: Force snooping improvement

2022-05-05 Thread Lu Baolu
Hi folks, Previously, the IOMMU capability of enforcing cache coherency was queried through iommu_capable(IOMMU_CAP_CACHE_COHERENCY). This is a global capability, hence the IOMMU driver reports support for this capability only when all IOMMUs in the system has this support. Commit 6043257b1de06

Re: [PATCH RFC 11/12] iommufd: vfio container FD ioctl compatibility

2022-05-05 Thread David Gibson
On Thu, May 05, 2022 at 04:07:28PM -0300, Jason Gunthorpe wrote: > On Mon, May 02, 2022 at 05:30:05PM +1000, David Gibson wrote: > > > > It is a bit more CPU work since maps in the lower range would have to > > > be copied over, but conceptually the model matches the HW nesting. > > > > Ah.. ok.

RE: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-05-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, May 5, 2022 10:08 PM > > On Thu, May 05, 2022 at 07:40:37AM +, Tian, Kevin wrote: > > > In concept this is an iommu property instead of a domain property. > > Not really, domains shouldn't be changing behaviors once they are > created. If a domain

RE: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-05-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, May 5, 2022 9:55 PM > > On Thu, May 05, 2022 at 11:03:18AM +, Tian, Kevin wrote: > > > iiuc the purpose of 'write-protection' here is to capture in-fly dirty pages > > in the said race window until unmap and iotlb is invalidated is completed. > >

RE: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-05-05 Thread Tian, Kevin
> From: Joao Martins > Sent: Thursday, May 5, 2022 7:51 PM > > On 5/5/22 12:03, Tian, Kevin wrote: > >> From: Joao Martins > >> Sent: Thursday, May 5, 2022 6:07 PM > >> > >> On 5/5/22 08:42, Tian, Kevin wrote: > From: Jason Gunthorpe > Sent: Tuesday, May 3, 2022 2:53 AM > >

Re: [PATCH v2] iommu/sva: Fix PASID use-after-free issue

2022-05-05 Thread Zhangfei Gao
On 2022/4/29 上午9:39, Zhangfei Gao wrote: On 2022/4/29 上午2:00, Fenghua Yu wrote: The PASID is being freed too early.  It needs to stay around until after device drivers that might be using it have had a chance to clear it out of the hardware. As a reminder: mmget() /mmput()  refcount the

[PATCH v6 29/29] x86/tsc: Switch to perf-based hardlockup detector if TSC become unstable

2022-05-05 Thread Ricardo Neri
The HPET-based hardlockup detector relies on the TSC to determine if an observed NMI interrupt was originated by HPET timer. Hence, this detector can no longer be used with an unstable TSC. In such case, permanently stop the HPET-based hardlockup detector and start the perf-based detector. Cc:

[PATCH v6 26/29] x86/watchdog: Add a shim hardlockup detector

2022-05-05 Thread Ricardo Neri
The generic hardlockup detector is based on perf. It also provides a set of weak functions that CPU architectures can override. Add a shim hardlockup detector for x86 that overrides such functions and can select between perf and HPET implementations of the detector. For clarity, add the

[PATCH v6 23/29] x86/watchdog/hardlockup/hpet: Determine if HPET timer caused NMI

2022-05-05 Thread Ricardo Neri
It is not possible to determine the source of a non-maskable interrupt (NMI) in x86. When dealing with an HPET channel, the only direct method to determine whether it caused an NMI would be to read the Interrupt Status register. However, reading HPET registers is slow and, therefore, not to be

[PATCH v6 27/29] watchdog: Expose lockup_detector_reconfigure()

2022-05-05 Thread Ricardo Neri
When there are multiple implementations of the NMI watchdog, there may be situations in which switching from one to another is needed. If the time- stamp counter becomes unstable, the HPET-based NMI watchdog can no longer be used. Similarly, the HPET-based NMI watchdog relies on tsc_khz and needs

[PATCH v6 28/29] x86/tsc: Restart NMI watchdog after refining tsc_khz

2022-05-05 Thread Ricardo Neri
The HPET hardlockup detector relies on tsc_khz to estimate the value of that the TSC will have when its HPET channel fires. A refined tsc_khz helps to estimate better the expected TSC value. Using the early value of tsc_khz may lead to a large error in the expected TSC value. Restarting the NMI

[PATCH v6 25/29] watchdog/hardlockup/hpet: Only enable the HPET watchdog via a boot parameter

2022-05-05 Thread Ricardo Neri
Keep the HPET-based hardlockup detector disabled unless explicitly enabled via a command-line argument. If such parameter is not given, the initialization of the HPET-based hardlockup detector fails and the NMI watchdog will fall back to use the perf-based implementation. Implement the

[PATCH v6 22/29] x86/watchdog/hardlockup: Add an HPET-based hardlockup detector

2022-05-05 Thread Ricardo Neri
Implement a hardlockup detector that uses an HPET channel as the source of the non-maskable interrupt. Implement the basic functionality to start, stop, and configure the timer. Designate as the handling CPU one of the CPUs that the detector monitors. Use it to service the NMI from the HPET

[PATCH v6 24/29] watchdog/hardlockup: Use parse_option_str() to handle "nmi_watchdog"

2022-05-05 Thread Ricardo Neri
Prepare hardlockup_panic_setup() to handle a comma-separated list of options. Thus, it can continue parsing its own command-line options while ignoring parameters that are relevant only to specific implementations of the hardlockup detector. Such implementations may use an early_param to parse

[PATCH v6 20/29] init/main: Delay initialization of the lockup detector after smp_init()

2022-05-05 Thread Ricardo Neri
Certain implementations of the hardlockup detector require support for Inter-Processor Interrupt shorthands. On x86, support for these can only be determined after all the possible CPUs have booted once (in smp_init()). Other architectures may not need such check. lockup_detector_init() only

[PATCH v6 21/29] x86/nmi: Add an NMI_WATCHDOG NMI handler category

2022-05-05 Thread Ricardo Neri
Add a NMI_WATCHDOG as a new category of NMI handler. This new category is to be used with the HPET-based hardlockup detector. This detector does not have a direct way of checking if the HPET timer is the source of the NMI. Instead, it indirectly estimates it using the time-stamp counter.

[PATCH v6 18/29] watchdog/hardlockup: Define a generic function to detect hardlockups

2022-05-05 Thread Ricardo Neri
The procedure to detect hardlockups is independent of the underlying mechanism that generates the non-maskable interrupt used to drive the detector. Thus, it can be put in a separate, generic function. In this manner, it can be invoked by various implementations of the NMI watchdog. For this

[PATCH v6 19/29] watchdog/hardlockup: Decouple the hardlockup detector from perf

2022-05-05 Thread Ricardo Neri
The current default implementation of the hardlockup detector assumes that it is implemented using perf events. However, the hardlockup detector can be driven by other sources of non-maskable interrupts (e.g., a properly configured timer). Group and wrap in #ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF

[PATCH v6 17/29] x86/hpet: Reserve an HPET channel for the hardlockup detector

2022-05-05 Thread Ricardo Neri
The HPET hardlockup detector needs a dedicated HPET channel. Hence, create a new HPET_MODE_NMI_WATCHDOG mode category to indicate that it cannot be used for other purposes. Using MSI interrupts greatly simplifies the implementation of the detector. Specifically, it helps to avoid the complexities

[PATCH v6 08/29] iommu/vt-d: Rework prepare_irte() to support per-IRQ delivery mode

2022-05-05 Thread Ricardo Neri
struct irq_cfg::delivery_mode specifies the delivery mode of each IRQ separately. Configuring the delivery mode of an IRTE would require adding a third argument to prepare_irte(). Instead, simply take a pointer to the irq_cfg for which an IRTE is being configured. This change does not cause

[PATCH v6 01/29] irq/matrix: Expose functions to allocate the best CPU for new vectors

2022-05-05 Thread Ricardo Neri
Certain types of interrupts, such as NMI, do not have an associated vector. They, however, target specific CPUs. Thus, when assigning the destination CPU, it is beneficial to select the one with the lowest number of vectors. Prepend the functions matrix_find_best_cpu_managed() and

[PATCH v6 16/29] x86/hpet: Prepare IRQ assignments to use the X86_ALLOC_AS_NMI flag

2022-05-05 Thread Ricardo Neri
The flag X86_ALLOC_AS_NMI indicates that the IRQs to be allocated in an IRQ domain need to be configured as NMIs. Add an as_nmi argument to hpet_assign_irq(). Even though the HPET clock events do not need NMI IRQs, the HPET hardlockup detector does. A subsequent changeset will implement the

[PATCH v6 15/29] x86/hpet: Add helper function hpet_set_comparator_periodic()

2022-05-05 Thread Ricardo Neri
Programming an HPET channel as periodic requires setting the HPET_TN_SETVAL bit in the channel configuration. Plus, the comparator register must be written twice (once for the comparator value and once for the periodic value). Since this programming might be needed in several places (e.g., the

[PATCH v6 03/29] x86/apic/msi: Set the delivery mode individually for each IRQ

2022-05-05 Thread Ricardo Neri
There are no restrictions in hardware to set MSI messages with its own delivery mode. Use the mode specified in the provided IRQ hardware configuration data. Since most of the IRQs are configured to use the delivery mode of the APIC driver in use (set in all of them to APIC_DELIVERY_MODE_FIXED),

[PATCH v6 11/29] iommu/amd: Expose [set|get]_dev_entry_bit()

2022-05-05 Thread Ricardo Neri
These functions are used to check and set specific bits in a Device Table Entry. For instance, they can be used to modify the setting of the NMIPass field. Currently, these functions are used only for ACPI-specified devices. However, an interrupt is to be allocated with NMI as delivery mode, the

[PATCH v6 12/29] iommu/amd: Enable NMIPass when allocating an NMI irq

2022-05-05 Thread Ricardo Neri
As per the AMD I/O Virtualization Technology (IOMMU) Specification, the AMD IOMMU only remaps fixed and arbitrated MSIs. NMIs are controlled by the NMIPass bit of a Device Table Entry. When set, the IOMMU passes through NMI interrupt messages unmapped. Otherwise, they are aborted. Furthermore,

[PATCH v6 00/29] x86: Implement an HPET-based hardlockup detector

2022-05-05 Thread Ricardo Neri
Hi, This is the sixth version of this patchset. It again took me a while to post this version as I have been working on other projects and implemented major reworks in the series. This work has gone through several versions. I have incorporated feedback from Thomas Gleixner and others. Many of

[PATCH v6 14/29] x86/hpet: Expose hpet_writel() in header

2022-05-05 Thread Ricardo Neri
In order to allow hpet_writel() to be used by other components (e.g., the HPET-based hardlockup detector), expose it in the HPET header file. Cc: Andi Kleen Cc: Stephane Eranian Cc: "Ravi V. Shankar" Cc: iommu@lists.linux-foundation.org Cc: linuxppc-...@lists.ozlabs.org Cc: x...@kernel.org

[PATCH v6 13/29] iommu/amd: Compose MSI messages for NMI irqs in non-IR format

2022-05-05 Thread Ricardo Neri
If NMIPass is enabled in a device's DTE, the IOMMU lets NMI interrupt messages pass through unmapped. Therefore, the contents of the MSI message, not an IRTE, determine how and where the NMI is delivered. Since the IOMMU driver owns the MSI message of the NMI irq, compose it using the

[PATCH v6 07/29] iommu/vt-d: Clear the redirection hint when the destination mode is physical

2022-05-05 Thread Ricardo Neri
When the destination mode of an interrupt is physical APICID, the interrupt is delivered only to the single CPU of which the physical APICID is specified in the destination ID field. Therefore, the redirection hint is meaningless. Furthermore, on certain processors, the IOMMU does not deliver the

[PATCH v6 10/29] iommu/vt-d: Implement minor tweaks for NMI irqs

2022-05-05 Thread Ricardo Neri
The Intel IOMMU interrupt remapping driver already programs correctly the delivery mode of individual irqs as per their irq_data. Improve handling of NMIs. Allow only one irq per NMI. Also, it is not necessary to cleanup irq vectors after updating affinity. NMIs do not have associated vectors.

[PATCH v6 02/29] x86/apic: Add irq_cfg::delivery_mode

2022-05-05 Thread Ricardo Neri
Currently, the delivery mode of all interrupts is set to the mode of the APIC driver in use. There are no restrictions in hardware to configure the delivery mode of each interrupt individually. Also, certain IRQs need to be configured with a specific delivery mode (e.g., NMI). Add a new member,

[PATCH v6 09/29] iommu/vt-d: Set the IRTE delivery mode individually for each IRQ

2022-05-05 Thread Ricardo Neri
There are no hardware requirements to use the same delivery mode for all interrupts. Use the mode specified in the provided IRQ hardware configuration data. Since all IRQs are configured to use the delivery mode of the APIC drive, the only functional changes are where IRQs are configured to use a

[PATCH v6 06/29] x86/apic/vector: Implement support for NMI delivery mode

2022-05-05 Thread Ricardo Neri
The flag X86_IRQ_ALLOC_AS_NMI indicates to the interrupt controller that it should configure the delivery mode of an IRQ as NMI. Implement such request. This causes irq_domain children in the hierarchy to configure their irq_chips accordingly. When no specific delivery mode is requested, continue

[PATCH v6 04/29] x86/apic: Add the X86_IRQ_ALLOC_AS_NMI irq allocation flag

2022-05-05 Thread Ricardo Neri
There are cases in which it is necessary to set the delivery mode of an interrupt as NMI. Add a new flag that callers can specify when allocating an IRQ. Cc: Andi Kleen Cc: "Ravi V. Shankar" Cc: Stephane Eranian Cc: iommu@lists.linux-foundation.org Cc: linuxppc-...@lists.ozlabs.org Cc:

[PATCH v6 05/29] x86/apic/vector: Do not allocate vectors for NMIs

2022-05-05 Thread Ricardo Neri
Vectors are meaningless when allocating IRQs with NMI as the delivery mode. In such case, skip the reservation of IRQ vectors. Do it in the lowest- level functions where the actual IRQ reservation takes place. Since NMIs target specific CPUs, keep the functionality to find the best CPU. Cc: Andi

RE: [PATCH] iommu: Reorganize __iommu_attach_group()

2022-05-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Friday, May 6, 2022 12:16 AM > > Call iommu_group_do_attach_device() only from > __iommu_group_attach_domain() which should be used to attach any > domain to > the group. > > The only unique thing __iommu_attach_group() does is to check if the group > is already

RE: [PATCH v2] iommu: iommu_group_claim_dma_owner() must always assign a domain

2022-05-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, May 5, 2022 11:33 PM > > > /* > > > - * If the group has been claimed already, do not re-attach the default > > > - * domain. > > > + * New drivers should support default domains and so the > > > detach_dev() op > > > + * will never be called.

[PATCH] iommu/vt-d: Increase DMAR_UNITS_SUPPORTED

2022-05-05 Thread Steve Wahl
Increase DMAR_UNITS_SUPPORTED to support 64 sockets with 10 DMAR units each, for a total of 640. If the available hardware exceeds DMAR_UNITS_SUPPORTED (previously set to MAX_IO_APICS, or 128), it causes these messages: "DMAR: Failed to allocate seq_id", "DMAR: Parse DMAR table failure.", and

Re: [PATCH v2] iommu: iommu_group_claim_dma_owner() must always assign a domain

2022-05-05 Thread Robin Murphy
On 2022-05-05 20:27, Jason Gunthorpe wrote: On Thu, May 05, 2022 at 07:56:59PM +0100, Robin Murphy wrote: Ack to that, there are certainly further improvements to consider once we've got known-working code into a released kernel, but let's not get ahead of ourselves just now. Yes please

Re: [PATCH v2] iommu: iommu_group_claim_dma_owner() must always assign a domain

2022-05-05 Thread Jason Gunthorpe via iommu
On Thu, May 05, 2022 at 07:56:59PM +0100, Robin Murphy wrote: > Ack to that, there are certainly further improvements to consider once we've > got known-working code into a released kernel, but let's not get ahead of > ourselves just now. Yes please > (I'm pretty sure we could get away with a

Re: [PATCH RFC 11/12] iommufd: vfio container FD ioctl compatibility

2022-05-05 Thread Jason Gunthorpe via iommu
On Mon, May 02, 2022 at 05:30:05PM +1000, David Gibson wrote: > > It is a bit more CPU work since maps in the lower range would have to > > be copied over, but conceptually the model matches the HW nesting. > > Ah.. ok. IIUC what you're saying is that the kernel-side IOASes have > fixed

Re: [PATCH v2] iommu: iommu_group_claim_dma_owner() must always assign a domain

2022-05-05 Thread Robin Murphy
On 2022-05-05 16:33, Jason Gunthorpe wrote: On Thu, May 05, 2022 at 10:56:28AM +, Tian, Kevin wrote: From: Jason Gunthorpe Sent: Thursday, May 5, 2022 3:09 AM Once the group enters 'owned' mode it can never be assigned back to the default_domain or to a NULL domain. It must always be

Re: [PATCH v7 5/7] perf tool: Add support for HiSilicon PCIe Tune and Trace device driver

2022-05-05 Thread liuqi (BA) via iommu
Hi Leo, Thanks for your review, some replies below. On 2022/4/30 15:35, Leo Yan wrote: On Thu, Apr 07, 2022 at 08:58:39PM +0800, Yicong Yang via iommu wrote: From: Qi Liu 'perf record' and 'perf report --dump-raw-trace' supported in this patch. Example usage: Output will contain raw PTT

[PATCH] iommu: Reorganize __iommu_attach_group()

2022-05-05 Thread Jason Gunthorpe via iommu
Call iommu_group_do_attach_device() only from __iommu_group_attach_domain() which should be used to attach any domain to the group. The only unique thing __iommu_attach_group() does is to check if the group is already attached to some caller specified group. Put this test into

Re: [PATCH v2] iommu: iommu_group_claim_dma_owner() must always assign a domain

2022-05-05 Thread Jason Gunthorpe via iommu
On Thu, May 05, 2022 at 10:56:28AM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Thursday, May 5, 2022 3:09 AM > > > > Once the group enters 'owned' mode it can never be assigned back to the > > default_domain or to a NULL domain. It must always be actively assigned to > > worth

Re: [PATCH v3 0/3] iommu/arm-smmu: Support Tegra234 SMMU

2022-05-05 Thread Thierry Reding
On Thu, May 05, 2022 at 03:53:08PM +0100, Will Deacon wrote: > On Thu, May 05, 2022 at 04:15:29PM +0200, Thierry Reding wrote: > > On Fri, Apr 29, 2022 at 10:22:40AM +0200, Thierry Reding wrote: > > > From: Thierry Reding > > > > > > Hi Joerg, > > > > > > this is essentially a resend of v2 with

Re: [PATCH v3] iommu/mediatek: Fix NULL pointer dereference when printing dev_name

2022-05-05 Thread AngeloGioacchino Del Regno
Il 05/05/22 15:27, Miles Chen ha scritto: When larbdev is NULL (in the case I hit, the node is incorrectly set iommus = < NUM>), it will cause device_link_add() fail and kernel crashes when we try to print dev_name(larbdev). Let's fail the probe if a larbdev is NULL to avoid invalid inputs from

Re: [PATCH v3 0/3] iommu/arm-smmu: Support Tegra234 SMMU

2022-05-05 Thread Will Deacon
On Thu, May 05, 2022 at 04:15:29PM +0200, Thierry Reding wrote: > On Fri, Apr 29, 2022 at 10:22:40AM +0200, Thierry Reding wrote: > > From: Thierry Reding > > > > Hi Joerg, > > > > this is essentially a resend of v2 with a Acked-by:s from Robin and Will > > added. These have been on the list

Re: [PATCH v3 0/3] iommu/arm-smmu: Support Tegra234 SMMU

2022-05-05 Thread Thierry Reding
On Fri, Apr 29, 2022 at 10:22:40AM +0200, Thierry Reding wrote: > From: Thierry Reding > > Hi Joerg, > > this is essentially a resend of v2 with a Acked-by:s from Robin and Will > added. These have been on the list for quite a while now, but apparently > there was a misunderstanding, so neither

Re: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-05-05 Thread Jason Gunthorpe via iommu
On Thu, May 05, 2022 at 07:40:37AM +, Tian, Kevin wrote: > In concept this is an iommu property instead of a domain property. Not really, domains shouldn't be changing behaviors once they are created. If a domain supports dirty tracking and I attach a new device then it still must support

Re: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-05-05 Thread Jason Gunthorpe via iommu
On Thu, May 05, 2022 at 11:03:18AM +, Tian, Kevin wrote: > iiuc the purpose of 'write-protection' here is to capture in-fly dirty pages > in the said race window until unmap and iotlb is invalidated is completed. No, the purpose is to perform "unmap" without destroying the dirty bit in the

Re: [PATCH v5 10/12] iommu: Prepare IOMMU domain for IOPF

2022-05-05 Thread Jean-Philippe Brucker
Hi Baolu, On Thu, May 05, 2022 at 04:31:38PM +0800, Baolu Lu wrote: > On 2022/5/4 02:20, Jean-Philippe Brucker wrote: > > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > > > index 7cae631c1baa..33449523afbe 100644 > > > --- a/drivers/iommu/iommu.c > > > +++ b/drivers/iommu/iommu.c

[PATCH v3] iommu/mediatek: Fix NULL pointer dereference when printing dev_name

2022-05-05 Thread Miles Chen via iommu
When larbdev is NULL (in the case I hit, the node is incorrectly set iommus = < NUM>), it will cause device_link_add() fail and kernel crashes when we try to print dev_name(larbdev). Let's fail the probe if a larbdev is NULL to avoid invalid inputs from dts. It should work for normal correct

Re: [PATCH 1/7] dt-bindings: gpio: renesas,rcar-gpio: R-Car V3U is R-Car Gen4

2022-05-05 Thread Bartosz Golaszewski
On Mon, May 2, 2022 at 3:35 PM Geert Uytterhoeven wrote: > > Despite the name, R-Car V3U is the first member of the R-Car Gen4 > family. Hence move its compatible value to the R-Car Gen4 section. > > Signed-off-by: Geert Uytterhoeven > --- >

Re: [PATCH v2 4/4] iommu/vt-d: Remove hard coding PGSNP bit in PASID entries

2022-05-05 Thread Baolu Lu
On 2022/5/5 16:46, Tian, Kevin wrote: From: Lu Baolu Sent: Thursday, May 5, 2022 9:07 AM As enforce_cache_coherency has been introduced into the iommu_domain_ops, the kernel component which owns the iommu domain is able to opt-in its requirement for force snooping support. The iommu driver has

Re: [PATCH v7 2/7] hwtracing: Add trace function support for HiSilicon PCIe Tune and Trace device

2022-05-05 Thread Yicong Yang via iommu
Hi Leo, Thanks for the comments. Some questions and replies below. On 2022/4/30 0:00, Leo Yan wrote: > On Thu, Apr 07, 2022 at 08:58:36PM +0800, Yicong Yang via iommu wrote: >> HiSilicon PCIe tune and trace device(PTT) is a PCIe Root Complex integrated >> Endpoint(RCiEP) device, providing the

Re: [PATCH v2 2/4] iommu/vt-d: Check domain force_snooping against attached devices

2022-05-05 Thread Baolu Lu
On 2022/5/5 16:43, Tian, Kevin wrote: From: Lu Baolu Sent: Thursday, May 5, 2022 9:07 AM As domain->force_snooping only impacts the devices attached with the domain, there's no need to check against all IOMMU units. At the same time, for a brand new domain (hasn't been attached to any device),

Re: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-05-05 Thread Joao Martins
On 5/5/22 12:03, Tian, Kevin wrote: >> From: Joao Martins >> Sent: Thursday, May 5, 2022 6:07 PM >> >> On 5/5/22 08:42, Tian, Kevin wrote: From: Jason Gunthorpe Sent: Tuesday, May 3, 2022 2:53 AM On Mon, May 02, 2022 at 12:11:07PM -0600, Alex Williamson wrote: > On Fri,

RE: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-05-05 Thread Tian, Kevin
> From: Joao Martins > Sent: Thursday, May 5, 2022 6:07 PM > > On 5/5/22 08:42, Tian, Kevin wrote: > >> From: Jason Gunthorpe > >> Sent: Tuesday, May 3, 2022 2:53 AM > >> > >> On Mon, May 02, 2022 at 12:11:07PM -0600, Alex Williamson wrote: > >>> On Fri, 29 Apr 2022 05:45:20 + > >>> "Tian,

RE: [PATCH v2] iommu: iommu_group_claim_dma_owner() must always assign a domain

2022-05-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, May 5, 2022 3:09 AM > > Once the group enters 'owned' mode it can never be assigned back to the > default_domain or to a NULL domain. It must always be actively assigned to worth pointing out that a NULL domain is not always translated to DMA blocked on

Re: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-05-05 Thread Joao Martins
On 5/5/22 08:42, Tian, Kevin wrote: >> From: Jason Gunthorpe >> Sent: Tuesday, May 3, 2022 2:53 AM >> >> On Mon, May 02, 2022 at 12:11:07PM -0600, Alex Williamson wrote: >>> On Fri, 29 Apr 2022 05:45:20 + >>> "Tian, Kevin" wrote: > From: Joao Martins > 3) Unmapping an IOVA range

Re: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-05-05 Thread Joao Martins
On 5/5/22 08:25, Shameerali Kolothum Thodi wrote: >> -Original Message- >> From: Joao Martins [mailto:joao.m.mart...@oracle.com] >> Sent: 29 April 2022 12:05 >> To: Tian, Kevin >> Cc: Joerg Roedel ; Suravee Suthikulpanit >> ; Will Deacon ; Robin >> Murphy ; Jean-Philippe Brucker >> ;

Re: [PATCH v2 10/37] iommu/amd: Introduce per PCI segment last_bdf

2022-05-05 Thread Vasant Hegde via iommu
Hi Joerg, On 5/2/2022 4:24 PM, Joerg Roedel wrote: > Hi Vasant, > > On Fri, Apr 29, 2022 at 08:15:49PM +0530, Vasant Hegde wrote: >> We still need to parse IVHD to find max devices supported by each PCI segment >> (same as the way its doing it today). Hence we need all these variables. > >

RE: [PATCH v2 4/4] iommu/vt-d: Remove hard coding PGSNP bit in PASID entries

2022-05-05 Thread Tian, Kevin
> From: Lu Baolu > Sent: Thursday, May 5, 2022 9:07 AM > > As enforce_cache_coherency has been introduced into the > iommu_domain_ops, > the kernel component which owns the iommu domain is able to opt-in its > requirement for force snooping support. The iommu driver has no need to > hard code

RE: [PATCH v2 3/4] iommu/vt-d: Remove domain_update_iommu_snooping()

2022-05-05 Thread Tian, Kevin
> From: Lu Baolu > Sent: Thursday, May 5, 2022 9:07 AM > > The IOMMU force snooping capability is not required to be consistent > among all the IOMMUs anymore. Remove force snooping capability check > in the IOMMU hot-add path and domain_update_iommu_snooping() > becomes > a dead code now. > >

RE: [PATCH v2 2/4] iommu/vt-d: Check domain force_snooping against attached devices

2022-05-05 Thread Tian, Kevin
> From: Lu Baolu > Sent: Thursday, May 5, 2022 9:07 AM > > As domain->force_snooping only impacts the devices attached with the > domain, there's no need to check against all IOMMU units. At the same > time, for a brand new domain (hasn't been attached to any device), the > force_snooping field

RE: [PATCH v2 1/4] iommu/vt-d: Block force-snoop domain attaching if no SC support

2022-05-05 Thread Tian, Kevin
> From: Lu Baolu > Sent: Thursday, May 5, 2022 9:07 AM > > In the attach_dev callback of the default domain ops, if the domain has > been set force_snooping, but the iommu hardware of the device does not > support SC(Snoop Control) capability, the callback should block it and > return a

Re: [PATCH v5 10/12] iommu: Prepare IOMMU domain for IOPF

2022-05-05 Thread Baolu Lu
On 2022/5/4 02:20, Jean-Philippe Brucker wrote: diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 7cae631c1baa..33449523afbe 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -3174,3 +3174,24 @@ void iommu_detach_device_pasid(struct iommu_domain *domain,

RE: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-05-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, May 3, 2022 2:53 AM > > On Mon, May 02, 2022 at 12:11:07PM -0600, Alex Williamson wrote: > > On Fri, 29 Apr 2022 05:45:20 + > > "Tian, Kevin" wrote: > > > > From: Joao Martins > > > > 3) Unmapping an IOVA range while returning its dirty bit prior

RE: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-05-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Friday, April 29, 2022 8:39 PM > > > >> * There's no capabilities API in IOMMUFD, and in this RFC each vendor > tracks > > > > > > there was discussion adding device capability uAPI somewhere. > > > > > ack let me know if there was snippets to the conversation as

RE: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-05-05 Thread Shameerali Kolothum Thodi via iommu
> -Original Message- > From: Joao Martins [mailto:joao.m.mart...@oracle.com] > Sent: 29 April 2022 12:05 > To: Tian, Kevin > Cc: Joerg Roedel ; Suravee Suthikulpanit > ; Will Deacon ; Robin > Murphy ; Jean-Philippe Brucker > ; zhukeqian ; > Shameerali Kolothum Thodi ; > David Woodhouse

Re: [PATCH v5 07/12] arm-smmu-v3/sva: Add SVA domain support

2022-05-05 Thread Baolu Lu
On 2022/5/4 02:12, Jean-Philippe Brucker wrote: On Mon, May 02, 2022 at 09:48:37AM +0800, Lu Baolu wrote: Add support for SVA domain allocation and provide an SVA-specific iommu_domain_ops. Signed-off-by: Lu Baolu --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 14 +++

Re: [PATCH v5 04/12] iommu/sva: Basic data structures for SVA

2022-05-05 Thread Baolu Lu
On 2022/5/4 02:09, Jean-Philippe Brucker wrote: On Mon, May 02, 2022 at 09:48:34AM +0800, Lu Baolu wrote: Use below data structures for SVA implementation in the IOMMU core: - struct iommu_sva_ioas Represent the I/O address space shared with an application CPU address space. This

Re: [PATCH v5 03/12] iommu: Add attach/detach_dev_pasid domain ops

2022-05-05 Thread Baolu Lu
On 2022/5/4 02:07, Jean-Philippe Brucker wrote: On Mon, May 02, 2022 at 09:48:33AM +0800, Lu Baolu wrote: Attaching an IOMMU domain to a PASID of a device is a generic operation for modern IOMMU drivers which support PASID-granular DMA address translation. Currently visible usage scenarios

Re: [PATCH v5 02/12] iommu: Add pasid_bits field in struct dev_iommu

2022-05-05 Thread Baolu Lu
On 2022/5/4 02:02, Jean-Philippe Brucker wrote: On Mon, May 02, 2022 at 09:48:32AM +0800, Lu Baolu wrote: Use this field to save the pasid/ssid bits that a device is able to support with its IOMMU hardware. It is a generic attribute of a device and lifting it into the per-device dev_iommu