[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.2003201423230.205664@chino.kir.corp.google.com>
Date: Fri, 20 Mar 2020 14:23:58 -0700 (PDT)
From: David Rientjes <rientjes@...gle.com>
To: Joerg Roedel <joro@...tes.org>, erdemaktas@...gle.com
cc: x86@...nel.org, hpa@...or.com, Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Hellstrom <thellstrom@...are.com>,
Jiri Slaby <jslaby@...e.cz>,
Dan Williams <dan.j.williams@...el.com>,
Tom Lendacky <thomas.lendacky@....com>,
Juergen Gross <jgross@...e.com>,
Kees Cook <keescook@...omium.org>,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
virtualization@...ts.linux-foundation.org,
Joerg Roedel <jroedel@...e.de>
Subject: Re: [PATCH 62/70] x86/kvm: Add KVM specific VMMCALL handling under
SEV-ES
On Thu, 19 Mar 2020, Joerg Roedel wrote:
> From: Tom Lendacky <thomas.lendacky@....com>
>
> Implement the callbacks to copy the processor state required by KVM to
> the GHCB.
>
> Signed-off-by: Tom Lendacky <thomas.lendacky@....com>
> [ jroedel@...e.de: - Split out of a larger patch
> - Adapt to different callback functions ]
> Co-developed-by: Joerg Roedel <jroedel@...e.de>
> Signed-off-by: Joerg Roedel <jroedel@...e.de>
> ---
> arch/x86/kernel/kvm.c | 35 +++++++++++++++++++++++++++++------
> 1 file changed, 29 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index 6efe0410fb72..0e3fc798d719 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -34,6 +34,8 @@
> #include <asm/hypervisor.h>
> #include <asm/tlb.h>
> #include <asm/cpuidle_haltpoll.h>
> +#include <asm/ptrace.h>
> +#include <asm/svm.h>
>
> static int kvmapf = 1;
>
> @@ -729,13 +731,34 @@ static void __init kvm_init_platform(void)
> x86_platform.apic_post_init = kvm_apic_init;
> }
>
> +#if defined(CONFIG_AMD_MEM_ENCRYPT)
> +static void kvm_sev_es_hcall_prepare(struct ghcb *ghcb, struct pt_regs *regs)
> +{
> + /* RAX and CPL are already in the GHCB */
> + ghcb_set_rbx(ghcb, regs->bx);
> + ghcb_set_rcx(ghcb, regs->cx);
> + ghcb_set_rdx(ghcb, regs->dx);
> + ghcb_set_rsi(ghcb, regs->si);
Is it possible to check the hypercall from RAX and only copy the needed
regs or is there a requirement that they must all be copied
unconditionally?
> +}
> +
> +static bool kvm_sev_es_hcall_finish(struct ghcb *ghcb, struct pt_regs *regs)
> +{
> + /* No checking of the return state needed */
> + return true;
> +}
> +#endif
> +
> const __initconst struct hypervisor_x86 x86_hyper_kvm = {
> - .name = "KVM",
> - .detect = kvm_detect,
> - .type = X86_HYPER_KVM,
> - .init.guest_late_init = kvm_guest_init,
> - .init.x2apic_available = kvm_para_available,
> - .init.init_platform = kvm_init_platform,
> + .name = "KVM",
> + .detect = kvm_detect,
> + .type = X86_HYPER_KVM,
> + .init.guest_late_init = kvm_guest_init,
> + .init.x2apic_available = kvm_para_available,
> + .init.init_platform = kvm_init_platform,
> +#if defined(CONFIG_AMD_MEM_ENCRYPT)
> + .runtime.sev_es_hcall_prepare = kvm_sev_es_hcall_prepare,
> + .runtime.sev_es_hcall_finish = kvm_sev_es_hcall_finish,
> +#endif
> };
>
> static __init int activate_jump_labels(void)
> --
> 2.17.1
>
>
Powered by blists - more mailing lists