From: Tianyu Lan <ltykernel@xxxxxxxxx> Sent: Friday, October 22, 2021 6:37 AM > > Hyper-V needs to call ghcb hv call to write/read MSR in Isolation VM. > So expose sev_es_ghcb_hv_call() to call it in the Hyper-V code. > > Hyper-V Isolation VM is unenlightened guests and run a paravisor in the > VMPL0 for communicating and GHCB pages are being allocated and set up by > that paravisor. Linux gets ghcb page pa via MSR_AMD64_SEV_ES_GHCB > from paravisor and should not change it. Add set_ghcb_msr parameter for > sev_es_ghcb_hv_call() and not set ghcb page pa when it's false. > > Signed-off-by: Tianyu Lan <Tianyu.Lan@xxxxxxxxxxxxx> > --- > Change since v8: > Fix commit in the sev_es_ghcb_hv_call(). > > arch/x86/include/asm/sev.h | 12 ++++++++++++ > arch/x86/kernel/sev-shared.c | 25 ++++++++++++++++--------- > arch/x86/kernel/sev.c | 13 +++++++------ > 3 files changed, 35 insertions(+), 15 deletions(-) > > diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h > index fa5cd05d3b5b..5b7f7e2b81f7 100644 > --- a/arch/x86/include/asm/sev.h > +++ b/arch/x86/include/asm/sev.h > @@ -81,12 +81,24 @@ static __always_inline void sev_es_nmi_complete(void) > __sev_es_nmi_complete(); > } > extern int __init sev_es_efi_map_ghcbs(pgd_t *pgd); > +extern enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb, > + bool set_ghcb_msr, > + struct es_em_ctxt *ctxt, > + u64 exit_code, u64 exit_info_1, > + u64 exit_info_2); > #else > static inline void sev_es_ist_enter(struct pt_regs *regs) { } > static inline void sev_es_ist_exit(void) { } > static inline int sev_es_setup_ap_jump_table(struct real_mode_header *rmh) { return 0; } > static inline void sev_es_nmi_complete(void) { } > static inline int sev_es_efi_map_ghcbs(pgd_t *pgd) { return 0; } > +static inline enum > +es_result sev_es_ghcb_hv_call(struct ghcb *ghcb, > + bool set_ghcb_msr, u64 exit_code, The "struct es_em_ctxt *ctxt" argument is missing from this declaration, which would presumably produce a compile error. > + u64 exit_info_1, u64 exit_info_2) > +{ > + return ES_VMM_ERROR; > +} > #endif > > #endif