H. Peter Anvin | e08cae4 | 2010-05-07 16:57:28 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_MSHYPER_H |
| 2 | #define _ASM_X86_MSHYPER_H |
Ky Srinivasan | a2a47c6 | 2010-05-06 12:08:41 -0700 | [diff] [blame] | 3 | |
H. Peter Anvin | e08cae4 | 2010-05-07 16:57:28 -0700 | [diff] [blame] | 4 | #include <linux/types.h> |
Thomas Gleixner | 1aec169 | 2014-02-23 21:40:22 +0000 | [diff] [blame] | 5 | #include <linux/interrupt.h> |
H. Peter Anvin | e08cae4 | 2010-05-07 16:57:28 -0700 | [diff] [blame] | 6 | #include <asm/hyperv.h> |
| 7 | |
| 8 | struct ms_hyperv_info { |
| 9 | u32 features; |
Denis V. Lunev | cc2dd40 | 2015-08-01 16:08:20 -0700 | [diff] [blame] | 10 | u32 misc_features; |
H. Peter Anvin | e08cae4 | 2010-05-07 16:57:28 -0700 | [diff] [blame] | 11 | u32 hints; |
| 12 | }; |
| 13 | |
| 14 | extern struct ms_hyperv_info ms_hyperv; |
Ky Srinivasan | a2a47c6 | 2010-05-06 12:08:41 -0700 | [diff] [blame] | 15 | |
K. Y. Srinivasan | 3f646ed | 2017-01-18 16:45:00 -0700 | [diff] [blame] | 16 | /* |
| 17 | * Declare the MSR used to setup pages used to communicate with the hypervisor. |
| 18 | */ |
| 19 | union hv_x64_msr_hypercall_contents { |
| 20 | u64 as_uint64; |
| 21 | struct { |
| 22 | u64 enable:1; |
| 23 | u64 reserved:11; |
| 24 | u64 guest_physical_address:52; |
| 25 | }; |
| 26 | }; |
| 27 | |
K. Y. Srinivasan | 352c962 | 2017-01-18 16:45:01 -0700 | [diff] [blame^] | 28 | /* |
| 29 | * The guest OS needs to register the guest ID with the hypervisor. |
| 30 | * The guest ID is a 64 bit entity and the structure of this ID is |
| 31 | * specified in the Hyper-V specification: |
| 32 | * |
| 33 | * msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx |
| 34 | * |
| 35 | * While the current guideline does not specify how Linux guest ID(s) |
| 36 | * need to be generated, our plan is to publish the guidelines for |
| 37 | * Linux and other guest operating systems that currently are hosted |
| 38 | * on Hyper-V. The implementation here conforms to this yet |
| 39 | * unpublished guidelines. |
| 40 | * |
| 41 | * |
| 42 | * Bit(s) |
| 43 | * 63 - Indicates if the OS is Open Source or not; 1 is Open Source |
| 44 | * 62:56 - Os Type; Linux is 0x100 |
| 45 | * 55:48 - Distro specific identification |
| 46 | * 47:16 - Linux kernel version number |
| 47 | * 15:0 - Distro specific identification |
| 48 | * |
| 49 | * |
| 50 | */ |
| 51 | |
| 52 | #define HV_LINUX_VENDOR_ID 0x8800 |
| 53 | |
| 54 | /* |
| 55 | * Generate the guest ID based on the guideline described above. |
| 56 | */ |
| 57 | |
| 58 | static inline __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version, |
| 59 | __u64 d_info2) |
| 60 | { |
| 61 | __u64 guest_id = 0; |
| 62 | |
| 63 | guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 56); |
| 64 | guest_id |= (d_info1 << 48); |
| 65 | guest_id |= (kernel_version << 16); |
| 66 | guest_id |= d_info2; |
| 67 | |
| 68 | return guest_id; |
| 69 | } |
| 70 | |
K. Y. Srinivasan | bc2b033 | 2013-02-03 17:22:39 -0800 | [diff] [blame] | 71 | void hyperv_callback_vector(void); |
Seiji Aguchi | cf910e8 | 2013-06-20 11:46:53 -0400 | [diff] [blame] | 72 | #ifdef CONFIG_TRACING |
| 73 | #define trace_hyperv_callback_vector hyperv_callback_vector |
| 74 | #endif |
K. Y. Srinivasan | bc2b033 | 2013-02-03 17:22:39 -0800 | [diff] [blame] | 75 | void hyperv_vector_handler(struct pt_regs *regs); |
Thomas Gleixner | 76d388c | 2014-03-05 13:42:14 +0100 | [diff] [blame] | 76 | void hv_setup_vmbus_irq(void (*handler)(void)); |
| 77 | void hv_remove_vmbus_irq(void); |
K. Y. Srinivasan | bc2b033 | 2013-02-03 17:22:39 -0800 | [diff] [blame] | 78 | |
Vitaly Kuznetsov | 2517281 | 2015-08-01 16:08:07 -0700 | [diff] [blame] | 79 | void hv_setup_kexec_handler(void (*handler)(void)); |
| 80 | void hv_remove_kexec_handler(void); |
Vitaly Kuznetsov | b4370df | 2015-08-01 16:08:09 -0700 | [diff] [blame] | 81 | void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs)); |
| 82 | void hv_remove_crash_handler(void); |
Ky Srinivasan | a2a47c6 | 2010-05-06 12:08:41 -0700 | [diff] [blame] | 83 | #endif |