Re: [PATCH 2/9] x86/hyperv: Support hypercalls for fully enlightened TDX guests

From: Tianyu Lan
Date: Wed Aug 23 2023 - 03:06:25 EST


On 8/12/2023 6:18 AM, Dexuan Cui wrote:
A fully enlightened TDX guest on Hyper-V (i.e. without the paravisor) only
uses the GHCI call rather than hv_hypercall_pg.

In hv_do_hypercall(), Hyper-V requires that the input/output addresses
must have the cc_mask.

Reviewed-by: Kuppuswamy Sathyanarayanan<sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
Reviewed-by: Michael Kelley<mikelley@xxxxxxxxxxxxx>
Signed-off-by: Dexuan Cui<decui@xxxxxxxxxxxxx>
---

Reviewed-by: Tianyu Lan <tiala@xxxxxxxxxxxxx>

arch/x86/hyperv/hv_init.c | 8 ++++++++
arch/x86/hyperv/ivm.c | 17 +++++++++++++++++
arch/x86/include/asm/mshyperv.h | 15 +++++++++++++++
drivers/hv/hv_common.c | 10 ++++++++--
include/asm-generic/mshyperv.h | 1 +
5 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 547ebf6a03bc9..d8ea54663113c 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -481,6 +481,10 @@ void __init hyperv_init(void)
/* Hyper-V requires to write guest os id via ghcb in SNP IVM. */
hv_ghcb_msr_write(HV_X64_MSR_GUEST_OS_ID, guest_id);
+ /* A TDX guest uses the GHCI call rather than hv_hypercall_pg. */
+ if (hv_isolation_type_tdx())
+ goto skip_hypercall_pg_init;
+

Nitpick:
Put hypercal page initialization code into a sepearate function and skip the function in the tdx guest instead of adding the label.