1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 /* 4 * This file contains definitions from Hyper-V Hypervisor Top-Level Functional 5 * Specification (TLFS): 6 * https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs 7 */ 8 9 #ifndef _ASM_GENERIC_HYPERV_TLFS_H 10 #define _ASM_GENERIC_HYPERV_TLFS_H 11 12 #include <linux/types.h> 13 #include <linux/bits.h> 14 #include <linux/time64.h> 15 16 /* 17 * While not explicitly listed in the TLFS, Hyper-V always runs with a page size 18 * of 4096. These definitions are used when communicating with Hyper-V using 19 * guest physical pages and guest physical page addresses, since the guest page 20 * size may not be 4096 on all architectures. 21 */ 22 #define HV_HYP_PAGE_SHIFT 12 23 #define HV_HYP_PAGE_SIZE BIT(HV_HYP_PAGE_SHIFT) 24 #define HV_HYP_PAGE_MASK (~(HV_HYP_PAGE_SIZE - 1)) 25 26 /* 27 * Hyper-V provides two categories of flags relevant to guest VMs. The 28 * "Features" category indicates specific functionality that is available 29 * to guests on this particular instance of Hyper-V. The "Features" 30 * are presented in four groups, each of which is 32 bits. The group A 31 * and B definitions are common across architectures and are listed here. 32 * However, not all flags are relevant on all architectures. 33 * 34 * Groups C and D vary across architectures and are listed in the 35 * architecture specific portion of hyperv-tlfs.h. Some of these flags exist 36 * on multiple architectures, but the bit positions are different so they 37 * cannot appear in the generic portion of hyperv-tlfs.h. 38 * 39 * The "Enlightenments" category provides recommendations on whether to use 40 * specific enlightenments that are available. The Enlighenments are a single 41 * group of 32 bits, but they vary across architectures and are listed in 42 * the architecture specific portion of hyperv-tlfs.h. 43 */ 44 45 /* 46 * Group A Features. 47 */ 48 49 /* VP Runtime register available */ 50 #define HV_MSR_VP_RUNTIME_AVAILABLE BIT(0) 51 /* Partition Reference Counter available*/ 52 #define HV_MSR_TIME_REF_COUNT_AVAILABLE BIT(1) 53 /* Basic SynIC register available */ 54 #define HV_MSR_SYNIC_AVAILABLE BIT(2) 55 /* Synthetic Timer registers available */ 56 #define HV_MSR_SYNTIMER_AVAILABLE BIT(3) 57 /* Virtual APIC assist and VP assist page registers available */ 58 #define HV_MSR_APIC_ACCESS_AVAILABLE BIT(4) 59 /* Hypercall and Guest OS ID registers available*/ 60 #define HV_MSR_HYPERCALL_AVAILABLE BIT(5) 61 /* Access virtual processor index register available*/ 62 #define HV_MSR_VP_INDEX_AVAILABLE BIT(6) 63 /* Virtual system reset register available*/ 64 #define HV_MSR_RESET_AVAILABLE BIT(7) 65 /* Access statistics page registers available */ 66 #define HV_MSR_STAT_PAGES_AVAILABLE BIT(8) 67 /* Partition reference TSC register is available */ 68 #define HV_MSR_REFERENCE_TSC_AVAILABLE BIT(9) 69 /* Partition Guest IDLE register is available */ 70 #define HV_MSR_GUEST_IDLE_AVAILABLE BIT(10) 71 /* Partition local APIC and TSC frequency registers available */ 72 #define HV_ACCESS_FREQUENCY_MSRS BIT(11) 73 /* AccessReenlightenmentControls privilege */ 74 #define HV_ACCESS_REENLIGHTENMENT BIT(13) 75 /* AccessTscInvariantControls privilege */ 76 #define HV_ACCESS_TSC_INVARIANT BIT(15) 77 78 /* 79 * Group B features. 80 */ 81 #define HV_CREATE_PARTITIONS BIT(0) 82 #define HV_ACCESS_PARTITION_ID BIT(1) 83 #define HV_ACCESS_MEMORY_POOL BIT(2) 84 #define HV_ADJUST_MESSAGE_BUFFERS BIT(3) 85 #define HV_POST_MESSAGES BIT(4) 86 #define HV_SIGNAL_EVENTS BIT(5) 87 #define HV_CREATE_PORT BIT(6) 88 #define HV_CONNECT_PORT BIT(7) 89 #define HV_ACCESS_STATS BIT(8) 90 #define HV_DEBUGGING BIT(11) 91 #define HV_CPU_MANAGEMENT BIT(12) 92 #define HV_ENABLE_EXTENDED_HYPERCALLS BIT(20) 93 #define HV_ISOLATION BIT(22) 94 95 /* 96 * TSC page layout. 97 */ 98 struct ms_hyperv_tsc_page { 99 volatile u32 tsc_sequence; 100 u32 reserved1; 101 volatile u64 tsc_scale; 102 volatile s64 tsc_offset; 103 } __packed; 104 105 union hv_reference_tsc_msr { 106 u64 as_uint64; 107 struct { 108 u64 enable:1; 109 u64 reserved:11; 110 u64 pfn:52; 111 } __packed; 112 }; 113 114 /* 115 * The guest OS needs to register the guest ID with the hypervisor. 116 * The guest ID is a 64 bit entity and the structure of this ID is 117 * specified in the Hyper-V specification: 118 * 119 * msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx 120 * 121 * While the current guideline does not specify how Linux guest ID(s) 122 * need to be generated, our plan is to publish the guidelines for 123 * Linux and other guest operating systems that currently are hosted 124 * on Hyper-V. The implementation here conforms to this yet 125 * unpublished guidelines. 126 * 127 * 128 * Bit(s) 129 * 63 - Indicates if the OS is Open Source or not; 1 is Open Source 130 * 62:56 - Os Type; Linux is 0x100 131 * 55:48 - Distro specific identification 132 * 47:16 - Linux kernel version number 133 * 15:0 - Distro specific identification 134 * 135 * 136 */ 137 138 #define HV_LINUX_VENDOR_ID 0x8100 139 140 /* 141 * Crash notification flags. 142 */ 143 #define HV_CRASH_CTL_CRASH_NOTIFY_MSG BIT_ULL(62) 144 #define HV_CRASH_CTL_CRASH_NOTIFY BIT_ULL(63) 145 146 /* Declare the various hypercall operations. */ 147 #define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE 0x0002 148 #define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST 0x0003 149 #define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008 150 #define HVCALL_SEND_IPI 0x000b 151 #define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX 0x0013 152 #define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX 0x0014 153 #define HVCALL_SEND_IPI_EX 0x0015 154 #define HVCALL_GET_PARTITION_ID 0x0046 155 #define HVCALL_DEPOSIT_MEMORY 0x0048 156 #define HVCALL_CREATE_VP 0x004e 157 #define HVCALL_GET_VP_REGISTERS 0x0050 158 #define HVCALL_SET_VP_REGISTERS 0x0051 159 #define HVCALL_POST_MESSAGE 0x005c 160 #define HVCALL_SIGNAL_EVENT 0x005d 161 #define HVCALL_POST_DEBUG_DATA 0x0069 162 #define HVCALL_RETRIEVE_DEBUG_DATA 0x006a 163 #define HVCALL_RESET_DEBUG_SESSION 0x006b 164 #define HVCALL_ADD_LOGICAL_PROCESSOR 0x0076 165 #define HVCALL_MAP_DEVICE_INTERRUPT 0x007c 166 #define HVCALL_UNMAP_DEVICE_INTERRUPT 0x007d 167 #define HVCALL_RETARGET_INTERRUPT 0x007e 168 #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af 169 #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST 0x00b0 170 #define HVCALL_MODIFY_SPARSE_GPA_PAGE_HOST_VISIBILITY 0x00db 171 172 /* Extended hypercalls */ 173 #define HV_EXT_CALL_QUERY_CAPABILITIES 0x8001 174 #define HV_EXT_CALL_MEMORY_HEAT_HINT 0x8003 175 176 #define HV_FLUSH_ALL_PROCESSORS BIT(0) 177 #define HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES BIT(1) 178 #define HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY BIT(2) 179 #define HV_FLUSH_USE_EXTENDED_RANGE_FORMAT BIT(3) 180 181 /* Extended capability bits */ 182 #define HV_EXT_CAPABILITY_MEMORY_COLD_DISCARD_HINT BIT(8) 183 184 enum HV_GENERIC_SET_FORMAT { 185 HV_GENERIC_SET_SPARSE_4K, 186 HV_GENERIC_SET_ALL, 187 }; 188 189 #define HV_PARTITION_ID_SELF ((u64)-1) 190 #define HV_VP_INDEX_SELF ((u32)-2) 191 192 #define HV_HYPERCALL_RESULT_MASK GENMASK_ULL(15, 0) 193 #define HV_HYPERCALL_FAST_BIT BIT(16) 194 #define HV_HYPERCALL_VARHEAD_OFFSET 17 195 #define HV_HYPERCALL_VARHEAD_MASK GENMASK_ULL(26, 17) 196 #define HV_HYPERCALL_RSVD0_MASK GENMASK_ULL(31, 27) 197 #define HV_HYPERCALL_NESTED BIT_ULL(31) 198 #define HV_HYPERCALL_REP_COMP_OFFSET 32 199 #define HV_HYPERCALL_REP_COMP_1 BIT_ULL(32) 200 #define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32) 201 #define HV_HYPERCALL_RSVD1_MASK GENMASK_ULL(47, 44) 202 #define HV_HYPERCALL_REP_START_OFFSET 48 203 #define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48) 204 #define HV_HYPERCALL_RSVD2_MASK GENMASK_ULL(63, 60) 205 #define HV_HYPERCALL_RSVD_MASK (HV_HYPERCALL_RSVD0_MASK | \ 206 HV_HYPERCALL_RSVD1_MASK | \ 207 HV_HYPERCALL_RSVD2_MASK) 208 209 /* hypercall status code */ 210 #define HV_STATUS_SUCCESS 0 211 #define HV_STATUS_INVALID_HYPERCALL_CODE 2 212 #define HV_STATUS_INVALID_HYPERCALL_INPUT 3 213 #define HV_STATUS_INVALID_ALIGNMENT 4 214 #define HV_STATUS_INVALID_PARAMETER 5 215 #define HV_STATUS_ACCESS_DENIED 6 216 #define HV_STATUS_OPERATION_DENIED 8 217 #define HV_STATUS_INSUFFICIENT_MEMORY 11 218 #define HV_STATUS_INVALID_PORT_ID 17 219 #define HV_STATUS_INVALID_CONNECTION_ID 18 220 #define HV_STATUS_INSUFFICIENT_BUFFERS 19 221 222 /* 223 * The Hyper-V TimeRefCount register and the TSC 224 * page provide a guest VM clock with 100ns tick rate 225 */ 226 #define HV_CLOCK_HZ (NSEC_PER_SEC/100) 227 228 /* Define the number of synthetic interrupt sources. */ 229 #define HV_SYNIC_SINT_COUNT (16) 230 /* Define the expected SynIC version. */ 231 #define HV_SYNIC_VERSION_1 (0x1) 232 /* Valid SynIC vectors are 16-255. */ 233 #define HV_SYNIC_FIRST_VALID_VECTOR (16) 234 235 #define HV_SYNIC_CONTROL_ENABLE (1ULL << 0) 236 #define HV_SYNIC_SIMP_ENABLE (1ULL << 0) 237 #define HV_SYNIC_SIEFP_ENABLE (1ULL << 0) 238 #define HV_SYNIC_SINT_MASKED (1ULL << 16) 239 #define HV_SYNIC_SINT_AUTO_EOI (1ULL << 17) 240 #define HV_SYNIC_SINT_VECTOR_MASK (0xFF) 241 242 #define HV_SYNIC_STIMER_COUNT (4) 243 244 /* Define synthetic interrupt controller message constants. */ 245 #define HV_MESSAGE_SIZE (256) 246 #define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240) 247 #define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30) 248 249 /* 250 * Define hypervisor message types. Some of the message types 251 * are x86/x64 specific, but there's no good way to separate 252 * them out into the arch-specific version of hyperv-tlfs.h 253 * because C doesn't provide a way to extend enum types. 254 * Keeping them all in the arch neutral hyperv-tlfs.h seems 255 * the least messy compromise. 256 */ 257 enum hv_message_type { 258 HVMSG_NONE = 0x00000000, 259 260 /* Memory access messages. */ 261 HVMSG_UNMAPPED_GPA = 0x80000000, 262 HVMSG_GPA_INTERCEPT = 0x80000001, 263 264 /* Timer notification messages. */ 265 HVMSG_TIMER_EXPIRED = 0x80000010, 266 267 /* Error messages. */ 268 HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020, 269 HVMSG_UNRECOVERABLE_EXCEPTION = 0x80000021, 270 HVMSG_UNSUPPORTED_FEATURE = 0x80000022, 271 272 /* Trace buffer complete messages. */ 273 HVMSG_EVENTLOG_BUFFERCOMPLETE = 0x80000040, 274 275 /* Platform-specific processor intercept messages. */ 276 HVMSG_X64_IOPORT_INTERCEPT = 0x80010000, 277 HVMSG_X64_MSR_INTERCEPT = 0x80010001, 278 HVMSG_X64_CPUID_INTERCEPT = 0x80010002, 279 HVMSG_X64_EXCEPTION_INTERCEPT = 0x80010003, 280 HVMSG_X64_APIC_EOI = 0x80010004, 281 HVMSG_X64_LEGACY_FP_ERROR = 0x80010005 282 }; 283 284 /* Define synthetic interrupt controller message flags. */ 285 union hv_message_flags { 286 __u8 asu8; 287 struct { 288 __u8 msg_pending:1; 289 __u8 reserved:7; 290 } __packed; 291 }; 292 293 /* Define port identifier type. */ 294 union hv_port_id { 295 __u32 asu32; 296 struct { 297 __u32 id:24; 298 __u32 reserved:8; 299 } __packed u; 300 }; 301 302 /* Define synthetic interrupt controller message header. */ 303 struct hv_message_header { 304 __u32 message_type; 305 __u8 payload_size; 306 union hv_message_flags message_flags; 307 __u8 reserved[2]; 308 union { 309 __u64 sender; 310 union hv_port_id port; 311 }; 312 } __packed; 313 314 /* Define synthetic interrupt controller message format. */ 315 struct hv_message { 316 struct hv_message_header header; 317 union { 318 __u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT]; 319 } u; 320 } __packed; 321 322 /* Define the synthetic interrupt message page layout. */ 323 struct hv_message_page { 324 struct hv_message sint_message[HV_SYNIC_SINT_COUNT]; 325 } __packed; 326 327 /* Define timer message payload structure. */ 328 struct hv_timer_message_payload { 329 __u32 timer_index; 330 __u32 reserved; 331 __u64 expiration_time; /* When the timer expired */ 332 __u64 delivery_time; /* When the message was delivered */ 333 } __packed; 334 335 336 /* Define synthetic interrupt controller flag constants. */ 337 #define HV_EVENT_FLAGS_COUNT (256 * 8) 338 #define HV_EVENT_FLAGS_LONG_COUNT (256 / sizeof(unsigned long)) 339 340 /* 341 * Synthetic timer configuration. 342 */ 343 union hv_stimer_config { 344 u64 as_uint64; 345 struct { 346 u64 enable:1; 347 u64 periodic:1; 348 u64 lazy:1; 349 u64 auto_enable:1; 350 u64 apic_vector:8; 351 u64 direct_mode:1; 352 u64 reserved_z0:3; 353 u64 sintx:4; 354 u64 reserved_z1:44; 355 } __packed; 356 }; 357 358 359 /* Define the synthetic interrupt controller event flags format. */ 360 union hv_synic_event_flags { 361 unsigned long flags[HV_EVENT_FLAGS_LONG_COUNT]; 362 }; 363 364 /* Define SynIC control register. */ 365 union hv_synic_scontrol { 366 u64 as_uint64; 367 struct { 368 u64 enable:1; 369 u64 reserved:63; 370 } __packed; 371 }; 372 373 /* Define synthetic interrupt source. */ 374 union hv_synic_sint { 375 u64 as_uint64; 376 struct { 377 u64 vector:8; 378 u64 reserved1:8; 379 u64 masked:1; 380 u64 auto_eoi:1; 381 u64 polling:1; 382 u64 reserved2:45; 383 } __packed; 384 }; 385 386 /* Define the format of the SIMP register */ 387 union hv_synic_simp { 388 u64 as_uint64; 389 struct { 390 u64 simp_enabled:1; 391 u64 preserved:11; 392 u64 base_simp_gpa:52; 393 } __packed; 394 }; 395 396 /* Define the format of the SIEFP register */ 397 union hv_synic_siefp { 398 u64 as_uint64; 399 struct { 400 u64 siefp_enabled:1; 401 u64 preserved:11; 402 u64 base_siefp_gpa:52; 403 } __packed; 404 }; 405 406 struct hv_vpset { 407 u64 format; 408 u64 valid_bank_mask; 409 u64 bank_contents[]; 410 } __packed; 411 412 /* The maximum number of sparse vCPU banks which can be encoded by 'struct hv_vpset' */ 413 #define HV_MAX_SPARSE_VCPU_BANKS (64) 414 /* The number of vCPUs in one sparse bank */ 415 #define HV_VCPUS_PER_SPARSE_BANK (64) 416 417 /* HvCallSendSyntheticClusterIpi hypercall */ 418 struct hv_send_ipi { 419 u32 vector; 420 u32 reserved; 421 u64 cpu_mask; 422 } __packed; 423 424 /* HvCallSendSyntheticClusterIpiEx hypercall */ 425 struct hv_send_ipi_ex { 426 u32 vector; 427 u32 reserved; 428 struct hv_vpset vp_set; 429 } __packed; 430 431 /* HvFlushGuestPhysicalAddressSpace hypercalls */ 432 struct hv_guest_mapping_flush { 433 u64 address_space; 434 u64 flags; 435 } __packed; 436 437 /* 438 * HV_MAX_FLUSH_PAGES = "additional_pages" + 1. It's limited 439 * by the bitwidth of "additional_pages" in union hv_gpa_page_range. 440 */ 441 #define HV_MAX_FLUSH_PAGES (2048) 442 #define HV_GPA_PAGE_RANGE_PAGE_SIZE_2MB 0 443 #define HV_GPA_PAGE_RANGE_PAGE_SIZE_1GB 1 444 445 /* HvFlushGuestPhysicalAddressList, HvExtCallMemoryHeatHint hypercall */ 446 union hv_gpa_page_range { 447 u64 address_space; 448 struct { 449 u64 additional_pages:11; 450 u64 largepage:1; 451 u64 basepfn:52; 452 } page; 453 struct { 454 u64 reserved:12; 455 u64 page_size:1; 456 u64 reserved1:8; 457 u64 base_large_pfn:43; 458 }; 459 }; 460 461 /* 462 * All input flush parameters should be in single page. The max flush 463 * count is equal with how many entries of union hv_gpa_page_range can 464 * be populated into the input parameter page. 465 */ 466 #define HV_MAX_FLUSH_REP_COUNT ((HV_HYP_PAGE_SIZE - 2 * sizeof(u64)) / \ 467 sizeof(union hv_gpa_page_range)) 468 469 struct hv_guest_mapping_flush_list { 470 u64 address_space; 471 u64 flags; 472 union hv_gpa_page_range gpa_list[HV_MAX_FLUSH_REP_COUNT]; 473 }; 474 475 /* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */ 476 struct hv_tlb_flush { 477 u64 address_space; 478 u64 flags; 479 u64 processor_mask; 480 u64 gva_list[]; 481 } __packed; 482 483 /* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */ 484 struct hv_tlb_flush_ex { 485 u64 address_space; 486 u64 flags; 487 struct hv_vpset hv_vp_set; 488 u64 gva_list[]; 489 } __packed; 490 491 /* HvGetPartitionId hypercall (output only) */ 492 struct hv_get_partition_id { 493 u64 partition_id; 494 } __packed; 495 496 /* HvDepositMemory hypercall */ 497 struct hv_deposit_memory { 498 u64 partition_id; 499 u64 gpa_page_list[]; 500 } __packed; 501 502 struct hv_proximity_domain_flags { 503 u32 proximity_preferred : 1; 504 u32 reserved : 30; 505 u32 proximity_info_valid : 1; 506 } __packed; 507 508 /* Not a union in windows but useful for zeroing */ 509 union hv_proximity_domain_info { 510 struct { 511 u32 domain_id; 512 struct hv_proximity_domain_flags flags; 513 }; 514 u64 as_uint64; 515 } __packed; 516 517 struct hv_lp_startup_status { 518 u64 hv_status; 519 u64 substatus1; 520 u64 substatus2; 521 u64 substatus3; 522 u64 substatus4; 523 u64 substatus5; 524 u64 substatus6; 525 } __packed; 526 527 /* HvAddLogicalProcessor hypercall */ 528 struct hv_add_logical_processor_in { 529 u32 lp_index; 530 u32 apic_id; 531 union hv_proximity_domain_info proximity_domain_info; 532 u64 flags; 533 } __packed; 534 535 struct hv_add_logical_processor_out { 536 struct hv_lp_startup_status startup_status; 537 } __packed; 538 539 enum HV_SUBNODE_TYPE 540 { 541 HvSubnodeAny = 0, 542 HvSubnodeSocket = 1, 543 HvSubnodeAmdNode = 2, 544 HvSubnodeL3 = 3, 545 HvSubnodeCount = 4, 546 HvSubnodeInvalid = -1 547 }; 548 549 /* HvCreateVp hypercall */ 550 struct hv_create_vp { 551 u64 partition_id; 552 u32 vp_index; 553 u8 padding[3]; 554 u8 subnode_type; 555 u64 subnode_id; 556 union hv_proximity_domain_info proximity_domain_info; 557 u64 flags; 558 } __packed; 559 560 enum hv_interrupt_source { 561 HV_INTERRUPT_SOURCE_MSI = 1, /* MSI and MSI-X */ 562 HV_INTERRUPT_SOURCE_IOAPIC, 563 }; 564 565 union hv_ioapic_rte { 566 u64 as_uint64; 567 568 struct { 569 u32 vector:8; 570 u32 delivery_mode:3; 571 u32 destination_mode:1; 572 u32 delivery_status:1; 573 u32 interrupt_polarity:1; 574 u32 remote_irr:1; 575 u32 trigger_mode:1; 576 u32 interrupt_mask:1; 577 u32 reserved1:15; 578 579 u32 reserved2:24; 580 u32 destination_id:8; 581 }; 582 583 struct { 584 u32 low_uint32; 585 u32 high_uint32; 586 }; 587 } __packed; 588 589 struct hv_interrupt_entry { 590 u32 source; 591 u32 reserved1; 592 union { 593 union hv_msi_entry msi_entry; 594 union hv_ioapic_rte ioapic_rte; 595 }; 596 } __packed; 597 598 /* 599 * flags for hv_device_interrupt_target.flags 600 */ 601 #define HV_DEVICE_INTERRUPT_TARGET_MULTICAST 1 602 #define HV_DEVICE_INTERRUPT_TARGET_PROCESSOR_SET 2 603 604 struct hv_device_interrupt_target { 605 u32 vector; 606 u32 flags; 607 union { 608 u64 vp_mask; 609 struct hv_vpset vp_set; 610 }; 611 } __packed; 612 613 struct hv_retarget_device_interrupt { 614 u64 partition_id; /* use "self" */ 615 u64 device_id; 616 struct hv_interrupt_entry int_entry; 617 u64 reserved2; 618 struct hv_device_interrupt_target int_target; 619 } __packed __aligned(8); 620 621 622 /* HvGetVpRegisters hypercall input with variable size reg name list*/ 623 struct hv_get_vp_registers_input { 624 struct { 625 u64 partitionid; 626 u32 vpindex; 627 u8 inputvtl; 628 u8 padding[3]; 629 } header; 630 struct input { 631 u32 name0; 632 u32 name1; 633 } element[]; 634 } __packed; 635 636 637 /* HvGetVpRegisters returns an array of these output elements */ 638 struct hv_get_vp_registers_output { 639 union { 640 struct { 641 u32 a; 642 u32 b; 643 u32 c; 644 u32 d; 645 } as32 __packed; 646 struct { 647 u64 low; 648 u64 high; 649 } as64 __packed; 650 }; 651 }; 652 653 /* HvSetVpRegisters hypercall with variable size reg name/value list*/ 654 struct hv_set_vp_registers_input { 655 struct { 656 u64 partitionid; 657 u32 vpindex; 658 u8 inputvtl; 659 u8 padding[3]; 660 } header; 661 struct { 662 u32 name; 663 u32 padding1; 664 u64 padding2; 665 u64 valuelow; 666 u64 valuehigh; 667 } element[]; 668 } __packed; 669 670 enum hv_device_type { 671 HV_DEVICE_TYPE_LOGICAL = 0, 672 HV_DEVICE_TYPE_PCI = 1, 673 HV_DEVICE_TYPE_IOAPIC = 2, 674 HV_DEVICE_TYPE_ACPI = 3, 675 }; 676 677 typedef u16 hv_pci_rid; 678 typedef u16 hv_pci_segment; 679 typedef u64 hv_logical_device_id; 680 union hv_pci_bdf { 681 u16 as_uint16; 682 683 struct { 684 u8 function:3; 685 u8 device:5; 686 u8 bus; 687 }; 688 } __packed; 689 690 union hv_pci_bus_range { 691 u16 as_uint16; 692 693 struct { 694 u8 subordinate_bus; 695 u8 secondary_bus; 696 }; 697 } __packed; 698 699 union hv_device_id { 700 u64 as_uint64; 701 702 struct { 703 u64 reserved0:62; 704 u64 device_type:2; 705 }; 706 707 /* HV_DEVICE_TYPE_LOGICAL */ 708 struct { 709 u64 id:62; 710 u64 device_type:2; 711 } logical; 712 713 /* HV_DEVICE_TYPE_PCI */ 714 struct { 715 union { 716 hv_pci_rid rid; 717 union hv_pci_bdf bdf; 718 }; 719 720 hv_pci_segment segment; 721 union hv_pci_bus_range shadow_bus_range; 722 723 u16 phantom_function_bits:2; 724 u16 source_shadow:1; 725 726 u16 rsvdz0:11; 727 u16 device_type:2; 728 } pci; 729 730 /* HV_DEVICE_TYPE_IOAPIC */ 731 struct { 732 u8 ioapic_id; 733 u8 rsvdz0; 734 u16 rsvdz1; 735 u16 rsvdz2; 736 737 u16 rsvdz3:14; 738 u16 device_type:2; 739 } ioapic; 740 741 /* HV_DEVICE_TYPE_ACPI */ 742 struct { 743 u32 input_mapping_base; 744 u32 input_mapping_count:30; 745 u32 device_type:2; 746 } acpi; 747 } __packed; 748 749 enum hv_interrupt_trigger_mode { 750 HV_INTERRUPT_TRIGGER_MODE_EDGE = 0, 751 HV_INTERRUPT_TRIGGER_MODE_LEVEL = 1, 752 }; 753 754 struct hv_device_interrupt_descriptor { 755 u32 interrupt_type; 756 u32 trigger_mode; 757 u32 vector_count; 758 u32 reserved; 759 struct hv_device_interrupt_target target; 760 } __packed; 761 762 struct hv_input_map_device_interrupt { 763 u64 partition_id; 764 u64 device_id; 765 u64 flags; 766 struct hv_interrupt_entry logical_interrupt_entry; 767 struct hv_device_interrupt_descriptor interrupt_descriptor; 768 } __packed; 769 770 struct hv_output_map_device_interrupt { 771 struct hv_interrupt_entry interrupt_entry; 772 } __packed; 773 774 struct hv_input_unmap_device_interrupt { 775 u64 partition_id; 776 u64 device_id; 777 struct hv_interrupt_entry interrupt_entry; 778 } __packed; 779 780 #define HV_SOURCE_SHADOW_NONE 0x0 781 #define HV_SOURCE_SHADOW_BRIDGE_BUS_RANGE 0x1 782 783 /* 784 * The whole argument should fit in a page to be able to pass to the hypervisor 785 * in one hypercall. 786 */ 787 #define HV_MEMORY_HINT_MAX_GPA_PAGE_RANGES \ 788 ((HV_HYP_PAGE_SIZE - sizeof(struct hv_memory_hint)) / \ 789 sizeof(union hv_gpa_page_range)) 790 791 /* HvExtCallMemoryHeatHint hypercall */ 792 #define HV_EXT_MEMORY_HEAT_HINT_TYPE_COLD_DISCARD 2 793 struct hv_memory_hint { 794 u64 type:2; 795 u64 reserved:62; 796 union hv_gpa_page_range ranges[]; 797 } __packed; 798 799 #endif 800