From: Saurabh Singh Sengar <ssengar@xxxxxxxxxxxxxxxxxxx> Sent: Monday, March 13, 2023 10:02 AM > > On Mon, Mar 13, 2023 at 03:45:02PM +0100, Vitaly Kuznetsov wrote: > > Saurabh Sengar <ssengar@xxxxxxxxxxxxxxxxxxx> writes: > > [snip] > > > diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h > > > index 4c4c0ec3b62e..4ff549dcd49a 100644 > > > --- a/arch/x86/include/asm/mshyperv.h > > > +++ b/arch/x86/include/asm/mshyperv.h > > > @@ -11,6 +11,10 @@ > > > #include <asm/paravirt.h> > > > #include <asm/mshyperv.h> > > > > > > +#define HV_VTL_NORMAL 0x0 > > > +#define HV_VTL_SECURE 0x1 > > > +#define HV_VTL_MGMT 0x2 > > > > Don't these belong to hyperv-tlfs.h too (even if they're not directly > > described in Hyper-V TLFS)? > > Can move these to x86/include/asm/hyperv-tlfs.h > While VTL 0 is always the "normal" VTL, the use case for the other VTLs isn't controlled or specified by Hyper-V. To me, it did not seem appropriate to put the definitions of "VTL_SECURE" and "VTL_MGMT in the TLFS include file. My earlier recommendation had been the Linux-specific mshyperv.h. That said, to me it's not a big issue either way. I have a preference for mshyperv.h, but could go with either. Michael > > > > > + > > > union hv_ghcb; > > > > > > DECLARE_STATIC_KEY_FALSE(isolation_type_snp); > > > @@ -181,6 +185,11 @@ static inline struct hv_vp_assist_page > *hv_get_vp_assist_page(unsigned int cpu) > > > return hv_vp_assist_page[cpu]; > > > } > > > > > > +static inline unsigned char hv_get_nmi_reason(void) > > > +{ > > > + return 0; > > > +} > > > + > > > void __init hyperv_init(void); > > > void hyperv_setup_mmu_ops(void); > > > void set_hv_tscchange_cb(void (*cb)(void)); > > > @@ -266,6 +275,11 @@ static inline int hv_set_mem_host_visibility(unsigned long > addr, int numpages, > > > } > > > #endif /* CONFIG_HYPERV */ > > > > > > +#ifdef CONFIG_HYPERV_VTL > > > +void __init hv_vtl_init_platform(void); > > > +#else > > > +static inline void __init hv_vtl_init_platform(void) {} > > > +#endif > > > > > > #include <asm-generic/mshyperv.h> > > > > > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c > > > index f36dc2f796c5..da5d13d29c4e 100644 > > > --- a/arch/x86/kernel/cpu/mshyperv.c > > > +++ b/arch/x86/kernel/cpu/mshyperv.c > > > @@ -250,11 +250,6 @@ static uint32_t __init ms_hyperv_platform(void) > > > return HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS; > > > } > > > > > > -static unsigned char hv_get_nmi_reason(void) > > > -{ > > > - return 0; > > > -} > > > - > > > #ifdef CONFIG_X86_LOCAL_APIC > > > /* > > > * Prior to WS2016 Debug-VM sends NMIs to all CPUs which makes > > > @@ -521,6 +516,7 @@ static void __init ms_hyperv_init_platform(void) > > > > > > /* Register Hyper-V specific clocksource */ > > > hv_init_clocksource(); > > > + hv_vtl_init_platform(); > > > #endif > > > /* > > > * TSC should be marked as unstable only after Hyper-V > > > diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h > > > index b870983596b9..87258341fd7c 100644 > > > --- a/include/asm-generic/hyperv-tlfs.h > > > +++ b/include/asm-generic/hyperv-tlfs.h > > > @@ -146,6 +146,7 @@ union hv_reference_tsc_msr { > > > /* Declare the various hypercall operations. */ > > > #define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE 0x0002 > > > #define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST 0x0003 > > > +#define HVCALL_ENABLE_VP_VTL 0x000f > > > #define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008 > > > #define HVCALL_SEND_IPI 0x000b > > > #define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX 0x0013 > > > @@ -165,6 +166,8 @@ union hv_reference_tsc_msr { > > > #define HVCALL_MAP_DEVICE_INTERRUPT 0x007c > > > #define HVCALL_UNMAP_DEVICE_INTERRUPT 0x007d > > > #define HVCALL_RETARGET_INTERRUPT 0x007e > > > +#define HVCALL_START_VP 0x0099 > > > +#define HVCALL_GET_VP_ID_FROM_APIC_ID 0x009a > > > #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af > > > #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST 0x00b0 > > > #define HVCALL_MODIFY_SPARSE_GPA_PAGE_HOST_VISIBILITY 0x00db > > > @@ -218,6 +221,7 @@ enum HV_GENERIC_SET_FORMAT { > > > #define HV_STATUS_INVALID_PORT_ID 17 > > > #define HV_STATUS_INVALID_CONNECTION_ID 18 > > > #define HV_STATUS_INSUFFICIENT_BUFFERS 19 > > > +#define HV_STATUS_VTL_ALREADY_ENABLED 134 > > > > > > /* > > > * The Hyper-V TimeRefCount register and the TSC > > > > -- > > Vitaly