[PATCH v3 22/34] KVM: SVM: Add support for CR4 write traps for an SEV-ES guest

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky For SEV-ES guests, the interception of control register write access is not recommended. Control register interception occurs prior to the control register being modified and the hypervisor is unable to modify the control register itself because the register is located

[PATCH v3 26/34] KVM: SVM: Guest FPU state save/restore not needed for SEV-ES guest

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky The guest FPU state is automatically restored on VMRUN and saved on VMEXIT by the hardware, so there is no reason to do this in KVM. Eliminate the allocation of the guest_fpu save area and key off that to skip operations related to the guest FPU state. Signed-off-by: Tom

[PATCH v3 23/34] KVM: SVM: Add support for CR8 write traps for an SEV-ES guest

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky For SEV-ES guests, the interception of control register write access is not recommended. Control register interception occurs prior to the control register being modified and the hypervisor is unable to modify the control register itself because the register is located

[PATCH v3 25/34] KVM: SVM: Do not report support for SMM for an SEV-ES guest

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky SEV-ES guests do not currently support SMM. Update the has_emulated_msr() kvm_x86_ops function to take a struct kvm parameter so that the capability can be reported at a VM level. Since this op is also called during KVM initialization and before a struct kvm instance

[PATCH v3 24/34] KVM: x86: Update __get_sregs() / __set_sregs() to support SEV-ES

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky Since many of the registers used by the SEV-ES are encrypted and cannot be read or written, adjust the __get_sregs() / __set_sregs() to take into account whether the VMSA/guest state is encrypted. For __get_sregs(), return the actual value that is in use by the guest for all

[PATCH v3 21/34] KVM: SVM: Add support for CR0 write traps for an SEV-ES guest

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky For SEV-ES guests, the interception of control register write access is not recommended. Control register interception occurs prior to the control register being modified and the hypervisor is unable to modify the control register itself because the register is located

[PATCH v3 19/34] KVM: SVM: Support string IO operations for an SEV-ES guest

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky For an SEV-ES guest, string-based port IO is performed to a shared (un-encrypted) page so that both the hypervisor and guest can read or write to it and each see the contents. For string-based port IO operations, invoke SEV-ES specific routines that can complete the operation

[PATCH v3 20/34] KVM: SVM: Add support for EFER write traps for an SEV-ES guest

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky For SEV-ES guests, the interception of EFER write access is not recommended. EFER interception occurs prior to EFER being modified and the hypervisor is unable to modify EFER itself because the register is located in the encrypted register state. SEV-ES support introduces

[PATCH v3 18/34] KVM: SVM: Support MMIO for an SEV-ES guest

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky For an SEV-ES guest, MMIO is performed to a shared (un-encrypted) page so that both the hypervisor and guest can read or write to it and each see the contents. The GHCB specification provides software-defined VMGEXIT exit codes to indicate a request for an MMIO read

[PATCH v3 13/34] KVM: SVM: Create trace events for VMGEXIT processing

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky Add trace events for entry to and exit from VMGEXIT processing. The vCPU id and the exit reason will be common for the trace events. The exit info fields will represent the input and output values for the entry and exit events, respectively. Signed-off-by: Tom Lendacky

[PATCH v3 14/34] KVM: SVM: Add support for SEV-ES GHCB MSR protocol function 0x002

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky The GHCB specification defines a GHCB MSR protocol using the lower 12-bits of the GHCB MSR (in the hypervisor this corresponds to the GHCB GPA field in the VMCB). Function 0x002 is a request to set the GHCB MSR value to the SEV INFO as per the specification via the VMCB GHCB

[PATCH v3 11/34] KVM: SVM: Prepare for SEV-ES exit handling in the sev.c file

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky This is a pre-patch to consolidate some exit handling code into callable functions. Follow-on patches for SEV-ES exit handling will then be able to use them from the sev.c file. Signed-off-by: Tom Lendacky --- arch/x86/kvm/svm/svm.c | 64

[PATCH v3 15/34] KVM: SVM: Add support for SEV-ES GHCB MSR protocol function 0x004

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky The GHCB specification defines a GHCB MSR protocol using the lower 12-bits of the GHCB MSR (in the hypervisor this corresponds to the GHCB GPA field in the VMCB). Function 0x004 is a request for CPUID information. Only a single CPUID result register can be sent per invocation

[PATCH v3 17/34] KVM: SVM: Create trace events for VMGEXIT MSR protocol processing

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky Add trace events for entry to and exit from VMGEXIT MSR protocol processing. The vCPU will be common for the trace events. The MSR protocol processing is guided by the GHCB GPA in the VMCB, so the GHCB GPA will represent the input and output values for the entry and exit

[PATCH v3 16/34] KVM: SVM: Add support for SEV-ES GHCB MSR protocol function 0x100

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky The GHCB specification defines a GHCB MSR protocol using the lower 12-bits of the GHCB MSR (in the hypervisor this corresponds to the GHCB GPA field in the VMCB). Function 0x100 is a request for termination of the guest. The guest has encountered some situation for which

[PATCH v3 09/34] KVM: SVM: Do not allow instruction emulation under SEV-ES

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky When a guest is running as an SEV-ES guest, it is not possible to emulate instructions. Add support to prevent instruction emulation. Signed-off-by: Tom Lendacky --- arch/x86/kvm/svm/svm.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b

[PATCH v3 12/34] KVM: SVM: Add initial support for a VMGEXIT VMEXIT

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky SEV-ES adds a new VMEXIT reason code, VMGEXIT. Initial support for a VMGEXIT includes mapping the GHCB based on the guest GPA, which is obtained from a new VMCB field, and then validating the required inputs for the VMGEXIT exit reason. Since many of the VMGEXIT exit reasons

[PATCH v3 08/34] KVM: SVM: Prevent debugging under SEV-ES

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky Since the guest register state of an SEV-ES guest is encrypted, debugging is not supported. Update the code to prevent guest debugging when the guest has protected state. Additionally, an SEV-ES guest must only and always intercept DR7 reads and writes. Update

[PATCH v3 07/34] KVM: SVM: Add required changes to support intercepts under SEV-ES

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky When a guest is running under SEV-ES, the hypervisor cannot access the guest register state. There are numerous places in the KVM code where certain registers are accessed that are not allowed to be accessed (e.g. RIP, CR0, etc). Add checks to prevent register accesses and add

[PATCH v3 06/34] KVM: x86: Mark GPRs dirty when written

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky When performing VMGEXIT processing for an SEV-ES guest, register values will be synced between KVM and the GHCB. Prepare for detecting when a GPR has been updated (marked dirty) in order to determine whether to sync the register to the GHCB. Signed-off-by: Tom Lendacky

[PATCH v3 10/34] KVM: SVM: Cannot re-initialize the VMCB after shutdown with SEV-ES

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky When a SHUTDOWN VMEXIT is encountered, normally the VMCB is re-initialized so that the guest can be re-launched. But when a guest is running as an SEV-ES guest, the VMSA cannot be re-initialized because it has been encrypted. For now, just return -EINVAL to prevent a possible

[PATCH v3 05/34] KVM: SVM: Add support for the SEV-ES VMSA

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky Allocate a page during vCPU creation to be used as the encrypted VM save area (VMSA) for the SEV-ES guest. Provide a flag in the kvm_vcpu_arch structure that indicates whether the guest state is protected. When freeing a VMSA page that has been encrypted, the cache contents

[PATCH v3 03/34] KVM: SVM: Add support for SEV-ES capability in KVM

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky Add support to KVM for determining if a system is capable of supporting SEV-ES as well as determining if a guest is an SEV-ES guest. Signed-off-by: Tom Lendacky --- arch/x86/kvm/Kconfig | 3 ++- arch/x86/kvm/svm/sev.c | 47 ++ arch

[PATCH v3 01/34] x86/cpu: Add VM page flush MSR availablility as a CPUID feature

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky On systems that do not have hardware enforced cache coherency between encrypted and unencrypted mappings of the same physical page, the hypervisor can use the VM page flush MSR (0xc001011e) to flush the cache contents of an SEV guest page. When a small number of pages

[PATCH v3 04/34] KVM: SVM: Add GHCB accessor functions for retrieving fields

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky Update the GHCB accessor functions to add functions for retrieve GHCB fields by name. Update existing code to use the new accessor functions. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/svm.h | 10 ++ arch/x86/kernel/cpu/vmware.c | 12 ++-- 2

[PATCH v3 02/34] KVM: SVM: Remove the call to sev_platform_status() during setup

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky When both KVM support and the CCP driver are built into the kernel instead of as modules, KVM initialization can happen before CCP initialization. As a result, sev_platform_status() will return a failure when it is called from sev_hardware_setup(), when this isn't really

[PATCH v3 00/34] SEV-ES hypervisor support

2020-11-09 Thread Tom Lendacky
From: Tom Lendacky This patch series provides support for running SEV-ES guests under KVM. Secure Encrypted Virtualization - Encrypted State (SEV-ES) expands on the SEV support to protect the guest register state from the hypervisor. See "AMD64 Architecture Programmer's Manual Volume 2: S

Re: [PATCH] x86/mm/sme: Fix definition of PMD_FLAGS_DEC_WP

2020-11-09 Thread Tom Lendacky
in the definition of PMD_FLAGS_DEC_WP to get the correct PAT > index for write-protected pages. > > Remove a duplication definition of _PAGE_PAT_LARGE. > > Signed-off-by: Arvind Sankar Fixes: tag? Tested-by: Tom Lendacky > --- > arch/x86/include/asm

Re: Definition of PMD_FLAGS_DEC_WP in arch/x86/mm/mem_encrypt_identity.c

2020-11-09 Thread Tom Lendacky
On 11/8/20 10:37 AM, Arvind Sankar wrote: > Hi, I have a question about this definition in > arch/x86/mm/mem_encrypt_identity.c: > > #define PMD_FLAGS_LARGE (__PAGE_KERNEL_LARGE_EXEC & > ~_PAGE_GLOBAL) > > #define PMD_FLAGS_DEC PMD_FLAGS_LARGE > #define

Re: [PATCH v2] x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP

2020-11-05 Thread Tom Lendacky
ly STIBP or IBPB is unconditionally on. But it allows the conditional feature to work as expected, without affecting the unconditional one. Signed-off-by: Anand K Mistry Does it need a Fixes: tag? Acked-by: Tom Lendacky --- Changes in v2: - Fix typo in commit message - s

Re: [PATCH 1/1] x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP

2020-10-31 Thread Tom Lendacky
On 10/29/20 1:51 AM, Anand K Mistry wrote: On AMD CPUs which have the feature X86_FEATURE_AMD_STIBP_ALWAYS_ON, STIBP is set to on and 'spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED'. At the same time, IBPB can be set to conditional. However, this leads to the case where it's

Re: [PATCH 0/1] x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP

2020-10-31 Thread Tom Lendacky
On 10/29/20 1:51 AM, Anand K Mistry wrote: When attempting to do some performance testing of IBPB on and AMD platform, I noticed the IBPB instruction was never being issued, even though it was conditionally on and various seccomp protected processes were force enabling it. Turns out, on those

Re: [PATCH v4 4/5] x86/head/64: Check SEV encryption before switching to kernel page-table

2020-10-28 Thread Tom Lendacky
verified before the > kernel page-table is used. > > Call the sev_verify_cbit() function before writing the CR3. > > Signed-off-by: Joerg Roedel Reviewed-by: Tom Lendacky > --- > arch/x86/kernel/head_64.S | 16 > arch/x86/mm/mem_encrypt.c | 1 + > 2

Re: [PATCH v4 5/5] x86/sev-es: Do not support MMIO to/from encrypted memory

2020-10-28 Thread Tom Lendacky
ge in the nested page-table, so that any guest access to it > will trigger a #VC exception and leak the data on that page to the > hypervisor via the GHCB (like with valid MMIO). On the read side this > attack would allow the HV to inject data into the guest. > > Signed-off-by: Joer

Re: [PATCH v4 3/5] x86/boot/compressed/64: Check SEV encryption in 64-bit boot-path

2020-10-28 Thread Tom Lendacky
nction is in arch/x86/kernel/sev_verify_cbit.S so that it > can be re-used in the running kernel image. > > Signed-off-by: Joerg Roedel Just one minor comment below, otherwise: Reviewed-by: Tom Lendacky > --- > arch/x86/boot/compressed/ident_map_64.c | 1 + > arch/

Re: [PATCH v4 2/5] x86/boot/compressed/64: Add CPUID sanity check to early #VC handler

2020-10-28 Thread Tom Lendacky
ypervisor. > > Add sanity checks to the early #VC handlers to make sure the hypervisor > can not pretend that SEV is disabled. > > Signed-off-by: Joerg Roedel Reviewed-by: Tom Lendacky > --- > arch/x86/kernel/sev-es-shared.c | 26 ++ > 1 file ch

Re: [PATCH v4 1/5] x86/boot/compressed/64: Introduce sev_status

2020-10-28 Thread Tom Lendacky
On 10/28/20 11:46 AM, Joerg Roedel wrote: > From: Joerg Roedel > > Introduce sev_status and initialize it together with sme_me_mask to have > an indicator which SEV features are enabled. > > Signed-off-by: Joerg Roedel Reviewed-by: Tom Lendacky > --- >

Re: [RFCv2 15/16] KVM: Unmap protected pages from direct mapping

2020-10-26 Thread Tom Lendacky
On 10/20/20 7:18 AM, David Hildenbrand wrote: > On 20.10.20 08:18, Kirill A. Shutemov wrote: >> If the protected memory feature enabled, unmap guest memory from >> kernel's direct mappings. > > Gah, ugly. I guess this also defeats compaction, swapping, ... oh gosh. > As if all of the encrypted VM

Re: default cpufreq gov, was: [PATCH] sched/fair: check for idle core

2020-10-23 Thread Tom Lendacky
On 10/23/20 2:03 AM, Peter Zijlstra wrote: On Thu, Oct 22, 2020 at 10:10:35PM +0200, Giovanni Gherdovich wrote: * for the AMD EPYC machines we haven't yet implemented frequency invariant accounting, which might explain why schedutil looses to ondemand on all the benchmarks. Right, I

Re: AMD SME encrpytion and PCI BAR pages to user space

2020-10-21 Thread Tom Lendacky
On 10/21/20 6:59 AM, Jason Gunthorpe wrote: > On Mon, Oct 19, 2020 at 11:36:16AM -0500, Tom Lendacky wrote: > >>> io_remap_pfn_range()? Is there use cases where a caller actually wants >>> encrypted io memory? >> >> As long as you never have physical me

Re: AMD SME encrpytion and PCI BAR pages to user space

2020-10-19 Thread Tom Lendacky
On 10/19/20 12:00 PM, Jason Gunthorpe wrote: > On Mon, Oct 19, 2020 at 11:36:16AM -0500, Tom Lendacky wrote: > >>> Is RDMA missing something? I don't see anything special in VFIO for >>> instance and the two are very similar - does VFIO work with SME, eg >>

Re: AMD SME encrpytion and PCI BAR pages to user space

2020-10-19 Thread Tom Lendacky
On 10/19/20 10:25 AM, Jason Gunthorpe wrote: > Hi Tom, Hi Jason, > > We've found a bug where systems that have the AMD SME turned on are > not able to run RDMA work loads. It seems the kernel is automatically > encrypting VMA's pointing at PCI BAR memory created by > io_remap_pfn_range() -

Re: [RFC PATCH 00/35] SEV-ES hypervisor support

2020-10-13 Thread Tom Lendacky
: > On Tue, Sep 15, 2020 at 12:22:05PM -0500, Tom Lendacky wrote: >> On 9/14/20 5:59 PM, Sean Christopherson wrote: >>> Given that we don't yet have publicly available KVM code for TDX, what if I >>> generate and post a list of ioctls() that are denied by either SEV-ES

[RFC PATCH v2 31/33] KVM: SVM: Provide support for SEV-ES vCPU loading

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky An SEV-ES vCPU requires additional VMCB vCPU load/put requirements. SEV-ES hardware will restore certain registers on VMEXIT, but not save them on VMRUM (see Table B-3 and Table B-4 of the AMD64 APM Volume 2), so make the following changes: General vCPU load changes

[RFC PATCH v2 32/33] KVM: SVM: Provide an updated VMRUN invocation for SEV-ES guests

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky The run sequence is different for an SEV-ES guest compared to a legacy or even an SEV guest. The guest vCPU register state of an SEV-ES guest will be restored on VMRUN and saved on VMEXIT. There is no need to restore the guest registers directly and through VMLOAD before VMRUN

[RFC PATCH v2 33/33] KVM: SVM: Provide support to launch and run an SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky An SEV-ES guest is started by invoking a new SEV initialization ioctl, KVM_SEV_ES_INIT. This identifies the guest as an SEV-ES guest, which is used to drive the appropriate ASID allocation, VMSA encryption, etc. Before being able to run an SEV-ES vCPU, the vCPU VMSA must

[RFC PATCH v2 30/33] KVM: SVM: Provide support for SEV-ES vCPU creation/loading

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky An SEV-ES vCPU requires additional VMCB initialization requirements for vCPU creation and vCPU load/put requirements. This includes: General VMCB initialization changes: - Set a VMCB control bit to enable SEV-ES support on the vCPU. - Set the VMCB encrypted VM save area

[RFC PATCH v2 28/33] KVM: SVM: Set the encryption mask for the SVM host save area

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky The SVM host save area is used to restore some host state on VMEXIT of an SEV-ES guest. After allocating the save area, clear it and add the encryption mask to the SVM host save area physical address that is programmed into the VM_HSAVE_PA MSR. Signed-off-by: Tom Lendacky

[RFC PATCH v2 29/33] KVM: SVM: Update ASID allocation to support SEV-ES guests

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky SEV and SEV-ES guests each have dedicated ASID ranges. Update the ASID allocation routine to return an ASID in the respective range. Signed-off-by: Tom Lendacky --- arch/x86/kvm/svm/sev.c | 25 ++--- 1 file changed, 14 insertions(+), 11 deletions

[RFC PATCH v2 21/33] KVM: SVM: Add support for CR4 write traps for an SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky For SEV-ES guests, the interception of control register write access is not recommended. Control register interception occurs prior to the control register being modified and the hypervisor is unable to modify the control register itself because the register is located

[RFC PATCH v2 22/33] KVM: SVM: Add support for CR8 write traps for an SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky For SEV-ES guests, the interception of control register write access is not recommended. Control register interception occurs prior to the control register being modified and the hypervisor is unable to modify the control register itself because the register is located

[RFC PATCH v2 24/33] KVM: SVM: Do not report support for SMM for an SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky SEV-ES guests do not currently support SMM. Update the has_emulated_msr() kvm_x86_ops function to take a struct kvm parameter so that the capability can be reported at a VM level. Since this op is also called during KVM initialization and before a struct kvm instance

[RFC PATCH v2 26/33] KVM: SVM: Add support for booting APs for an SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky Typically under KVM, an AP is booted using the INIT-SIPI-SIPI sequence, where the guest vCPU register state is updated and then the vCPU is VMRUN to begin execution of the AP. For an SEV-ES guest, this won't work because the guest register state is encrypted. Following

[RFC PATCH v2 27/33] KVM: SVM: Add NMI support for an SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky The GHCB specification defines how NMIs are to be handled for an SEV-ES guest. To detect the completion of an NMI the hypervisor must not intercept the IRET instruction (because a #VC while running the NMI will issue an IRET) and, instead, must receive an NMI Complete exit

[RFC PATCH v2 23/33] KVM: x86: Update __get_sregs() / __set_sregs() to support SEV-ES

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky Since many of the registers used by the SEV-ES are encrypted and cannot be read or written, adjust the __get_sregs() / __set_sregs() to take into account whether the VMSA/guest state is encrypted. For __get_sregs(), return the actual value that is in use by the guest for all

[RFC PATCH v2 25/33] KVM: SVM: Guest FPU state save/restore not needed for SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky The guest FPU state is automatically restored on VMRUN and saved on VMEXIT by the hardware, so there is no reason to do this in KVM. Eliminate the allocation of the guest_fpu save area and key off that to skip operations related to the guest FPU state. Signed-off-by: Tom

[RFC PATCH v2 15/33] KVM: SVM: Add support for SEV-ES GHCB MSR protocol function 0x100

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky The GHCB specification defines a GHCB MSR protocol using the lower 12-bits of the GHCB MSR (in the hypervisor this corresponds to the GHCB GPA field in the VMCB). Function 0x100 is a request for termination of the guest. The guest has encountered some situation for which

[RFC PATCH v2 12/33] KVM: SVM: Create trace events for VMGEXIT processing

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky Add trace events for entry to and exit from VMGEXIT processing. The vCPU id and the exit reason will be common for the trace events. The exit info fields will represent the input and output values for the entry and exit events, respectively. Signed-off-by: Tom Lendacky

[RFC PATCH v2 16/33] KVM: SVM: Create trace events for VMGEXIT MSR protocol processing

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky Add trace events for entry to and exit from VMGEXIT MSR protocol processing. The vCPU will be common for the trace events. The MSR protocol processing is guided by the GHCB GPA in the VMCB, so the GHCB GPA will represent the input and output values for the entry and exit

[RFC PATCH v2 20/33] KVM: SVM: Add support for CR0 write traps for an SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky For SEV-ES guests, the interception of control register write access is not recommended. Control register interception occurs prior to the control register being modified and the hypervisor is unable to modify the control register itself because the register is located

[RFC PATCH v2 11/33] KVM: SVM: Add initial support for a VMGEXIT VMEXIT

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky SEV-ES adds a new VMEXIT reason code, VMGEXIT. Initial support for a VMGEXIT includes mapping the GHCB based on the guest GPA, which is obtained from a new VMCB field, and then validating the required inputs for the VMGEXIT exit reason. Since many of the VMGEXIT exit reasons

[RFC PATCH v2 19/33] KVM: SVM: Add support for EFER write traps for an SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky For SEV-ES guests, the interception of EFER write access is not recommended. EFER interception occurs prior to EFER being modified and the hypervisor is unable to modify EFER itself because the register is located in the encrypted register state. SEV-ES support introduces

[RFC PATCH v2 18/33] KVM: SVM: Support port IO operations for an SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky For an SEV-ES guest, string-based port IO is performed to a shared (un-encrypted) page so that both the hypervisor and guest can read or write to it and each see the contents. For string-based port IO operations, invoke SEV-ES specific routines that can complete the operation

[RFC PATCH v2 17/33] KVM: SVM: Support MMIO for an SEV-ES guest

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky For an SEV-ES guest, MMIO is performed to a shared (un-encrypted) page so that both the hypervisor and guest can read or write to it and each see the contents. The GHCB specification provides software-defined VMGEXIT exit codes to indicate a request for an MMIO read

[RFC PATCH v2 14/33] KVM: SVM: Add support for SEV-ES GHCB MSR protocol function 0x004

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky The GHCB specification defines a GHCB MSR protocol using the lower 12-bits of the GHCB MSR (in the hypervisor this corresponds to the GHCB GPA field in the VMCB). Function 0x004 is a request for CPUID information. Only a single CPUID result register can be sent per invocation

[RFC PATCH v2 09/33] KVM: SVM: Cannot re-initialize the VMCB after shutdown with SEV-ES

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky When a SHUTDOWN VMEXIT is encountered, normally the VMCB is re-initialized so that the guest can be re-launched. But when a guest is running as an SEV-ES guest, the VMSA cannot be re-initialized because it has been encrypted. For now, just return -EINVAL to prevent a possible

[RFC PATCH v2 07/33] KVM: SVM: Prevent debugging under SEV-ES

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky Since the guest register state of an SEV-ES guest is encrypted, debugging is not supported. Update the code to prevent guest debugging when the guest has protected state. Additionally, an SEV-ES guest must only and always intercept DR7 reads and writes. Update

[RFC PATCH v2 13/33] KVM: SVM: Add support for SEV-ES GHCB MSR protocol function 0x002

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky The GHCB specification defines a GHCB MSR protocol using the lower 12-bits of the GHCB MSR (in the hypervisor this corresponds to the GHCB GPA field in the VMCB). Function 0x002 is a request to set the GHCB MSR value to the SEV INFO as per the specification via the VMCB GHCB

[RFC PATCH v2 10/33] KVM: SVM: Prepare for SEV-ES exit handling in the sev.c file

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky This is a pre-patch to consolidate some exit handling code into callable functions. Follow-on patches for SEV-ES exit handling will then be able to use them from the sev.c file. Signed-off-by: Tom Lendacky --- arch/x86/kvm/svm/svm.c | 64

[RFC PATCH v2 08/33] KVM: SVM: Do not allow instruction emulation under SEV-ES

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky When a guest is running as an SEV-ES guest, it is not possible to emulate instructions. Add support to prevent instruction emulation. Signed-off-by: Tom Lendacky --- arch/x86/kvm/svm/svm.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b

[RFC PATCH v2 05/33] KVM: x86: Mark GPRs dirty when written

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky When performing VMGEXIT processing for an SEV-ES guest, register values will be synced between KVM and the GHCB. Prepare for detecting when a GPR has been updated (marked dirty) in order to determine whether to sync the register to the GHCB. Signed-off-by: Tom Lendacky

[RFC PATCH v2 06/33] KVM: SVM: Add required changes to support intercepts under SEV-ES

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky When a guest is running under SEV-ES, the hypervisor cannot access the guest register state. There are numerous places in the KVM code where certain registers are accessed that are not allowed to be accessed (e.g. RIP, CR0, etc). Add checks to prevent register accesses and add

[RFC PATCH v2 04/33] KVM: SVM: Add support for the SEV-ES VMSA

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky Allocate a page during vCPU creation to be used as the encrypted VM save area (VMSA) for the SEV-ES guest. Provide a flag in the kvm_vcpu_arch structure that indicates whether the guest state is protected. When freeing a VMSA page that has been encrypted, the cache contents

[RFC PATCH v2 02/33] KVM: SVM: Add support for SEV-ES capability in KVM

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky Add support to KVM for determining if a system is capable of supporting SEV-ES as well as determining if a guest is an SEV-ES guest. Signed-off-by: Tom Lendacky --- arch/x86/kvm/Kconfig | 3 ++- arch/x86/kvm/svm/sev.c | 47 ++ arch

[RFC PATCH v2 03/33] KVM: SVM: Add GHCB accessor functions for retrieving fields

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky Update the GHCB accessor functions to add functions for retrieve GHCB fields by name. Update existing code to use the new accessor functions. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/svm.h | 10 ++ arch/x86/kernel/cpu/vmware.c | 12 ++-- 2

[RFC PATCH v2 01/33] KVM: SVM: Remove the call to sev_platform_status() during setup

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky When both KVM support and the CCP driver are built into the kernel instead of as modules, KVM initialization happens before CCP initialization. As a result, sev_platform_status() will return a failure when it is called from sev_hardware_setup(), when this isn't really an error

[RFC PATCH v2 00/33] SEV-ES hypervisor support

2020-10-02 Thread Tom Lendacky
From: Tom Lendacky This patch series provides support for running SEV-ES guests under KVM. Secure Encrypted Virtualization - Encrypted State (SEV-ES) expands on the SEV support to protect the guest register state from the hypervisor. See "AMD64 Architecture Programmer's Manual Volume 2: S

Re: [RFC Patch 0/2] KVM: SVM: Cgroup support for SVM SEV ASIDs

2020-10-01 Thread Tom Lendacky
On 10/1/20 1:08 PM, Peter Gonda wrote: On Thu, Sep 24, 2020 at 1:55 PM Tom Lendacky wrote: On 9/24/20 2:21 PM, Sean Christopherson wrote: On Tue, Sep 22, 2020 at 02:14:04PM -0700, Vipin Sharma wrote: On Mon, Sep 21, 2020 at 06:48:38PM -0700, Sean Christopherson wrote: On Mon, Sep 21, 2020

[tip: x86/seves] x86/sev-es: Use GHCB accessor for setting the MMIO scratch buffer

2020-09-25 Thread tip-bot2 for Tom Lendacky
The following commit has been merged into the x86/seves branch of tip: Commit-ID: 0ddfb1cf3b6b07c97cff16ea69931d986f9622ee Gitweb: https://git.kernel.org/tip/0ddfb1cf3b6b07c97cff16ea69931d986f9622ee Author:Tom Lendacky AuthorDate:Fri, 25 Sep 2020 08:38:26 -05:00 Committer

[PATCH] x86/sev-es: Use GHCB accessor for setting the MMIO scratch buffer

2020-09-25 Thread Tom Lendacky
From: Tom Lendacky Use ghcb_set_sw_scratch() to set the GHCB scratch field, which will also set the corresponding bit in the GHCB valid_bitmap field. Signed-off-by: Tom Lendacky --- arch/x86/kernel/sev-es.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel

Re: [RFC Patch 0/2] KVM: SVM: Cgroup support for SVM SEV ASIDs

2020-09-24 Thread Tom Lendacky
On 9/24/20 2:21 PM, Sean Christopherson wrote: On Tue, Sep 22, 2020 at 02:14:04PM -0700, Vipin Sharma wrote: On Mon, Sep 21, 2020 at 06:48:38PM -0700, Sean Christopherson wrote: On Mon, Sep 21, 2020 at 05:40:22PM -0700, Vipin Sharma wrote: Hello, This patch series adds a new SEV controller

[PATCH v2 1/2] KVM: SVM: Add a dedicated INVD intercept routine

2020-09-24 Thread Tom Lendacky
From: Tom Lendacky The INVD instruction intercept performs emulation. Emulation can't be done on an SEV guest because the guest memory is encrypted. Provide a dedicated intercept routine for the INVD intercept. And since the instruction is emulated as a NOP, just skip it instead. Fixes

[PATCH v2 2/2] KVM: VMX: Do not perform emulation for INVD intercept

2020-09-24 Thread Tom Lendacky
From: Tom Lendacky The INVD instruction is emulated as a NOP, just skip the instruction instead. Signed-off-by: Tom Lendacky --- arch/x86/kvm/vmx/vmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 8646a797b7a8

[PATCH v2 0/2] INVD intercept change to skip instruction

2020-09-24 Thread Tom Lendacky
From: Tom Lendacky This series updates the INVD intercept support for both SVM and VMX to skip the instruction rather than emulating it, since emulation of this instruction is just a NOP. For SVM, it requires creating a dedicated INVD intercept routine that invokes kvm_skip_emulated_instruction

Re: [PATCH] KVM: SVM: Add a dedicated INVD intercept routine

2020-09-24 Thread Tom Lendacky
On 9/24/20 1:51 AM, Paolo Bonzini wrote: On 23/09/20 22:40, Tom Lendacky wrote: +static int invd_interception(struct vcpu_svm *svm) +{ + /* +* Can't do emulation on an SEV guest and INVD is emulated +* as a NOP, so just skip the instruction. +*/ + return

Re: [PATCH] KVM: SVM: Add a dedicated INVD intercept routine

2020-09-23 Thread Tom Lendacky
On 9/23/20 3:32 PM, Sean Christopherson wrote: > On Wed, Sep 23, 2020 at 03:27:39PM -0500, Tom Lendacky wrote: >> From: Tom Lendacky >> >> The INVD instruction intercept performs emulation. Emulation can't be done >> on an SEV guest because the guest memory is encrypted

[PATCH] KVM: SVM: Add a dedicated INVD intercept routine

2020-09-23 Thread Tom Lendacky
From: Tom Lendacky The INVD instruction intercept performs emulation. Emulation can't be done on an SEV guest because the guest memory is encrypted. Provide a dedicated intercept routine for the INVD intercept. Within this intercept routine just skip the instruction for an SEV guest, since

Re: [PATCH] crypto: ccp - fix error handling

2020-09-22 Thread Tom Lendacky
On 9/21/20 6:34 AM, Pavel Machek wrote: > Fix resource leak in error handling. Does it need a Fixes: tag? Thanks, Tom > > Signed-off-by: Pavel Machek (CIP) > > diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c > index bd270e66185e..40869ea1ed20 100644 > ---

Re: [RFC PATCH 08/35] KVM: SVM: Prevent debugging under SEV-ES

2020-09-17 Thread Tom Lendacky
On 9/16/20 5:50 PM, Sean Christopherson wrote: On Wed, Sep 16, 2020 at 03:27:13PM -0500, Tom Lendacky wrote: On 9/16/20 11:49 AM, Sean Christopherson wrote: On Wed, Sep 16, 2020 at 11:38:38AM -0500, Tom Lendacky wrote: On 9/16/20 11:02 AM, Sean Christopherson wrote: On Wed, Sep 16, 2020

Re: [RFC PATCH 08/35] KVM: SVM: Prevent debugging under SEV-ES

2020-09-16 Thread Tom Lendacky
On 9/15/20 3:13 PM, Tom Lendacky wrote: > On 9/15/20 11:30 AM, Sean Christopherson wrote: >> On Tue, Sep 15, 2020 at 08:37:12AM -0500, Tom Lendacky wrote: >>> On 9/14/20 4:26 PM, Sean Christopherson wrote: >>>> On Mon, Sep 14, 2020 at 03:15:22PM -0500, Tom Lendacky w

Re: [RFC PATCH 11/35] KVM: SVM: Prepare for SEV-ES exit handling in the sev.c file

2020-09-16 Thread Tom Lendacky
On 9/15/20 12:21 PM, Sean Christopherson wrote: > On Mon, Sep 14, 2020 at 03:15:25PM -0500, Tom Lendacky wrote: >> From: Tom Lendacky >> >> This is a pre-patch to consolidate some exit handling code into callable >> functions. Follow-on patches for SEV-ES exit handling

Re: [RFC PATCH 08/35] KVM: SVM: Prevent debugging under SEV-ES

2020-09-16 Thread Tom Lendacky
On 9/16/20 11:49 AM, Sean Christopherson wrote: > On Wed, Sep 16, 2020 at 11:38:38AM -0500, Tom Lendacky wrote: >> >> >> On 9/16/20 11:02 AM, Sean Christopherson wrote: >>> On Wed, Sep 16, 2020 at 10:11:10AM -0500, Tom Lendacky wrote: >>>> On 9/15/20 3:1

Re: [RFC PATCH 08/35] KVM: SVM: Prevent debugging under SEV-ES

2020-09-16 Thread Tom Lendacky
On 9/16/20 11:02 AM, Sean Christopherson wrote: > On Wed, Sep 16, 2020 at 10:11:10AM -0500, Tom Lendacky wrote: >> On 9/15/20 3:13 PM, Tom Lendacky wrote: >>> On 9/15/20 11:30 AM, Sean Christopherson wrote: >>>> I don't quite follow the "doesn't mean debuggin

Re: [RFC PATCH 05/35] KVM: SVM: Add initial support for SEV-ES GHCB access to KVM

2020-09-16 Thread Tom Lendacky
On 9/15/20 11:28 AM, Sean Christopherson wrote: > On Tue, Sep 15, 2020 at 08:24:22AM -0500, Tom Lendacky wrote: >> On 9/14/20 3:58 PM, Sean Christopherson wrote: >>>> @@ -79,6 +88,9 @@ static inline void kvm_register_write(struct kvm_vcpu >>>> *vcpu, int reg, &

Re: [RFC PATCH 05/35] KVM: SVM: Add initial support for SEV-ES GHCB access to KVM

2020-09-15 Thread Tom Lendacky
On 9/14/20 3:58 PM, Sean Christopherson wrote: > On Mon, Sep 14, 2020 at 03:15:19PM -0500, Tom Lendacky wrote: >> From: Tom Lendacky >> >> Provide initial support for accessing the GHCB when needing to access >> registers for an SEV-ES guest. The support consists of: &

Re: [RFC PATCH 26/35] KVM: SVM: Guest FPU state save/restore not needed for SEV-ES guest

2020-09-15 Thread Tom Lendacky
On 9/14/20 4:39 PM, Sean Christopherson wrote: > On Mon, Sep 14, 2020 at 03:15:40PM -0500, Tom Lendacky wrote: >> From: Tom Lendacky >> >> The guest FPU is automatically restored on VMRUN and saved on VMEXIT by >> the hardware, so there is no reason to do this in KVM.

Re: [RFC PATCH 25/35] KVM: x86: Update __get_sregs() / __set_sregs() to support SEV-ES

2020-09-15 Thread Tom Lendacky
On 9/14/20 4:37 PM, Sean Christopherson wrote: > On Mon, Sep 14, 2020 at 03:15:39PM -0500, Tom Lendacky wrote: >> From: Tom Lendacky >> >> Since many of the registers used by the SEV-ES are encrypted and cannot >> be read or written, adjust the __get_sregs() / __set_sr

Re: [RFC PATCH 21/35] KVM: SVM: Add support for EFER write traps for an SEV-ES guest

2020-09-15 Thread Tom Lendacky
On 9/14/20 5:08 PM, Sean Christopherson wrote: > On Mon, Sep 14, 2020 at 03:15:35PM -0500, Tom Lendacky wrote: >> From: Tom Lendacky >> >> For SEV-ES guests, the interception of EFER write access is not >> recommended. EFER interception occurs prior to EFER being mod

Re: [RFC PATCH 22/35] KVM: SVM: Add support for CR0 write traps for an SEV-ES guest

2020-09-15 Thread Tom Lendacky
On 9/14/20 5:13 PM, Sean Christopherson wrote: > On Mon, Sep 14, 2020 at 03:15:36PM -0500, Tom Lendacky wrote: >> From: Tom Lendacky >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index b65bd0c986d4..6f5988c305e1 100644 >> --- a/arch/x86/kvm/x86.c

Re: [RFC PATCH 24/35] KVM: SVM: Add support for CR8 write traps for an SEV-ES guest

2020-09-15 Thread Tom Lendacky
On 9/14/20 5:19 PM, Sean Christopherson wrote: > On Mon, Sep 14, 2020 at 03:15:38PM -0500, Tom Lendacky wrote: >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index 5e5f1e8fed3a..6e445a76b691 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x

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