RE: [PATCH 5/6] x86/hyperv: Support hypercalls for TDX guests
From: Dexuan Cui
Date: Tue Nov 22 2022 - 21:15:08 EST
> From: Dave Hansen <dave.hansen@xxxxxxxxx>
> Sent: Monday, November 21, 2022 12:05 PM
> [...]
> > #ifdef CONFIG_X86_64
> > +#if CONFIG_INTEL_TDX_GUEST
> > + if (hv_isolation_type_tdx()) {
>
> > #ifdef CONFIG_X86_64
> > +#if CONFIG_INTEL_TDX_GUEST
> > + if (hv_isolation_type_tdx())
>
> > #ifdef CONFIG_X86_64
> > +#if CONFIG_INTEL_TDX_GUEST
> > + if (hv_isolation_type_tdx())
> > + return __tdx_ms_hv_hypercall(control, input2, input1);
>
> See any common patterns there?
>
> The "no #ifdef's in C files" rule would be good to apply here. Please
> do one #ifdef in a header.
Sorry, I should use #ifdef rather than #if. I'll fix it like the below.
I don't think I can do one #ifdef, because, in the header file, there are
already 3 existing instances of
#ifdef CONFIG_X86_64
#else
#endif
and I'm just adding a new block "#ifdef CONFIG_INTEL_TDX_GUEST ... #endif"
to the CONFIG_X86_64 case. FWIW, CONFIG_INTEL_TDX_GUEST already
depends on CONFIG_X86_64.
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -48,7 +48,7 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
u64 hv_status;
#ifdef CONFIG_X86_64
-#if CONFIG_INTEL_TDX_GUEST
+#ifdef CONFIG_INTEL_TDX_GUEST
if (hv_isolation_type_tdx()) {
if (input_address)
input_address += ms_hyperv.shared_gpa_boundary;
@@ -97,7 +97,7 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
u64 hv_status, control = (u64)code | HV_HYPERCALL_FAST_BIT;
#ifdef CONFIG_X86_64
-#if CONFIG_INTEL_TDX_GUEST
+#ifdef CONFIG_INTEL_TDX_GUEST
if (hv_isolation_type_tdx())
return __tdx_ms_hv_hypercall(control, 0, input1);
#endif
@@ -133,7 +133,7 @@ static inline u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2)
u64 hv_status, control = (u64)code | HV_HYPERCALL_FAST_BIT;
#ifdef CONFIG_X86_64
-#if CONFIG_INTEL_TDX_GUEST
+#ifdef CONFIG_INTEL_TDX_GUEST
if (hv_isolation_type_tdx())
return __tdx_ms_hv_hypercall(control, input2, input1);
#endif