Re: [PATCH v2] iommu/mediatek: fix NULL pointer dereference when printing dev_name

2022-04-25 Thread Yong Wu via iommu
On Mon, 2022-04-25 at 11:03 +0100, Robin Murphy wrote: > On 2022-04-25 09:24, Miles Chen via iommu 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

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

2022-04-25 Thread Zhangfei Gao
On 2022/4/26 下午12:36, Fenghua Yu wrote: On Tue, Apr 26, 2022 at 12:28:00PM +0800, Zhangfei Gao wrote: Hi, Jean On 2022/4/26 上午12:13, Jean-Philippe Brucker wrote: Hi Jacob, On Mon, Apr 25, 2022 at 08:34:44AM -0700, Jacob Pan wrote: Hi Jean-Philippe, On Mon, 25 Apr 2022 15:26:40 +0100,

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

2022-04-25 Thread Zhangfei Gao
On 2022/4/26 下午12:20, Fenghua Yu wrote: Hi, Jean and Zhangfei, On Mon, Apr 25, 2022 at 05:13:02PM +0100, Jean-Philippe Brucker wrote: Could we move mm_pasid_drop() to __mmdrop() instead of __mmput()? For Arm we do need to hold the mm_count until unbind(), and mmgrab()/mmdrop() is also part

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

2022-04-25 Thread Fenghua Yu
On Tue, Apr 26, 2022 at 12:28:00PM +0800, Zhangfei Gao wrote: > Hi, Jean > > On 2022/4/26 上午12:13, Jean-Philippe Brucker wrote: > > Hi Jacob, > > > > On Mon, Apr 25, 2022 at 08:34:44AM -0700, Jacob Pan wrote: > > > Hi Jean-Philippe, > > > > > > On Mon, 25 Apr 2022 15:26:40 +0100, Jean-Philippe

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

2022-04-25 Thread Zhangfei Gao
Hi, Jean On 2022/4/26 上午12:13, Jean-Philippe Brucker wrote: Hi Jacob, On Mon, Apr 25, 2022 at 08:34:44AM -0700, Jacob Pan wrote: Hi Jean-Philippe, On Mon, 25 Apr 2022 15:26:40 +0100, Jean-Philippe Brucker wrote: On Mon, Apr 25, 2022 at 07:18:36AM -0700, Dave Hansen wrote: On 4/25/22

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

2022-04-25 Thread Fenghua Yu
Hi, Jean and Zhangfei, On Mon, Apr 25, 2022 at 05:13:02PM +0100, Jean-Philippe Brucker wrote: > Could we move mm_pasid_drop() to __mmdrop() instead of __mmput()? For Arm > we do need to hold the mm_count until unbind(), and mmgrab()/mmdrop() is > also part of Lu's rework [1]. Is this a right

[PATCH v6 1/2] PCI/ACPI: Support Microsoft's "DmaProperty"

2022-04-25 Thread Rajat Jain via iommu
The "DmaProperty" is supported and currently documented and used by Microsoft [link 1 below], to flag internal PCIe root ports that need DMA protection [link 2 below]. We have discussed with them and reached a common understanding that they shall change their MSDN documentation to say that the

[PATCH v6 2/2] PCI: Rename pci_dev->untrusted to pci_dev->untrusted_dma

2022-04-25 Thread Rajat Jain via iommu
Rename the field to make it more clear, that the device can execute DMA attacks on the system, and thus the system may need protection from such attacks from this device. No functional change intended. Signed-off-by: Rajat Jain Reviewed-by: Mika Westerberg Acked-by: Rafael J. Wysocki --- v6:

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

2022-04-25 Thread Jacob Pan
Hi Jean-Philippe, On Mon, 25 Apr 2022 17:13:02 +0100, Jean-Philippe Brucker wrote: > Hi Jacob, > > On Mon, Apr 25, 2022 at 08:34:44AM -0700, Jacob Pan wrote: > > Hi Jean-Philippe, > > > > On Mon, 25 Apr 2022 15:26:40 +0100, Jean-Philippe Brucker > > wrote: > > > > > On Mon, Apr 25, 2022

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

2022-04-25 Thread Jean-Philippe Brucker
On Mon, Apr 25, 2022 at 08:55:46AM -0700, Dave Hansen wrote: > On 4/25/22 07:26, Jean-Philippe Brucker wrote: > >> > >> How does the IOMMU hardware know that all activity to a given PASID is > >> finished? That activity should, today, be independent of an mm or a > >> fd's lifetime. > > In the

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

2022-04-25 Thread Jean-Philippe Brucker
Hi Jacob, On Mon, Apr 25, 2022 at 08:34:44AM -0700, Jacob Pan wrote: > Hi Jean-Philippe, > > On Mon, 25 Apr 2022 15:26:40 +0100, Jean-Philippe Brucker > wrote: > > > On Mon, Apr 25, 2022 at 07:18:36AM -0700, Dave Hansen wrote: > > > On 4/25/22 06:53, Jean-Philippe Brucker wrote: > > > > On

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

2022-04-25 Thread Dave Hansen
On 4/25/22 07:26, Jean-Philippe Brucker wrote: >> >> How does the IOMMU hardware know that all activity to a given PASID is >> finished? That activity should, today, be independent of an mm or a >> fd's lifetime. > In the case of uacce, it's tied to the fd lifetime: opening an accelerator > queue

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

2022-04-25 Thread Jacob Pan
Hi Jean-Philippe, On Mon, 25 Apr 2022 15:26:40 +0100, Jean-Philippe Brucker wrote: > On Mon, Apr 25, 2022 at 07:18:36AM -0700, Dave Hansen wrote: > > On 4/25/22 06:53, Jean-Philippe Brucker wrote: > > > On Sat, Apr 23, 2022 at 07:13:39PM +0800, zhangfei@foxmail.com > > > wrote: > >

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

2022-04-25 Thread Jean-Philippe Brucker
On Mon, Apr 25, 2022 at 07:18:36AM -0700, Dave Hansen wrote: > On 4/25/22 06:53, Jean-Philippe Brucker wrote: > > On Sat, Apr 23, 2022 at 07:13:39PM +0800, zhangfei@foxmail.com wrote: > On 5.17 > fops_release is called automatically, as well as iommu_sva_unbind_device. > On

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

2022-04-25 Thread Dave Hansen
On 4/25/22 06:53, Jean-Philippe Brucker wrote: > On Sat, Apr 23, 2022 at 07:13:39PM +0800, zhangfei@foxmail.com wrote: On 5.17 fops_release is called automatically, as well as iommu_sva_unbind_device. On 5.18-rc1. fops_release is not called, have to manually call close(fd)

[PATCH] iommu/sva: Revert mm_pasid_drop and reusing refcount in pasid allocation

2022-04-25 Thread Zhangfei Gao
Commit 701fac40384f ("iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit") However the Arm code was written expecting the PASID to be freed on unbind(), not mm exit. The mm_pasid_drop in mmput free mm->pasid, which is only index, but all related resources are still there.

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

2022-04-25 Thread Jean-Philippe Brucker
On Sat, Apr 23, 2022 at 07:13:39PM +0800, zhangfei@foxmail.com wrote: > > > On 5.17 > > > fops_release is called automatically, as well as iommu_sva_unbind_device. > > > On 5.18-rc1. > > > fops_release is not called, have to manually call close(fd) > > Right that's weird > Looks it is caused

[PATCH v4 3/4] thunderbolt: Make iommu_dma_protection more accurate

2022-04-25 Thread Robin Murphy
Between me trying to get rid of iommu_present() and Mario wanting to support the AMD equivalent of DMAR_PLATFORM_OPT_IN, scrutiny has shown that the iommu_dma_protection attribute is being far too optimistic. Even if an IOMMU might be present for some PCI segment in the system, that doesn't

[PATCH v4 4/4] iommu/amd: Indicate whether DMA remap support is enabled

2022-04-25 Thread Robin Murphy
From: Mario Limonciello Bit 1 of the IVFS IVInfo field indicates that IOMMU has been used for pre-boot DMA protection. Export this capability to allow other places in the kernel to be able to check for it on AMD systems. Link: https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf

[PATCH v4 2/4] iommu: Add capability for pre-boot DMA protection

2022-04-25 Thread Robin Murphy
VT-d's dmar_platform_optin() actually represents a combination of properties fairly well standardised by Microsoft as "Pre-boot DMA Protection" and "Kernel DMA Protection"[1]. As such, we can provide interested consumers with an abstracted capability rather than driver-specific interfaces that

[PATCH v4 1/4] iommu: Introduce device_iommu_capable()

2022-04-25 Thread Robin Murphy
iommu_capable() only really works for systems where all IOMMU instances are completely homogeneous, and all devices are IOMMU-mapped. Implement the new variant which will be able to give a more accurate answer for whichever device the caller is actually interested in, and even more so once all the

[PATCH v4 0/4] iommu, thunderbolt: Make iommu_dma_protection more accurate

2022-04-25 Thread Robin Murphy
Hi all, As promised, here's the really-actually-final version, cleaning up the new interface in patch #1 to not introduce the new parameter before it's ready, and rebased to make sure it correctly applies on -rc3. Thanks, Robin. Mario Limonciello (1): iommu/amd: Indicate whether DMA remap

[PATCH v2 37/37] iommu/amd: Update amd_iommu_fault structure to include PCI seg ID

2022-04-25 Thread Vasant Hegde via iommu
Rename 'device_id' as 'sbdf' and extend it to 32bit so that we can pass PCI segment ID to ppr_notifier(). Also pass PCI segment ID to pci_get_domain_bus_and_slot() instead of default value. Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 2 +- drivers/iommu/amd/iommu.c

[PATCH v2 36/37] iommu/amd: Update device_state structure to include PCI seg ID

2022-04-25 Thread Vasant Hegde via iommu
Rename struct device_state.devid variable to struct device_state.sbdf and extend it to 32-bit to include the 16-bit PCI segment ID via the helper function get_pci_sbdf_id(). Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde ---

[PATCH v2 35/37] iommu/amd: Print PCI segment ID in error log messages

2022-04-25 Thread Vasant Hegde via iommu
Print pci segment ID along with bdf. Useful for debugging. Co-developed-by: Suravee Suthikulpaint Signed-off-by: Suravee Suthikulpaint Signed-off-by: Vasant Hegde --- drivers/iommu/amd/init.c | 10 +- drivers/iommu/amd/iommu.c | 36 ++-- 2 files

[PATCH v2 34/37] iommu/amd: Add PCI segment support for ivrs_ioapic, ivrs_hpet, ivrs_acpihid commands

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit By default, PCI segment is zero and can be omitted. To support system with non-zero PCI segment ID, modify the parsing functions to allow PCI segment ID. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- .../admin-guide/kernel-parameters.txt

[PATCH v2 33/37] iommu/amd: Specify PCI segment ID when getting pci device

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Upcoming AMD systems can have multiple PCI segments. Hence pass PCI segment ID to pci_get_domain_bus_and_slot() instead of '0'. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/init.c | 6

[PATCH v2 32/37] iommu/amd: Include PCI segment ID when initialize IOMMU

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Extend current device ID variables to 32-bit to include the 16-bit segment ID when parsing device information from IVRS table to initialize each IOMMU. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit ---

[PATCH v2 31/37] iommu/amd: Introduce get_device_sbdf_id() helper function

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Current get_device_id() only provide 16-bit PCI device ID (i.e. BDF). With multiple PCI segment support, we need to extend the helper function to include PCI segment ID. So, introduce a new helper function get_device_sbdf_id() to replace the current

[PATCH v2 30/37] iommu/amd: Flush upto last_bdf only

2022-04-25 Thread Vasant Hegde via iommu
Fix amd_iommu_flush_dte_all() and amd_iommu_flush_tlb_all() to flush upto last_bdf only. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff

[PATCH v2 29/37] iommu/amd: Remove global amd_iommu_last_bdf

2022-04-25 Thread Vasant Hegde via iommu
Replace it with per PCI segment last_bdf variable. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 --- drivers/iommu/amd/init.c| 35 ++---

[PATCH v2 28/37] iommu/amd: Remove global amd_iommu_alias_table

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This is replaced by the per PCI segment alias table. Also remove alias_table_size variable. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 6 --

[PATCH v2 27/37] iommu/amd: Remove global amd_iommu_dev_table

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Replace global amd_iommu_dev_table with per PCI segment device table. Also remove "dev_table_size". Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 6 --

[PATCH v2 26/37] iommu/amd: Update set_dev_entry_bit() and get_dev_entry_bit()

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit To include a pointer to per PCI segment device table. Also include struct amd_iommu as one of the function parameter to amd_iommu_apply_erratum_63() since it is needed when setting up DTE. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by:

[PATCH v2 25/37] iommu/amd: Update (un)init_device_table_dma()

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Include struct amd_iommu_pci_seg as a function parameter since we need to access per PCI segment device table. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/init.c | 27

[PATCH v2 24/37] iommu/amd: Update set_dte_irq_entry

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment device table instead of global device table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git

[PATCH v2 23/37] iommu/amd: Update dump_dte_entry

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment device table instead of global device table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git

[PATCH v2 22/37] iommu/amd: Update iommu_ignore_device

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment device table instead of global device table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git

[PATCH v2 21/37] iommu/amd: Update set_dte_entry and clear_dte_entry

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Start using per PCI segment data structures instead of global data structures. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 19 +++ 1 file changed, 11 insertions(+), 8 deletions(-) diff --git

[PATCH v2 20/37] iommu/amd: Convert to use per PCI segment rlookup_table

2022-04-25 Thread Vasant Hegde via iommu
Then, remove the global amd_iommu_rlookup_table and rlookup_table_size. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 5 - drivers/iommu/amd/init.c| 23 ++-

[PATCH v2 19/37] iommu/amd: Update alloc_irq_table and alloc_irq_index

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Pass amd_iommu structure as one of the parameter to these functions as its needed to retrieve variable tables inside these functions. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/iommu.c | 26

[PATCH v2 18/37] iommu/amd: Update amd_irte_ops functions

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Pass amd_iommu structure as one of the parameter to amd_irte_ops functions since its needed to activate/deactivate the iommu. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 6 ++--

[PATCH v2 17/37] iommu/amd: Introduce struct amd_ir_data.iommu

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Add a pointer to struct amd_iommu to amd_ir_data structure, which can be used to correlate interrupt remapping data to a per-PCI-segment interrupt remapping table. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit ---

[PATCH v2 16/37] iommu/amd: Update irq_remapping_alloc to use IOMMU lookup helper function

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit To allow IOMMU rlookup using both PCI segment and device ID. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/iommu.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff

[PATCH v2 15/37] iommu/amd: Convert to use rlookup_amd_iommu helper function

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Use rlookup_amd_iommu() helper function which will give per PCI segment rlookup_table. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/iommu.c | 64 +++ 1 file changed, 38 insertions(+), 26

[PATCH v2 14/37] iommu/amd: Convert to use per PCI segment irq_lookup_table

2022-04-25 Thread Vasant Hegde via iommu
Then, remove the global irq_lookup_table. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 2 -- drivers/iommu/amd/init.c| 19 --- drivers/iommu/amd/iommu.c | 36

[PATCH v2 13/37] iommu/amd: Introduce per PCI segment rlookup table size

2022-04-25 Thread Vasant Hegde via iommu
It will replace global "rlookup_table_size" variable. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 +++ drivers/iommu/amd/init.c| 11 ++- 2 files changed, 9

[PATCH v2 12/37] iommu/amd: Introduce per PCI segment alias table size

2022-04-25 Thread Vasant Hegde via iommu
It will replace global "alias_table_size" variable. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 +++ drivers/iommu/amd/init.c| 5 +++-- 2 files changed, 6 insertions(+), 2

[PATCH v2 11/37] iommu/amd: Introduce per PCI segment device table size

2022-04-25 Thread Vasant Hegde via iommu
With multiple pci segment support, number of BDF supported by each segment may differ. Hence introduce per segment device table size which depends on last_bdf. This will replace global "device_table_size" variable. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit

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

2022-04-25 Thread Vasant Hegde via iommu
Current code uses global "amd_iommu_last_bdf" to track the last bdf supported by the system. This value is used for various memory allocation, device data flushing, etc. Introduce per PCI segment last_bdf which will be used to track last bdf supported by the given PCI segment and use this value

[PATCH v2 09/37] iommu/amd: Introduce per PCI segment unity map list

2022-04-25 Thread Vasant Hegde via iommu
Newer AMD systems can support multiple PCI segments. In order to support multiple PCI segments IVMD table in IVRS structure is enhanced to include pci segment id. Update ivmd_header structure to include "pci_seg". Also introduce per PCI segment unity map list. It will replace global

[PATCH v2 08/37] iommu/amd: Introduce per PCI segment alias_table

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This will replace global alias table (amd_iommu_alias_table). Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 7 + drivers/iommu/amd/init.c| 41

[PATCH v2 07/37] iommu/amd: Introduce per PCI segment old_dev_tbl_cpy

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit It will remove global old_dev_tbl_cpy. Also update copy_device_table() copy device table for all PCI segments. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd/amd_iommu_types.h | 6 ++

[PATCH v2 06/37] iommu/amd: Introduce per PCI segment dev_data_list

2022-04-25 Thread Vasant Hegde via iommu
This will replace global dev_data_list. Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 3 +++ drivers/iommu/amd/init.c| 1 + drivers/iommu/amd/iommu.c | 21

[PATCH v2 05/37] iommu/amd: Introduce per PCI segment irq_lookup_table

2022-04-25 Thread Vasant Hegde via iommu
This will replace global irq lookup table (irq_lookup_table). Co-developed-by: Suravee Suthikulpanit Signed-off-by: Suravee Suthikulpanit Signed-off-by: Vasant Hegde --- drivers/iommu/amd/amd_iommu_types.h | 6 ++ drivers/iommu/amd/init.c| 27 +++ 2

[PATCH v2 04/37] iommu/amd: Introduce per PCI segment rlookup table

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit This will replace global rlookup table (amd_iommu_rlookup_table). Also add helper functions to set/get rlookup table for the given device. Co-developed-by: Vasant Hegde Signed-off-by: Vasant Hegde Signed-off-by: Suravee Suthikulpanit ---

[PATCH v2 03/37] iommu/amd: Introduce per PCI segment device table

2022-04-25 Thread Vasant Hegde via iommu
From: Suravee Suthikulpanit Introduce per PCI segment device table. All IOMMUs within the segment will share this device table. This will replace global device table i.e. amd_iommu_dev_table. Also introduce helper function to get the device table for the given IOMMU. Co-developed-by: Vasant

[PATCH v2 02/37] iommu/amd: Introduce pci segment structure

2022-04-25 Thread Vasant Hegde via iommu
Newer AMD systems can support multiple PCI segments, where each segment contains one or more IOMMU instances. However, an IOMMU instance can only support a single PCI segment. Current code assumes that system contains only one pci segment (segment 0) and creates global data structures such as

[PATCH v2 01/37] iommu/amd: Update struct iommu_dev_data defination

2022-04-25 Thread Vasant Hegde via iommu
struct iommu_dev_data contains member "pdev" to point to pci_dev. This is valid for only PCI devices and for other devices this will be NULL. This causes unnecessary "pdev != NULL" check at various places. Replace "struct pci_dev" member with "struct device" and use to_pci_dev() to get pci device

[PATCH v2 00/37] iommu/amd: Add multiple PCI segments support

2022-04-25 Thread Vasant Hegde via iommu
Newer AMD systems can support multiple PCI segments, where each segment contains one or more IOMMU instances. However, an IOMMU instance can only support a single PCI segment. Current code assumes a system contains only one PCI segment (segment 0) and creates global data structures such as device

[PATCH] iommu/arm-smmu-v3: check return value after calling platform_get_resource()

2022-04-25 Thread Yang Yingliang via iommu
It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Signed-off-by: Yang Yingliang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

[PATCH] iommu/arm-smmu: fix possible null-ptr-deref in arm_smmu_device_probe()

2022-04-25 Thread Yang Yingliang via iommu
It will cause null-ptr-deref when using 'res', if platform_get_resource() returns NULL, so move using 'res' after devm_ioremap_resource() that will check it to avoid null-ptr-deref. And use devm_platform_get_and_ioremap_resource() to simplify code. Fixes: 9648cbc9625b ("iommu/arm-smmu: Make use

Re: [PATCH v2] iommu/mediatek: fix NULL pointer dereference when printing dev_name

2022-04-25 Thread Robin Murphy
On 2022-04-25 09:24, Miles Chen via iommu 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). Fix it by adding a NULL pointer check before

[PATCH] iommu/dart: check return value after calling platform_get_resource()

2022-04-25 Thread Yang Yingliang via iommu
It will cause null-ptr-deref in resource_size(), if platform_get_resource() returns NULL, move calling resource_size() after devm_ioremap_resource() that will check 'res' to avoid null-ptr-deref. And use devm_platform_get_and_ioremap_resource() to simplify code. Fixes: 46d1fb072e76 ("iommu/dart:

[PATCH v2] iommu/mediatek: fix NULL pointer dereference when printing dev_name

2022-04-25 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). Fix it by adding a NULL pointer check before device_link_add/device_link_remove. It should work for normal