Re: [RFC PATCH V3 01/11] x86/HV: Initialize GHCB page in Isolation VM

From: Tianyu Lan
Date: Thu Jun 10 2021 - 10:14:03 EST


Hi Joerg:
Thanks for your review.


On 6/9/2021 8:38 PM, Joerg Roedel wrote:
On Sun, May 30, 2021 at 11:06:18AM -0400, Tianyu Lan wrote:
From: Tianyu Lan <Tianyu.Lan@xxxxxxxxxxxxx>

Hyper-V exposes GHCB page via SEV ES GHCB MSR for SNP guest
to communicate with hypervisor. Map GHCB page for all
cpus to read/write MSR register and submit hvcall request
via GHCB.

Signed-off-by: Tianyu Lan <Tianyu.Lan@xxxxxxxxxxxxx>
---
arch/x86/hyperv/hv_init.c | 60 ++++++++++++++++++++++++++++++---
arch/x86/include/asm/mshyperv.h | 2 ++
include/asm-generic/mshyperv.h | 2 ++
3 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index bb0ae4b5c00f..dc74d01cb859 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -60,6 +60,9 @@ static int hv_cpu_init(unsigned int cpu)
struct hv_vp_assist_page **hvp = &hv_vp_assist_page[smp_processor_id()];
void **input_arg;
struct page *pg;
+ u64 ghcb_gpa;
+ void *ghcb_va;
+ void **ghcb_base;

Any reason you can't reuse the SEV-ES support code in the Linux kernel?
It already has code to setup GHCBs for all vCPUs.

I see that you don't need #VC handling in your SNP VMs because of the
paravisor running underneath it, but just re-using the GHCB setup code
shouldn't be too hard.


Thanks for your suggestion. I will have a try to use SEV-ES code.