[PATCH 1/3] swiotlb: Introduce swiotlb_max_mapping_size()

2019-01-16 Thread Joerg Roedel
From: Joerg Roedel The function returns the maximum size that can be remapped by the SWIOTLB implementation. This function will be later exposed to users through the DMA-API. Signed-off-by: Joerg Roedel --- include/linux/swiotlb.h | 5 + kernel/dma/swiotlb.c| 5 + 2 files changed

Re: [PATCH v6 0/7] Add virtio-iommu driver

2019-01-16 Thread Joerg Roedel
Hi Jean-Philippe, On Thu, Dec 13, 2018 at 12:50:29PM +, Jean-Philippe Brucker wrote: > We already do deferred flush: UNMAP requests are added to the queue by > iommu_unmap(), and then flushed out by iotlb_sync(). So we switch to the > host only on iotlb_sync(), or when the request queue is

Re: [PATCH 1/3] swiotlb: Export maximum allocation size

2019-01-16 Thread Joerg Roedel
On Thu, Jan 10, 2019 at 12:02:05PM -0500, Konrad Rzeszutek Wilk wrote: > Why not use swiotlb_nr_tbl ? That is how drivers/gpu/drm use to figure if they > need to limit the size of pages. That function just exports the overall size of the swiotlb aperture, no? What I need here is the maximum size

Re: [PATCH 0/3] Fix virtio-blk issue with SWIOTLB

2019-01-16 Thread Joerg Roedel
On Fri, Jan 11, 2019 at 11:29:31AM +0800, Jason Wang wrote: > Just wonder if my understanding is correct IOMMU_PLATFORM must be set for > all virtio devices under AMD-SEV guests? Yes, that is correct. Emulated DMA can only happen on the SWIOTLB aperture, because that memory is not encrypted. The

Re: [PATCH 0/3] Fix virtio-blk issue with SWIOTLB

2019-01-16 Thread Joerg Roedel
On Mon, Jan 14, 2019 at 01:20:45PM -0500, Michael S. Tsirkin wrote: > Which would be fine especially if we can manage not to introduce a bunch > of indirect calls all over the place and hurt performance. Which indirect calls? In case of unset dma_ops the DMA-API functions call directly into the

[PATCH 2/3] dma: Introduce dma_max_mapping_size()

2019-01-16 Thread Joerg Roedel
From: Joerg Roedel The function returns the maximum size that can be mapped using DMA-API functions. The patch also adds the implementation for direct DMA and a new dma_map_ops pointer so that other implementations can expose their limit. Signed-off-by: Joerg Roedel --- include/linux/dma

Re: [PATCH 2/3] dma: Introduce dma_max_mapping_size()

2019-01-16 Thread Joerg Roedel
On Tue, Jan 15, 2019 at 02:37:54PM +0100, Christoph Hellwig wrote: > > +size_t dma_direct_max_mapping_size(struct device *dev) > > +{ > > + /* > > +* Return the minimum of the direct DMA limit and the SWIOTLB limit. > > +* Since direct DMA has no limit, it is fine to just return the

[PATCH 0/3 v2] Fix virtio-blk issue with SWIOTLB

2019-01-16 Thread Joerg Roedel
by Christoph Hellwig. Please review. Thanks, Joerg Joerg Roedel (3): swiotlb: Introduce swiotlb_max_mapping_size() dma: Introduce dma_max_mapping_size() virtio-blk: Consider dma_max_mapping_size() for maximum segment size drivers/block/virtio_blk.c | 10 ++ include/linux

[PATCH 3/3] virtio-blk: Consider dma_max_mapping_size() for maximum segment size

2019-01-16 Thread Joerg Roedel
From: Joerg Roedel Segments can't be larger than the maximum DMA mapping size supported on the platform. Take that into account when setting the maximum segment size for a block device. Signed-off-by: Joerg Roedel --- drivers/block/virtio_blk.c | 10 ++ 1 file changed, 6 insertions

Re: [PATCH 3/3] virtio-blk: Consider dma_max_mapping_size() for maximum segment size

2019-01-16 Thread Joerg Roedel
On Wed, Jan 16, 2019 at 09:05:40AM -0500, Michael S. Tsirkin wrote: > On Tue, Jan 15, 2019 at 02:22:57PM +0100, Joerg Roedel wrote: > > + max_size = dma_max_mapping_size(>dev); > > + > > > Should this be limited to ACCESS_PLATFORM? > > I see no reason t

Re: [PATCH v7 0/7] Add virtio-iommu driver

2019-01-23 Thread Joerg Roedel
Hi Jean-Philippe, thanks for all your hard work on this! On Tue, Jan 15, 2019 at 12:19:52PM +, Jean-Philippe Brucker wrote: > Implement the virtio-iommu driver, following specification v0.9 [1]. To make progress on this I think the spec needs to be close to something that can be included

[PATCH 2/5] swiotlb: Add is_swiotlb_active() function

2019-01-23 Thread Joerg Roedel
From: Joerg Roedel This function will be used from dma_direct code to determine the maximum segment size of a dma mapping. Signed-off-by: Joerg Roedel --- include/linux/swiotlb.h | 6 ++ kernel/dma/swiotlb.c| 5 + 2 files changed, 11 insertions(+) diff --git a/include/linux

[PATCH 1/5] swiotlb: Introduce swiotlb_max_mapping_size()

2019-01-23 Thread Joerg Roedel
From: Joerg Roedel The function returns the maximum size that can be remapped by the SWIOTLB implementation. This function will be later exposed to users through the DMA-API. Signed-off-by: Joerg Roedel --- include/linux/swiotlb.h | 5 + kernel/dma/swiotlb.c| 5 + 2 files changed

[PATCH 4/5] virtio: Introduce virtio_max_dma_size()

2019-01-23 Thread Joerg Roedel
From: Joerg Roedel This function returns the maximum segment size for a single dma transaction of a virtio device. The possible limit comes from the SWIOTLB implementation in the Linux kernel, that has an upper limit of (currently) 256kb of contiguous memory it can map. Other DMA-API

[PATCH 3/5] dma: Introduce dma_max_mapping_size()

2019-01-23 Thread Joerg Roedel
From: Joerg Roedel The function returns the maximum size that can be mapped using DMA-API functions. The patch also adds the implementation for direct DMA and a new dma_map_ops pointer so that other implementations can expose their limit. Signed-off-by: Joerg Roedel --- include/linux/dma

[PATCH 0/5 v3] Fix virtio-blk issue with SWIOTLB

2019-01-23 Thread Joerg Roedel
limit in dma_direct_max_mapping_size() * Only apply the maximum segment limit in virtio-blk when DMA-API is used for the vring Please review. Thanks, Joerg Joerg Roedel (5): swiotlb: Introduce swiotlb_max_mapping_size() swiotlb: Add is_swiotlb_active

[PATCH 5/5] virtio-blk: Consider virtio_max_dma_size() for maximum segment size

2019-01-23 Thread Joerg Roedel
From: Joerg Roedel Segments can't be larger than the maximum DMA mapping size supported on the platform. Take that into account when setting the maximum segment size for a block device. Signed-off-by: Joerg Roedel --- drivers/block/virtio_blk.c | 10 ++ 1 file changed, 6 insertions

Re: [PATCH v6 0/7] Add virtio-iommu driver

2018-12-13 Thread Joerg Roedel
Hi, to make progress on this, we should first agree on the protocol used between guest and host. I have a few points to discuss on the protocol first. On Tue, Dec 11, 2018 at 06:20:57PM +, Jean-Philippe Brucker wrote: > [1] Virtio-iommu specification v0.9, sources and pdf >

Re: [PATCH 0/3] Fix virtio-blk issue with SWIOTLB

2019-01-10 Thread Joerg Roedel
Hi Christoph, On Thu, Jan 10, 2019 at 02:59:52PM +0100, Christoph Hellwig wrote: > On Thu, Jan 10, 2019 at 02:44:30PM +0100, Joerg Roedel wrote: > > The problem is a limitation of the SWIOTLB implementation, > > which does not support allocations larger than 256kb. When > >

[PATCH 1/3] swiotlb: Export maximum allocation size

2019-01-10 Thread Joerg Roedel
From: Joerg Roedel The SWIOTLB implementation has a maximum size it can allocate dma-handles for. This needs to be exported so that device drivers don't try to allocate larger chunks. This is especially important for block device drivers like virtio-blk, that might do DMA through SWIOTLB

[PATCH 3/3] virtio-blk: Consider virtio_max_dma_size() for maximum segment size

2019-01-10 Thread Joerg Roedel
From: Joerg Roedel Segments can't be larger than the maximum DMA allocation size supported by virtio on the platform. Take that into account when setting the maximum segment size for a block device. Signed-off-by: Joerg Roedel --- drivers/block/virtio_blk.c | 10 ++ 1 file changed, 6

[PATCH 0/3] Fix virtio-blk issue with SWIOTLB

2019-01-10 Thread Joerg Roedel
SWIOTLB bounce buffering and limits the maximum segment size in the virtio-blk driver in this case, so that it doesn't try to do larger reads/writes. Please review. Thanks, Joerg Joerg Roedel (3): swiotlb: Export maximum allocation size virtio: Introduce virtio_max_dma_size() virtio-blk

[PATCH 2/3] virtio: Introduce virtio_max_dma_size()

2019-01-10 Thread Joerg Roedel
From: Joerg Roedel This function returns the maximum segment size for a single dma transaction of a virtio device. The possible limit comes from the SWIOTLB implementation in the Linux kernel, that has an upper limit of (currently) 256kb of contiguous memory it can map. The functions return

Re: [PATCH v7 0/7] Add virtio-iommu driver

2019-05-27 Thread Joerg Roedel
d because the Spec was not yet official. So for the code: Acked-by: Joerg Roedel ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH v4 0/5] iommu/amd: Convert the AMD iommu driver to the dma-iommu api

2019-07-01 Thread Joerg Roedel
Hi, On Sun, Jun 23, 2019 at 11:19:45PM -0700, Christoph Hellwig wrote: > Joerg, any chance you could review this? Toms patches to convert the > AMD and Intel IOMMU drivers to the dma-iommu code are going to make my > life in DMA land significantly easier, so I have a vested interest > in

Re: [PATCH] iommu/virtio: Update to most recent specification

2019-07-22 Thread Joerg Roedel
On Mon, Jul 22, 2019 at 11:16:08AM -0400, Michael S. Tsirkin wrote: > I'm merging this for this release, unless someone objects. No objections from me. Acked-by: Joerg Roedel ___ Virtualization mailing list Virtualization@lists.linux-foundation.

Re: [PATCH] iommu/virtio: Remove unused variable

2019-10-30 Thread Joerg Roedel
On Fri, Oct 25, 2019 at 01:13:40PM -0300, Cristiane Naves wrote: > Remove the variable of return. Issue found by > coccicheck(scripts/coccinelle/misc/returnvar.cocci) > > Signed-off-by: Cristiane Naves > --- > drivers/iommu/virtio-iommu.c | 3 +-- > 1 file changed, 1 insertion(+), 2

Re: [PATCH v2 0/5] iommu: Implement iommu_put_resv_regions_simple()

2019-12-17 Thread Joerg Roedel
Hi Thierry On Mon, Dec 09, 2019 at 03:50:02PM +0100, Thierry Reding wrote: > From: Thierry Reding > > Most IOMMU drivers only need to free the memory allocated for each > reserved region. Instead of open-coding the loop to do this in each > driver, extract the code into a common function that

Re: [PATCH v6 0/5] iommu/amd: Convert the AMD iommu driver to the dma-iommu api

2019-10-08 Thread Joerg Roedel
On Sun, Sep 08, 2019 at 09:56:36AM -0700, Tom Murphy wrote: > Convert the AMD iommu driver to the dma-iommu api. Remove the iova > handling and reserve region code from the AMD iommu driver. Applied, thanks. Note that it will not show up in linux-next before -rc3.

Re: [PATCH v3 4/5] iommu: intel: Use generic_iommu_put_resv_regions()

2019-12-19 Thread Joerg Roedel
On Thu, Dec 19, 2019 at 01:47:47PM +0100, Thierry Reding wrote: > On Thu, Dec 19, 2019 at 09:53:22AM +0800, Lu Baolu wrote: > > Please tweak the title to > > > > "iommu/vt-d: Use generic_iommu_put_resv_regions()" > > > > then, > > > > Acked-by: Lu Baolu > > > > Best regards, > > baolu > >

Re: [PATCH 23/62] x86/idt: Move IDT to data segment

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 02:41:25PM -0800, Andy Lutomirski wrote: > On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > > > From: Joerg Roedel > > > > With SEV-ES, exception handling is needed very early, even before the > > kernel has cleared the bss segm

Re: [PATCH 19/62] x86/sev-es: Add support for handling IOIO exceptions

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 02:28:06PM -0800, Andy Lutomirski wrote: > On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > It would be nice if this could reuse the existing in-kernel > instruction decoder. Is there some reason it can't? It does, see patch 5, which makes the inat-tables

Re: [PATCH 08/62] x86/boot/compressed/64: Add IDT Infrastructure

2020-02-12 Thread Joerg Roedel
Hi Andy, thanks a lot for your valuable reviews! On Tue, Feb 11, 2020 at 02:18:52PM -0800, Andy Lutomirski wrote: > On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > + entry.offset_low= (u16)(address & 0x); > > + entry.segment

Re: [PATCH 14/62] x86/boot/compressed/64: Add stage1 #VC handler

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 02:23:22PM -0800, Andy Lutomirski wrote: > On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > +void __init no_ghcb_vc_handler(struct pt_regs *regs) > > Isn't there a second parameter: unsigned long error_code? No, the function gets the error-code fro

Re: [PATCH 18/62] x86/boot/compressed/64: Setup GHCB Based VC Exception handler

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 02:25:49PM -0800, Andy Lutomirski wrote: > On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > > > From: Joerg Roedel > > > > Install an exception handler for #VC exception that uses a GHCB. Also > > add the infrastructure for handling

Re: [PATCH 25/62] x86/head/64: Install boot GDT

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 02:29:24PM -0800, Andy Lutomirski wrote: > On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > + /* GDT loaded - switch to __KERNEL_CS so IRET works reliably */ > > + pushq $__KERNEL_CS > > + leaq.Lon_kernel_cs(%rip), %

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

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 02:46:11PM -0800, Andy Lutomirski wrote: > On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > +/* Runtime GHCBs */ > > +static DEFINE_PER_CPU_DECRYPTED(struct ghcb, ghcb_page) > > __aligned(PAGE_SIZE); > > Hmm. This is a largeish amount

Re: [PATCH 46/62] x86/sev-es: Handle INVD Events

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 04:12:19PM -0800, Andy Lutomirski wrote: > > > > On Feb 11, 2020, at 5:53 AM, Joerg Roedel wrote: > > > > From: Tom Lendacky > > > > Implement a handler for #VC exceptions caused by INVD instructions. > > Uh, what? Surely t

Re: [PATCH 30/62] x86/head/64: Move early exception dispatch to C code

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 02:44:45PM -0800, Andy Lutomirski wrote: > How about int (or bool) handled; Or just if (!early_make_pgtable) > return; This would also be nicer if you inverted the return value so > that true means "I handled it". Okay, makes sense. Changed the return value of

Re: [RFC PATCH 00/62] Linux as SEV-ES Guest Support

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 02:12:04PM -0800, Andy Lutomirski wrote: > On Tue, Feb 11, 2020 at 7:43 AM Joerg Roedel wrote: > > > > On Tue, Feb 11, 2020 at 03:50:08PM +0100, Peter Zijlstra wrote: > > > > > Oh gawd; so instead of improving the whole NMI situation, AMD went

Re: [PATCH 39/62] x86/sev-es: Harden runtime #VC handler for exceptions from user-space

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 02:47:05PM -0800, Andy Lutomirski wrote: > On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > > > From: Joerg Roedel > > > > Send SIGBUS to the user-space process that caused the #VC exception > > instead of killing the machine. Als

Re: [PATCH 50/62] x86/sev-es: Handle VMMCALL Events

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 04:14:53PM -0800, Andy Lutomirski wrote: > > How about we just don’t do VMMCALL if we’re a SEV-ES guest? Otherwise > we add thousands of cycles of extra latency for no good reason. True, but I left that as a future optimization for now, given the size the patch-set

Re: [PATCH 62/62] x86/sev-es: Add NMI state tracking

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 02:50:29PM -0800, Andy Lutomirski wrote: > On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > This patch is overcomplicated IMO. Just do the magic incantation in C > from do_nmi or from here: > > /* > * For ease of testing, unma

Re: [RFC PATCH 00/62] Linux as SEV-ES Guest Support

2020-02-12 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 07:48:12PM -0800, Andy Lutomirski wrote: > > > > On Feb 11, 2020, at 5:53 AM, Joerg Roedel wrote: > > > > > > >* Putting some NMI-load on the guest will make it crash usually > > within a minute > > Suppose yo

Re: [PATCH 00/14] iommu: Move iommu_fwspec out of 'struct device'

2020-03-04 Thread Joerg Roedel
Hi Will, On Tue, Mar 03, 2020 at 07:16:25PM +, Will Deacon wrote: > I haven't had a chance to review this properly yet, but I did take it > for a spin on my Seattle board with MMU-400 (arm-smmu) and it seems to > work the same as before, so: > > Tested-by: Will Deacon # arm-smmu > > I'll

Re: [PATCH v2 1/3] iommu/virtio: Add topology description to virtio-iommu config space

2020-03-04 Thread Joerg Roedel
Hi Michael, On Tue, Mar 03, 2020 at 11:09:41AM -0500, Michael S. Tsirkin wrote: > No. It's coded into the hardware. Which might even be practical > for bare-metal (e.g. on-board flash), but is very practical > when the device is part of a hypervisor. If its that way on PPC, than fine for them.

Re: [PATCH v2 1/3] iommu/virtio: Add topology description to virtio-iommu config space

2020-03-04 Thread Joerg Roedel
On Wed, Mar 04, 2020 at 04:38:21PM +0100, Jean-Philippe Brucker wrote: > I agree with this. The problem is I don't know how to get a new ACPI table > or change an existing one. It needs to go through the UEFI forum in order > to be accepted, and I don't have any weight there. I've been trying to

Re: [PATCH v2 1/3] iommu/virtio: Add topology description to virtio-iommu config space

2020-03-04 Thread Joerg Roedel
On Wed, Mar 04, 2020 at 07:48:54AM -0800, Jacob Pan wrote: > For emulated VT-d IOMMU, GIOVA can also be build as first level page > tables then pass to the host IOMMU to bind. There is no need to shadow > in this case, pIOMMU will do nested translation and walk guest page > tables. Right, but

Re: [PATCH v2 1/3] iommu/virtio: Add topology description to virtio-iommu config space

2020-03-04 Thread Joerg Roedel
On Wed, Mar 04, 2020 at 02:34:33PM -0500, Michael S. Tsirkin wrote: > All these extra levels of indirection is one of the reasons > hypervisors such as kata try to avoid ACPI. Platforms that don't use ACPI need another hardware detection mechanism, which can also be supported. But the first step

Re: [PATCH v2 1/3] iommu/virtio: Add topology description to virtio-iommu config space

2020-03-04 Thread Joerg Roedel
On Wed, Mar 04, 2020 at 01:37:44PM -0800, Jacob Pan (Jun) wrote: > + Mike and Erik who work closely on UEFI and ACPICA. > > Copy paste Erik's initial response below on how to get a new table, > seems to confirm with the process you stated above. > > "Fairly easy. You reserve a 4-letter symbol by

Re: [PATCH v2 1/3] iommu/virtio: Add topology description to virtio-iommu config space

2020-03-02 Thread Joerg Roedel
On Fri, Feb 28, 2020 at 06:25:36PM +0100, Jean-Philippe Brucker wrote: > This solution isn't elegant nor foolproof, but is the best we can do at > the moment and works with existing virtio-iommu implementations. It also > enables an IOMMU for lightweight hypervisors that do not rely on > firmware

Re: [PATCH v2 1/3] iommu/virtio: Add topology description to virtio-iommu config space

2020-03-03 Thread Joerg Roedel
Hi Eric, On Tue, Mar 03, 2020 at 11:19:20AM +0100, Auger Eric wrote: > Michael has pushed this solution (putting the "configuration in the PCI > config space"), I think for those main reasons: > - ACPI may not be supported on some archs/hyps But on those there is device-tree, right? > - the

Re: [PATCH v2 1/3] iommu/virtio: Add topology description to virtio-iommu config space

2020-03-03 Thread Joerg Roedel
On Tue, Mar 03, 2020 at 09:00:05AM -0500, Michael S. Tsirkin wrote: > Not necessarily. E.g. some power systems have neither. > There are also systems looking to bypass ACPI e.g. for boot speed. If there is no firmware layer between the hardware and the OS the necessary information the OS needs to

[PATCH 04/14] iommu/arm-smmu: Fix uninitilized variable warning

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Some unrelated changes in the iommu code caused a new warning to appear in the arm-smmu driver: CC drivers/iommu/arm-smmu.o drivers/iommu/arm-smmu.c: In function 'arm_smmu_add_device': drivers/iommu/arm-smmu.c:1441:2: warning: 'smmu' may be used uninitialized

[PATCH 01/14] ACPI/IORT: Remove direct access of dev->iommu_fwspec

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Use the accessor functions instead of directly dereferencing dev->iommu_fwspec. Signed-off-by: Joerg Roedel --- drivers/acpi/arm64/iort.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c in

[PATCH 10/14] iommu/renesas: Use accessor functions for iommu private data

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Make use of dev_iommu_priv_set/get() functions. Signed-off-by: Joerg Roedel --- drivers/iommu/ipmmu-vmsa.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index ecb3f9464dd5..310cf09feea3

[PATCH 14/14] iommu: Move fwspec->iommu_priv to struct dev_iommu

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Move the pointer for iommu private data from struct iommu_fwspec to struct dev_iommu. Signed-off-by: Joerg Roedel --- include/linux/iommu.h | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index

[PATCH 05/14] iommu: Rename struct iommu_param to dev_iommu

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel The term dev_iommu aligns better with other existing structures and their accessor functions. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 28 ++-- include/linux/device.h | 6 +++--- include/linux/iommu.h | 4 ++-- 3 files changed, 19

[PATCH 03/14] iommu/tegra-gart: Remove direct access of dev->iommu_fwspec

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Use the accessor functions instead of directly dereferencing dev->iommu_fwspec. Signed-off-by: Joerg Roedel --- drivers/iommu/tegra-gart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c in

[PATCH 08/14] iommu/arm-smmu-v3: Use accessor functions for iommu private data

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Make use of dev_iommu_priv_set/get() functions in the code. Signed-off-by: Joerg Roedel --- drivers/iommu/arm-smmu-v3.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index

[PATCH 07/14] iommu: Introduce accessors for iommu private data

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Add dev_iommu_priv_get/set() functions to access per-device iommu private data. This makes it easier to move the pointer to a different location. Signed-off-by: Joerg Roedel --- include/linux/iommu.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/include

[PATCH 11/14] iommu/mediatek: Use accessor functions for iommu private data

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Make use of dev_iommu_priv_set/get() functions. Signed-off-by: Joerg Roedel --- drivers/iommu/mtk_iommu.c| 13 ++--- drivers/iommu/mtk_iommu_v1.c | 14 +++--- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b

[PATCH 12/14] iommu/qcom: Use accessor functions for iommu private data

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Make use of dev_iommu_priv_set/get() functions. Signed-off-by: Joerg Roedel --- drivers/iommu/qcom_iommu.c | 61 ++ 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/drivers/iommu/qcom_iommu.c b/drivers/iommu/qcom_iommu.c

[PATCH 00/14] iommu: Move iommu_fwspec out of 'struct device'

2020-02-28 Thread Joerg Roedel
of these drivers is greatly appreciated. I boot-tested these changes on arm-smmu-v3 enabled KVM VM. Please review. Regards, Joerg Joerg Roedel (14): ACPI/IORT: Remove direct access of dev->iommu_fwspec drm/msm/mdp5: Remove direct access of dev->iommu_fwspec iommu/tegr

[PATCH 06/14] iommu: Move iommu_fwspec to struct dev_iommu

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Move the iommu_fwspec pointer in struct device into struct dev_iommu. This is a step in the effort to reduce the iommu related pointers in struct device to one. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 3 +++ include/linux/device.h | 1 - include/linux

[PATCH 09/14] iommu/arm-smmu: Use accessor functions for iommu private data

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Make use of dev_iommu_priv_set/get() functions and simplify the code where possible with this change. Signed-off-by: Joerg Roedel --- drivers/iommu/arm-smmu.c | 56 +--- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git

[PATCH 13/14] iommu/virtio: Use accessor functions for iommu private data

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Make use of dev_iommu_priv_set/get() functions. Signed-off-by: Joerg Roedel --- drivers/iommu/virtio-iommu.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index cce329d71fba

[PATCH 02/14] drm/msm/mdp5: Remove direct access of dev->iommu_fwspec

2020-02-28 Thread Joerg Roedel
From: Joerg Roedel Use the accessor functions instead of directly dereferencing dev->iommu_fwspec. Signed-off-by: Joerg Roedel --- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c b/driv

Re: [PATCH] iommu/virtio: Build virtio-iommu as module

2020-02-19 Thread Joerg Roedel
On Wed, Feb 19, 2020 at 12:41:33PM +0100, Jean-Philippe Brucker wrote: > No, I meant Will's changes in 5.6 to make the SMMU drivers modular. This > patch doesn't depend on the x86 enablement patch-set, but there is a small > conflict in Kconfig since they both modify it (locally I have this patch

[PATCH 50/62] x86/sev-es: Handle VMMCALL Events

2020-02-11 Thread Joerg Roedel
handling infrastructure ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/arch/x86/kernel/sev-es.c b/arch/x86/kernel/sev-es.c index 8f1e84da6fa6..6bd2cae7eb9c 100644 --- a/arch/x86

[PATCH 38/62] x86/sev-es: Handle instruction fetches from user-space

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel When a #VC exception is triggered by user-space the instruction decoder needs to read the instruction bytes from user addresses. Enhance es_fetch_insn_byte() to safely fetch kernel and user instruction bytes. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 30

[PATCH 48/62] x86/sev-es: Handle MONITOR/MONITORX Events

2020-02-11 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by MONITOR and MONITORX 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 | 18

[PATCH 41/62] x86/sev-es: Handle MSR events

2020-02-11 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by RDMSR/WRMSR 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 | 32

[PATCH 57/62] x86/realmode: Setup AP jump table

2020-02-11 Thread Joerg Roedel
code ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/include/asm/sev-es.h | 11 ++ arch/x86/include/uapi/asm/svm.h | 3 ++ arch/x86/kernel/sev-es.c| 63 + arch/x86/realmode/init.c| 6 4 files changed, 83

[PATCH 54/62] x86/kvm: Add KVM specific VMMCALL handling under SEV-ES

2020-02-11 Thread Joerg Roedel
From: Tom Lendacky Implement the callbacks to copy the processor state required by KVM to the GHCB. Signed-off-by: Tom Lendacky [ jroe...@suse.de: - Split out of a larger patch - Adapt to different callback functions ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg

[PATCH 61/62] x86/cpufeature: Add SEV_ES_GUEST CPU Feature

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel The feature bit will indicate whether the kernel runs as an SEV-ES guest. This can be used to apply alternatives at boot for SEV-ES guests and provides a way for user-space to detect whether it runs as an SEV-ES guest. Signed-off-by: Joerg Roedel --- arch/x86/include/asm

[PATCH 62/62] x86/sev-es: Add NMI state tracking

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel Keep NMI state in SEV-ES code so the kernel can re-enable NMIs for the vCPU when it reaches IRET. Signed-off-by: Joerg Roedel --- arch/x86/entry/entry_64.S | 48 + arch/x86/include/asm/sev-es.h | 27 +++ arch/x86

[PATCH 52/62] x86/sev-es: Handle #DB Events

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel Handle #VC exceptions caused by #DB exceptions in the guest. Do not forward them to the hypervisor and handle them with do_debug() instead. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 12 1 file changed, 12 insertions(+) diff --git a/arch/x86

[PATCH 46/62] x86/sev-es: Handle INVD Events

2020-02-11 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by INVD 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 | 8 1 file changed, 8

[PATCH 56/62] x86/realmode: Add SEV-ES specific trampoline entry point

2020-02-11 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 44/62] x86/sev-es: Handle RDTSC Events

2020-02-11 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by RDTSC 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 | 20 1

[PATCH 59/62] x86/head/64: Rename start_cpu0

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel For SEV-ES this entry point will be used for restarting APs after they have been offlined. Remove the '0' from the name to reflect that. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/cpu.h | 2 +- arch/x86/kernel/head_32.S | 4 ++-- arch/x86/kernel/head_64.S | 6

[PATCH 60/62] x86/sev-es: Support CPU offline/online

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel Add a play_dead handler when running under SEV-ES. This is needed because the hypervisor can't deliver an SIPI request to restart the AP. Instead the kernel has to issue a VMGEXIT to halt the VCPU. When the hypervisor would deliver and SIPI is wakes up the VCPU instead

[PATCH 45/62] x86/sev-es: Handle RDPMC Events

2020-02-11 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by RDPMC 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 | 22 ++ 1

[PATCH 55/62] x86/vmware: Add VMware specific handling for VMMCALL under SEV-ES

2020-02-11 Thread Joerg Roedel
From: Doug Covelli This change adds VMware specific handling for #VC faults caused by VMMCALL instructions. Signed-off-by: Doug Covelli Signed-off-by: Tom Lendacky [ jroe...@suse.de: - Adapt to different paravirt interface ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel

[PATCH 49/62] x86/sev-es: Handle MWAIT/MWAITX Events

2020-02-11 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 | 11 +++ 1

[PATCH 43/62] x86/sev-es: Handle WBINVD Events

2020-02-11 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by WBINVD instructions. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC handling framework ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 9 + 1 file changed, 9

[PATCH 51/62] x86/sev-es: Handle #AC Events

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel Implement a handler for #VC exceptions caused by #AC exceptions. The #AC exception is just forwarded to do_alignment_check() and not pushed down to the hypervisor, as requested by the SEV-ES GHCB Standardization Specification. Signed-off-by: Joerg Roedel --- arch/x86/kernel

[PATCH 42/62] x86/sev-es: Handle DR7 read/write events

2020-02-11 Thread Joerg Roedel
-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 69 +--- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/sev-es.c b/arch/x86/kernel/sev-es.c index b27d5b0a8ae1..fcd67ab04d2d 100644 --- a/arch/x86/kernel

[PATCH 47/62] x86/sev-es: Handle RDTSCP Events

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel Extend the RDTSC handler to also handle RDTSCP events. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/sev-es.c b/arch/x86/kernel/sev-es.c index 485f5a14c3b4

[PATCH 53/62] x86/paravirt: Allow hypervisor specific VMMCALL handling under SEV-ES

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel Add two new paravirt callbacks to provide hypervisor specific processor state in the GHCB and to copy state from the hypervisor back to the processor. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/x86_init.h | 16 +++- arch/x86/kernel/sev-es.c| 12

[PATCH 58/62] x86/head/64: Don't call verify_cpu() on starting APs

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel The APs are not ready to handle exceptions when verify_cpu() is called in secondary_startup_64. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/realmode.h | 1 + arch/x86/kernel/head_64.S | 1 + arch/x86/realmode/init.c| 6 ++ 3 files changed, 8

[PATCH 05/62] x86/insn-decoder: Make inat-tables.c suitable for pre-decompression code

2020-02-11 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 35/62] x86/sev-es: Setup per-cpu GHCBs for the runtime handler

2020-02-11 Thread Joerg Roedel
From: Tom Lendacky The runtime handler needs a GHCB per CPU. Set them up and map them unencrypted. Signed-off-by: Tom Lendacky Signed-off-by: Joerg Roedel --- arch/x86/include/asm/mem_encrypt.h | 2 ++ arch/x86/kernel/sev-es.c | 25 - arch/x86/kernel

[PATCH 20/62] x86/fpu: Move xgetbv()/xsetbv() into separate header

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel The xgetbv() function is needed in pre-decompression boot code, but asm/fpu/internal.h can't be included there directly. Doing so opens the door to include-hell due to various include-magic in boot/compressed/misc.h. Avoid that by moving xgetbv()/xsetbv() to a separate header

[PATCH 39/62] x86/sev-es: Harden runtime #VC handler for exceptions from user-space

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel Send SIGBUS to the user-space process that caused the #VC exception instead of killing the machine. Also ratelimit the error messages so that user-space can't flood the kernel log. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 32

[PATCH 07/62] x86/boot/compressed/64: Disable red-zone usage

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel The x86-64 ABI defines a red-zone on the stack: The 128-byte area beyond the location pointed to by %rsp is considered to be reserved and shall not be modified by signal or interrupt handlers. 10 Therefore, functions may use this area for temporary data

[PATCH 36/62] x86/sev-es: Add Runtime #VC Exception Handler

2020-02-11 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 | 77

[PATCH 28/62] x86/head/64: Switch to initial stack earlier

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel Make sure there is a stack once the kernel runs from virual addresses. At this stage any secondary CPU which boots will have lost its stack because the kernel switched to a new page-table which does not map the real-mode stack anymore. This is also needed for handling early

[PATCH 40/62] x86/sev-es: Filter exceptions not supported from user-space

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel Currently only CPUID caused #VC exceptions are supported from user-space. Filter the others out early. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 24 1 file changed, 24 insertions(+) diff --git a/arch/x86/kernel/sev-es.c b/arch/x86

  1   2   3   4   5   6   7   8   9   >