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

2020-12-10 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 v5 16/34] KVM: SVM: Add support for SEV-ES GHCB MSR protocol function 0x100

2020-12-10 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 it

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

2020-12-10 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 v5 10/34] KVM: SVM: Cannot re-initialize the VMCB after shutdown with SEV-ES

2020-12-10 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 v5 14/34] KVM: SVM: Add support for SEV-ES GHCB MSR protocol function 0x002

2020-12-10 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 v5 11/34] KVM: SVM: Prepare for SEV-ES exit handling in the sev.c file

2020-12-10 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 v5 12/34] KVM: SVM: Add initial support for a VMGEXIT VMEXIT

2020-12-10 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 v5 19/34] KVM: SVM: Support string IO operations for an SEV-ES guest

2020-12-10 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 v5 17/34] KVM: SVM: Create trace events for VMGEXIT MSR protocol processing

2020-12-10 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 v5 20/34] KVM: SVM: Add support for EFER write traps for an SEV-ES guest

2020-12-10 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 a

[PATCH v5 27/34] KVM: SVM: Add support for booting APs for an SEV-ES guest

2020-12-10 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. Followin

[PATCH v5 29/34] KVM: SVM: Set the encryption mask for the SVM host save area

2020-12-10 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

[PATCH v5 30/34] KVM: SVM: Update ASID allocation to support SEV-ES guests

2020-12-10 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

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

2020-12-10 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 is

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

2020-12-10 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 in the

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

2020-12-10 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 v5 26/34] KVM: SVM: Guest FPU state save/restore not needed for SEV-ES guest

2020-12-10 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 v5 31/34] KVM: SVM: Provide support for SEV-ES vCPU creation/loading

2020-12-10 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

Re: [PATCH v5 00/34] SEV-ES hypervisor support

2020-12-10 Thread Tom Lendacky
On 12/10/20 11:06 AM, Tom Lendacky wrote: From: Tom Lendacky This patch series provides support for running SEV-ES guests under KVM. I cut the first send of this series short and resent it with a corrected email address for Sean (since he is copied on all the patches), so please look at

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

2020-12-10 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 v5 32/34] KVM: SVM: Provide support for SEV-ES vCPU loading

2020-12-10 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 VMRUN (see Table B-3 and Table B-4 of the AMD64 APM Volume 2), so make the following changes: General vCPU load changes

[PATCH v5 34/34] KVM: SVM: Provide support to launch and run an SEV-ES guest

2020-12-10 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 be

[PATCH v5 33/34] KVM: SVM: Provide an updated VMRUN invocation for SEV-ES guests

2020-12-10 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

[PATCH v5 28/34] KVM: SVM: Add NMI support for an SEV-ES guest

2020-12-10 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

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

2020-12-10 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 in the

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

2020-12-10 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 in the

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

2020-12-10 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 or an

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

2020-12-10 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 v5 00/34] SEV-ES hypervisor support

2020-12-10 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

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

2020-12-10 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 v5 02/34] KVM: SVM: Remove the call to sev_platform_status() during setup

2020-12-10 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 real

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

2020-12-10 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 v5 07/34] KVM: SVM: Add required changes to support intercepts under SEV-ES

2020-12-10 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 v5 01/34] x86/cpu: Add VM page flush MSR availablility as a CPUID feature

2020-12-10 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 are

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

2020-12-10 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 v5 00/34] SEV-ES hypervisor support

2020-12-10 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

Re: [PATCH] KVM/SVM: add support for SEV attestation command

2020-12-08 Thread Tom Lendacky
ESTATION_REPORT is that the later > can be called while the guest is running and the measurement value is > signed with PEK. > > Cc: James Bottomley > Cc: Tom Lendacky > Cc: David Rientjes > Cc: Paolo Bonzini > Cc: Sean Christopherson > Cc: Borislav Petkov > Cc: J

Re: [PATCH v8 13/18] KVM: x86: Introduce new KVM_FEATURE_SEV_LIVE_MIGRATION feature & Custom MSR.

2020-12-04 Thread Tom Lendacky
On 12/4/20 12:41 PM, Sean Christopherson wrote: On Fri, Dec 4, 2020 at 10:07 AM Ashish Kalra wrote: Yes i will post a fresh version of the live migration patches. Also, can you please check your email settings, we are only able to see your response on the mailing list but we are not getting

Re: [PATCH v2 1/3] x86/uprobes: Fix not using prefixes.nbytes for loop over prefixes.bytes

2020-12-03 Thread Tom Lendacky
On 12/3/20 12:17 PM, Borislav Petkov wrote: On Thu, Dec 03, 2020 at 12:10:10PM -0600, Tom Lendacky wrote: Since that struct is used in multiple places, I think basing it on the array size is the best way to go. The main point of the check is just to be sure you don't read outside of the

Re: [PATCH v2 1/3] x86/uprobes: Fix not using prefixes.nbytes for loop over prefixes.bytes

2020-12-03 Thread Tom Lendacky
On 12/3/20 11:01 AM, Borislav Petkov wrote: On Thu, Dec 03, 2020 at 05:54:20PM +0100, Borislav Petkov wrote: On Thu, Dec 03, 2020 at 10:45:48AM -0600, Tom Lendacky wrote: Since this is based on the array size, can idx < NUM_LEGACY_PREFIXES be replaced with: idx < ARRA

Re: [PATCH v2 1/3] x86/uprobes: Fix not using prefixes.nbytes for loop over prefixes.bytes

2020-12-03 Thread Tom Lendacky
On 12/3/20 6:48 AM, Borislav Petkov wrote: So it ended up like this: --- From 5014e4e902778d63ce392f864b3654baa4b72384 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Thu, 3 Dec 2020 13:50:37 +0900 Subject: [PATCH] x86/uprobes: Do not use prefixes.nbytes when looping over prefixes.byte

Re: [PATCH] x86/cpu/amd: Remove dead code for TSEG region remapping

2020-12-02 Thread Tom Lendacky
On 11/27/20 11:27 AM, Borislav Petkov wrote: On Fri, Nov 27, 2020 at 12:13:24PM -0500, Arvind Sankar wrote: Commit 26bfa5f89486 ("x86, amd: Cleanup init_amd") moved the code that remaps the TSEG region using 4k pages from init_amd() to bsp_init_amd(). However, bsp_init_amd() is executed well

Re: [PATCH v2] nvme: Cache DMA descriptors to prevent corruption.

2020-12-02 Thread Tom Lendacky
he 2019 Linux > Security Summit for info about SNP: > https://www.youtube.com/watch?v=yr56SaJ_0QI. > > >> >> Before you start sending patches that regress optimizations in various >> drivers (and there will be lots with this model) we need to have a >> broader dis

Re: [PATCH 1/3] x86/sev-es: Fix not using prefixes.nbytes for loop over prefixes.bytes

2020-12-02 Thread Tom Lendacky
On 12/2/20 2:51 AM, Masami Hiramatsu wrote: Since the insn.prefixes.nbytes can be bigger than the size of insn.prefixes.bytes[] when a same prefix is repeated, we have to check whether the insn.prefixes.bytes[i] != 0 and i < 4 instead of insn.prefixes.nbytes. Fixes: 25189d08e516 ("x86/sev-es: Ad

Re: [PATCH] x86/irq: Lower unhandled irq error severity

2020-12-01 Thread Tom Lendacky
On 12/1/20 8:44 AM, Laurențiu Nicola wrote: > On Tue, Dec 1, 2020, at 16:36, Tom Lendacky wrote: >> >> Thomas has reported this to me previously and I have reported it to our >> BIOS team. That previously reported problem has been fixed in BIOS, but >> I'm not sure

Re: [PATCH] x86/irq: Lower unhandled irq error severity

2020-12-01 Thread Tom Lendacky
On 11/30/20 5:34 PM, Thomas Gleixner wrote: > On Mon, Nov 30 2020 at 19:22, Laurențiu Nicola wrote: >> On Mon, Nov 30, 2020, at 18:56, Thomas Gleixner wrote: That's right, sorry. It still boots, but it's no longer "quiet", that's what I meant. >>> >>> Right, but surpressing that is not a

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

2020-11-30 Thread Tom Lendacky
On 11/30/20 9:31 AM, Paolo Bonzini wrote: > On 16/09/20 02:19, Sean Christopherson wrote: >> >> TDX also selectively blocks/skips portions of other ioctl()s so that the >> TDX code itself can yell loudly if e.g. .get_cpl() is invoked.  The event >> injection restrictions are due to direct injection

Re: [PATCH v4 00/34] SEV-ES hypervisor support

2020-11-25 Thread Tom Lendacky
On 11/24/20 12:52 PM, Sean Christopherson wrote: On Mon, Nov 23, 2020, Tom Lendacky wrote: On 11/17/20 11:07 AM, Tom Lendacky wrote: From: Tom Lendacky This patch series provides support for running SEV-ES guests under KVM. Any comments on this series? I'm planning on doing a tho

Re: [PATCH v4 00/34] SEV-ES hypervisor support

2020-11-23 Thread Tom Lendacky
On 11/17/20 11:07 AM, Tom Lendacky wrote: From: Tom Lendacky This patch series provides support for running SEV-ES guests under KVM. Any comments on this series? Thanks, Tom Secure Encrypted Virtualization - Encrypted State (SEV-ES) expands on the SEV support to protect the guest

[PATCH v4 32/34] KVM: SVM: Provide support for SEV-ES vCPU loading

2020-11-17 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

[PATCH v4 29/34] KVM: SVM: Set the encryption mask for the SVM host save area

2020-11-17 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

[PATCH v4 31/34] KVM: SVM: Provide support for SEV-ES vCPU creation/loading

2020-11-17 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

[PATCH v4 33/34] KVM: SVM: Provide an updated VMRUN invocation for SEV-ES guests

2020-11-17 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

[PATCH v4 28/34] KVM: SVM: Add NMI support for an SEV-ES guest

2020-11-17 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

[PATCH v4 30/34] KVM: SVM: Update ASID allocation to support SEV-ES guests

2020-11-17 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

[PATCH v4 34/34] KVM: SVM: Provide support to launch and run an SEV-ES guest

2020-11-17 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 be

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

2020-11-17 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 is

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

2020-11-17 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 v4 20/34] KVM: SVM: Add support for EFER write traps for an SEV-ES guest

2020-11-17 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 a

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

2020-11-17 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 v4 12/34] KVM: SVM: Add initial support for a VMGEXIT VMEXIT

2020-11-17 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 v4 22/34] KVM: SVM: Add support for CR4 write traps for an SEV-ES guest

2020-11-17 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 in the

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

2020-11-17 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 or an

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

2020-11-17 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 in the

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

2020-11-17 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 v4 23/34] KVM: SVM: Add support for CR8 write traps for an SEV-ES guest

2020-11-17 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 in the

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

2020-11-17 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 it

[PATCH v4 27/34] KVM: SVM: Add support for booting APs for an SEV-ES guest

2020-11-17 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. Followin

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

2020-11-17 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 v4 13/34] KVM: SVM: Create trace events for VMGEXIT processing

2020-11-17 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 v4 11/34] KVM: SVM: Prepare for SEV-ES exit handling in the sev.c file

2020-11-17 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 v4 14/34] KVM: SVM: Add support for SEV-ES GHCB MSR protocol function 0x002

2020-11-17 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 v4 19/34] KVM: SVM: Support string IO operations for an SEV-ES guest

2020-11-17 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 v4 26/34] KVM: SVM: Guest FPU state save/restore not needed for SEV-ES guest

2020-11-17 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 v4 07/34] KVM: SVM: Add required changes to support intercepts under SEV-ES

2020-11-17 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 v4 06/34] KVM: x86: Mark GPRs dirty when written

2020-11-17 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 v4 08/34] KVM: SVM: Prevent debugging under SEV-ES

2020-11-17 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 v4 05/34] KVM: SVM: Add support for the SEV-ES VMSA

2020-11-17 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 v4 09/34] KVM: SVM: Do not allow instruction emulation under SEV-ES

2020-11-17 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 v4 04/34] KVM: SVM: Add GHCB accessor functions for retrieving fields

2020-11-17 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 v4 03/34] KVM: SVM: Add support for SEV-ES capability in KVM

2020-11-17 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 v4 01/34] x86/cpu: Add VM page flush MSR availablility as a CPUID feature

2020-11-17 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 are

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

2020-11-17 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

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

2020-11-17 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 real

Re: [EXTERNAL] [tip: x86/apic] x86/io_apic: Cleanup trigger/polarity helpers

2020-11-11 Thread Tom Lendacky
On 11/11/20 6:32 AM, David Woodhouse wrote: > On Wed, 2020-11-11 at 10:36 +, David Woodhouse wrote: >> On Wed, 2020-11-11 at 10:46 +0100, Thomas Gleixner wrote: >>> Looking at it now with brain awake, the XTSUP stuff is pretty much >>> the same as DMAR, which I didn't realize yesterday. The aff

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

2020-11-10 Thread Tom Lendacky
On 11/9/20 3:42 PM, Arvind Sankar wrote: > On Mon, Nov 09, 2020 at 02:41:48PM -0600, Tom Lendacky wrote: >> On 11/9/20 11:35 AM, Arvind Sankar wrote: >>> The PAT bit is in different locations for 4k and 2M/1G page table >>> entries. >>> >>> Add a defin

Re: [EXTERNAL] [tip: x86/apic] x86/io_apic: Cleanup trigger/polarity helpers

2020-11-10 Thread Tom Lendacky
On 11/10/20 4:48 PM, Thomas Gleixner wrote: > On Tue, Nov 10 2020 at 16:00, Tom Lendacky wrote: >> On 11/10/20 3:30 PM, David Woodhouse wrote: >> [ 15.581115] WARNING: CPU: 6 PID: 1 at arch/x86/kernel/apic/apic.c:2527 >> __irq_msi_compose_msg+0x9f/0xb0 >>

Re: [EXTERNAL] [tip: x86/apic] x86/io_apic: Cleanup trigger/polarity helpers

2020-11-10 Thread Tom Lendacky
On 11/10/20 3:30 PM, David Woodhouse wrote: > > > On 10 November 2020 21:01:17 GMT, Thomas Gleixner wrote: >> On Tue, Nov 10 2020 at 19:21, David Woodhouse wrote: >> >>> On 10 November 2020 18:56:17 GMT, Thomas Gleixner >> wrote: On Tue, Nov 10 2020 at 18:50, Thomas Gleixner wrote: > O

Re: [EXTERNAL] [tip: x86/apic] x86/io_apic: Cleanup trigger/polarity helpers

2020-11-10 Thread Tom Lendacky
On 11/10/20 10:33 AM, David Woodhouse wrote: > On Tue, 2020-11-10 at 10:17 -0600, Tom Lendacky wrote: >> Yep. The warning started triggering with: >> 47bea873cf80 ("x86/msi: Only use high bits of MSI address for DMAR unit") >> >> Here's the backtrace: &

Re: [tip: x86/apic] x86/io_apic: Cleanup trigger/polarity helpers

2020-11-10 Thread Tom Lendacky
On 11/10/20 9:54 AM, Thomas Gleixner wrote: > On Tue, Nov 10 2020 at 08:55, Tom Lendacky wrote: >> On 11/10/20 8:34 AM, Thomas Gleixner wrote: >> I was about to send the dmesg output when I saw this. A quick test with >> this change resolves the boot issue, thanks! > >

Re: [tip: x86/apic] x86/io_apic: Cleanup trigger/polarity helpers

2020-11-10 Thread Tom Lendacky
On 11/10/20 8:34 AM, Thomas Gleixner wrote: > On Tue, Nov 10 2020 at 07:10, Borislav Petkov wrote: > >> On Mon, Nov 09, 2020 at 05:15:03PM -0600, Tom Lendacky wrote: >>> [ 105.325371] hpet: Lost 9601 RTC interrupts >>> [ 105.485766] hpet: Lost 9600 RTC interrupts

Re: [tip: x86/apic] x86/io_apic: Cleanup trigger/polarity helpers

2020-11-09 Thread Tom Lendacky
On 10/29/20 7:15 AM, tip-bot2 for Thomas Gleixner wrote: > The following commit has been merged into the x86/apic branch of tip: > > Commit-ID: a27dca645d2c0f31abb7858aa0e10b2fa0f2f659 > Gitweb: > https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=a27dca645d2c0f31ab

[PATCH v3 34/34] KVM: SVM: Provide support to launch and run an SEV-ES guest

2020-11-09 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 be

[PATCH v3 31/34] KVM: SVM: Provide support for SEV-ES vCPU creation/loading

2020-11-09 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

[PATCH v3 33/34] KVM: SVM: Provide an updated VMRUN invocation for SEV-ES guests

2020-11-09 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

[PATCH v3 30/34] KVM: SVM: Update ASID allocation to support SEV-ES guests

2020-11-09 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

[PATCH v3 27/34] KVM: SVM: Add support for booting APs for an SEV-ES guest

2020-11-09 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. Followin

[PATCH v3 28/34] KVM: SVM: Add NMI support for an SEV-ES guest

2020-11-09 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

[PATCH v3 32/34] KVM: SVM: Provide support for SEV-ES vCPU loading

2020-11-09 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

[PATCH v3 29/34] KVM: SVM: Set the encryption mask for the SVM host save area

2020-11-09 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

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