162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci/* 462306a36Sopenharmony_ci * This file contains definitions from Hyper-V Hypervisor Top-Level Functional 562306a36Sopenharmony_ci * Specification (TLFS): 662306a36Sopenharmony_ci * https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef _ASM_GENERIC_HYPERV_TLFS_H 1062306a36Sopenharmony_ci#define _ASM_GENERIC_HYPERV_TLFS_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/types.h> 1362306a36Sopenharmony_ci#include <linux/bits.h> 1462306a36Sopenharmony_ci#include <linux/time64.h> 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* 1762306a36Sopenharmony_ci * While not explicitly listed in the TLFS, Hyper-V always runs with a page size 1862306a36Sopenharmony_ci * of 4096. These definitions are used when communicating with Hyper-V using 1962306a36Sopenharmony_ci * guest physical pages and guest physical page addresses, since the guest page 2062306a36Sopenharmony_ci * size may not be 4096 on all architectures. 2162306a36Sopenharmony_ci */ 2262306a36Sopenharmony_ci#define HV_HYP_PAGE_SHIFT 12 2362306a36Sopenharmony_ci#define HV_HYP_PAGE_SIZE BIT(HV_HYP_PAGE_SHIFT) 2462306a36Sopenharmony_ci#define HV_HYP_PAGE_MASK (~(HV_HYP_PAGE_SIZE - 1)) 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* 2762306a36Sopenharmony_ci * Hyper-V provides two categories of flags relevant to guest VMs. The 2862306a36Sopenharmony_ci * "Features" category indicates specific functionality that is available 2962306a36Sopenharmony_ci * to guests on this particular instance of Hyper-V. The "Features" 3062306a36Sopenharmony_ci * are presented in four groups, each of which is 32 bits. The group A 3162306a36Sopenharmony_ci * and B definitions are common across architectures and are listed here. 3262306a36Sopenharmony_ci * However, not all flags are relevant on all architectures. 3362306a36Sopenharmony_ci * 3462306a36Sopenharmony_ci * Groups C and D vary across architectures and are listed in the 3562306a36Sopenharmony_ci * architecture specific portion of hyperv-tlfs.h. Some of these flags exist 3662306a36Sopenharmony_ci * on multiple architectures, but the bit positions are different so they 3762306a36Sopenharmony_ci * cannot appear in the generic portion of hyperv-tlfs.h. 3862306a36Sopenharmony_ci * 3962306a36Sopenharmony_ci * The "Enlightenments" category provides recommendations on whether to use 4062306a36Sopenharmony_ci * specific enlightenments that are available. The Enlighenments are a single 4162306a36Sopenharmony_ci * group of 32 bits, but they vary across architectures and are listed in 4262306a36Sopenharmony_ci * the architecture specific portion of hyperv-tlfs.h. 4362306a36Sopenharmony_ci */ 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci/* 4662306a36Sopenharmony_ci * Group A Features. 4762306a36Sopenharmony_ci */ 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* VP Runtime register available */ 5062306a36Sopenharmony_ci#define HV_MSR_VP_RUNTIME_AVAILABLE BIT(0) 5162306a36Sopenharmony_ci/* Partition Reference Counter available*/ 5262306a36Sopenharmony_ci#define HV_MSR_TIME_REF_COUNT_AVAILABLE BIT(1) 5362306a36Sopenharmony_ci/* Basic SynIC register available */ 5462306a36Sopenharmony_ci#define HV_MSR_SYNIC_AVAILABLE BIT(2) 5562306a36Sopenharmony_ci/* Synthetic Timer registers available */ 5662306a36Sopenharmony_ci#define HV_MSR_SYNTIMER_AVAILABLE BIT(3) 5762306a36Sopenharmony_ci/* Virtual APIC assist and VP assist page registers available */ 5862306a36Sopenharmony_ci#define HV_MSR_APIC_ACCESS_AVAILABLE BIT(4) 5962306a36Sopenharmony_ci/* Hypercall and Guest OS ID registers available*/ 6062306a36Sopenharmony_ci#define HV_MSR_HYPERCALL_AVAILABLE BIT(5) 6162306a36Sopenharmony_ci/* Access virtual processor index register available*/ 6262306a36Sopenharmony_ci#define HV_MSR_VP_INDEX_AVAILABLE BIT(6) 6362306a36Sopenharmony_ci/* Virtual system reset register available*/ 6462306a36Sopenharmony_ci#define HV_MSR_RESET_AVAILABLE BIT(7) 6562306a36Sopenharmony_ci/* Access statistics page registers available */ 6662306a36Sopenharmony_ci#define HV_MSR_STAT_PAGES_AVAILABLE BIT(8) 6762306a36Sopenharmony_ci/* Partition reference TSC register is available */ 6862306a36Sopenharmony_ci#define HV_MSR_REFERENCE_TSC_AVAILABLE BIT(9) 6962306a36Sopenharmony_ci/* Partition Guest IDLE register is available */ 7062306a36Sopenharmony_ci#define HV_MSR_GUEST_IDLE_AVAILABLE BIT(10) 7162306a36Sopenharmony_ci/* Partition local APIC and TSC frequency registers available */ 7262306a36Sopenharmony_ci#define HV_ACCESS_FREQUENCY_MSRS BIT(11) 7362306a36Sopenharmony_ci/* AccessReenlightenmentControls privilege */ 7462306a36Sopenharmony_ci#define HV_ACCESS_REENLIGHTENMENT BIT(13) 7562306a36Sopenharmony_ci/* AccessTscInvariantControls privilege */ 7662306a36Sopenharmony_ci#define HV_ACCESS_TSC_INVARIANT BIT(15) 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci/* 7962306a36Sopenharmony_ci * Group B features. 8062306a36Sopenharmony_ci */ 8162306a36Sopenharmony_ci#define HV_CREATE_PARTITIONS BIT(0) 8262306a36Sopenharmony_ci#define HV_ACCESS_PARTITION_ID BIT(1) 8362306a36Sopenharmony_ci#define HV_ACCESS_MEMORY_POOL BIT(2) 8462306a36Sopenharmony_ci#define HV_ADJUST_MESSAGE_BUFFERS BIT(3) 8562306a36Sopenharmony_ci#define HV_POST_MESSAGES BIT(4) 8662306a36Sopenharmony_ci#define HV_SIGNAL_EVENTS BIT(5) 8762306a36Sopenharmony_ci#define HV_CREATE_PORT BIT(6) 8862306a36Sopenharmony_ci#define HV_CONNECT_PORT BIT(7) 8962306a36Sopenharmony_ci#define HV_ACCESS_STATS BIT(8) 9062306a36Sopenharmony_ci#define HV_DEBUGGING BIT(11) 9162306a36Sopenharmony_ci#define HV_CPU_MANAGEMENT BIT(12) 9262306a36Sopenharmony_ci#define HV_ENABLE_EXTENDED_HYPERCALLS BIT(20) 9362306a36Sopenharmony_ci#define HV_ISOLATION BIT(22) 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci/* 9662306a36Sopenharmony_ci * TSC page layout. 9762306a36Sopenharmony_ci */ 9862306a36Sopenharmony_cistruct ms_hyperv_tsc_page { 9962306a36Sopenharmony_ci volatile u32 tsc_sequence; 10062306a36Sopenharmony_ci u32 reserved1; 10162306a36Sopenharmony_ci volatile u64 tsc_scale; 10262306a36Sopenharmony_ci volatile s64 tsc_offset; 10362306a36Sopenharmony_ci} __packed; 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ciunion hv_reference_tsc_msr { 10662306a36Sopenharmony_ci u64 as_uint64; 10762306a36Sopenharmony_ci struct { 10862306a36Sopenharmony_ci u64 enable:1; 10962306a36Sopenharmony_ci u64 reserved:11; 11062306a36Sopenharmony_ci u64 pfn:52; 11162306a36Sopenharmony_ci } __packed; 11262306a36Sopenharmony_ci}; 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci/* 11562306a36Sopenharmony_ci * The guest OS needs to register the guest ID with the hypervisor. 11662306a36Sopenharmony_ci * The guest ID is a 64 bit entity and the structure of this ID is 11762306a36Sopenharmony_ci * specified in the Hyper-V specification: 11862306a36Sopenharmony_ci * 11962306a36Sopenharmony_ci * msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx 12062306a36Sopenharmony_ci * 12162306a36Sopenharmony_ci * While the current guideline does not specify how Linux guest ID(s) 12262306a36Sopenharmony_ci * need to be generated, our plan is to publish the guidelines for 12362306a36Sopenharmony_ci * Linux and other guest operating systems that currently are hosted 12462306a36Sopenharmony_ci * on Hyper-V. The implementation here conforms to this yet 12562306a36Sopenharmony_ci * unpublished guidelines. 12662306a36Sopenharmony_ci * 12762306a36Sopenharmony_ci * 12862306a36Sopenharmony_ci * Bit(s) 12962306a36Sopenharmony_ci * 63 - Indicates if the OS is Open Source or not; 1 is Open Source 13062306a36Sopenharmony_ci * 62:56 - Os Type; Linux is 0x100 13162306a36Sopenharmony_ci * 55:48 - Distro specific identification 13262306a36Sopenharmony_ci * 47:16 - Linux kernel version number 13362306a36Sopenharmony_ci * 15:0 - Distro specific identification 13462306a36Sopenharmony_ci * 13562306a36Sopenharmony_ci * 13662306a36Sopenharmony_ci */ 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci#define HV_LINUX_VENDOR_ID 0x8100 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci/* 14162306a36Sopenharmony_ci * Crash notification flags. 14262306a36Sopenharmony_ci */ 14362306a36Sopenharmony_ci#define HV_CRASH_CTL_CRASH_NOTIFY_MSG BIT_ULL(62) 14462306a36Sopenharmony_ci#define HV_CRASH_CTL_CRASH_NOTIFY BIT_ULL(63) 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci/* Declare the various hypercall operations. */ 14762306a36Sopenharmony_ci#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE 0x0002 14862306a36Sopenharmony_ci#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST 0x0003 14962306a36Sopenharmony_ci#define HVCALL_ENABLE_VP_VTL 0x000f 15062306a36Sopenharmony_ci#define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008 15162306a36Sopenharmony_ci#define HVCALL_SEND_IPI 0x000b 15262306a36Sopenharmony_ci#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX 0x0013 15362306a36Sopenharmony_ci#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX 0x0014 15462306a36Sopenharmony_ci#define HVCALL_SEND_IPI_EX 0x0015 15562306a36Sopenharmony_ci#define HVCALL_GET_PARTITION_ID 0x0046 15662306a36Sopenharmony_ci#define HVCALL_DEPOSIT_MEMORY 0x0048 15762306a36Sopenharmony_ci#define HVCALL_CREATE_VP 0x004e 15862306a36Sopenharmony_ci#define HVCALL_GET_VP_REGISTERS 0x0050 15962306a36Sopenharmony_ci#define HVCALL_SET_VP_REGISTERS 0x0051 16062306a36Sopenharmony_ci#define HVCALL_POST_MESSAGE 0x005c 16162306a36Sopenharmony_ci#define HVCALL_SIGNAL_EVENT 0x005d 16262306a36Sopenharmony_ci#define HVCALL_POST_DEBUG_DATA 0x0069 16362306a36Sopenharmony_ci#define HVCALL_RETRIEVE_DEBUG_DATA 0x006a 16462306a36Sopenharmony_ci#define HVCALL_RESET_DEBUG_SESSION 0x006b 16562306a36Sopenharmony_ci#define HVCALL_ADD_LOGICAL_PROCESSOR 0x0076 16662306a36Sopenharmony_ci#define HVCALL_MAP_DEVICE_INTERRUPT 0x007c 16762306a36Sopenharmony_ci#define HVCALL_UNMAP_DEVICE_INTERRUPT 0x007d 16862306a36Sopenharmony_ci#define HVCALL_RETARGET_INTERRUPT 0x007e 16962306a36Sopenharmony_ci#define HVCALL_START_VP 0x0099 17062306a36Sopenharmony_ci#define HVCALL_GET_VP_ID_FROM_APIC_ID 0x009a 17162306a36Sopenharmony_ci#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af 17262306a36Sopenharmony_ci#define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST 0x00b0 17362306a36Sopenharmony_ci#define HVCALL_MODIFY_SPARSE_GPA_PAGE_HOST_VISIBILITY 0x00db 17462306a36Sopenharmony_ci#define HVCALL_MMIO_READ 0x0106 17562306a36Sopenharmony_ci#define HVCALL_MMIO_WRITE 0x0107 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci/* Extended hypercalls */ 17862306a36Sopenharmony_ci#define HV_EXT_CALL_QUERY_CAPABILITIES 0x8001 17962306a36Sopenharmony_ci#define HV_EXT_CALL_MEMORY_HEAT_HINT 0x8003 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci#define HV_FLUSH_ALL_PROCESSORS BIT(0) 18262306a36Sopenharmony_ci#define HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES BIT(1) 18362306a36Sopenharmony_ci#define HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY BIT(2) 18462306a36Sopenharmony_ci#define HV_FLUSH_USE_EXTENDED_RANGE_FORMAT BIT(3) 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci/* Extended capability bits */ 18762306a36Sopenharmony_ci#define HV_EXT_CAPABILITY_MEMORY_COLD_DISCARD_HINT BIT(8) 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_cienum HV_GENERIC_SET_FORMAT { 19062306a36Sopenharmony_ci HV_GENERIC_SET_SPARSE_4K, 19162306a36Sopenharmony_ci HV_GENERIC_SET_ALL, 19262306a36Sopenharmony_ci}; 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ci#define HV_PARTITION_ID_SELF ((u64)-1) 19562306a36Sopenharmony_ci#define HV_VP_INDEX_SELF ((u32)-2) 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci#define HV_HYPERCALL_RESULT_MASK GENMASK_ULL(15, 0) 19862306a36Sopenharmony_ci#define HV_HYPERCALL_FAST_BIT BIT(16) 19962306a36Sopenharmony_ci#define HV_HYPERCALL_VARHEAD_OFFSET 17 20062306a36Sopenharmony_ci#define HV_HYPERCALL_VARHEAD_MASK GENMASK_ULL(26, 17) 20162306a36Sopenharmony_ci#define HV_HYPERCALL_RSVD0_MASK GENMASK_ULL(31, 27) 20262306a36Sopenharmony_ci#define HV_HYPERCALL_NESTED BIT_ULL(31) 20362306a36Sopenharmony_ci#define HV_HYPERCALL_REP_COMP_OFFSET 32 20462306a36Sopenharmony_ci#define HV_HYPERCALL_REP_COMP_1 BIT_ULL(32) 20562306a36Sopenharmony_ci#define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32) 20662306a36Sopenharmony_ci#define HV_HYPERCALL_RSVD1_MASK GENMASK_ULL(47, 44) 20762306a36Sopenharmony_ci#define HV_HYPERCALL_REP_START_OFFSET 48 20862306a36Sopenharmony_ci#define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48) 20962306a36Sopenharmony_ci#define HV_HYPERCALL_RSVD2_MASK GENMASK_ULL(63, 60) 21062306a36Sopenharmony_ci#define HV_HYPERCALL_RSVD_MASK (HV_HYPERCALL_RSVD0_MASK | \ 21162306a36Sopenharmony_ci HV_HYPERCALL_RSVD1_MASK | \ 21262306a36Sopenharmony_ci HV_HYPERCALL_RSVD2_MASK) 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ci/* hypercall status code */ 21562306a36Sopenharmony_ci#define HV_STATUS_SUCCESS 0 21662306a36Sopenharmony_ci#define HV_STATUS_INVALID_HYPERCALL_CODE 2 21762306a36Sopenharmony_ci#define HV_STATUS_INVALID_HYPERCALL_INPUT 3 21862306a36Sopenharmony_ci#define HV_STATUS_INVALID_ALIGNMENT 4 21962306a36Sopenharmony_ci#define HV_STATUS_INVALID_PARAMETER 5 22062306a36Sopenharmony_ci#define HV_STATUS_ACCESS_DENIED 6 22162306a36Sopenharmony_ci#define HV_STATUS_OPERATION_DENIED 8 22262306a36Sopenharmony_ci#define HV_STATUS_INSUFFICIENT_MEMORY 11 22362306a36Sopenharmony_ci#define HV_STATUS_INVALID_PORT_ID 17 22462306a36Sopenharmony_ci#define HV_STATUS_INVALID_CONNECTION_ID 18 22562306a36Sopenharmony_ci#define HV_STATUS_INSUFFICIENT_BUFFERS 19 22662306a36Sopenharmony_ci#define HV_STATUS_TIME_OUT 120 22762306a36Sopenharmony_ci#define HV_STATUS_VTL_ALREADY_ENABLED 134 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci/* 23062306a36Sopenharmony_ci * The Hyper-V TimeRefCount register and the TSC 23162306a36Sopenharmony_ci * page provide a guest VM clock with 100ns tick rate 23262306a36Sopenharmony_ci */ 23362306a36Sopenharmony_ci#define HV_CLOCK_HZ (NSEC_PER_SEC/100) 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci/* Define the number of synthetic interrupt sources. */ 23662306a36Sopenharmony_ci#define HV_SYNIC_SINT_COUNT (16) 23762306a36Sopenharmony_ci/* Define the expected SynIC version. */ 23862306a36Sopenharmony_ci#define HV_SYNIC_VERSION_1 (0x1) 23962306a36Sopenharmony_ci/* Valid SynIC vectors are 16-255. */ 24062306a36Sopenharmony_ci#define HV_SYNIC_FIRST_VALID_VECTOR (16) 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_ci#define HV_SYNIC_CONTROL_ENABLE (1ULL << 0) 24362306a36Sopenharmony_ci#define HV_SYNIC_SIMP_ENABLE (1ULL << 0) 24462306a36Sopenharmony_ci#define HV_SYNIC_SIEFP_ENABLE (1ULL << 0) 24562306a36Sopenharmony_ci#define HV_SYNIC_SINT_MASKED (1ULL << 16) 24662306a36Sopenharmony_ci#define HV_SYNIC_SINT_AUTO_EOI (1ULL << 17) 24762306a36Sopenharmony_ci#define HV_SYNIC_SINT_VECTOR_MASK (0xFF) 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_ci#define HV_SYNIC_STIMER_COUNT (4) 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_ci/* Define synthetic interrupt controller message constants. */ 25262306a36Sopenharmony_ci#define HV_MESSAGE_SIZE (256) 25362306a36Sopenharmony_ci#define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240) 25462306a36Sopenharmony_ci#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30) 25562306a36Sopenharmony_ci 25662306a36Sopenharmony_ci/* 25762306a36Sopenharmony_ci * Define hypervisor message types. Some of the message types 25862306a36Sopenharmony_ci * are x86/x64 specific, but there's no good way to separate 25962306a36Sopenharmony_ci * them out into the arch-specific version of hyperv-tlfs.h 26062306a36Sopenharmony_ci * because C doesn't provide a way to extend enum types. 26162306a36Sopenharmony_ci * Keeping them all in the arch neutral hyperv-tlfs.h seems 26262306a36Sopenharmony_ci * the least messy compromise. 26362306a36Sopenharmony_ci */ 26462306a36Sopenharmony_cienum hv_message_type { 26562306a36Sopenharmony_ci HVMSG_NONE = 0x00000000, 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_ci /* Memory access messages. */ 26862306a36Sopenharmony_ci HVMSG_UNMAPPED_GPA = 0x80000000, 26962306a36Sopenharmony_ci HVMSG_GPA_INTERCEPT = 0x80000001, 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_ci /* Timer notification messages. */ 27262306a36Sopenharmony_ci HVMSG_TIMER_EXPIRED = 0x80000010, 27362306a36Sopenharmony_ci 27462306a36Sopenharmony_ci /* Error messages. */ 27562306a36Sopenharmony_ci HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020, 27662306a36Sopenharmony_ci HVMSG_UNRECOVERABLE_EXCEPTION = 0x80000021, 27762306a36Sopenharmony_ci HVMSG_UNSUPPORTED_FEATURE = 0x80000022, 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci /* Trace buffer complete messages. */ 28062306a36Sopenharmony_ci HVMSG_EVENTLOG_BUFFERCOMPLETE = 0x80000040, 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_ci /* Platform-specific processor intercept messages. */ 28362306a36Sopenharmony_ci HVMSG_X64_IOPORT_INTERCEPT = 0x80010000, 28462306a36Sopenharmony_ci HVMSG_X64_MSR_INTERCEPT = 0x80010001, 28562306a36Sopenharmony_ci HVMSG_X64_CPUID_INTERCEPT = 0x80010002, 28662306a36Sopenharmony_ci HVMSG_X64_EXCEPTION_INTERCEPT = 0x80010003, 28762306a36Sopenharmony_ci HVMSG_X64_APIC_EOI = 0x80010004, 28862306a36Sopenharmony_ci HVMSG_X64_LEGACY_FP_ERROR = 0x80010005 28962306a36Sopenharmony_ci}; 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci/* Define synthetic interrupt controller message flags. */ 29262306a36Sopenharmony_ciunion hv_message_flags { 29362306a36Sopenharmony_ci __u8 asu8; 29462306a36Sopenharmony_ci struct { 29562306a36Sopenharmony_ci __u8 msg_pending:1; 29662306a36Sopenharmony_ci __u8 reserved:7; 29762306a36Sopenharmony_ci } __packed; 29862306a36Sopenharmony_ci}; 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci/* Define port identifier type. */ 30162306a36Sopenharmony_ciunion hv_port_id { 30262306a36Sopenharmony_ci __u32 asu32; 30362306a36Sopenharmony_ci struct { 30462306a36Sopenharmony_ci __u32 id:24; 30562306a36Sopenharmony_ci __u32 reserved:8; 30662306a36Sopenharmony_ci } __packed u; 30762306a36Sopenharmony_ci}; 30862306a36Sopenharmony_ci 30962306a36Sopenharmony_ci/* Define synthetic interrupt controller message header. */ 31062306a36Sopenharmony_cistruct hv_message_header { 31162306a36Sopenharmony_ci __u32 message_type; 31262306a36Sopenharmony_ci __u8 payload_size; 31362306a36Sopenharmony_ci union hv_message_flags message_flags; 31462306a36Sopenharmony_ci __u8 reserved[2]; 31562306a36Sopenharmony_ci union { 31662306a36Sopenharmony_ci __u64 sender; 31762306a36Sopenharmony_ci union hv_port_id port; 31862306a36Sopenharmony_ci }; 31962306a36Sopenharmony_ci} __packed; 32062306a36Sopenharmony_ci 32162306a36Sopenharmony_ci/* Define synthetic interrupt controller message format. */ 32262306a36Sopenharmony_cistruct hv_message { 32362306a36Sopenharmony_ci struct hv_message_header header; 32462306a36Sopenharmony_ci union { 32562306a36Sopenharmony_ci __u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT]; 32662306a36Sopenharmony_ci } u; 32762306a36Sopenharmony_ci} __packed; 32862306a36Sopenharmony_ci 32962306a36Sopenharmony_ci/* Define the synthetic interrupt message page layout. */ 33062306a36Sopenharmony_cistruct hv_message_page { 33162306a36Sopenharmony_ci struct hv_message sint_message[HV_SYNIC_SINT_COUNT]; 33262306a36Sopenharmony_ci} __packed; 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_ci/* Define timer message payload structure. */ 33562306a36Sopenharmony_cistruct hv_timer_message_payload { 33662306a36Sopenharmony_ci __u32 timer_index; 33762306a36Sopenharmony_ci __u32 reserved; 33862306a36Sopenharmony_ci __u64 expiration_time; /* When the timer expired */ 33962306a36Sopenharmony_ci __u64 delivery_time; /* When the message was delivered */ 34062306a36Sopenharmony_ci} __packed; 34162306a36Sopenharmony_ci 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_ci/* Define synthetic interrupt controller flag constants. */ 34462306a36Sopenharmony_ci#define HV_EVENT_FLAGS_COUNT (256 * 8) 34562306a36Sopenharmony_ci#define HV_EVENT_FLAGS_LONG_COUNT (256 / sizeof(unsigned long)) 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_ci/* 34862306a36Sopenharmony_ci * Synthetic timer configuration. 34962306a36Sopenharmony_ci */ 35062306a36Sopenharmony_ciunion hv_stimer_config { 35162306a36Sopenharmony_ci u64 as_uint64; 35262306a36Sopenharmony_ci struct { 35362306a36Sopenharmony_ci u64 enable:1; 35462306a36Sopenharmony_ci u64 periodic:1; 35562306a36Sopenharmony_ci u64 lazy:1; 35662306a36Sopenharmony_ci u64 auto_enable:1; 35762306a36Sopenharmony_ci u64 apic_vector:8; 35862306a36Sopenharmony_ci u64 direct_mode:1; 35962306a36Sopenharmony_ci u64 reserved_z0:3; 36062306a36Sopenharmony_ci u64 sintx:4; 36162306a36Sopenharmony_ci u64 reserved_z1:44; 36262306a36Sopenharmony_ci } __packed; 36362306a36Sopenharmony_ci}; 36462306a36Sopenharmony_ci 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_ci/* Define the synthetic interrupt controller event flags format. */ 36762306a36Sopenharmony_ciunion hv_synic_event_flags { 36862306a36Sopenharmony_ci unsigned long flags[HV_EVENT_FLAGS_LONG_COUNT]; 36962306a36Sopenharmony_ci}; 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_ci/* Define SynIC control register. */ 37262306a36Sopenharmony_ciunion hv_synic_scontrol { 37362306a36Sopenharmony_ci u64 as_uint64; 37462306a36Sopenharmony_ci struct { 37562306a36Sopenharmony_ci u64 enable:1; 37662306a36Sopenharmony_ci u64 reserved:63; 37762306a36Sopenharmony_ci } __packed; 37862306a36Sopenharmony_ci}; 37962306a36Sopenharmony_ci 38062306a36Sopenharmony_ci/* Define synthetic interrupt source. */ 38162306a36Sopenharmony_ciunion hv_synic_sint { 38262306a36Sopenharmony_ci u64 as_uint64; 38362306a36Sopenharmony_ci struct { 38462306a36Sopenharmony_ci u64 vector:8; 38562306a36Sopenharmony_ci u64 reserved1:8; 38662306a36Sopenharmony_ci u64 masked:1; 38762306a36Sopenharmony_ci u64 auto_eoi:1; 38862306a36Sopenharmony_ci u64 polling:1; 38962306a36Sopenharmony_ci u64 reserved2:45; 39062306a36Sopenharmony_ci } __packed; 39162306a36Sopenharmony_ci}; 39262306a36Sopenharmony_ci 39362306a36Sopenharmony_ci/* Define the format of the SIMP register */ 39462306a36Sopenharmony_ciunion hv_synic_simp { 39562306a36Sopenharmony_ci u64 as_uint64; 39662306a36Sopenharmony_ci struct { 39762306a36Sopenharmony_ci u64 simp_enabled:1; 39862306a36Sopenharmony_ci u64 preserved:11; 39962306a36Sopenharmony_ci u64 base_simp_gpa:52; 40062306a36Sopenharmony_ci } __packed; 40162306a36Sopenharmony_ci}; 40262306a36Sopenharmony_ci 40362306a36Sopenharmony_ci/* Define the format of the SIEFP register */ 40462306a36Sopenharmony_ciunion hv_synic_siefp { 40562306a36Sopenharmony_ci u64 as_uint64; 40662306a36Sopenharmony_ci struct { 40762306a36Sopenharmony_ci u64 siefp_enabled:1; 40862306a36Sopenharmony_ci u64 preserved:11; 40962306a36Sopenharmony_ci u64 base_siefp_gpa:52; 41062306a36Sopenharmony_ci } __packed; 41162306a36Sopenharmony_ci}; 41262306a36Sopenharmony_ci 41362306a36Sopenharmony_cistruct hv_vpset { 41462306a36Sopenharmony_ci u64 format; 41562306a36Sopenharmony_ci u64 valid_bank_mask; 41662306a36Sopenharmony_ci u64 bank_contents[]; 41762306a36Sopenharmony_ci} __packed; 41862306a36Sopenharmony_ci 41962306a36Sopenharmony_ci/* The maximum number of sparse vCPU banks which can be encoded by 'struct hv_vpset' */ 42062306a36Sopenharmony_ci#define HV_MAX_SPARSE_VCPU_BANKS (64) 42162306a36Sopenharmony_ci/* The number of vCPUs in one sparse bank */ 42262306a36Sopenharmony_ci#define HV_VCPUS_PER_SPARSE_BANK (64) 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_ci/* HvCallSendSyntheticClusterIpi hypercall */ 42562306a36Sopenharmony_cistruct hv_send_ipi { 42662306a36Sopenharmony_ci u32 vector; 42762306a36Sopenharmony_ci u32 reserved; 42862306a36Sopenharmony_ci u64 cpu_mask; 42962306a36Sopenharmony_ci} __packed; 43062306a36Sopenharmony_ci 43162306a36Sopenharmony_ci/* HvCallSendSyntheticClusterIpiEx hypercall */ 43262306a36Sopenharmony_cistruct hv_send_ipi_ex { 43362306a36Sopenharmony_ci u32 vector; 43462306a36Sopenharmony_ci u32 reserved; 43562306a36Sopenharmony_ci struct hv_vpset vp_set; 43662306a36Sopenharmony_ci} __packed; 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_ci/* HvFlushGuestPhysicalAddressSpace hypercalls */ 43962306a36Sopenharmony_cistruct hv_guest_mapping_flush { 44062306a36Sopenharmony_ci u64 address_space; 44162306a36Sopenharmony_ci u64 flags; 44262306a36Sopenharmony_ci} __packed; 44362306a36Sopenharmony_ci 44462306a36Sopenharmony_ci/* 44562306a36Sopenharmony_ci * HV_MAX_FLUSH_PAGES = "additional_pages" + 1. It's limited 44662306a36Sopenharmony_ci * by the bitwidth of "additional_pages" in union hv_gpa_page_range. 44762306a36Sopenharmony_ci */ 44862306a36Sopenharmony_ci#define HV_MAX_FLUSH_PAGES (2048) 44962306a36Sopenharmony_ci#define HV_GPA_PAGE_RANGE_PAGE_SIZE_2MB 0 45062306a36Sopenharmony_ci#define HV_GPA_PAGE_RANGE_PAGE_SIZE_1GB 1 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ci/* HvFlushGuestPhysicalAddressList, HvExtCallMemoryHeatHint hypercall */ 45362306a36Sopenharmony_ciunion hv_gpa_page_range { 45462306a36Sopenharmony_ci u64 address_space; 45562306a36Sopenharmony_ci struct { 45662306a36Sopenharmony_ci u64 additional_pages:11; 45762306a36Sopenharmony_ci u64 largepage:1; 45862306a36Sopenharmony_ci u64 basepfn:52; 45962306a36Sopenharmony_ci } page; 46062306a36Sopenharmony_ci struct { 46162306a36Sopenharmony_ci u64 reserved:12; 46262306a36Sopenharmony_ci u64 page_size:1; 46362306a36Sopenharmony_ci u64 reserved1:8; 46462306a36Sopenharmony_ci u64 base_large_pfn:43; 46562306a36Sopenharmony_ci }; 46662306a36Sopenharmony_ci}; 46762306a36Sopenharmony_ci 46862306a36Sopenharmony_ci/* 46962306a36Sopenharmony_ci * All input flush parameters should be in single page. The max flush 47062306a36Sopenharmony_ci * count is equal with how many entries of union hv_gpa_page_range can 47162306a36Sopenharmony_ci * be populated into the input parameter page. 47262306a36Sopenharmony_ci */ 47362306a36Sopenharmony_ci#define HV_MAX_FLUSH_REP_COUNT ((HV_HYP_PAGE_SIZE - 2 * sizeof(u64)) / \ 47462306a36Sopenharmony_ci sizeof(union hv_gpa_page_range)) 47562306a36Sopenharmony_ci 47662306a36Sopenharmony_cistruct hv_guest_mapping_flush_list { 47762306a36Sopenharmony_ci u64 address_space; 47862306a36Sopenharmony_ci u64 flags; 47962306a36Sopenharmony_ci union hv_gpa_page_range gpa_list[HV_MAX_FLUSH_REP_COUNT]; 48062306a36Sopenharmony_ci}; 48162306a36Sopenharmony_ci 48262306a36Sopenharmony_ci/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */ 48362306a36Sopenharmony_cistruct hv_tlb_flush { 48462306a36Sopenharmony_ci u64 address_space; 48562306a36Sopenharmony_ci u64 flags; 48662306a36Sopenharmony_ci u64 processor_mask; 48762306a36Sopenharmony_ci u64 gva_list[]; 48862306a36Sopenharmony_ci} __packed; 48962306a36Sopenharmony_ci 49062306a36Sopenharmony_ci/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */ 49162306a36Sopenharmony_cistruct hv_tlb_flush_ex { 49262306a36Sopenharmony_ci u64 address_space; 49362306a36Sopenharmony_ci u64 flags; 49462306a36Sopenharmony_ci struct hv_vpset hv_vp_set; 49562306a36Sopenharmony_ci u64 gva_list[]; 49662306a36Sopenharmony_ci} __packed; 49762306a36Sopenharmony_ci 49862306a36Sopenharmony_ci/* HvGetPartitionId hypercall (output only) */ 49962306a36Sopenharmony_cistruct hv_get_partition_id { 50062306a36Sopenharmony_ci u64 partition_id; 50162306a36Sopenharmony_ci} __packed; 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_ci/* HvDepositMemory hypercall */ 50462306a36Sopenharmony_cistruct hv_deposit_memory { 50562306a36Sopenharmony_ci u64 partition_id; 50662306a36Sopenharmony_ci u64 gpa_page_list[]; 50762306a36Sopenharmony_ci} __packed; 50862306a36Sopenharmony_ci 50962306a36Sopenharmony_cistruct hv_proximity_domain_flags { 51062306a36Sopenharmony_ci u32 proximity_preferred : 1; 51162306a36Sopenharmony_ci u32 reserved : 30; 51262306a36Sopenharmony_ci u32 proximity_info_valid : 1; 51362306a36Sopenharmony_ci} __packed; 51462306a36Sopenharmony_ci 51562306a36Sopenharmony_ci/* Not a union in windows but useful for zeroing */ 51662306a36Sopenharmony_ciunion hv_proximity_domain_info { 51762306a36Sopenharmony_ci struct { 51862306a36Sopenharmony_ci u32 domain_id; 51962306a36Sopenharmony_ci struct hv_proximity_domain_flags flags; 52062306a36Sopenharmony_ci }; 52162306a36Sopenharmony_ci u64 as_uint64; 52262306a36Sopenharmony_ci} __packed; 52362306a36Sopenharmony_ci 52462306a36Sopenharmony_cistruct hv_lp_startup_status { 52562306a36Sopenharmony_ci u64 hv_status; 52662306a36Sopenharmony_ci u64 substatus1; 52762306a36Sopenharmony_ci u64 substatus2; 52862306a36Sopenharmony_ci u64 substatus3; 52962306a36Sopenharmony_ci u64 substatus4; 53062306a36Sopenharmony_ci u64 substatus5; 53162306a36Sopenharmony_ci u64 substatus6; 53262306a36Sopenharmony_ci} __packed; 53362306a36Sopenharmony_ci 53462306a36Sopenharmony_ci/* HvAddLogicalProcessor hypercall */ 53562306a36Sopenharmony_cistruct hv_add_logical_processor_in { 53662306a36Sopenharmony_ci u32 lp_index; 53762306a36Sopenharmony_ci u32 apic_id; 53862306a36Sopenharmony_ci union hv_proximity_domain_info proximity_domain_info; 53962306a36Sopenharmony_ci u64 flags; 54062306a36Sopenharmony_ci} __packed; 54162306a36Sopenharmony_ci 54262306a36Sopenharmony_cistruct hv_add_logical_processor_out { 54362306a36Sopenharmony_ci struct hv_lp_startup_status startup_status; 54462306a36Sopenharmony_ci} __packed; 54562306a36Sopenharmony_ci 54662306a36Sopenharmony_cienum HV_SUBNODE_TYPE 54762306a36Sopenharmony_ci{ 54862306a36Sopenharmony_ci HvSubnodeAny = 0, 54962306a36Sopenharmony_ci HvSubnodeSocket = 1, 55062306a36Sopenharmony_ci HvSubnodeAmdNode = 2, 55162306a36Sopenharmony_ci HvSubnodeL3 = 3, 55262306a36Sopenharmony_ci HvSubnodeCount = 4, 55362306a36Sopenharmony_ci HvSubnodeInvalid = -1 55462306a36Sopenharmony_ci}; 55562306a36Sopenharmony_ci 55662306a36Sopenharmony_ci/* HvCreateVp hypercall */ 55762306a36Sopenharmony_cistruct hv_create_vp { 55862306a36Sopenharmony_ci u64 partition_id; 55962306a36Sopenharmony_ci u32 vp_index; 56062306a36Sopenharmony_ci u8 padding[3]; 56162306a36Sopenharmony_ci u8 subnode_type; 56262306a36Sopenharmony_ci u64 subnode_id; 56362306a36Sopenharmony_ci union hv_proximity_domain_info proximity_domain_info; 56462306a36Sopenharmony_ci u64 flags; 56562306a36Sopenharmony_ci} __packed; 56662306a36Sopenharmony_ci 56762306a36Sopenharmony_cienum hv_interrupt_source { 56862306a36Sopenharmony_ci HV_INTERRUPT_SOURCE_MSI = 1, /* MSI and MSI-X */ 56962306a36Sopenharmony_ci HV_INTERRUPT_SOURCE_IOAPIC, 57062306a36Sopenharmony_ci}; 57162306a36Sopenharmony_ci 57262306a36Sopenharmony_ciunion hv_ioapic_rte { 57362306a36Sopenharmony_ci u64 as_uint64; 57462306a36Sopenharmony_ci 57562306a36Sopenharmony_ci struct { 57662306a36Sopenharmony_ci u32 vector:8; 57762306a36Sopenharmony_ci u32 delivery_mode:3; 57862306a36Sopenharmony_ci u32 destination_mode:1; 57962306a36Sopenharmony_ci u32 delivery_status:1; 58062306a36Sopenharmony_ci u32 interrupt_polarity:1; 58162306a36Sopenharmony_ci u32 remote_irr:1; 58262306a36Sopenharmony_ci u32 trigger_mode:1; 58362306a36Sopenharmony_ci u32 interrupt_mask:1; 58462306a36Sopenharmony_ci u32 reserved1:15; 58562306a36Sopenharmony_ci 58662306a36Sopenharmony_ci u32 reserved2:24; 58762306a36Sopenharmony_ci u32 destination_id:8; 58862306a36Sopenharmony_ci }; 58962306a36Sopenharmony_ci 59062306a36Sopenharmony_ci struct { 59162306a36Sopenharmony_ci u32 low_uint32; 59262306a36Sopenharmony_ci u32 high_uint32; 59362306a36Sopenharmony_ci }; 59462306a36Sopenharmony_ci} __packed; 59562306a36Sopenharmony_ci 59662306a36Sopenharmony_cistruct hv_interrupt_entry { 59762306a36Sopenharmony_ci u32 source; 59862306a36Sopenharmony_ci u32 reserved1; 59962306a36Sopenharmony_ci union { 60062306a36Sopenharmony_ci union hv_msi_entry msi_entry; 60162306a36Sopenharmony_ci union hv_ioapic_rte ioapic_rte; 60262306a36Sopenharmony_ci }; 60362306a36Sopenharmony_ci} __packed; 60462306a36Sopenharmony_ci 60562306a36Sopenharmony_ci/* 60662306a36Sopenharmony_ci * flags for hv_device_interrupt_target.flags 60762306a36Sopenharmony_ci */ 60862306a36Sopenharmony_ci#define HV_DEVICE_INTERRUPT_TARGET_MULTICAST 1 60962306a36Sopenharmony_ci#define HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET 2 61062306a36Sopenharmony_ci 61162306a36Sopenharmony_cistruct hv_device_interrupt_target { 61262306a36Sopenharmony_ci u32 vector; 61362306a36Sopenharmony_ci u32 flags; 61462306a36Sopenharmony_ci union { 61562306a36Sopenharmony_ci u64 vp_mask; 61662306a36Sopenharmony_ci struct hv_vpset vp_set; 61762306a36Sopenharmony_ci }; 61862306a36Sopenharmony_ci} __packed; 61962306a36Sopenharmony_ci 62062306a36Sopenharmony_cistruct hv_retarget_device_interrupt { 62162306a36Sopenharmony_ci u64 partition_id; /* use "self" */ 62262306a36Sopenharmony_ci u64 device_id; 62362306a36Sopenharmony_ci struct hv_interrupt_entry int_entry; 62462306a36Sopenharmony_ci u64 reserved2; 62562306a36Sopenharmony_ci struct hv_device_interrupt_target int_target; 62662306a36Sopenharmony_ci} __packed __aligned(8); 62762306a36Sopenharmony_ci 62862306a36Sopenharmony_ci 62962306a36Sopenharmony_ci/* HvGetVpRegisters hypercall input with variable size reg name list*/ 63062306a36Sopenharmony_cistruct hv_get_vp_registers_input { 63162306a36Sopenharmony_ci struct { 63262306a36Sopenharmony_ci u64 partitionid; 63362306a36Sopenharmony_ci u32 vpindex; 63462306a36Sopenharmony_ci u8 inputvtl; 63562306a36Sopenharmony_ci u8 padding[3]; 63662306a36Sopenharmony_ci } header; 63762306a36Sopenharmony_ci struct input { 63862306a36Sopenharmony_ci u32 name0; 63962306a36Sopenharmony_ci u32 name1; 64062306a36Sopenharmony_ci } element[]; 64162306a36Sopenharmony_ci} __packed; 64262306a36Sopenharmony_ci 64362306a36Sopenharmony_ci 64462306a36Sopenharmony_ci/* HvGetVpRegisters returns an array of these output elements */ 64562306a36Sopenharmony_cistruct hv_get_vp_registers_output { 64662306a36Sopenharmony_ci union { 64762306a36Sopenharmony_ci struct { 64862306a36Sopenharmony_ci u32 a; 64962306a36Sopenharmony_ci u32 b; 65062306a36Sopenharmony_ci u32 c; 65162306a36Sopenharmony_ci u32 d; 65262306a36Sopenharmony_ci } as32 __packed; 65362306a36Sopenharmony_ci struct { 65462306a36Sopenharmony_ci u64 low; 65562306a36Sopenharmony_ci u64 high; 65662306a36Sopenharmony_ci } as64 __packed; 65762306a36Sopenharmony_ci }; 65862306a36Sopenharmony_ci}; 65962306a36Sopenharmony_ci 66062306a36Sopenharmony_ci/* HvSetVpRegisters hypercall with variable size reg name/value list*/ 66162306a36Sopenharmony_cistruct hv_set_vp_registers_input { 66262306a36Sopenharmony_ci struct { 66362306a36Sopenharmony_ci u64 partitionid; 66462306a36Sopenharmony_ci u32 vpindex; 66562306a36Sopenharmony_ci u8 inputvtl; 66662306a36Sopenharmony_ci u8 padding[3]; 66762306a36Sopenharmony_ci } header; 66862306a36Sopenharmony_ci struct { 66962306a36Sopenharmony_ci u32 name; 67062306a36Sopenharmony_ci u32 padding1; 67162306a36Sopenharmony_ci u64 padding2; 67262306a36Sopenharmony_ci u64 valuelow; 67362306a36Sopenharmony_ci u64 valuehigh; 67462306a36Sopenharmony_ci } element[]; 67562306a36Sopenharmony_ci} __packed; 67662306a36Sopenharmony_ci 67762306a36Sopenharmony_cienum hv_device_type { 67862306a36Sopenharmony_ci HV_DEVICE_TYPE_LOGICAL = 0, 67962306a36Sopenharmony_ci HV_DEVICE_TYPE_PCI = 1, 68062306a36Sopenharmony_ci HV_DEVICE_TYPE_IOAPIC = 2, 68162306a36Sopenharmony_ci HV_DEVICE_TYPE_ACPI = 3, 68262306a36Sopenharmony_ci}; 68362306a36Sopenharmony_ci 68462306a36Sopenharmony_citypedef u16 hv_pci_rid; 68562306a36Sopenharmony_citypedef u16 hv_pci_segment; 68662306a36Sopenharmony_citypedef u64 hv_logical_device_id; 68762306a36Sopenharmony_ciunion hv_pci_bdf { 68862306a36Sopenharmony_ci u16 as_uint16; 68962306a36Sopenharmony_ci 69062306a36Sopenharmony_ci struct { 69162306a36Sopenharmony_ci u8 function:3; 69262306a36Sopenharmony_ci u8 device:5; 69362306a36Sopenharmony_ci u8 bus; 69462306a36Sopenharmony_ci }; 69562306a36Sopenharmony_ci} __packed; 69662306a36Sopenharmony_ci 69762306a36Sopenharmony_ciunion hv_pci_bus_range { 69862306a36Sopenharmony_ci u16 as_uint16; 69962306a36Sopenharmony_ci 70062306a36Sopenharmony_ci struct { 70162306a36Sopenharmony_ci u8 subordinate_bus; 70262306a36Sopenharmony_ci u8 secondary_bus; 70362306a36Sopenharmony_ci }; 70462306a36Sopenharmony_ci} __packed; 70562306a36Sopenharmony_ci 70662306a36Sopenharmony_ciunion hv_device_id { 70762306a36Sopenharmony_ci u64 as_uint64; 70862306a36Sopenharmony_ci 70962306a36Sopenharmony_ci struct { 71062306a36Sopenharmony_ci u64 reserved0:62; 71162306a36Sopenharmony_ci u64 device_type:2; 71262306a36Sopenharmony_ci }; 71362306a36Sopenharmony_ci 71462306a36Sopenharmony_ci /* HV_DEVICE_TYPE_LOGICAL */ 71562306a36Sopenharmony_ci struct { 71662306a36Sopenharmony_ci u64 id:62; 71762306a36Sopenharmony_ci u64 device_type:2; 71862306a36Sopenharmony_ci } logical; 71962306a36Sopenharmony_ci 72062306a36Sopenharmony_ci /* HV_DEVICE_TYPE_PCI */ 72162306a36Sopenharmony_ci struct { 72262306a36Sopenharmony_ci union { 72362306a36Sopenharmony_ci hv_pci_rid rid; 72462306a36Sopenharmony_ci union hv_pci_bdf bdf; 72562306a36Sopenharmony_ci }; 72662306a36Sopenharmony_ci 72762306a36Sopenharmony_ci hv_pci_segment segment; 72862306a36Sopenharmony_ci union hv_pci_bus_range shadow_bus_range; 72962306a36Sopenharmony_ci 73062306a36Sopenharmony_ci u16 phantom_function_bits:2; 73162306a36Sopenharmony_ci u16 source_shadow:1; 73262306a36Sopenharmony_ci 73362306a36Sopenharmony_ci u16 rsvdz0:11; 73462306a36Sopenharmony_ci u16 device_type:2; 73562306a36Sopenharmony_ci } pci; 73662306a36Sopenharmony_ci 73762306a36Sopenharmony_ci /* HV_DEVICE_TYPE_IOAPIC */ 73862306a36Sopenharmony_ci struct { 73962306a36Sopenharmony_ci u8 ioapic_id; 74062306a36Sopenharmony_ci u8 rsvdz0; 74162306a36Sopenharmony_ci u16 rsvdz1; 74262306a36Sopenharmony_ci u16 rsvdz2; 74362306a36Sopenharmony_ci 74462306a36Sopenharmony_ci u16 rsvdz3:14; 74562306a36Sopenharmony_ci u16 device_type:2; 74662306a36Sopenharmony_ci } ioapic; 74762306a36Sopenharmony_ci 74862306a36Sopenharmony_ci /* HV_DEVICE_TYPE_ACPI */ 74962306a36Sopenharmony_ci struct { 75062306a36Sopenharmony_ci u32 input_mapping_base; 75162306a36Sopenharmony_ci u32 input_mapping_count:30; 75262306a36Sopenharmony_ci u32 device_type:2; 75362306a36Sopenharmony_ci } acpi; 75462306a36Sopenharmony_ci} __packed; 75562306a36Sopenharmony_ci 75662306a36Sopenharmony_cienum hv_interrupt_trigger_mode { 75762306a36Sopenharmony_ci HV_INTERRUPT_TRIGGER_MODE_EDGE = 0, 75862306a36Sopenharmony_ci HV_INTERRUPT_TRIGGER_MODE_LEVEL = 1, 75962306a36Sopenharmony_ci}; 76062306a36Sopenharmony_ci 76162306a36Sopenharmony_cistruct hv_device_interrupt_descriptor { 76262306a36Sopenharmony_ci u32 interrupt_type; 76362306a36Sopenharmony_ci u32 trigger_mode; 76462306a36Sopenharmony_ci u32 vector_count; 76562306a36Sopenharmony_ci u32 reserved; 76662306a36Sopenharmony_ci struct hv_device_interrupt_target target; 76762306a36Sopenharmony_ci} __packed; 76862306a36Sopenharmony_ci 76962306a36Sopenharmony_cistruct hv_input_map_device_interrupt { 77062306a36Sopenharmony_ci u64 partition_id; 77162306a36Sopenharmony_ci u64 device_id; 77262306a36Sopenharmony_ci u64 flags; 77362306a36Sopenharmony_ci struct hv_interrupt_entry logical_interrupt_entry; 77462306a36Sopenharmony_ci struct hv_device_interrupt_descriptor interrupt_descriptor; 77562306a36Sopenharmony_ci} __packed; 77662306a36Sopenharmony_ci 77762306a36Sopenharmony_cistruct hv_output_map_device_interrupt { 77862306a36Sopenharmony_ci struct hv_interrupt_entry interrupt_entry; 77962306a36Sopenharmony_ci} __packed; 78062306a36Sopenharmony_ci 78162306a36Sopenharmony_cistruct hv_input_unmap_device_interrupt { 78262306a36Sopenharmony_ci u64 partition_id; 78362306a36Sopenharmony_ci u64 device_id; 78462306a36Sopenharmony_ci struct hv_interrupt_entry interrupt_entry; 78562306a36Sopenharmony_ci} __packed; 78662306a36Sopenharmony_ci 78762306a36Sopenharmony_ci#define HV_SOURCE_SHADOW_NONE 0x0 78862306a36Sopenharmony_ci#define HV_SOURCE_SHADOW_BRIDGE_BUS_RANGE 0x1 78962306a36Sopenharmony_ci 79062306a36Sopenharmony_ci/* 79162306a36Sopenharmony_ci * The whole argument should fit in a page to be able to pass to the hypervisor 79262306a36Sopenharmony_ci * in one hypercall. 79362306a36Sopenharmony_ci */ 79462306a36Sopenharmony_ci#define HV_MEMORY_HINT_MAX_GPA_PAGE_RANGES \ 79562306a36Sopenharmony_ci ((HV_HYP_PAGE_SIZE - sizeof(struct hv_memory_hint)) / \ 79662306a36Sopenharmony_ci sizeof(union hv_gpa_page_range)) 79762306a36Sopenharmony_ci 79862306a36Sopenharmony_ci/* HvExtCallMemoryHeatHint hypercall */ 79962306a36Sopenharmony_ci#define HV_EXT_MEMORY_HEAT_HINT_TYPE_COLD_DISCARD 2 80062306a36Sopenharmony_cistruct hv_memory_hint { 80162306a36Sopenharmony_ci u64 type:2; 80262306a36Sopenharmony_ci u64 reserved:62; 80362306a36Sopenharmony_ci union hv_gpa_page_range ranges[]; 80462306a36Sopenharmony_ci} __packed; 80562306a36Sopenharmony_ci 80662306a36Sopenharmony_ci/* Data structures for HVCALL_MMIO_READ and HVCALL_MMIO_WRITE */ 80762306a36Sopenharmony_ci#define HV_HYPERCALL_MMIO_MAX_DATA_LENGTH 64 80862306a36Sopenharmony_ci 80962306a36Sopenharmony_cistruct hv_mmio_read_input { 81062306a36Sopenharmony_ci u64 gpa; 81162306a36Sopenharmony_ci u32 size; 81262306a36Sopenharmony_ci u32 reserved; 81362306a36Sopenharmony_ci} __packed; 81462306a36Sopenharmony_ci 81562306a36Sopenharmony_cistruct hv_mmio_read_output { 81662306a36Sopenharmony_ci u8 data[HV_HYPERCALL_MMIO_MAX_DATA_LENGTH]; 81762306a36Sopenharmony_ci} __packed; 81862306a36Sopenharmony_ci 81962306a36Sopenharmony_cistruct hv_mmio_write_input { 82062306a36Sopenharmony_ci u64 gpa; 82162306a36Sopenharmony_ci u32 size; 82262306a36Sopenharmony_ci u32 reserved; 82362306a36Sopenharmony_ci u8 data[HV_HYPERCALL_MMIO_MAX_DATA_LENGTH]; 82462306a36Sopenharmony_ci} __packed; 82562306a36Sopenharmony_ci 82662306a36Sopenharmony_ci#endif 827