Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

hyperv: Add definitions for root partition driver to hv headers

A few additional definitions are required for the mshv driver code
(to follow). Introduce those here and clean up a little bit while
at it.

Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Reviewed-by: Roman Kisel <romank@linux.microsoft.com>
Reviewed-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Reviewed-by: Tianyu Lan <tiala@microsoft.com>
Link: https://lore.kernel.org/r/1741980536-3865-10-git-send-email-nunodasneves@linux.microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <1741980536-3865-10-git-send-email-nunodasneves@linux.microsoft.com>

authored by

Nuno Das Neves and committed by
Wei Liu
0bd921a4 e2575ffe

+284 -11
+67 -5
include/hyperv/hvgdk_mini.h
··· 13 13 u64 high_part; 14 14 } __packed; 15 15 16 - /* NOTE: when adding below, update hv_status_to_string() */ 16 + /* NOTE: when adding below, update hv_result_to_string() */ 17 17 #define HV_STATUS_SUCCESS 0x0 18 18 #define HV_STATUS_INVALID_HYPERCALL_CODE 0x2 19 19 #define HV_STATUS_INVALID_HYPERCALL_INPUT 0x3 ··· 51 51 #define HV_HYP_PAGE_SHIFT 12 52 52 #define HV_HYP_PAGE_SIZE BIT(HV_HYP_PAGE_SHIFT) 53 53 #define HV_HYP_PAGE_MASK (~(HV_HYP_PAGE_SIZE - 1)) 54 + #define HV_HYP_LARGE_PAGE_SHIFT 21 54 55 55 56 #define HV_PARTITION_ID_INVALID ((u64)0) 56 57 #define HV_PARTITION_ID_SELF ((u64)-1) ··· 375 374 #define HV_SHARED_GPA_BOUNDARY_ACTIVE BIT(5) 376 375 #define HV_SHARED_GPA_BOUNDARY_BITS GENMASK(11, 6) 377 376 377 + /* HYPERV_CPUID_FEATURES.ECX bits. */ 378 + #define HV_VP_DISPATCH_INTERRUPT_INJECTION_AVAILABLE BIT(9) 379 + #define HV_VP_GHCB_ROOT_MAPPING_AVAILABLE BIT(10) 380 + 378 381 enum hv_isolation_type { 379 382 HV_ISOLATION_TYPE_NONE = 0, /* HV_PARTITION_ISOLATION_TYPE_NONE */ 380 383 HV_ISOLATION_TYPE_VBS = 1, ··· 441 436 #define HVCALL_WITHDRAW_MEMORY 0x0049 442 437 #define HVCALL_MAP_GPA_PAGES 0x004b 443 438 #define HVCALL_UNMAP_GPA_PAGES 0x004c 439 + #define HVCALL_INSTALL_INTERCEPT 0x004d 444 440 #define HVCALL_CREATE_VP 0x004e 445 441 #define HVCALL_DELETE_VP 0x004f 446 442 #define HVCALL_GET_VP_REGISTERS 0x0050 447 443 #define HVCALL_SET_VP_REGISTERS 0x0051 444 + #define HVCALL_TRANSLATE_VIRTUAL_ADDRESS 0x0052 445 + #define HVCALL_CLEAR_VIRTUAL_INTERRUPT 0x0056 448 446 #define HVCALL_DELETE_PORT 0x0058 449 447 #define HVCALL_DISCONNECT_PORT 0x005b 450 448 #define HVCALL_POST_MESSAGE 0x005c ··· 455 447 #define HVCALL_POST_DEBUG_DATA 0x0069 456 448 #define HVCALL_RETRIEVE_DEBUG_DATA 0x006a 457 449 #define HVCALL_RESET_DEBUG_SESSION 0x006b 450 + #define HVCALL_MAP_STATS_PAGE 0x006c 451 + #define HVCALL_UNMAP_STATS_PAGE 0x006d 458 452 #define HVCALL_ADD_LOGICAL_PROCESSOR 0x0076 459 453 #define HVCALL_GET_SYSTEM_PROPERTY 0x007b 460 454 #define HVCALL_MAP_DEVICE_INTERRUPT 0x007c 461 455 #define HVCALL_UNMAP_DEVICE_INTERRUPT 0x007d 462 456 #define HVCALL_RETARGET_INTERRUPT 0x007e 463 457 #define HVCALL_NOTIFY_PORT_RING_EMPTY 0x008b 458 + #define HVCALL_REGISTER_INTERCEPT_RESULT 0x0091 464 459 #define HVCALL_ASSERT_VIRTUAL_INTERRUPT 0x0094 465 460 #define HVCALL_CREATE_PORT 0x0095 466 461 #define HVCALL_CONNECT_PORT 0x0096 ··· 471 460 #define HVCALL_GET_VP_ID_FROM_APIC_ID 0x009a 472 461 #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af 473 462 #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST 0x00b0 463 + #define HVCALL_SIGNAL_EVENT_DIRECT 0x00c0 464 + #define HVCALL_POST_MESSAGE_DIRECT 0x00c1 474 465 #define HVCALL_DISPATCH_VP 0x00c2 466 + #define HVCALL_GET_GPA_PAGES_ACCESS_STATES 0x00c9 467 + #define HVCALL_ACQUIRE_SPARSE_SPA_PAGE_HOST_ACCESS 0x00d7 468 + #define HVCALL_RELEASE_SPARSE_SPA_PAGE_HOST_ACCESS 0x00d8 475 469 #define HVCALL_MODIFY_SPARSE_GPA_PAGE_HOST_VISIBILITY 0x00db 476 470 #define HVCALL_MAP_VP_STATE_PAGE 0x00e1 477 471 #define HVCALL_UNMAP_VP_STATE_PAGE 0x00e2 478 472 #define HVCALL_GET_VP_STATE 0x00e3 479 473 #define HVCALL_SET_VP_STATE 0x00e4 474 + #define HVCALL_GET_VP_CPUID_VALUES 0x00f4 480 475 #define HVCALL_MMIO_READ 0x0106 481 476 #define HVCALL_MMIO_WRITE 0x0107 482 477 ··· 792 775 793 776 /* Define timer message payload structure. */ 794 777 struct hv_timer_message_payload { 795 - __u32 timer_index; 796 - __u32 reserved; 797 - __u64 expiration_time; /* When the timer expired */ 798 - __u64 delivery_time; /* When the message was delivered */ 778 + u32 timer_index; 779 + u32 reserved; 780 + u64 expiration_time; /* When the timer expired */ 781 + u64 delivery_time; /* When the message was delivered */ 799 782 } __packed; 800 783 801 784 struct hv_x64_segment_register { ··· 823 806 u16 limit; 824 807 u64 base; 825 808 } __packed; 809 + 810 + #define HV_NORMAL_VTL 0 826 811 827 812 union hv_input_vtl { 828 813 u8 as_uint8; ··· 1343 1324 u64 reserved2; 1344 1325 struct hv_device_interrupt_target int_target; 1345 1326 } __packed __aligned(8); 1327 + 1328 + enum hv_intercept_type { 1329 + #if defined(CONFIG_X86) 1330 + HV_INTERCEPT_TYPE_X64_IO_PORT = 0x00000000, 1331 + HV_INTERCEPT_TYPE_X64_MSR = 0x00000001, 1332 + HV_INTERCEPT_TYPE_X64_CPUID = 0x00000002, 1333 + #endif 1334 + HV_INTERCEPT_TYPE_EXCEPTION = 0x00000003, 1335 + /* Used to be HV_INTERCEPT_TYPE_REGISTER */ 1336 + HV_INTERCEPT_TYPE_RESERVED0 = 0x00000004, 1337 + HV_INTERCEPT_TYPE_MMIO = 0x00000005, 1338 + #if defined(CONFIG_X86) 1339 + HV_INTERCEPT_TYPE_X64_GLOBAL_CPUID = 0x00000006, 1340 + HV_INTERCEPT_TYPE_X64_APIC_SMI = 0x00000007, 1341 + #endif 1342 + HV_INTERCEPT_TYPE_HYPERCALL = 0x00000008, 1343 + #if defined(CONFIG_X86) 1344 + HV_INTERCEPT_TYPE_X64_APIC_INIT_SIPI = 0x00000009, 1345 + HV_INTERCEPT_MC_UPDATE_PATCH_LEVEL_MSR_READ = 0x0000000A, 1346 + HV_INTERCEPT_TYPE_X64_APIC_WRITE = 0x0000000B, 1347 + HV_INTERCEPT_TYPE_X64_MSR_INDEX = 0x0000000C, 1348 + #endif 1349 + HV_INTERCEPT_TYPE_MAX, 1350 + HV_INTERCEPT_TYPE_INVALID = 0xFFFFFFFF, 1351 + }; 1352 + 1353 + union hv_intercept_parameters { 1354 + /* HV_INTERCEPT_PARAMETERS is defined to be an 8-byte field. */ 1355 + u64 as_uint64; 1356 + #if defined(CONFIG_X86) 1357 + /* HV_INTERCEPT_TYPE_X64_IO_PORT */ 1358 + u16 io_port; 1359 + /* HV_INTERCEPT_TYPE_X64_CPUID */ 1360 + u32 cpuid_index; 1361 + /* HV_INTERCEPT_TYPE_X64_APIC_WRITE */ 1362 + u32 apic_write_mask; 1363 + /* HV_INTERCEPT_TYPE_EXCEPTION */ 1364 + u16 exception_vector; 1365 + /* HV_INTERCEPT_TYPE_X64_MSR_INDEX */ 1366 + u32 msr_index; 1367 + #endif 1368 + /* N.B. Other intercept types do not have any parameters. */ 1369 + }; 1346 1370 1347 1371 /* Data structures for HVCALL_MMIO_READ and HVCALL_MMIO_WRITE */ 1348 1372 #define HV_HYPERCALL_MMIO_MAX_DATA_LENGTH 64
+126 -6
include/hyperv/hvhdk.h
··· 19 19 20 20 #define HV_VP_REGISTER_PAGE_VERSION_1 1u 21 21 22 + #define HV_VP_REGISTER_PAGE_MAX_VECTOR_COUNT 7 23 + 24 + union hv_vp_register_page_interrupt_vectors { 25 + u64 as_uint64; 26 + struct { 27 + u8 vector_count; 28 + u8 vector[HV_VP_REGISTER_PAGE_MAX_VECTOR_COUNT]; 29 + } __packed; 30 + }; 31 + 22 32 struct hv_vp_register_page { 23 33 u16 version; 24 34 u8 isvalid; 25 35 u8 rsvdz; 26 36 u32 dirty; 37 + 38 + #if IS_ENABLED(CONFIG_X86) 39 + 27 40 union { 28 41 struct { 29 42 /* General purpose registers ··· 108 95 union hv_x64_pending_interruption_register pending_interruption; 109 96 union hv_x64_interrupt_state_register interrupt_state; 110 97 u64 instruction_emulation_hints; 98 + u64 xfem; 99 + 100 + /* 101 + * Fields from this point are not included in the register page save chunk. 102 + * The reserved field is intended to maintain alignment for unsaved fields. 103 + */ 104 + u8 reserved1[0x100]; 105 + 106 + /* 107 + * Interrupts injected as part of HvCallDispatchVp. 108 + */ 109 + union hv_vp_register_page_interrupt_vectors interrupt_vectors; 110 + 111 + #elif IS_ENABLED(CONFIG_ARM64) 112 + /* Not yet supported in ARM */ 113 + #endif 111 114 } __packed; 112 115 113 116 #define HV_PARTITION_PROCESSOR_FEATURES_BANKS 2 ··· 328 299 #define HV_PARTITION_ISOLATION_HOST_TYPE_RESERVED 0x2 329 300 330 301 /* Note: Exo partition is enabled by default */ 331 - #define HV_PARTITION_CREATION_FLAG_EXO_PARTITION BIT(8) 332 - #define HV_PARTITION_CREATION_FLAG_LAPIC_ENABLED BIT(13) 333 - #define HV_PARTITION_CREATION_FLAG_INTERCEPT_MESSAGE_PAGE_ENABLED BIT(19) 334 - #define HV_PARTITION_CREATION_FLAG_X2APIC_CAPABLE BIT(22) 302 + #define HV_PARTITION_CREATION_FLAG_GPA_SUPER_PAGES_ENABLED BIT(4) 303 + #define HV_PARTITION_CREATION_FLAG_EXO_PARTITION BIT(8) 304 + #define HV_PARTITION_CREATION_FLAG_LAPIC_ENABLED BIT(13) 305 + #define HV_PARTITION_CREATION_FLAG_INTERCEPT_MESSAGE_PAGE_ENABLED BIT(19) 306 + #define HV_PARTITION_CREATION_FLAG_X2APIC_CAPABLE BIT(22) 335 307 336 308 struct hv_input_create_partition { 337 309 u64 flags; ··· 379 349 enum hv_vp_state_page_type { 380 350 HV_VP_STATE_PAGE_REGISTERS = 0, 381 351 HV_VP_STATE_PAGE_INTERCEPT_MESSAGE = 1, 352 + HV_VP_STATE_PAGE_GHCB = 2, 382 353 HV_VP_STATE_PAGE_COUNT 383 354 }; 384 355 385 356 struct hv_input_map_vp_state_page { 386 357 u64 partition_id; 387 358 u32 vp_index; 388 - u32 type; /* enum hv_vp_state_page_type */ 359 + u16 type; /* enum hv_vp_state_page_type */ 360 + union hv_input_vtl input_vtl; 361 + union { 362 + u8 as_uint8; 363 + struct { 364 + u8 map_location_provided : 1; 365 + u8 reserved : 7; 366 + }; 367 + } flags; 368 + u64 requested_map_location; 389 369 } __packed; 390 370 391 371 struct hv_output_map_vp_state_page { ··· 405 365 struct hv_input_unmap_vp_state_page { 406 366 u64 partition_id; 407 367 u32 vp_index; 408 - u32 type; /* enum hv_vp_state_page_type */ 368 + u16 type; /* enum hv_vp_state_page_type */ 369 + union hv_input_vtl input_vtl; 370 + u8 reserved0; 371 + } __packed; 372 + 373 + struct hv_x64_apic_eoi_message { 374 + u32 vp_index; 375 + u32 interrupt_vector; 409 376 } __packed; 410 377 411 378 struct hv_opaque_intercept_message { ··· 562 515 u64 reserved[5]; 563 516 } __packed; 564 517 518 + struct hv_async_completion_message_payload { 519 + u64 partition_id; 520 + u32 status; 521 + u32 completion_count; 522 + u64 sub_status; 523 + } __packed; 524 + 565 525 union hv_input_delete_vp { 566 526 u64 as_uint64[2]; 567 527 struct { ··· 703 649 union hv_input_set_vp_state_data data[]; 704 650 } __packed; 705 651 652 + union hv_x64_vp_execution_state { 653 + u16 as_uint16; 654 + struct { 655 + u16 cpl:2; 656 + u16 cr0_pe:1; 657 + u16 cr0_am:1; 658 + u16 efer_lma:1; 659 + u16 debug_active:1; 660 + u16 interruption_pending:1; 661 + u16 vtl:4; 662 + u16 enclave_mode:1; 663 + u16 interrupt_shadow:1; 664 + u16 virtualization_fault_active:1; 665 + u16 reserved:2; 666 + } __packed; 667 + }; 668 + 669 + struct hv_x64_intercept_message_header { 670 + u32 vp_index; 671 + u8 instruction_length:4; 672 + u8 cr8:4; /* Only set for exo partitions */ 673 + u8 intercept_access_type; 674 + union hv_x64_vp_execution_state execution_state; 675 + struct hv_x64_segment_register cs_segment; 676 + u64 rip; 677 + u64 rflags; 678 + } __packed; 679 + 680 + union hv_x64_memory_access_info { 681 + u8 as_uint8; 682 + struct { 683 + u8 gva_valid:1; 684 + u8 gva_gpa_valid:1; 685 + u8 hypercall_output_pending:1; 686 + u8 tlb_locked_no_overlay:1; 687 + u8 reserved:4; 688 + } __packed; 689 + }; 690 + 691 + struct hv_x64_memory_intercept_message { 692 + struct hv_x64_intercept_message_header header; 693 + u32 cache_type; /* enum hv_cache_type */ 694 + u8 instruction_byte_count; 695 + union hv_x64_memory_access_info memory_access_info; 696 + u8 tpr_priority; 697 + u8 reserved1; 698 + u64 guest_virtual_address; 699 + u64 guest_physical_address; 700 + u8 instruction_bytes[16]; 701 + } __packed; 702 + 706 703 /* 707 704 * Dispatch state for the VP communicated by the hypervisor to the 708 705 * VP-dispatching thread in the root on return from HVCALL_DISPATCH_VP. ··· 821 716 #define HV_DISPATCH_VP_FLAG_SKIP_VP_SPEC_FLUSH 0x8 822 717 #define HV_DISPATCH_VP_FLAG_SKIP_CALLER_SPEC_FLUSH 0x10 823 718 #define HV_DISPATCH_VP_FLAG_SKIP_CALLER_USER_SPEC_FLUSH 0x20 719 + #define HV_DISPATCH_VP_FLAG_SCAN_INTERRUPT_INJECTION 0x40 824 720 825 721 struct hv_input_dispatch_vp { 826 722 u64 partition_id; ··· 835 729 u32 dispatch_state; /* enum hv_vp_dispatch_state */ 836 730 u32 dispatch_event; /* enum hv_vp_dispatch_event */ 837 731 } __packed; 732 + 733 + struct hv_input_modify_sparse_spa_page_host_access { 734 + u32 host_access : 2; 735 + u32 reserved : 30; 736 + u32 flags; 737 + u64 partition_id; 738 + u64 spa_page_list[]; 739 + } __packed; 740 + 741 + /* hv_input_modify_sparse_spa_page_host_access flags */ 742 + #define HV_MODIFY_SPA_PAGE_HOST_ACCESS_MAKE_EXCLUSIVE 0x1 743 + #define HV_MODIFY_SPA_PAGE_HOST_ACCESS_MAKE_SHARED 0x2 744 + #define HV_MODIFY_SPA_PAGE_HOST_ACCESS_LARGE_PAGE 0x4 745 + #define HV_MODIFY_SPA_PAGE_HOST_ACCESS_HUGE_PAGE 0x8 838 746 839 747 #endif /* _HV_HVHDK_H */
+91
include/hyperv/hvhdk_mini.h
··· 36 36 HV_SCHEDULER_TYPE_MAX 37 37 }; 38 38 39 + /* HV_STATS_AREA_TYPE */ 40 + enum hv_stats_area_type { 41 + HV_STATS_AREA_SELF = 0, 42 + HV_STATS_AREA_PARENT = 1, 43 + HV_STATS_AREA_INTERNAL = 2, 44 + HV_STATS_AREA_COUNT 45 + }; 46 + 47 + enum hv_stats_object_type { 48 + HV_STATS_OBJECT_HYPERVISOR = 0x00000001, 49 + HV_STATS_OBJECT_LOGICAL_PROCESSOR = 0x00000002, 50 + HV_STATS_OBJECT_PARTITION = 0x00010001, 51 + HV_STATS_OBJECT_VP = 0x00010002 52 + }; 53 + 54 + union hv_stats_object_identity { 55 + /* hv_stats_hypervisor */ 56 + struct { 57 + u8 reserved[15]; 58 + u8 stats_area_type; 59 + } __packed hv; 60 + 61 + /* hv_stats_logical_processor */ 62 + struct { 63 + u32 lp_index; 64 + u8 reserved[11]; 65 + u8 stats_area_type; 66 + } __packed lp; 67 + 68 + /* hv_stats_partition */ 69 + struct { 70 + u64 partition_id; 71 + u8 reserved[7]; 72 + u8 stats_area_type; 73 + } __packed partition; 74 + 75 + /* hv_stats_vp */ 76 + struct { 77 + u64 partition_id; 78 + u32 vp_index; 79 + u16 flags; 80 + u8 reserved; 81 + u8 stats_area_type; 82 + } __packed vp; 83 + }; 84 + 39 85 enum hv_partition_property_code { 40 86 /* Privilege properties */ 41 87 HV_PARTITION_PROPERTY_PRIVILEGE_FLAGS = 0x00010000, ··· 93 47 94 48 /* Compatibility properties */ 95 49 HV_PARTITION_PROPERTY_PROCESSOR_XSAVE_FEATURES = 0x00060002, 50 + HV_PARTITION_PROPERTY_XSAVE_STATES = 0x00060007, 96 51 HV_PARTITION_PROPERTY_MAX_XSAVE_DATA_SIZE = 0x00060008, 97 52 HV_PARTITION_PROPERTY_PROCESSOR_CLOCK_FREQUENCY = 0x00060009, 53 + }; 54 + 55 + enum hv_snp_status { 56 + HV_SNP_STATUS_NONE = 0, 57 + HV_SNP_STATUS_AVAILABLE = 1, 58 + HV_SNP_STATUS_INCOMPATIBLE = 2, 59 + HV_SNP_STATUS_PSP_UNAVAILABLE = 3, 60 + HV_SNP_STATUS_PSP_INIT_FAILED = 4, 61 + HV_SNP_STATUS_PSP_BAD_FW_VERSION = 5, 62 + HV_SNP_STATUS_BAD_CONFIGURATION = 6, 63 + HV_SNP_STATUS_PSP_FW_UPDATE_IN_PROGRESS = 7, 64 + HV_SNP_STATUS_PSP_RB_INIT_FAILED = 8, 65 + HV_SNP_STATUS_PSP_PLATFORM_STATUS_FAILED = 9, 66 + HV_SNP_STATUS_PSP_INIT_LATE_FAILED = 10, 98 67 }; 99 68 100 69 enum hv_system_property { 101 70 /* Add more values when needed */ 102 71 HV_SYSTEM_PROPERTY_SCHEDULER_TYPE = 15, 72 + HV_DYNAMIC_PROCESSOR_FEATURE_PROPERTY = 21, 73 + }; 74 + 75 + enum hv_dynamic_processor_feature_property { 76 + /* Add more values when needed */ 77 + HV_X64_DYNAMIC_PROCESSOR_FEATURE_MAX_ENCRYPTED_PARTITIONS = 13, 78 + HV_X64_DYNAMIC_PROCESSOR_FEATURE_SNP_STATUS = 16, 103 79 }; 104 80 105 81 struct hv_input_get_system_property { 106 82 u32 property_id; /* enum hv_system_property */ 107 83 union { 108 84 u32 as_uint32; 85 + #if IS_ENABLED(CONFIG_X86) 86 + /* enum hv_dynamic_processor_feature_property */ 87 + u32 hv_processor_feature; 88 + #endif 109 89 /* More fields to be filled in when needed */ 110 90 }; 111 91 } __packed; ··· 139 67 struct hv_output_get_system_property { 140 68 union { 141 69 u32 scheduler_type; /* enum hv_scheduler_type */ 70 + #if IS_ENABLED(CONFIG_X86) 71 + u64 hv_processor_feature_value; 72 + #endif 142 73 }; 74 + } __packed; 75 + 76 + struct hv_input_map_stats_page { 77 + u32 type; /* enum hv_stats_object_type */ 78 + u32 padding; 79 + union hv_stats_object_identity identity; 80 + } __packed; 81 + 82 + struct hv_output_map_stats_page { 83 + u64 map_location; 84 + } __packed; 85 + 86 + struct hv_input_unmap_stats_page { 87 + u32 type; /* enum hv_stats_object_type */ 88 + u32 padding; 89 + union hv_stats_object_identity identity; 143 90 } __packed; 144 91 145 92 struct hv_proximity_domain_flags {