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

Dexuan Cui
2023-08-16T21:33:30Z

> --- 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");