Skip to content

Commit c26e052

Browse files
Saurabh Sengarliuw
authored andcommitted
x86/hyperv: Add VTL specific structs and hypercalls
Add structs and hypercalls required to enable VTL support on x86. Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Reviewed-by: Stanislav Kinsburskii <stanislav.kinsburskii@gmail.com> Link: https://lore.kernel.org/r/1681192532-15460-3-git-send-email-ssengar@linux.microsoft.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent d21a19e commit c26e052

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

arch/x86/include/asm/hyperv-tlfs.h

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,81 @@ union hv_msi_entry {
716716
} __packed;
717717
};
718718

719+
struct hv_x64_segment_register {
720+
u64 base;
721+
u32 limit;
722+
u16 selector;
723+
union {
724+
struct {
725+
u16 segment_type : 4;
726+
u16 non_system_segment : 1;
727+
u16 descriptor_privilege_level : 2;
728+
u16 present : 1;
729+
u16 reserved : 4;
730+
u16 available : 1;
731+
u16 _long : 1;
732+
u16 _default : 1;
733+
u16 granularity : 1;
734+
} __packed;
735+
u16 attributes;
736+
};
737+
} __packed;
738+
739+
struct hv_x64_table_register {
740+
u16 pad[3];
741+
u16 limit;
742+
u64 base;
743+
} __packed;
744+
745+
struct hv_init_vp_context {
746+
u64 rip;
747+
u64 rsp;
748+
u64 rflags;
749+
750+
struct hv_x64_segment_register cs;
751+
struct hv_x64_segment_register ds;
752+
struct hv_x64_segment_register es;
753+
struct hv_x64_segment_register fs;
754+
struct hv_x64_segment_register gs;
755+
struct hv_x64_segment_register ss;
756+
struct hv_x64_segment_register tr;
757+
struct hv_x64_segment_register ldtr;
758+
759+
struct hv_x64_table_register idtr;
760+
struct hv_x64_table_register gdtr;
761+
762+
u64 efer;
763+
u64 cr0;
764+
u64 cr3;
765+
u64 cr4;
766+
u64 msr_cr_pat;
767+
} __packed;
768+
769+
union hv_input_vtl {
770+
u8 as_uint8;
771+
struct {
772+
u8 target_vtl: 4;
773+
u8 use_target_vtl: 1;
774+
u8 reserved_z: 3;
775+
};
776+
} __packed;
777+
778+
struct hv_enable_vp_vtl {
779+
u64 partition_id;
780+
u32 vp_index;
781+
union hv_input_vtl target_vtl;
782+
u8 mbz0;
783+
u16 mbz1;
784+
struct hv_init_vp_context vp_context;
785+
} __packed;
786+
787+
struct hv_get_vp_from_apic_id_in {
788+
u64 partition_id;
789+
union hv_input_vtl target_vtl;
790+
u8 res[7];
791+
u32 apic_ids[];
792+
} __packed;
793+
719794
#include <asm-generic/hyperv-tlfs.h>
720795

721796
#endif

include/asm-generic/hyperv-tlfs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ union hv_reference_tsc_msr {
146146
/* Declare the various hypercall operations. */
147147
#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE 0x0002
148148
#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST 0x0003
149+
#define HVCALL_ENABLE_VP_VTL 0x000f
149150
#define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008
150151
#define HVCALL_SEND_IPI 0x000b
151152
#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX 0x0013
@@ -165,6 +166,8 @@ union hv_reference_tsc_msr {
165166
#define HVCALL_MAP_DEVICE_INTERRUPT 0x007c
166167
#define HVCALL_UNMAP_DEVICE_INTERRUPT 0x007d
167168
#define HVCALL_RETARGET_INTERRUPT 0x007e
169+
#define HVCALL_START_VP 0x0099
170+
#define HVCALL_GET_VP_ID_FROM_APIC_ID 0x009a
168171
#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af
169172
#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST 0x00b0
170173
#define HVCALL_MODIFY_SPARSE_GPA_PAGE_HOST_VISIBILITY 0x00db
@@ -220,6 +223,7 @@ enum HV_GENERIC_SET_FORMAT {
220223
#define HV_STATUS_INVALID_PORT_ID 17
221224
#define HV_STATUS_INVALID_CONNECTION_ID 18
222225
#define HV_STATUS_INSUFFICIENT_BUFFERS 19
226+
#define HV_STATUS_VTL_ALREADY_ENABLED 134
223227

224228
/*
225229
* The Hyper-V TimeRefCount register and the TSC

0 commit comments

Comments
 (0)