Re: [PATCH v3 0/2] iommu/virtio: Enable IOMMU_CAP_DERRED_FLUSH

2023-11-27 Thread Joerg Roedel
On Mon, Nov 20, 2023 at 03:51:55PM +0100, Niklas Schnelle wrote: > Niklas Schnelle (2): > iommu/virtio: Make use of ops->iotlb_sync_map > iommu/virtio: Add ops->flush_iotlb_all and enable deferred flush > > drivers/iommu/virtio-iommu.c | 33 - > 1 file

Re: [PATCH][next] iommu/virtio: Add __counted_by for struct viommu_request and use struct_size()

2023-10-16 Thread Joerg Roedel
On Mon, Oct 09, 2023 at 12:24:27PM -0600, Gustavo A. R. Silva wrote: > drivers/iommu/virtio-iommu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Applied, thanks. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org h

Re: [PATCH] iommu: Explicitly include correct DT includes

2023-08-07 Thread Joerg Roedel
On Fri, Jul 14, 2023 at 11:46:39AM -0600, Rob Herring wrote: > drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c | 2 +- > drivers/iommu/arm/arm-smmu/arm-smmu.c| 1 - > drivers/iommu/arm/arm-smmu/qcom_iommu.c | 3 +-- > drivers/iommu/ipmmu-vmsa.c | 1 - >

Re: [PATCH v2 0/2] iommu/virtio: Fixes

2023-05-22 Thread Joerg Roedel
On Mon, May 15, 2023 at 12:39:46PM +0100, Jean-Philippe Brucker wrote: > One fix reported by Akihiko, and another found while going over the > driver. > > Jean-Philippe Brucker (2): > iommu/virtio: Detach domain on endpoint release > iommu/virtio: Return size mapped for a detached domain > >

Re: [PATCH v3 00/10] Let iommufd charge IOPTE allocations to the memory cgroup

2023-01-25 Thread Joerg Roedel
On Mon, Jan 23, 2023 at 04:35:53PM -0400, Jason Gunthorpe wrote: > Jason Gunthorpe (10): > iommu: Add a gfp parameter to iommu_map() > iommu: Remove iommu_map_atomic() > iommu: Add a gfp parameter to iommu_map_sg() > iommu/dma: Use the gfp parameter in __iommu_dma_alloc_noncontiguous() >

Re: [PATCH 1/8] iommu: Add a gfp parameter to iommu_map()

2023-01-23 Thread Joerg Roedel
On Fri, Jan 20, 2023 at 01:53:40PM -0400, Jason Gunthorpe wrote: > > Well, having GFP parameters is not a strict kernel convention. There are > > places doing it differently and have sleeping and atomic variants of > > APIs. I have to say I like the latter more. But given that this leads to > > an

Re: [PATCH 1/8] iommu: Add a gfp parameter to iommu_map()

2023-01-20 Thread Joerg Roedel
On Fri, Jan 06, 2023 at 01:24:11PM -0400, Jason Gunthorpe wrote: > I think it is just better to follow kernel convention and have > allocation functions include the GFP because it is a clear signal to > the user that there is an allocation hidden inside the API. The whole > point of gfp is not to h

Re: [GIT PULL iommu] Please pull iommu errno changes

2022-11-03 Thread Joerg Roedel
On Wed, Nov 02, 2022 at 09:51:56AM -0300, Jason Gunthorpe wrote: > git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-joerg Pulled, thanks Jason and Nicolin. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org

Re: [PATCH v6 0/5] Define EINVAL as device/domain incompatibility

2022-09-26 Thread Joerg Roedel
Hi Nicolin, On Fri, Sep 23, 2022 at 12:16:29AM -0700, Nicolin Chen wrote: > This series is to replace the previous EMEDIUMTYPE patch in a VFIO series: > https://lore.kernel.org/kvm/yxnt9uqtmbqul...@8bytes.org/ \o/ > Nicolin Chen (5): > iommu/amd: Drop unnecessary checks in amd_iommu_attach_dev

Re: [PATCH v6 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-09-08 Thread Joerg Roedel
On Wed, Sep 07, 2022 at 02:10:33PM -0300, Jason Gunthorpe wrote: > Sure, rust has all sorts of nice things. But the kernel doesn't follow > rust idioms, and I don't think this is a great place to start > experimenting with them. It is actually a great place to start experimenting. The IOMMU interf

[PATCH] iommu/virtio: Fix compile error with viommu_capable()

2022-09-07 Thread Joerg Roedel
From: Joerg Roedel A recent fix introduced viommu_capable() but other changes from Robin change the function signature of the call-back it is used for. When both changes are merged a compile error will happen because the function pointer types mismatch. Fix that by updating the viommu_capable

Re: [PATCH v6 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-09-07 Thread Joerg Roedel
On Wed, Sep 07, 2022 at 10:47:39AM -0300, Jason Gunthorpe wrote: > Would you be happier if we wrote it like > > #define IOMMU_EINCOMPATIBLE_DEVICE xx > > Which tells "which of the function parameters is actually invalid" ? Having done some Rust hacking in the last months, I have to say I like t

Re: [PATCH v3] iommu/virtio: Fix interaction with VFIO

2022-09-07 Thread Joerg Roedel
On Thu, Aug 25, 2022 at 04:46:24PM +0100, Jean-Philippe Brucker wrote: > Cc: sta...@vger.kernel.org > Fixes: e8ae0e140c05 ("vfio: Require that devices support DMA cache coherence") > Signed-off-by: Jean-Philippe Brucker > --- > Since v2 [1], I tried to refine the commit message. > This fix is need

Re: [PATCH v6 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

2022-09-07 Thread Joerg Roedel
On Mon, Aug 15, 2022 at 11:14:33AM -0700, Nicolin Chen wrote: > Provide a dedicated errno from the IOMMU driver during attach that the > reason attached failed is because of domain incompatability. EMEDIUMTYPE > is chosen because it is never used within the iommu subsystem today and > evokes a sens

Re: [PATCH v1 1/1] iommu/virtio: Do not dereference fwnode in struct device

2022-09-07 Thread Joerg Roedel
On Mon, Aug 01, 2022 at 07:51:42PM +0300, Andy Shevchenko wrote: > drivers/iommu/virtio-iommu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied, thanks. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://li

Re: [PATCH v2] iommu/iova: Separate out rcache init

2022-02-14 Thread Joerg Roedel
On Thu, Feb 03, 2022 at 05:59:20PM +0800, John Garry wrote: > Currently the rcache structures are allocated for all IOVA domains, even if > they do not use "fast" alloc+free interface. This is wasteful of memory. > > In addition, fails in init_iova_rcaches() are not handled safely, which is > less

[PATCH v3 07/10] x86/sev: Use AP Jump Table blob to stop CPU

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel To support kexec under SEV-ES the APs can't be parked with HLT. Upon wakeup the AP needs to find its way to execute at the reset vector set by the new kernel and in real-mode. This is what the AP jump table blob provides, so stop the APs the SEV-ES way by calling the AP-

[PATCH v3 05/10] x86/sev: Setup code to park APs in the AP Jump Table

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel The AP jump table under SEV-ES contains the reset vector where non-boot CPUs start executing when coming out of reset. This means that a CPU coming out of the AP-reset-hold VMGEXIT also needs to start executing at the reset vector stored in the AP jump table. The problem is

[PATCH v3 08/10] x86/sev: Add MMIO handling support to boot/compressed/ code

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel Move the code for MMIO handling in the #VC handler to sev-shared.c so that it can be used in the decompressor code. The decompressor needs to handle MMIO events for writing to the VGA framebuffer. When the kernel is booted via UEFI the VGA console is not enabled that early

[PATCH v3 09/10] x86/sev: Handle CLFLUSH MMIO events

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel Handle CLFLUSH instruction to MMIO memory in the #VC handler. The instruction is ignored by the handler, as the Hypervisor is responsible for cache management of emulated MMIO memory. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/insn-eval.h | 1 + arch/x86/kernel

[PATCH v3 10/10] x86/kexec/64: Support kexec under SEV-ES with AP Jump Table Blob

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel When the AP jump table blob is installed the kernel can hand over the APs from the old to the new kernel. Enable kexec when the AP jump table blob has been installed. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/sev.h | 2 ++ arch/x86/kernel

[PATCH v3 06/10] x86/sev: Park APs on AP Jump Table with GHCB protocol version 2

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel GHCB protocol version 2 adds the MSR-based AP-reset-hold VMGEXIT which does not need a GHCB. Use that to park APs in 16-bit protected mode on the AP jump table. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/realmode.h | 3 ++ arch/x86/kernel/sev.c | 51

[PATCH v3 04/10] x86/sev: Cache AP Jump Table Address

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel Store the physical address of the AP jump table in kernel memory so that it does not need to be fetched from the Hypervisor again. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev.c | 28 +++- 1 file changed, 15 insertions(+), 13 deletions

[PATCH v3 02/10] x86/sev: Save and print negotiated GHCB protocol version

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel Save the results of the GHCB protocol negotiation into a data structure and print information about versions supported and used to the kernel log. This is useful for debugging kexec issues in SEV-ES guests down the road to quickly spot whether kexec is supported on the given

[PATCH v3 03/10] x86/sev: Set GHCB data structure version

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel It turned out that the GHCB->protocol field does not declare the version of the guest-hypervisor communication protocol, but rather the version of the GHCB data structure. Reflect that in the define used to set the protocol field. Signed-off-by: Joerg Roedel --- arch/

[PATCH v3 00/10] x86/sev: KEXEC/KDUMP support for SEV-ES guests

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel Hi, here are changes to enable kexec/kdump in SEV-ES guests. The biggest problem for supporting kexec/kdump under SEV-ES is to find a way to hand the non-boot CPUs (APs) from one kernel to another. Without SEV-ES the first kernel parks the CPUs in a HLT loop until they get

[PATCH v3 01/10] x86/kexec/64: Disable kexec when SEV-ES is active

2022-01-27 Thread Joerg Roedel
From: Joerg Roedel SEV-ES needs special handling to support kexec. Disable it when SEV-ES is active until support is implemented. Cc: sta...@vger.kernel.org # v5.10+ Signed-off-by: Joerg Roedel --- arch/x86/kernel/machine_kexec_64.c | 11 +++ 1 file changed, 11 insertions(+) diff

Re: [PATCH v2 08/12] x86/sev: Park APs on AP Jump Table with GHCB protocol version 2

2022-01-27 Thread Joerg Roedel
On Fri, Nov 12, 2021 at 05:33:05PM +0100, Borislav Petkov wrote: > On Mon, Sep 13, 2021 at 05:55:59PM +0200, Joerg Roedel wrote: > > +"ljmpl *%0" : : > > +"m" (real_mode_header->sev_real_ap_park_asm), > > +

Re: [PATCH v2 07/12] x86/sev: Setup code to park APs in the AP Jump Table

2022-01-26 Thread Joerg Roedel
On Wed, Nov 10, 2021 at 05:37:32PM +0100, Borislav Petkov wrote: > On Mon, Sep 13, 2021 at 05:55:58PM +0200, Joerg Roedel wrote: > > extern unsigned char real_mode_blob[]; > > diff --git a/arch/x86/include/asm/sev-ap-jumptable.h > > b/arch/x86/include/asm/sev-ap-jumptabl

Re: [PATCH v2 03/12] x86/sev: Save and print negotiated GHCB protocol version

2022-01-26 Thread Joerg Roedel
On Wed, Nov 03, 2021 at 03:27:23PM +0100, Borislav Petkov wrote: > On Mon, Sep 13, 2021 at 05:55:54PM +0200, Joerg Roedel wrote: > > From: Joerg Roedel > > > > Save the results of the GHCB protocol negotiation into a data structure > > and print information about ver

Re: [PATCH v2] iova: Move fast alloc size roundup into alloc_iova_fast()

2021-12-17 Thread Joerg Roedel
On Tue, Dec 07, 2021 at 07:17:26PM +0800, John Garry wrote: > It really is a property of the IOVA rcache code that we need to alloc a > power-of-2 size, so relocate the functionality to resize into > alloc_iova_fast(), rather than the callsites. > > Signed-off-by: John Garry > Acked-by: Will Deac

Re: [PATCH] iommu/virtio: Fix typo in a comment

2021-12-17 Thread Joerg Roedel
On Thu, Dec 16, 2021 at 04:33:02PM +0800, Xiang wangx wrote: > The double `as' in a comment is repeated, thus it should be removed. > > Signed-off-by: Xiang wangx > --- > drivers/iommu/virtio-iommu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied, thanks. __

Re: [PATCH v3 0/5] iommu/virtio: Add identity domains

2021-12-06 Thread Joerg Roedel
On Wed, Dec 01, 2021 at 05:33:20PM +, Jean-Philippe Brucker wrote: > Jean-Philippe Brucker (5): > iommu/virtio: Add definitions for VIRTIO_IOMMU_F_BYPASS_CONFIG > iommu/virtio: Support bypass domains > iommu/virtio: Sort reserved regions > iommu/virtio: Pass end address to viommu_add_ma

Re: [PATCH v2] x86/sev-es: Fix SEV-ES INS/OUTS instructions for word, dword, and qword

2021-11-24 Thread Joerg Roedel
e > full string is now written and read back. > > Fixes: f980f9c31a923 (x86/sev-es: Compile early handler code into kernel > image) > Reviewed-by: Paolo Bonzini > Reviewed-by: Marc Orr > Reviewed-by: Peter Gonda > Signed-off-by: Michael Sterritt Reviewed-by: Joerg Roedel __

Re: [PATCH] Fix SEV-ES INS/OUTS instructions for word, dword, and qword.

2021-11-19 Thread Joerg Roedel
Hi Michael, On Wed, Nov 17, 2021 at 06:13:26PM -0800, Michael Sterritt wrote: > Properly type the operands being passed to __put_user()/__get_user(). > Otherwise, these routines truncate data for dependent instructions > (e.g., INSW) and only read/write one byte. > > Tested: Tested by sending a s

Re: [PATCH v2 01/12] kexec: Allow architecture code to opt-out at runtime

2021-11-02 Thread Joerg Roedel
Hi again, On Mon, Nov 01, 2021 at 04:11:42PM -0500, Eric W. Biederman wrote: > I seem to remember the consensus when this was reviewed that it was > unnecessary and there is already support for doing something like > this at a more fine grained level so we don't need a new kexec hook. Forgot to s

Re: [PATCH v2 01/12] kexec: Allow architecture code to opt-out at runtime

2021-11-02 Thread Joerg Roedel
On Mon, Nov 01, 2021 at 04:11:42PM -0500, Eric W. Biederman wrote: > I seem to remember the consensus when this was reviewed that it was > unnecessary and there is already support for doing something like > this at a more fine grained level so we don't need a new kexec hook. It was a discussion, n

[PATCH 2/2] x86/sev: Allow #VC exceptions on the VC2 stack

2021-10-21 Thread Joerg Roedel
From: Joerg Roedel When code running on the VC2 stack causes a nested VC exception, the handler will not handle it as expected but goes again into the error path. The result is that the panic() call happening when the VC exception was raised in an invalid context is called recursively. Fix this

[PATCH 1/2] x86/sev: Fix stack type check in vc_switch_off_ist()

2021-10-21 Thread Joerg Roedel
From: Joerg Roedel The value of STACK_TYPE_EXCEPTION_LAST points to the last _valid_ exception stack. Reflect that in the check done in the vc_switch_off_ist() function. Reported-by: Tom Lendacky Fixes: a13644f3a53de ("x86/entry/64: Add entry code for #VC handler") Signed-off-by: Jo

[PATCH 0/2] x86/sev: Two fixes for SEV-ES VC stack handling

2021-10-21 Thread Joerg Roedel
From: Joerg Roedel Hi, here are two fixes for recently discovered issues in the handling of VC handler stack. Please review. Thanks, Joerg Joerg Roedel (2): x86/sev: Fix stack type check in vc_switch_off_ist() x86/sev: Allow #VC exceptions on the VC2 stack arch/x86/kernel

Re: [PATCH v2 00/12] x86/sev: KEXEC/KDUMP support for SEV-ES guests

2021-09-13 Thread Joerg Roedel
On Mon, Sep 13, 2021 at 09:02:38AM -0700, Dave Hansen wrote: > On 9/13/21 8:55 AM, Joerg Roedel wrote: > > This does not work under SEV-ES, because the hypervisor has no access > > to the vCPU registers and can't make modifications to them. So an > > SEV-ES guest needs to

[PATCH v2 12/12] x86/sev: Support kexec under SEV-ES with AP Jump Table blob

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel When the AP Jump Table blob is installed the kernel can hand over the APs from the old to the new kernel. Enable kexec when the AP Jump Table blob has been installed. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/sev.h | 2 ++ arch/x86/kernel

[PATCH v2 10/12] x86/sev: Add MMIO handling support to boot/compressed/ code

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel Move the code for MMIO handling in the #VC handler to sev-shared.c so that it can be used in the decompressor code. The decompressor needs to handle MMIO events for writing to the VGA framebuffer. When the kernel is booted via UEFI the VGA console is not enabled that early

[PATCH v2 09/12] x86/sev: Use AP Jump Table blob to stop CPU

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel To support kexec under SEV-ES the APs can't be parked with HLT. Upon wakeup the AP needs to find its way to execute at the reset vector set by the new kernel and in real-mode. This is what the AP Jump Table blob provides, so stop the APs the SEV-ES way by calling the AP-

[PATCH v2 11/12] x86/sev: Handle CLFLUSH MMIO events

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel Handle CLFLUSH instruction to MMIO memory in the #VC handler. The instruction is ignored by the handler, as the Hypervisor is responsible for cache management of emulated MMIO memory. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-shared.c | 9 + 1 file changed

[PATCH v2 07/12] x86/sev: Setup code to park APs in the AP Jump Table

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel The AP Jump Table under SEV-ES contains the reset vector where non-boot CPUs start executing when coming out of reset. This means that a CPU coming out of the AP-reset-hold VMGEXIT also needs to start executing at the reset vector stored in the AP Jump Table. The problem is

[PATCH v2 08/12] x86/sev: Park APs on AP Jump Table with GHCB protocol version 2

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel GHCB protocol version 2 adds the MSR-based AP-reset-hold VMGEXIT which does not need a GHCB. Use that to park APs in 16-bit protected mode on the AP Jump Table. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/realmode.h| 3 + arch/x86/kernel/sev.c

[PATCH v2 03/12] x86/sev: Save and print negotiated GHCB protocol version

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel Save the results of the GHCB protocol negotiation into a data structure and print information about versions supported and used to the kernel log. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev.c | 2 +- arch/x86/kernel/sev-shared.c | 22

[PATCH v2 05/12] x86/sev: Use GHCB protocol version 2 if supported

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel Check whether the hypervisor supports GHCB version 2 and use it if available. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev.c | 10 -- arch/x86/include/asm/sev.h | 4 ++-- arch/x86/kernel/sev-shared.c | 17 ++--- 3 files changed, 24

[PATCH v2 06/12] x86/sev: Cache AP Jump Table Address

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel Store the physical address of the AP Jump Table in kernel memory so that it does not need to be fetched from the Hypervisor again. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev.c | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) diff

[PATCH v2 00/12] x86/sev: KEXEC/KDUMP support for SEV-ES guests

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel Hi, here are changes to enable kexec/kdump in SEV-ES guests. The biggest problem for supporting kexec/kdump under SEV-ES is to find a way to hand the non-boot CPUs (APs) from one kernel to another. Without SEV-ES the first kernel parks the CPUs in a HLT loop until they get

[PATCH v2 01/12] kexec: Allow architecture code to opt-out at runtime

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel Allow a runtime opt-out of kexec support for architecture code in case the kernel is running in an environment where kexec is not properly supported yet. This will be used on x86 when the kernel is running as an SEV-ES guest. SEV-ES guests need special handling for kexec to

[PATCH v2 04/12] x86/sev: Do not hardcode GHCB protocol version

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel Introduce the sev_get_ghcb_proto_ver() which will return the negotiated GHCB protocol version and use it to set the version field in the GHCB. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev.c | 5 + arch/x86/kernel/sev-shared.c | 5 - arch/x86/kernel

[PATCH v2 02/12] x86/kexec/64: Forbid kexec when running as an SEV-ES guest

2021-09-13 Thread Joerg Roedel
From: Joerg Roedel For now, kexec is not supported when running as an SEV-ES guest. Doing so requires additional hypervisor support and special code to hand over the CPUs to the new kernel in a safe way. Until this is implemented, do not support kexec in SEV-ES guests. Cc: sta

Re: [kvm-unit-tests PATCH 0/6] Initial x86_64 UEFI support

2021-08-17 Thread Joerg Roedel
Hi Marc, On Fri, Aug 13, 2021 at 11:44:39AM -0700, Marc Orr wrote: > To date, we have _most_ x86 test cases (39/44) working under UEFI and > we've also got some of the test cases to boot under SEV-ES, using the > UEFI #VC handler. While the EFI APP approach simplifies the implementation a lot, I

Re: [PATCH 04/12] x86/sev: Do not hardcode GHCB protocol version

2021-07-31 Thread Joerg Roedel
Hi Tom, On Wed, Jul 21, 2021 at 04:17:38PM -0500, Tom Lendacky wrote: > On 7/21/21 9:20 AM, Joerg Roedel wrote: > > /* Fill in protocol and format specifiers */ > > - ghcb->protocol_version = GHCB_PROTOCOL_MAX; > > + ghcb->protocol_version = sev_get_ghcb_proto_v

Re: [PATCH 11/12] x86/sev: Handle CLFLUSH MMIO events

2021-07-31 Thread Joerg Roedel
Hi Sean, On Fri, Jul 30, 2021 at 10:42:30PM +, Sean Christopherson wrote: > On Wed, Jul 21, 2021, Joerg Roedel wrote: > This wording can be misread as "the hypervisor is responsible for _all_ cache > management". Maybe just: > > /* >

[PATCH 12/12] x86/sev: Support kexec under SEV-ES with AP Jump Table blob

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel When the AP Jump Table blob is installed the kernel can hand over the APs from the old to the new kernel. Enable kexec when the AP Jump Table blob has been installed. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/sev.h | 2 ++ arch/x86/kernel

[PATCH 10/12] x86/sev: Add MMIO handling support to boot/compressed/ code

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel Move the code for MMIO handling in the #VC handler to sev-shared.c so that it can be used in the decompressor code. The decompressor needs to handle MMIO events for writing to the VGA framebuffer. When the kernel is booted via UEFI the VGA console is not enabled that early

[PATCH 11/12] x86/sev: Handle CLFLUSH MMIO events

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel Handle CLFLUSH instruction to MMIO memory in the #VC handler. The instruction is ignored by the handler, as the Hypervisor is responsible for cache management of emulated MMIO memory. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-shared.c | 9 + 1 file changed

[PATCH 09/12] x86/sev: Use AP Jump Table blob to stop CPU

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel To support kexec under SEV-ES the APs can't be parked with HLT. Upon wakeup the AP needs to find its way to execute at the reset vector set by the new kernel and in real-mode. This is what the AP Jump Table blob provides, so stop the APs the SEV-ES way by calling the AP-

[PATCH 08/12] x86/sev: Park APs on AP Jump Table with GHCB protocol version 2

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel GHCB protocol version 2 adds the MSR-based AP-reset-hold VMGEXIT which does not need a GHCB. Use that to park APs in 16-bit protected mode on the AP Jump Table. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/realmode.h| 3 + arch/x86/kernel/sev.c

[PATCH 07/12] x86/sev: Setup code to park APs in the AP Jump Table

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel The AP Jump Table under SEV-ES contains the reset vector where non-boot CPUs start executing when coming out of reset. This means that a CPU coming out of the AP-reset-hold VMGEXIT also needs to start executing at the reset vector stored in the AP Jump Table. The problem is

[PATCH 06/12] x86/sev: Cache AP Jump Table Address

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel Store the physical address of the AP Jump Table in kernel memory so that it does not need to be fetched from the Hypervisor again. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev.c | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) diff

[PATCH 05/12] x86/sev: Use GHCB protocol version 2 if supported

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel Check whether the hypervisor supports GHCB version 2 and use it if available. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev.c | 10 -- arch/x86/include/asm/sev.h | 4 ++-- arch/x86/kernel/sev-shared.c | 17 ++--- 3 files changed, 24

[PATCH 04/12] x86/sev: Do not hardcode GHCB protocol version

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel Introduce the sev_get_ghcb_proto_ver() which will return the negotiated GHCB protocol version and use it to set the version field in the GHCB. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev.c | 5 + arch/x86/kernel/sev-shared.c | 5 - arch/x86/kernel

[PATCH 03/12] x86/sev: Save and print negotiated GHCB protocol version

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel Save the results of the GHCB protocol negotiation into a data structure and print information about versions supported and used to the kernel log. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev.c | 2 +- arch/x86/kernel/sev-shared.c | 22

[PATCH 02/12] x86/kexec/64: Forbid kexec when running as an SEV-ES guest

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel For now, kexec is not supported when running as an SEV-ES guest. Doing so requires additional hypervisor support and special code to hand over the CPUs to the new kernel in a safe way. Until this is implemented, do not support kexec in SEV-ES guests. Cc: sta

[PATCH 01/12] kexec: Allow architecture code to opt-out at runtime

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel Allow a runtime opt-out of kexec support for architecture code in case the kernel is running in an environment where kexec is not properly supported yet. This will be used on x86 when the kernel is running as an SEV-ES guest. SEV-ES guests need special handling for kexec to

[PATCH 00/12] x86/sev: KEXEC/KDUMP support for SEV-ES guests

2021-07-21 Thread Joerg Roedel
From: Joerg Roedel Hi, here are changes to enable kexec/kdump in SEV-ES guests. The biggest problem for supporting kexec/kdump under SEV-ES is to find a way to hand the non-boot CPUs (APs) from one kernel to another. Without SEV-ES the first kernel parks the CPUs in a HLT loop until they get

[RFC PATCH 10/12] x86/sev: Add MMIO handling support to boot/compressed/ code

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel Move the code for MMIO handling in the #VC handler to sev-shared.c so that it can be used in the decompressor code. The decompressor needs to handle MMIO events for writing to the VGA framebuffer. When the kernel is booted via UEFI the VGA console is not enabled that early

[RFC PATCH 05/12] x86/sev: Use GHCB protocol version 2 if supported

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel Check whether the hypervisor supports GHCB version 2 and use it if available. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev.c | 10 -- arch/x86/include/asm/sev.h | 4 ++-- arch/x86/kernel/sev-shared.c | 17 ++--- 3 files changed, 24

[RFC PATCH 06/12] x86/sev: Cache AP Jump Table Address

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel Store the physical address of the AP Jump Table in kernel memory so that it does not need to be fetched from the Hypervisor again. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev.c | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) diff

[RFC PATCH 08/12] x86/sev: Park APs on AP Jump Table with GHCB protocol version 2

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel GHCB protocol version 2 adds the MSR-based AP-reset-hold VMGEXIT which does not need a GHCB. Use that to park APs in 16-bit protected mode on the AP Jump Table. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/realmode.h| 3 + arch/x86/kernel/sev.c

[RFC PATCH 04/12] x86/sev: Do not hardcode GHCB protocol version

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel Introduce the sev_get_ghcb_proto_ver() which will return the negotiated GHCB protocol version and use it to set the version field in the GHCB. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev.c | 5 + arch/x86/kernel/sev-shared.c | 5 - arch/x86/kernel

[RFC PATCH 11/12] x86/sev: Handle CLFLUSH MMIO events

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel Handle CLFLUSH instruction to MMIO memory in the #VC handler. The instruction is ignored by the handler, as the Hypervisor is responsible for cache management of emulated MMIO memory. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-shared.c | 9 + 1 file changed

[RFC PATCH 07/12] x86/sev: Setup code to park APs in the AP Jump Table

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel The AP Jump Table under SEV-ES contains the reset vector where non-boot CPUs start executing when coming out of reset. This means that a CPU coming out of the AP-reset-hold VMGEXIT also needs to start executing at the reset vector stored in the AP Jump Table. The problem is

[RFC PATCH 09/12] x86/sev: Use AP Jump Table blob to stop CPU

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel To support kexec under SEV-ES the APs can't be parked with HLT. Upon wakeup the AP needs to find its way to execute at the reset vector set by the new kernel and in real-mode. This is what the AP Jump Table blob provides, so stop the APs the SEV-ES way by calling the AP-

[RFC PATCH 12/12] x86/sev: Support kexec under SEV-ES with AP Jump Table blob

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel When the AP Jump Table blob is installed the kernel can hand over the APs from the old to the new kernel. Enable kexec when the AP Jump Table blob has been installed. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/sev.h | 2 ++ arch/x86/kernel

[RFC PATCH 02/12] x86/kexec/64: Forbid kexec when running as an SEV-ES guest

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel For now, kexec is not supported when running as an SEV-ES guest. Doing so requires additional hypervisor support and special code to hand over the CPUs to the new kernel in a safe way. Until this is implemented, do not support kexec in SEV-ES guests. Cc: sta

[RFC PATCH 03/12] x86/sev: Save and print negotiated GHCB protocol version

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel Save the results of the GHCB protocol negotiation into a data structure and print information about versions supported and used to the kernel log. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev.c | 2 +- arch/x86/kernel/sev-shared.c | 22

[RFC PATCH 00/12] x86/sev: KEXEC/KDUMP support for SEV-ES guests

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel Hi, here are changes to enable kexec/kdump in SEV-ES guests. The biggest problem for supporting kexec/kdump under SEV-ES is to find a way to hand the non-boot CPUs (APs) from one kernel to another. Without SEV-ES the first kernel parks the CPUs in a HLT loop until they get

[RFC PATCH 01/12] kexec: Allow architecture code to opt-out at runtime

2021-07-05 Thread Joerg Roedel
From: Joerg Roedel Allow a runtime opt-out of kexec support for architecture code in case the kernel is running in an environment where kexec is not properly supported yet. This will be used on x86 when the kernel is running as an SEV-ES guest. SEV-ES guests need special handling for kexec to

Re: [PATCH v5 0/5] Add support for ACPI VIOT

2021-06-25 Thread Joerg Roedel
On Fri, Jun 18, 2021 at 05:20:55PM +0200, Jean-Philippe Brucker wrote: > Jean-Philippe Brucker (5): > ACPI: arm64: Move DMA setup operations out of IORT > ACPI: Move IOMMU setup code out of IORT > ACPI: Add driver for the VIOT table > iommu/dma: Pass address limit rather than size to >

Re: [PATCH 2/3] x86/sev: Add defines for GHCB version 2 MSR protocol requests

2021-06-23 Thread Joerg Roedel
On Wed, Jun 23, 2021 at 11:32:50AM +0200, Borislav Petkov wrote: > Ok, so I took a critical look at this and it doesn't make sense to have > a differently named define each time you need the [63:12] slice of > GHCBData. So you can simply use GHCB_DATA(msr_value) instead, see below. > > Complaints?

[PATCH 2/3] x86/sev: Add defines for GHCB version 2 MSR protocol requests

2021-06-22 Thread Joerg Roedel
-by: Brijesh Singh Signed-off-by: Tom Lendacky Co-developed-by: Tom Lendacky Signed-off-by: Joerg Roedel --- arch/x86/include/asm/sev-common.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h index

[PATCH 2/3] x86/sev: Add defines for GHCB version 2 MSR protocol requests

2021-06-22 Thread Joerg Roedel
-by: Brijesh Singh Co-developed-by: Tom Lendacky Signed-off-by: Tom Lendacky Signed-off-by: Joerg Roedel --- arch/x86/include/asm/sev-common.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h index

[PATCH 3/3] x86/sev: Use "SEV: " prefix for messages from sev.c

2021-06-22 Thread Joerg Roedel
From: Joerg Roedel The source file has been renamed froms sev-es.c to sev.c, but the messages are still prefixed with "SEV-ES: ". Change that to "SEV: " to make it consistent. Fixes: e759959fe3b8 ("x86/sev-es: Rename sev-es.{ch} to sev.{ch}") Signed-off-by: Joer

[PATCH 0/3] x86/sev: Minor updates for SEV guest support

2021-06-22 Thread Joerg Roedel
From: Joerg Roedel Hi, here are three small patches to update SEV-ES guest support in Linux. It would be great to have at least patch 3 merged for v5.14 to avoid future merge conflicts. It contains defines needed by KVM and X86 patches under development. Thanks, Joerg Brijesh Singh

[PATCH 1/3] x86/sev: Add Comments to existing GHCB MSR protocol defines

2021-06-22 Thread Joerg Roedel
From: Joerg Roedel Add comments to the defines for SEV Info and CPUID MSR protocol defines to document to which protocol part they belong. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/sev-common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/include/asm/sev-common.h

Re: [PATCH v7 0/2] x86/sev: Fixes for SEV-ES Guest Support

2021-06-21 Thread Joerg Roedel
On Mon, Jun 21, 2021 at 03:13:18PM +0200, Peter Zijlstra wrote: > On Fri, Jun 18, 2021 at 01:54:07PM +0200, Joerg Roedel wrote: > > Joerg Roedel (2): > > x86/sev: Make sure IRQs are disabled while GHCB is active > > x86/sev: Split up runtime #VC handler for correct state t

[PATCH v7 0/2] x86/sev: Fixes for SEV-ES Guest Support

2021-06-18 Thread Joerg Roedel
From: Joerg Roedel Hi, please find here the next iteration of my pending fixes for SEV-ES guest support in Linux. This version addresses the comments I received from Peter on the previous version, in particular: - Removed IRQ disable/enable calls in the ap-hlt loop code - Made

[PATCH v7 2/2] x86/sev: Split up runtime #VC handler for correct state tracking

2021-06-18 Thread Joerg Roedel
From: Joerg Roedel Split up the #VC handler code into a from-user and a from-kernel part. This allows clean and correct state tracking, as the #VC handler needs to enter NMI-state when raised from kernel mode and plain IRQ state when raised from user-mode. Fixes: 62441a1fb532 ("x86/s

[PATCH v7 1/2] x86/sev: Make sure IRQs are disabled while GHCB is active

2021-06-18 Thread Joerg Roedel
From: Joerg Roedel The #VC handler only cares about IRQs being disabled while the GHCB is active, as it must not be interrupted by something which could cause another #VC while it holds the GHCB (NMI is the exception for which the backup GHCB exits). Make sure nothing interrupts the code path

Re: [PATCH v6 1/2] x86/sev: Make sure IRQs are disabled while GHCB is active

2021-06-18 Thread Joerg Roedel
On Thu, Jun 17, 2021 at 05:00:48PM +0200, Peter Zijlstra wrote: > I think this is broken, at this point RCU is quite dead on this CPU and > local_irq_save/restore include tracing and all sorts. > > Also, shouldn't IRQs already be disabled by the time we get here? Yes it is, I removed these calls,

Re: [PATCH v6 1/2] x86/sev: Make sure IRQs are disabled while GHCB is active

2021-06-18 Thread Joerg Roedel
On Thu, Jun 17, 2021 at 05:38:46PM +0200, Peter Zijlstra wrote: > I'm getting (with all of v6.1 applied): > > vmlinux.o: warning: objtool: __sev_es_nmi_complete()+0x1bf: call to panic() > leaves .noinstr.text section > > $ ./scripts/faddr2line defconfig-build/vmlinux __sev_es_nmi_complete+0x1bf

[PATCH v6.1 2/2] x86/sev: Split up runtime #VC handler for correct state tracking

2021-06-17 Thread Joerg Roedel
From: Joerg Roedel Split up the #VC handler code into a from-user and a from-kernel part. This allows clean and correct state tracking, as the #VC handler needs to enter NMI-state when raised from kernel mode and plain IRQ state when raised from user-mode. Fixes: 62441a1fb532 ("x86/s

Re: [PATCH v5 3/6] x86/sev-es: Split up runtime #VC handler for correct state tracking

2021-06-16 Thread Joerg Roedel
Hi Peter, sorry, missed this email before sending out v6. On Wed, Jun 16, 2021 at 06:04:26PM +0200, Peter Zijlstra wrote: > On Mon, Jun 14, 2021 at 03:53:24PM +0200, Joerg Roedel wrote: > > _ASM_NOKPROBE(\asmsym) > > SYM_CODE_END(\asmsym) > > Consistency with idtentry

[PATCH v6 2/2] x86/sev: Split up runtime #VC handler for correct state tracking

2021-06-16 Thread Joerg Roedel
From: Joerg Roedel Split up the #VC handler code into a from-user and a from-kernel part. This allows clean and correct state tracking, as the #VC handler needs to enter NMI-state when raised from kernel mode and plain IRQ state when raised from user-mode. Fixes: 62441a1fb532 ("x86/s

[PATCH v6 1/2] x86/sev: Make sure IRQs are disabled while GHCB is active

2021-06-16 Thread Joerg Roedel
From: Joerg Roedel The #VC handler only cares about IRQs being disabled while the GHCB is active, as it must not be interrupted by something which could cause another #VC while it holds the GHCB (NMI is the exception for which the backup GHCB exits). Make sure nothing interrupts the code path

  1   2   3   4   5   6   7   8   9   10   >