Re: [PATCH v6 02/11] driver core: Add dma_cleanup callback in bus_type

2022-02-18 Thread Christoph Hellwig
So we are back to the callback madness instead of the nice and simple flag? Sigh. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v6 01/11] iommu: Add dma ownership management interfaces

2022-02-18 Thread Christoph Hellwig
The overall API and patch looks fine, but: > + * iommu_group_dma_owner_claimed() - Query group dma ownership status > + * @group: The group. > + * > + * This provides status query on a given group. It is racey and only for > + * non-binding status reporting. s/racey/racy/ > + */ > +bool iommu_gr

Re: [PATCH] iommu/vt-d: Enable ATS for the devices in SATC table

2022-02-18 Thread Chen, Yian
On 2/17/2022 6:53 PM, Lu Baolu wrote: Hi Yian, On 2/17/22 3:36 AM, Yian Chen wrote: Starting from Intel VT-d v3.2, Intel platform BIOS can provide additional SATC table structure. SATC table includes a list of SoC integrated devices that support ATC (Address translation cache). Enabling ATC

[PATCH] iova: Remove forward declarations

2022-02-18 Thread John Garry via iommu
Now that the FQ code has been moved to dma-iommu.c and also the rcache- related structures have been brought into iova.c, let's rearrange the code to remove all the forward declarations. The general order is as follows: - RB tree code - iova management - magazine helpers - rcache code and "fast" A

[PATCH v5 02/12] Documentation/x86: Secure Launch kernel documentation

2022-02-18 Thread Ross Philipson
Introduce background, overview and configuration/ABI information for the Secure Launch kernel feature. Signed-off-by: Daniel P. Smith Signed-off-by: Ross Philipson --- Documentation/security/index.rst | 1 + Documentation/security/launch-integrity/index.rst | 10 + .../sec

[PATCH v5 01/12] x86/boot: Place kernel_info at a fixed offset

2022-02-18 Thread Ross Philipson
From: Arvind Sankar There are use cases for storing the offset of a symbol in kernel_info. For example, the trenchboot series [0] needs to store the offset of the Measured Launch Environment header in kernel_info. Since commit (note: commit ID from tip/master) commit 527afc212231 ("x86/boot: Ch

[PATCH v5 06/12] x86: Secure Launch kernel early boot stub

2022-02-18 Thread Ross Philipson
The Secure Launch (SL) stub provides the entry point for Intel TXT (and later AMD SKINIT) to vector to during the late launch. The symbol sl_stub_entry is that entry point and its offset into the kernel is conveyed to the launching code using the MLE (Measured Launch Environment) header in the stru

[PATCH v5 07/12] x86: Secure Launch kernel late boot stub

2022-02-18 Thread Ross Philipson
The routine slaunch_setup is called out of the x86 specific setup_arch routine during early kernel boot. After determining what platform is present, various operations specific to that platform occur. This includes finalizing setting for the platform late launch and verifying that memory protection

[PATCH v5 11/12] x86: Secure Launch late initcall platform module

2022-02-18 Thread Ross Philipson
From: "Daniel P. Smith" The Secure Launch platform module is a late init module. During the init call, the TPM event log is read and measurements taken in the early boot stub code are located. These measurements are extended into the TPM PCRs using the mainline TPM kernel driver. The platform mo

[PATCH v5 00/12] x86: Trenchboot secure dynamic launch Linux kernel support

2022-02-18 Thread Ross Philipson
The larger focus of the TrenchBoot project (https://github.com/TrenchBoot) is to enhance the boot security and integrity in a unified manner. The first area of focus has been on the Trusted Computing Group's Dynamic Launch for establishing a hardware Root of Trust for Measurement, also know as DRTM

[PATCH v5 12/12] tpm: Allow locality 2 to be set when initializing the TPM for Secure Launch

2022-02-18 Thread Ross Philipson
The Secure Launch MLE environment uses PCRs that are only accessible from the DRTM locality 2. By default the TPM drivers always initialize the locality to 0. When a Secure Launch is in progress, initialize the locality to 2. Signed-off-by: Ross Philipson --- drivers/char/tpm/tpm-chip.c | 9

[PATCH v5 09/12] kexec: Secure Launch kexec SEXIT support

2022-02-18 Thread Ross Philipson
Prior to running the next kernel via kexec, the Secure Launch code closes down private SMX resources and does an SEXIT. This allows the next kernel to start normally without any issues starting the APs etc. Signed-off-by: Ross Philipson --- arch/x86/kernel/slaunch.c | 69

[PATCH v5 10/12] reboot: Secure Launch SEXIT support on reboot paths

2022-02-18 Thread Ross Philipson
If the MLE kernel is being powered off, rebooted or halted, then SEXIT must be called. Note that the SEXIT GETSEC leaf can only be called after a machine_shutdown() has been done on these paths. The machine_shutdown() is not called on a few paths like when poweroff action does not have a poweroff c

[PATCH v5 03/12] x86: Secure Launch Kconfig

2022-02-18 Thread Ross Philipson
Initial bits to bring in Secure Launch functionality. Add Kconfig options for compiling in/out the Secure Launch code. Signed-off-by: Ross Philipson --- arch/x86/Kconfig | 34 ++ 1 file changed, 34 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig in

[PATCH v5 04/12] x86: Secure Launch main header file

2022-02-18 Thread Ross Philipson
Introduce the main Secure Launch header file used in the early SL stub and the early setup code. Signed-off-by: Ross Philipson --- include/linux/slaunch.h | 532 1 file changed, 532 insertions(+) create mode 100644 include/linux/slaunch.h diff -

[PATCH v5 08/12] x86: Secure Launch SMP bringup support

2022-02-18 Thread Ross Philipson
On Intel, the APs are left in a well documented state after TXT performs the late launch. Specifically they cannot have #INIT asserted on them so a standard startup via INIT/SIPI/SIPI cannot be performed. Instead the early SL stub code parked the APs in a pause/jmp loop waiting for an NMI. The modi

[PATCH v5 05/12] x86: Add early SHA support for Secure Launch early measurements

2022-02-18 Thread Ross Philipson
From: "Daniel P. Smith" The SHA algorithms are necessary to measure configuration information into the TPM as early as possible before using the values. This implementation uses the established approach of #including the SHA libraries directly in the code since the compressed kernel is not uncomp

Re: [PATCH v6 00/11] Fix BUG_ON in vfio_iommu_group_notifier()

2022-02-18 Thread Jason Gunthorpe via iommu
On Fri, Feb 18, 2022 at 08:55:10AM +0800, Lu Baolu wrote: > Hi folks, > > The iommu group is the minimal isolation boundary for DMA. Devices in > a group can access each other's MMIO registers via peer to peer DMA > and also need share the same I/O address space. > > Once the I/O address space is

Re: [PATCH v5 27/34] iommu/mediatek-v1: Just rename mtk_iommu to mtk_iommu_v1

2022-02-18 Thread AngeloGioacchino Del Regno
Il 17/02/22 12:34, Yong Wu ha scritto: No functional change. Just rename this for readable. Differentiate this from mtk_iommu.c Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu_v1.c | 211 +-- 1 file changed, 103

Re: [PATCH v5 32/34] iommu/mediatek: Initialise/Remove for multi bank dev

2022-02-18 Thread AngeloGioacchino Del Regno
Il 17/02/22 12:34, Yong Wu ha scritto: The registers for each bank of the IOMMU base are in order, delta is 0x1000. Initialise the base for each bank. For all the previous SoC, we only have bank0. thus use "do {} while()" to allow bank0 always go. When removing the device, Not always all the ba

Re: [PATCH v5 26/34] iommu/mediatek: Remove mtk_iommu.h

2022-02-18 Thread AngeloGioacchino Del Regno
Il 17/02/22 12:34, Yong Wu ha scritto: Currently there is only compare_of/release_of/a suspend structure in the header file. I think it is no need to keep a header file only for these. Move these into the c file and rm this header file. I think there should be a common helper for compare_of and

Re: [PATCH v5 25/34] iommu/mediatek: Separate mtk_iommu_data for v1 and v2

2022-02-18 Thread AngeloGioacchino Del Regno
Il 17/02/22 12:34, Yong Wu ha scritto: Prepare for adding the structure "mtk_iommu_bank_data". No functional change. The mtk_iommu_domain in v1 and v2 are different, we could not add current data as bank[0] in v1 simplistically. Currently we have no plan to add new SoC for v1, in order to avoid

Re: [PATCH v5 21/34] iommu/mediatek: Add PCIe support

2022-02-18 Thread AngeloGioacchino Del Regno
Il 17/02/22 12:34, Yong Wu ha scritto: Currently the code for of_iommu_configure_dev_id is like this: static int of_iommu_configure_dev_id(struct device_node *master_np, struct device *dev, const u32 *id) { struc

Re: [PATCH v5 19/34] iommu/mediatek: Add a PM_CLK_AO flag for infra iommu

2022-02-18 Thread AngeloGioacchino Del Regno
Il 17/02/22 12:34, Yong Wu ha scritto: The power/clock of infra iommu is always on, and it doesn't have the device link with the master devices, then the infra iommu device's pm statua is not active, thus we add A PM_CLK_AO flag for infra iommu. The tlb operation is a bit not clear in this file,

[PATCH v3 2/9] gpu: host1x: Add context bus

2022-02-18 Thread Mikko Perttunen via iommu
The context bus is a "dummy" bus that contains struct devices that correspond to IOMMU contexts assigned through Host1x to processes. Even when host1x itself is built as a module, the bus is registered in built-in code so that the built-in ARM SMMU driver is able to reference it. Signed-off-by: M

[PATCH v3 6/9] arm64: tegra: Add Host1x context stream IDs on Tegra186+

2022-02-18 Thread Mikko Perttunen via iommu
Add Host1x context stream IDs on systems that support Host1x context isolation. Host1x and attached engines can use these stream IDs to allow isolation between memory used by different processes. The specified stream IDs must match those configured by the hypervisor, if one is present. Signed-off

[PATCH v3 8/9] drm/tegra: vic: Implement get_streamid_offset

2022-02-18 Thread Mikko Perttunen via iommu
Implement the get_streamid_offset required for supporting context isolation. Since old firmware cannot support context isolation without hacks that we don't want to implement, check the firmware binary to see if context isolation should be enabled. Signed-off-by: Mikko Perttunen --- drivers/gpu/

[PATCH v3 5/9] iommu/arm-smmu: Attach to host1x context device bus

2022-02-18 Thread Mikko Perttunen via iommu
Set itself as the IOMMU for the host1x context device bus, containing "dummy" devices used for Host1x context isolation. Signed-off-by: Mikko Perttunen --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu

[PATCH v3 4/9] gpu: host1x: Program context stream ID on submission

2022-02-18 Thread Mikko Perttunen via iommu
Add code to do stream ID switching at the beginning of a job. The stream ID is switched to the stream ID specified by the context passed in the job structure. Before switching the stream ID, an OP_DONE wait is done on the channel's engine to ensure that there is no residual ongoing work that might

[PATCH v3 3/9] gpu: host1x: Add context device management code

2022-02-18 Thread Mikko Perttunen via iommu
Add code to register context devices from device tree, allocate them out and manage their refcounts. Signed-off-by: Mikko Perttunen --- v2: * Directly set DMA mask instead of inheriting from Host1x. * Use iommu-map instead of custom DT property. --- drivers/gpu/host1x/Makefile | 1 + drivers/

[PATCH v3 1/9] dt-bindings: host1x: Add memory-contexts property

2022-02-18 Thread Mikko Perttunen via iommu
Add schema information for the memory-contexts property used to specify context stream IDs. This uses the standard iommu-map property inside a child node. Signed-off-by: Mikko Perttunen --- v3: * New patch --- .../bindings/display/tegra/nvidia,tegra20-host1x.yaml | 10 ++ 1 file changed

[PATCH v3 0/9] Host1x context isolation support

2022-02-18 Thread Mikko Perttunen via iommu
*** New in v3: Added device tree bindings for new property. Rebased. *** *** New in v2: Added support for Tegra194 Use standard iommu-map property instead of custom mechanism *** This series adds support for Host1x 'context isolation'. Since when programming engines through Host1x, userspace ca

[PATCH v3 9/9] drm/tegra: Support context isolation

2022-02-18 Thread Mikko Perttunen via iommu
For engines that support context isolation, allocate a context when opening a channel, and set up stream ID offset and context fields when submitting a job. Signed-off-by: Mikko Perttunen --- drivers/gpu/drm/tegra/drm.h| 2 ++ drivers/gpu/drm/tegra/submit.c | 13 drivers/gpu/dr

[PATCH v3 7/9] drm/tegra: falcon: Set DMACTX field on DMA transactions

2022-02-18 Thread Mikko Perttunen via iommu
The DMACTX field determines which context, as specified in the TRANSCFG register, is used. While during boot it doesn't matter which is used, later on it matters and this value is reused by the firmware. Signed-off-by: Mikko Perttunen --- drivers/gpu/drm/tegra/falcon.c | 8 drivers/gpu/

Re: [PATCH 2/2] iommu/mediatek: Add mt8186 iommu support

2022-02-18 Thread AngeloGioacchino Del Regno
Il 18/02/22 04:32, Yong Wu ha scritto: On Mon, 2022-01-31 at 10:25 +0100, AngeloGioacchino Del Regno wrote: Il 28/01/22 10:39, Yong Wu ha scritto: On Thu, 2022-01-27 at 12:28 +0100, AngeloGioacchino Del Regno wrote: Il 25/01/22 10:32, Yong Wu ha scritto: Add mt8186 iommu supports. Signed-off

Re: [PATCH v2 1/1] iommu/vt-d: Fix list_add double add when enabling VMD and scalable mode

2022-02-18 Thread Huang Adrian
On Fri, Feb 18, 2022 at 10:30 AM Lu Baolu wrote: > > On 2/16/22 5:13 PM, Adrian Huang wrote: > > pci_real_dma_dev() in pci_for_each_dma_alias() gets the real dma device > > which is the VMD device :59:00.5. However, pte of the VMD device > > :59:00.5 has been configured during this message