RE: [PATCH v6 5/8] x86/hyperv: Use vmmcall to implement Hyper-V hypercall in sev-snp enlightened guest

From: Dexuan Cui
Date: Wed Aug 16 2023 - 17:33:30 EST


> From: Tianyu Lan <ltykernel@xxxxxxxxx>
> Sent: Wednesday, August 16, 2023 8:59 AM
> [...]
> --- a/arch/x86/include/asm/mshyperv.h
> +++ b/arch/x86/include/asm/mshyperv.h
> @@ -59,16 +59,25 @@ static inline u64 hv_do_hypercall(u64 control, void
> *input, void *output)
> u64 hv_status;
>
> #ifdef CONFIG_X86_64
> - if (!hv_hypercall_pg)
> - return U64_MAX;
> + if (hv_isolation_type_en_snp()) {

I got a build failure:

In file included from arch/x86/hyperv/hv_spinlock.c:15:
./arch/x86/include/asm/mshyperv.h: In function 'hv_do_hypercall':
./arch/x86/include/asm/mshyperv.h:69:6: error: implicit declaration of function 'hv_isolation_type_en_snp' [-Werror=implicit-function-declaration]
69 | if (hv_isolation_type_en_snp()) {
| ^~~~~~~~~~~~~~~~~~~~~~~~

In arch/x86/include/asm/mshyperv.h, we do have
extern bool hv_isolation_type_en_snp(void);
but it's defined at a late place. I think we need to move it to before
hv_do_hypercall().

We also have
extern bool hv_isolation_type_en_snp(void);
in include/asm-generic/mshyperv.h, but that header file
is included at the end of arch/x86/include/asm/mshyperv.h.


> + __asm__ __volatile__("mov %4, %%r8\n"
> + "vmmcall"
> + : "=a" (hv_status),
> ASM_CALL_CONSTRAINT,
> + "+c" (control), "+d" (input_address)
> + : "r" (output_address)
> + : "cc", "memory", "r8", "r9", "r10", "r11");