[PATCH v3 47/75] x86/sev-es: Add Runtime #VC Exception Handler

2020-04-28 Thread Joerg Roedel
From: Tom Lendacky Add the handler for #VC exceptions invoked at runtime. Signed-off-by: Tom Lendacky Signed-off-by: Joerg Roedel --- arch/x86/entry/entry_64.S| 4 + arch/x86/include/asm/traps.h | 7 ++ arch/x86/kernel/idt.c| 4 +- arch/x86/kernel/sev-es.c | 167

[PATCH v3 60/75] x86/sev-es: Handle MWAIT/MWAITX Events

2020-04-28 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by MWAIT and MWAITX instructions. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC handling infrastructure ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 12

[PATCH v3 68/75] x86/realmode: Add SEV-ES specific trampoline entry point

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel The code at the trampoline entry point is executed in real-mode. In real-mode #VC exceptions can't be handled, so anything that might cause such an exception must be avoided. In the standard trampoline entry code this is the WBINVD instruction and the call to verify_cpu

[PATCH v3 32/75] x86/head/64: Reload GDT after switch to virtual addresses

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel Reload the GDT after switching to virtual addresses to make sure it will not go away when the lower mappings are removed. This will also reload the GDT for booting APs, which will need a working GDT too to handle #VC exceptions. Signed-off-by: Joerg Roedel --- arch/x86

[PATCH v3 01/75] KVM: SVM: Add GHCB definitions

2020-04-28 Thread Joerg Roedel
From: Tom Lendacky Extend the vmcb_safe_area with SEV-ES fields and add a new 'struct ghcb' which will be used for guest-hypervisor communication. Signed-off-by: Tom Lendacky Signed-off-by: Joerg Roedel --- arch/x86/include/asm/svm.h | 42 ++ 1 file

[PATCH v3 05/75] x86/traps: Move some definitions to

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel Move the definition of x86 trap vector numbers and the page-fault error code bits to the new header file asm/trap_defs.h. This makes it easier to include them into pre-decompression boot code. No functional changes. Signed-off-by: Joerg Roedel --- arch/x86/include/asm

[PATCH v3 25/75] x86/sev-es: Add support for handling IOIO exceptions

2020-04-28 Thread Joerg Roedel
From: Tom Lendacky Add support for decoding and handling #VC exceptions for IOIO events. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapted code to #VC handling framework ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev-es.c | 32 + arch

[PATCH v3 03/75] KVM: SVM: Use __packed shorthand

2020-04-28 Thread Joerg Roedel
From: Borislav Petkov I guess we can do that ontop. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/svm.h | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index e4e9f6bacfaa..9adbf69f003c 100644

[PATCH v3 04/75] x86/cpufeatures: Add SEV-ES CPU feature

2020-04-28 Thread Joerg Roedel
From: Tom Lendacky Add CPU feature detection for Secure Encrypted Virtualization with Encrypted State. This feature enhances SEV by also encrypting the guest register state, making it in-accessible to the hypervisor. Signed-off-by: Tom Lendacky Signed-off-by: Joerg Roedel --- arch/x86

[PATCH v3 08/75] x86/umip: Factor out instruction decoding

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel Factor out the code used to decode an instruction with the correct address and operand sizes to a helper function. No functional changes. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/insn-eval.h | 2 ++ arch/x86/kernel/umip.c | 23 +--- arch

[PATCH v3 00/75] x86: SEV-ES Guest Support

2020-04-28 Thread Joerg Roedel
): x86/vmware: Add VMware specific handling for VMMCALL under SEV-ES Joerg Roedel (53): KVM: SVM: Add GHCB Accessor functions x86/traps: Move some definitions to x86/insn: Make inat-tables.c suitable for pre-decompression code x86/umip: Factor out instruction fetch x86/umip: Factor out

[PATCH v3 30/75] x86/idt: Move two function from k/idt.c to i/a/desc.h

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel Move these two functions from kernel/idt.c to include/asm/desc.h: * init_idt_data() * idt_init_desc() These functions are needed to setup IDT entries very early and need to be called from head64.c. To be usable this early these functions need to be compiled

[PATCH v3 02/75] KVM: SVM: Add GHCB Accessor functions

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel Building a correct GHCB for the hypervisor requires setting valid bits in the GHCB. Simplify that process by providing accessor functions to set values and to update the valid bitmap. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/svm.h | 61

[PATCH v3 21/75] x86/boot/compressed/64: Check return value of kernel_ident_mapping_init()

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel The function can fail to create an identity mapping, check for that and bail out if it happens. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/ident_map_64.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed

[PATCH v3 19/75] x86/boot/compressed/64: Add stage1 #VC handler

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel Add the first handler for #VC exceptions. At stage 1 there is no GHCB yet becaue we might still be on the EFI page table and thus can't map memory unencrypted. The stage 1 handler is limited to the MSR based protocol to talk to the hypervisor and can only support CPUID exit

[PATCH v3 06/75] x86/insn: Make inat-tables.c suitable for pre-decompression code

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel The inat-tables.c file has some arrays in it that contain pointers to other arrays. These pointers need to be relocated when the kernel image is moved to a different location. The pre-decompression boot-code has no support for applying ELF relocations, so initialize

[PATCH v3 10/75] x86/insn: Add insn_rep_prefix() helper

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel Add a function to check whether an instruction has a REP prefix. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/insn-eval.h | 1 + arch/x86/lib/insn-eval.c | 24 2 files changed, 25 insertions(+) diff --git a/arch/x86/include/asm

[PATCH v3 14/75] x86/boot/compressed/64: Rename kaslr_64.c to ident_map_64.c

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel The file contains only code related to identity mapped page-tables. Rename the file and compile it always in. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/Makefile| 2 +- .../boot/compressed/{kaslr_64.c => ident_map_64.c} |

[PATCH v3 07/75] x86/umip: Factor out instruction fetch

2020-04-28 Thread Joerg Roedel
From: Joerg Roedel Factor out the code to fetch the instruction from user-space to a helper function. No functional changes. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/insn-eval.h | 2 ++ arch/x86/kernel/umip.c | 26 +- arch/x86/lib/insn-eval.c

Re: [PATCH] Allow RDTSC and RDTSCP from userspace

2020-04-25 Thread Joerg Roedel
Hi Dave, On Fri, Apr 24, 2020 at 03:53:09PM -0700, Dave Hansen wrote: > Ahh, so any instruction that can have an instruction intercept set > potentially needs to be able to tolerate a #VC? Those instruction > intercepts are under the control of the (untrusted relative to the > guest) hypervisor,

Re: [PATCH] Allow RDTSC and RDTSCP from userspace

2020-04-25 Thread Joerg Roedel
Hi Mike, On Fri, Apr 24, 2020 at 02:03:16PM -0700, Mike Stunes wrote: > I needed to allow RDTSC(P) from userspace and in early boot in order to > get userspace started properly. Patch below. Thanks, but this is not needed anymore. I removed the vc_context_filter from the code. The emulation code

Re: [PATCH] Allow RDTSC and RDTSCP from userspace

2020-04-25 Thread Joerg Roedel
On Sat, Apr 25, 2020 at 11:15:35AM -0700, Andy Lutomirski wrote: > shift_ist is gross. What's it for? If it's not needed, I'd rather > not use it, and I eventually want to get rid of it for #DB as well. The #VC handler needs to be able to nest, there is no way around that for various reasons,

Re: [PATCH] Allow RDTSC and RDTSCP from userspace

2020-04-25 Thread Joerg Roedel
On Sat, Apr 25, 2020 at 12:47:31PM -0700, Andy Lutomirski wrote: > I assume the race you mean is: > > #VC > Immediate NMI before IST gets shifted > #VC > > Kaboom. > > How are you dealing with this? Ultimately, I think that NMI will need > to turn off IST before engaging in any funny business.

Re: Re: [PATCH 40/70] x86/sev-es: Setup per-cpu GHCBs for the runtime handler

2020-04-23 Thread Joerg Roedel
On Wed, Apr 22, 2020 at 06:33:13PM -0700, Bo Gan wrote: > On 4/15/20 8:53 AM, Joerg Roedel wrote: > > Hi Mike, > > > > On Tue, Apr 14, 2020 at 07:03:44PM +, Mike Stunes wrote: > > > set_memory_decrypted needs to check the return value. I see it > > >

[PATCH v3 08/34] iommu: Move default domain allocation to iommu_probe_device()

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Well, not really. The call to iommu_alloc_default_domain() in iommu_group_get_for_dev() has to stay around as long as there are IOMMU drivers using the add/remove_device() call-backs instead of probe/release_device(). Those drivers expect that iommu_group_get_for_dev

[PATCH v3 26/34] iommu/tegra: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the Tegra IOMMU drivers to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/tegra-gart.c | 24 ++-- drivers/iommu/tegra

[PATCH v3 30/34] iommu/exynos: Use first SYSMMU in controllers list for IOMMU core

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel On Exynos platforms there can be more than one SYSMMU (IOMMU) for one DMA master device. Since the IOMMU core code expects only one hardware IOMMU, use the first SYSMMU in the list. Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Signed-off-by: Joerg Roedel

[PATCH v3 34/34] iommu: Unexport iommu_group_get_for_dev()

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel The function is now only used in IOMMU core code and shouldn't be used outside of it anyway, so remove the export for it. Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 4 ++-- include/linux/iommu.h | 1 - 2

[PATCH v3 31/34] iommu/exynos: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the Exynos IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Signed-off-by: Joerg Roedel --- drivers/iommu/exynos

[PATCH v3 09/34] iommu: Keep a list of allocated groups in __iommu_probe_device()

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel This is needed to defer default_domain allocation for new IOMMU groups until all devices have been added to the group. Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 9 +++-- 1 file changed, 7 insertions

[PATCH v3 07/34] iommu: Add probe_device() and release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Add call-backs to 'struct iommu_ops' as an alternative to the add_device() and remove_device() call-backs, which will be removed when all drivers are converted. The new call-backs will not setup IOMMU groups and domains anymore, so also add a probe_finalize() call-back where

[PATCH v3 02/34] iommu: Add def_domain_type() callback in iommu_ops

2020-04-29 Thread Joerg Roedel
it to allocate the default domain ] Co-developed-by: Joerg Roedel Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 20 +--- include/linux/iommu.h | 6 ++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git

[PATCH v3 14/34] iommu/amd: Remove dev_data->passthrough

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Make use of generic IOMMU infrastructure to gather the same information carried in dev_data->passthrough and remove the struct member. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 10 +- drivers/iommu/amd_iommu_types.h | 1 - 2 files changed

[PATCH v3 05/34] iommu/amd: Remove dma_mask check from check_device()

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel The check was only needed for the DMA-API implementation in the AMD IOMMU driver, which no longer exists. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu

[PATCH v3 21/34] iommu/msm: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the MSM IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/msm_iommu.c | 34 +++--- 1 file changed

[PATCH v3 19/34] iommu/s390: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the S390 IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/s390-iommu.c | 22 ++ 1 file changed, 6

[PATCH v3 16/34] iommu/vt-d: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the Intel IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 67 - 1 file

[PATCH v3 25/34] iommu/rockchip: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the Rockchip IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/rockchip-iommu.c | 26 +++--- 1 file

[PATCH v3 03/34] iommu/amd: Implement iommu_ops->def_domain_type call-back

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Implement the new def_domain_type call-back for the AMD IOMMU driver. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 20cce366e951

[PATCH v3 10/34] iommu: Move new probe_device path to separate function

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel This makes it easier to remove to old code-path when all drivers are converted. As a side effect that it also fixes the error cleanup path. Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 69

[PATCH v3 00/34] iommu: Move iommu_group setup to IOMMU core code

2020-04-29 Thread Joerg Roedel
nks, Joerg Joerg Roedel (33): iommu: Move default domain allocation to separate function iommu/amd: Implement iommu_ops->def_domain_type call-back iommu/vt-d: Wire up iommu_ops->def_domain_type iommu/amd: Remove dma_mask check from check_device() iommu/amd: Return -ENODEV in add_de

[PATCH v3 23/34] iommu/mediatek-v1 Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the Mediatek-v1 IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/mtk_iommu_v1.c | 50 +++- 1

[PATCH v3 24/34] iommu/qcom: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the QCOM IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/qcom_iommu.c | 24 +++- 1 file changed, 7

[PATCH v3 22/34] iommu/mediatek: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the Mediatek IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/mtk_iommu.c | 24 ++-- 1 file changed, 6

[PATCH v3 18/34] iommu/pamu: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the PAMU IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/fsl_pamu_domain.c | 22 +- 1 file changed, 5

[PATCH v3 13/34] iommu: Export bus_iommu_probe() and make is safe for re-probing

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Add a check to the bus_iommu_probe() call-path to make sure it ignores devices which have already been successfully probed. Then export the bus_iommu_probe() function so it can be used by IOMMU drivers. Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Signed-off

[PATCH v3 11/34] iommu: Split off default domain allocation from group assignment

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel When a bus is initialized with iommu-ops, all devices on the bus are scanned and iommu-groups are allocated for them, and each groups will also get a default domain allocated. Until now this happened as soon as the group was created and the first device added to it. When

[PATCH v3 04/34] iommu/vt-d: Wire up iommu_ops->def_domain_type

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel The Intel VT-d driver already has a matching function to determine the default domain type for a device. Wire it up in intel_iommu_ops. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/intel

[PATCH v3 29/34] iommu/omap: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the OMAP IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/omap-iommu.c | 49 ++ 1 file

[PATCH v3 28/34] iommu/omap: Remove orphan_dev tracking

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Remove the tracking of device which could not be probed because their IOMMU is not probed yet. Replace it with a call to bus_iommu_probe() when a new IOMMU is probed. Signed-off-by: Joerg Roedel --- drivers/iommu/omap-iommu.c | 54 +++--- 1

[PATCH v3 12/34] iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device()

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel After the previous changes the iommu group may not have a default domain when iommu_group_add_device() is called. With no default domain iommu_group_create_direct_mappings() will do nothing and no direct mappings will be created. Rename iommu_group_create_direct_mappings

[PATCH v3 20/34] iommu/virtio: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the VirtIO IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/virtio-iommu.c | 41 +--- 1 file

[PATCH v3 01/34] iommu: Move default domain allocation to separate function

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Move the code out of iommu_group_get_for_dev() into a separate function. Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 74 ++- 1 file changed, 45 insertions(+), 29

[PATCH v3 27/34] iommu/renesas: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the Renesas IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/ipmmu-vmsa.c | 60 +- 1

[PATCH v3 17/34] iommu/arm-smmu: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the arm-smmu and arm-smmu-v3 drivers to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/arm-smmu-v3.c | 38

[PATCH v3 15/34] iommu/amd: Convert to probe/release_device() call-backs

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Convert the AMD IOMMU Driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 71 --- 1 file

[PATCH v3 33/34] iommu: Move more initialization to __iommu_probe_device()

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel Move the calls to dev_iommu_get() and try_module_get() into __iommu_probe_device(), so that the callers don't have to do it on their own. Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 47

[PATCH v3 06/34] iommu/amd: Return -ENODEV in add_device when device is not handled by IOMMU

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel When check_device() fails on the device, it is not handled by the IOMMU and amd_iommu_add_device() needs to return -ENODEV. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iommu

[PATCH v3 32/34] iommu: Remove add_device()/remove_device() code-paths

2020-04-29 Thread Joerg Roedel
From: Joerg Roedel All drivers are converted to use the probe/release_device() call-backs, so the add_device/remove_device() pointers are unused and the code using them can be removed. Tested-by: Marek Szyprowski Acked-by: Marek Szyprowski Signed-off-by: Joerg Roedel --- drivers/iommu

Re: [PATCH v3 12/75] x86/boot/compressed/64: Switch to __KERNEL_CS after GDT is loaded

2020-05-04 Thread Joerg Roedel
On Mon, May 04, 2020 at 12:41:29PM +0200, Borislav Petkov wrote: > On Tue, Apr 28, 2020 at 05:16:22PM +0200, Joerg Roedel wrote: > > + /* Reload CS so IRET returns to a CS actually in the GDT */ > > + pushq $__KERNEL_CS > > + leaq.Lon_kernel_cs(%rip), %rax

Re: [PATCH v3 13/75] x86/boot/compressed/64: Add IDT Infrastructure

2020-05-04 Thread Joerg Roedel
On Mon, May 04, 2020 at 12:54:45PM +0200, Borislav Petkov wrote: > On Tue, Apr 28, 2020 at 05:16:23PM +0200, Joerg Roedel wrote: > > diff --git a/arch/x86/boot/compressed/idt_handlers_64.S > > b/arch/x86/boot/compressed/idt_handlers_64.S > > new file mode 100644 &

Re: Should SEV-ES #VC use IST? (Re: [PATCH] Allow RDTSC and RDTSCP from userspace)

2020-04-28 Thread Joerg Roedel
On Mon, Apr 27, 2020 at 10:37:41AM -0700, Andy Lutomirski wrote: > I have a somewhat serious question: should we use IST for #VC at all? > As I understand it, Rome and Naples make it mandatory for hypervisors > to intercept #DB, which means that, due to the MOV SS mess, it's sort > of mandatory to

[PATCH v2 03/33] iommu/amd: Implement iommu_ops->def_domain_type call-back

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Implement the new def_domain_type call-back for the AMD IOMMU driver. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 20cce366e951

[PATCH v2 20/33] iommu/virtio: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the VirtIO IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/virtio-iommu.c | 41 +--- 1 file

[PATCH v2 14/33] iommu/amd: Remove dev_data->passthrough

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Make use of generic IOMMU infrastructure to gather the same information carried in dev_data->passthrough and remove the struct member. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 10 +- drivers/iommu/amd_iommu_types.h | 1 - 2 files changed

[PATCH v2 26/33] iommu/tegra: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Tegra IOMMU drivers to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/tegra-gart.c | 24 ++-- drivers/iommu/tegra

[PATCH v2 32/33] iommu: Remove add_device()/remove_device() code-paths

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel All drivers are converted to use the probe/release_device() call-backs, so the add_device/remove_device() pointers are unused and the code using them can be removed. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 149

[PATCH v2 25/33] iommu/rockchip: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Rockchip IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/rockchip-iommu.c | 26 +++--- 1 file

[PATCH v2 21/33] iommu/msm: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the MSM IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/msm_iommu.c | 34 +++--- 1 file changed

[PATCH v2 16/33] iommu/vt-d: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Intel IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 67 - 1 file

[PATCH v2 02/33] iommu: Add def_domain_type() callback in iommu_ops

2020-04-14 Thread Joerg Roedel
it to allocate the default domain ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 20 +--- include/linux/iommu.h | 6 ++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index

[PATCH v2 00/33] iommu: Move iommu_group setup to IOMMU core code

2020-04-14 Thread Joerg Roedel
tps://git.kernel.org/pub/scm/linux/kernel/git/joro/linux.git/log/?h=iommu-probe-device-v2 Please review. Thanks, Joerg Joerg Roedel (32): iommu: Move default domain allocation to separate function iommu/amd: Implement iommu_ops->def_domain_type call-back iommu/vt-d: Wire up iom

[PATCH v2 30/33] iommu/exynos: Use first SYSMMU in controllers list for IOMMU core

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel On Exynos platforms there can be more than one SYSMMU (IOMMU) for one DMA master device. Since the IOMMU core code expects only one hardware IOMMU, use the first SYSMMU in the list. Signed-off-by: Joerg Roedel --- drivers/iommu/exynos-iommu.c | 10 ++ 1 file changed

[PATCH v2 27/33] iommu/renesas: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Renesas IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/ipmmu-vmsa.c | 60 +- 1

[PATCH v2 31/33] iommu/exynos: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Exynos IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/exynos-iommu.c | 26 ++ 1 file changed

Re: [PATCH] iommu/exynos: Get rid of 'struct exynos_iommu_owner' exynos_iommu_owner

2020-04-14 Thread Joerg Roedel
On Thu, Apr 09, 2020 at 03:58:00PM +0200, Marek Szyprowski wrote: > I've checked and it works fine on top of > ff68eb23308e6538ec7864c83d39540f423bbe90. However I'm not a fan of > removing this 'owner' structure. It gave a nice abstraction for the all > SYSMMU controllers for the given device

[PATCH v2 23/33] iommu/mediatek-v1 Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Mediatek-v1 IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/mtk_iommu_v1.c | 50 +++- 1

[PATCH v2 12/33] iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device()

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel After the previous changes the iommu group may not have a default domain when iommu_group_add_device() is called. With no default domain iommu_group_create_direct_mappings() will do nothing and no direct mappings will be created. Rename iommu_group_create_direct_mappings

[PATCH v2 05/33] iommu/amd: Remove dma_mask check from check_device()

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel The check was only needed for the DMA-API implementation in the AMD IOMMU driver, which no longer exists. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu

[PATCH v2 28/33] iommu/omap: Remove orphan_dev tracking

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Remove the tracking of device which could not be probed because their IOMMU is not probed yet. Replace it with a call to bus_iommu_probe() when a new IOMMU is probed. Signed-off-by: Joerg Roedel --- drivers/iommu/omap-iommu.c | 54 +++--- 1

[PATCH v2 01/33] iommu: Move default domain allocation to separate function

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Move the code out of iommu_group_get_for_dev() into a separate function. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 74 ++- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers

[PATCH v2 15/33] iommu/amd: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the AMD IOMMU Driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 71 --- 1 file

[PATCH v2 09/33] iommu: Keep a list of allocated groups in __iommu_probe_device()

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel This is needed to defer default_domain allocation for new IOMMU groups until all devices have been added to the group. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommu.c b

[PATCH v2 10/33] iommu: Move new probe_device path to separate function

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel This makes it easier to remove to old code-path when all drivers are converted. As a side effect that it also fixes the error cleanup path. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 69 --- 1 file changed, 46 insertions

[PATCH v2 11/33] iommu: Split off default domain allocation from group assignment

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel When a bus is initialized with iommu-ops, all devices on the bus are scanned and iommu-groups are allocated for them, and each groups will also get a default domain allocated. Until now this happened as soon as the group was created and the first device added to it. When

[PATCH v2 07/33] iommu: Add probe_device() and remove_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Add call-backs to 'struct iommu_ops' as an alternative to the add_device() and remove_device() call-backs, which will be removed when all drivers are converted. The new call-backs will not setupt IOMMU groups and domains anymore, so also add a probe_finalize() call-back where

[PATCH v2 22/33] iommu/mediatek: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Mediatek IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/mtk_iommu.c | 24 ++-- 1 file changed, 6

[PATCH v2 06/33] iommu/amd: Return -ENODEV in add_device when device is not handled by IOMMU

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel When check_device() fails on the device, it is not handled by the IOMMU and amd_iommu_add_device() needs to return -ENODEV. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iommu

[PATCH v2 17/33] iommu/arm-smmu: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the arm-smmu and arm-smmu-v3 drivers to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/arm-smmu-v3.c | 38

[PATCH v2 19/33] iommu/s390: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the S390 IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/s390-iommu.c | 22 ++ 1 file changed, 6

[PATCH v2 18/33] iommu/pamu: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the PAMU IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/fsl_pamu_domain.c | 22 +- 1 file changed, 5

[PATCH v2 29/33] iommu/omap: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the OMAP IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/omap-iommu.c | 49 ++ 1 file

[PATCH v2 24/33] iommu/qcom: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the QCOM IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/qcom_iommu.c | 24 +++- 1 file changed, 7

[PATCH v2 33/33] iommu: Unexport iommu_group_get_for_dev()

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel The function is now only used in IOMMU core code and shouldn't be used outside of it anyway, so remove the export for it. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 4 ++-- include/linux/iommu.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff

[PATCH v2 08/33] iommu: Move default domain allocation to iommu_probe_device()

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Well, not really. The call to iommu_alloc_default_domain() in iommu_group_get_for_dev() has to stay around as long as there are IOMMU drivers using the add/remove_device() call-backs instead of probe/release_device(). Those drivers expect that iommu_group_get_for_dev

[PATCH v2 04/33] iommu/vt-d: Wire up iommu_ops->def_domain_type

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel The Intel VT-d driver already has a matching function to determine the default domain type for a device. Wire it up in intel_iommu_ops. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/intel

[PATCH v2 13/33] iommu: Export bus_iommu_probe() and make is safe for re-probing

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Add a check to the bus_iommu_probe() call-path to make sure it ignores devices which have already been successfully probed. Then export the bus_iommu_probe() function so it can be used by IOMMU drivers. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 6

Re: [RFC PATCH 33/34] iommu: Remove add_device()/remove_device() code-paths

2020-04-14 Thread Joerg Roedel
Hi Marek, On Fri, Apr 10, 2020 at 12:39:38PM +0200, Marek Szyprowski wrote: > > + if (!group->default_domain) > > + continue; > > It doesn't look straight from the above diff, but this continue leaks > group->lock taken. You are right, thanks for the review! I fixed

Re: [PATCH 40/70] x86/sev-es: Setup per-cpu GHCBs for the runtime handler

2020-04-15 Thread Joerg Roedel
Hi Mike, On Tue, Apr 14, 2020 at 07:03:44PM +, Mike Stunes wrote: > set_memory_decrypted needs to check the return value. I see it > consistently return ENOMEM. I've traced that back to split_large_page > in arch/x86/mm/pat/set_memory.c. I agree that the return code needs to be checked. But

Re: [PATCH 40/70] x86/sev-es: Setup per-cpu GHCBs for the runtime handler

2020-04-15 Thread Joerg Roedel
On Tue, Apr 14, 2020 at 03:04:42PM -0500, Tom Lendacky wrote: > At that point the guest won't be able to communicate with the hypervisor, > too. Maybe we should BUG() here to terminate further processing? We could talk to the hypervisor, there is still the boot-GHCB in the bss-decrypted section.

<    1   2   3   4   5   6   7   8   9   10   >