RE: [PATCH V3 05/13] HV: Add Write/Read MSR registers via ghcb page

From: Michael Kelley
Date: Fri Aug 13 2021 - 16:26:32 EST


From: Michael Kelley <mikelley@xxxxxxxxxxxxx> Sent: Friday, August 13, 2021 12:31 PM
> To: Tianyu Lan <ltykernel@xxxxxxxxx>; KY Srinivasan <kys@xxxxxxxxxxxxx>; Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>;
> Stephen Hemminger <sthemmin@xxxxxxxxxxxxx>; wei.liu@xxxxxxxxxx; Dexuan Cui <decui@xxxxxxxxxxxxx>;
> tglx@xxxxxxxxxxxxx; mingo@xxxxxxxxxx; bp@xxxxxxxxx; x86@xxxxxxxxxx; hpa@xxxxxxxxx; dave.hansen@xxxxxxxxxxxxxxx;
> luto@xxxxxxxxxx; peterz@xxxxxxxxxxxxx; konrad.wilk@xxxxxxxxxx; boris.ostrovsky@xxxxxxxxxx; jgross@xxxxxxxx;
> sstabellini@xxxxxxxxxx; joro@xxxxxxxxxx; will@xxxxxxxxxx; davem@xxxxxxxxxxxxx; kuba@xxxxxxxxxx; jejb@xxxxxxxxxxxxx;
> martin.petersen@xxxxxxxxxx; arnd@xxxxxxxx; hch@xxxxxx; m.szyprowski@xxxxxxxxxxx; robin.murphy@xxxxxxx;
> thomas.lendacky@xxxxxxx; brijesh.singh@xxxxxxx; ardb@xxxxxxxxxx; Tianyu Lan <Tianyu.Lan@xxxxxxxxxxxxx>;
> pgonda@xxxxxxxxxx; martin.b.radev@xxxxxxxxx; akpm@xxxxxxxxxxxxxxxxxxxx; kirill.shutemov@xxxxxxxxxxxxxxx;
> rppt@xxxxxxxxxx; sfr@xxxxxxxxxxxxxxxx; saravanand@xxxxxx; krish.sadhukhan@xxxxxxxxxx;
> aneesh.kumar@xxxxxxxxxxxxx; xen-devel@xxxxxxxxxxxxxxxxxxxx; rientjes@xxxxxxxxxx; hannes@xxxxxxxxxxx;
> tj@xxxxxxxxxx
> Cc: iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx; linux-arch@xxxxxxxxxxxxxxx; linux-hyperv@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; linux-scsi@xxxxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; vkuznets <vkuznets@xxxxxxxxxx>;
> parri.andrea@xxxxxxxxx; dave.hansen@xxxxxxxxx
> Subject: RE: [PATCH V3 05/13] HV: Add Write/Read MSR registers via ghcb page
>
> From: Tianyu Lan <ltykernel@xxxxxxxxx> Sent: Monday, August 9, 2021 10:56 AM
> > Subject: [PATCH V3 05/13] HV: Add Write/Read MSR registers via ghcb page
>
> See previous comments about tag in the Subject line.
>
> > Hyper-V provides GHCB protocol to write Synthetic Interrupt
> > Controller MSR registers in Isolation VM with AMD SEV SNP
> > and these registers are emulated by hypervisor directly.
> > Hyper-V requires to write SINTx MSR registers twice. First
> > writes MSR via GHCB page to communicate with hypervisor
> > and then writes wrmsr instruction to talk with paravisor
> > which runs in VMPL0. Guest OS ID MSR also needs to be set
> > via GHCB.
> >
> > Signed-off-by: Tianyu Lan <Tianyu.Lan@xxxxxxxxxxxxx>
> > ---
> > Change since v1:
> > * Introduce sev_es_ghcb_hv_call_simple() and share code
> > between SEV and Hyper-V code.
> > ---
> > arch/x86/hyperv/hv_init.c | 33 ++-------
> > arch/x86/hyperv/ivm.c | 110 +++++++++++++++++++++++++++++
> > arch/x86/include/asm/mshyperv.h | 78 +++++++++++++++++++-
> > arch/x86/include/asm/sev.h | 3 +
> > arch/x86/kernel/cpu/mshyperv.c | 3 +
> > arch/x86/kernel/sev-shared.c | 63 ++++++++++-------
> > drivers/hv/hv.c | 121 ++++++++++++++++++++++----------
> > include/asm-generic/mshyperv.h | 12 +++-
> > 8 files changed, 329 insertions(+), 94 deletions(-)
> >
> > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> > index b3683083208a..ab0b33f621e7 100644
> > --- a/arch/x86/hyperv/hv_init.c
> > +++ b/arch/x86/hyperv/hv_init.c
> > @@ -423,7 +423,7 @@ void __init hyperv_init(void)
> > goto clean_guest_os_id;
> >
> > if (hv_isolation_type_snp()) {
> > - ms_hyperv.ghcb_base = alloc_percpu(void *);
> > + ms_hyperv.ghcb_base = alloc_percpu(union hv_ghcb __percpu *);
>
> union hv_ghcb isn't defined. It is not added until patch 6 of the series.
>

Ignore this comment. My mistake.

Michael