Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1152006ybb; Fri, 20 Mar 2020 14:25:37 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvm1+cYh1ntbxvwYQkyRDXsRlJfKhweObA11/FdkwPtzsAufSEcHycCWaKLNRFCf7VGLrJX X-Received: by 2002:a05:6830:10b:: with SMTP id i11mr7984323otp.99.1584739537731; Fri, 20 Mar 2020 14:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584739537; cv=none; d=google.com; s=arc-20160816; b=l3OTF0CoULGXz/Vm8U+6MY7xPp7jwfJe5WPQMhLcdezGiWHqIiPpNT6lwNNfx3cmN/ 0EMkzbCC5N7oh3OcgSwHDJaKEwtwzYrwLq3uil5A3sjQmVuvSn/Jy2LhBMVXukrBo/dZ ueKrLV1FaNXnFsonVdxtZeAvnAeZlv+g0Uj1yceSD2QjPcDOIuJq0gGclpjuQqdbvB4g PXKJZCRp+LP7M507yLelKAWzjoUdbnVii5F7gbkH77PkiIEv/iRtte1kOGFnF9xCAL/+ oCHpDGJN6ofYPLU7VbjILU7fp09wI9CioCuKhQ1fbzf/c3vNKub2lTPx64SGAUtTKFfY 2Ovw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=X/c8paRwLZjm2U0/5wiR8BCzpWAXOizbkJkAGz1/xTY=; b=KGJUpKKUj4yWMM6XGMPRtdkZa+NAiHcp8j3GblnyPUbg984lp//o7TJZbOy2VCPOPe OkYqXJQ0A5Tol22CkXy3DLxyq17jP+VPnp5e/Wbt23g3V5OvwL3ZcK1XQX2qdagA/py2 2CkppZ3vHckkbvXtBW0eh0buYsQkewc8gQCYW1HykOJKtYytpE7Jr3n03BtsmTTwAYZ1 zF5CoTawSQ0KL9RXA3645h0aGHG2mPKIzClpJErZcp3+VNTwjR7qNHlyRHiPH+zbbaVe Fc0EcAqs8Gqo9ixNJYOzHEr/4hzmQXFQShU7LSBVmlyHvM4kh2gob8onKOVeCCNKz/D6 +t5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FmSfes3f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20si3645482oti.311.2020.03.20.14.25.25; Fri, 20 Mar 2020 14:25:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FmSfes3f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbgCTVYB (ORCPT + 99 others); Fri, 20 Mar 2020 17:24:01 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:52777 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbgCTVYB (ORCPT ); Fri, 20 Mar 2020 17:24:01 -0400 Received: by mail-pj1-f67.google.com with SMTP id ng8so3056251pjb.2 for ; Fri, 20 Mar 2020 14:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=X/c8paRwLZjm2U0/5wiR8BCzpWAXOizbkJkAGz1/xTY=; b=FmSfes3fzmDsxSDf9OY3G5hCUjwK5b8FM/PgWRhGkPg+DeLtF37pFoTd3rxKuwRYor ZCG6EBLl0CqtWgB3EdHZkzQk6pM2lbakxbB1mYU135Wm5BVhHt1Iz4pyKDxPIMg4ZCun 8YLRN13LNT6V5rDbTkeJNTL0ZLKid/Pypuew9XtXwAj1kr6LqqvGg/kaXs1xPqC1Hz09 DUCHFkfuoOBZkvFw2+KKaJJjzlrXzzkQr2q3KcQkX8xxl+zD7eIbz0GyzuAeL5sD2lMm FOHpJsqjzxYtysFc+O4sRpPPoFB2Xl/6In0xHpPy2UEf3iOoJdjtgODqaD3nCxRGPeFj C8NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=X/c8paRwLZjm2U0/5wiR8BCzpWAXOizbkJkAGz1/xTY=; b=Yr42ylg0vR5OoPoEr4RbsByod1Hs/O1k17HBptJD1MWUJ70PFpcihVXQYAYaL5WCyg F9TJP7t1UgTDkhGBX0C20YodYqNlPvzkR1TZlIWQ4qNo+VhnvJiRbp3BWqtf9rdubJMI hQ/Fw3QHkLhlXiGX6f2m3eABejG68zHpYacm5RZQ1cNhmvjHMJLK9/Cqud1T76mY5ikk vftQ2JArNlfv7J8NPK7k7pWjG9KV2+yjSeoiy8+0Gyf4zU5R8y23375HRMMyrute1gZ0 9Qv8YhZIR5JSwmKIjEI4RJlp87ZBUQZ8wGtF4z3gO70ocAepinUsT/Byyg6DHZE2Z5OB hiDA== X-Gm-Message-State: ANhLgQ01D+86ctu4oIiNPE1J/qD4LIeUoGE6ApfEHg1xPnys1ZEQxgpl olIQZ9I7bnXnx8RDSgCHzx0LvA== X-Received: by 2002:a17:90a:a791:: with SMTP id f17mr12242960pjq.22.1584739440181; Fri, 20 Mar 2020 14:24:00 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id h11sm6340185pfq.56.2020.03.20.14.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2020 14:23:59 -0700 (PDT) Date: Fri, 20 Mar 2020 14:23:58 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Joerg Roedel , erdemaktas@google.com cc: x86@kernel.org, hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Hellstrom , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel Subject: Re: [PATCH 62/70] x86/kvm: Add KVM specific VMMCALL handling under SEV-ES In-Reply-To: <20200319091407.1481-63-joro@8bytes.org> Message-ID: References: <20200319091407.1481-1-joro@8bytes.org> <20200319091407.1481-63-joro@8bytes.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Mar 2020, Joerg Roedel wrote: > From: Tom Lendacky > > Implement the callbacks to copy the processor state required by KVM to > the GHCB. > > Signed-off-by: Tom Lendacky > [ jroedel@suse.de: - Split out of a larger patch > - Adapt to different callback functions ] > Co-developed-by: Joerg Roedel > Signed-off-by: Joerg Roedel > --- > 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 > #include > #include > +#include > +#include > > 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 > >