diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-12 18:28:38 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-12 18:28:38 -0400 |
| commit | 16c97650a56abdd067f7da079007b7e00b307083 (patch) | |
| tree | e6e96a73f7b1d6d963fed99ad0c2fe6bf77aa545 | |
| parent | 9e3a25dc992dd9f3170fb643bdd95da5ca9c5576 (diff) | |
| parent | 765e33f5211ab620c117ff1ee0c4f38c10f7a973 (diff) | |
Merge tag 'hyperv-next-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
Pull hyper-v updates from Sasha Levin:
- Add a module description to the Hyper-V vmbus module.
- Rework some vmbus code to separate architecture specifics out to
arch/x86/. This is part of the work of adding arm64 support to
Hyper-V.
* tag 'hyperv-next-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
Drivers: hv: vmbus: Break out ISA independent parts of mshyperv.h
drivers: hv: Add a module description line to the hv_vmbus driver
| -rw-r--r-- | MAINTAINERS | 1 | ||||
| -rw-r--r-- | arch/x86/include/asm/mshyperv.h | 148 | ||||
| -rw-r--r-- | drivers/hv/vmbus_drv.c | 1 | ||||
| -rw-r--r-- | include/asm-generic/mshyperv.h | 180 |
4 files changed, 187 insertions, 143 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 60218e6a60ec..16a17fe87fe6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -7422,6 +7422,7 @@ F: net/vmw_vsock/hyperv_transport.c | |||
| 7422 | F: include/clocksource/hyperv_timer.h | 7422 | F: include/clocksource/hyperv_timer.h |
| 7423 | F: include/linux/hyperv.h | 7423 | F: include/linux/hyperv.h |
| 7424 | F: include/uapi/linux/hyperv.h | 7424 | F: include/uapi/linux/hyperv.h |
| 7425 | F: include/asm-generic/mshyperv.h | ||
| 7425 | F: tools/hv/ | 7426 | F: tools/hv/ |
| 7426 | F: Documentation/ABI/stable/sysfs-bus-vmbus | 7427 | F: Documentation/ABI/stable/sysfs-bus-vmbus |
| 7427 | 7428 | ||
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index f4fa8a9d5d0b..2ef31cc8c529 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h | |||
| @@ -3,84 +3,15 @@ | |||
| 3 | #define _ASM_X86_MSHYPER_H | 3 | #define _ASM_X86_MSHYPER_H |
| 4 | 4 | ||
| 5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
| 6 | #include <linux/atomic.h> | ||
| 7 | #include <linux/nmi.h> | 6 | #include <linux/nmi.h> |
| 8 | #include <asm/io.h> | 7 | #include <asm/io.h> |
| 9 | #include <asm/hyperv-tlfs.h> | 8 | #include <asm/hyperv-tlfs.h> |
| 10 | #include <asm/nospec-branch.h> | 9 | #include <asm/nospec-branch.h> |
| 11 | 10 | ||
| 12 | #define VP_INVAL U32_MAX | ||
| 13 | |||
| 14 | struct ms_hyperv_info { | ||
| 15 | u32 features; | ||
| 16 | u32 misc_features; | ||
| 17 | u32 hints; | ||
| 18 | u32 nested_features; | ||
| 19 | u32 max_vp_index; | ||
| 20 | u32 max_lp_index; | ||
| 21 | }; | ||
| 22 | |||
| 23 | extern struct ms_hyperv_info ms_hyperv; | ||
| 24 | |||
| 25 | |||
| 26 | typedef int (*hyperv_fill_flush_list_func)( | 11 | typedef int (*hyperv_fill_flush_list_func)( |
| 27 | struct hv_guest_mapping_flush_list *flush, | 12 | struct hv_guest_mapping_flush_list *flush, |
| 28 | void *data); | 13 | void *data); |
| 29 | 14 | ||
| 30 | /* | ||
| 31 | * Generate the guest ID. | ||
| 32 | */ | ||
| 33 | |||
| 34 | static inline __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version, | ||
| 35 | __u64 d_info2) | ||
| 36 | { | ||
| 37 | __u64 guest_id = 0; | ||
| 38 | |||
| 39 | guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48); | ||
| 40 | guest_id |= (d_info1 << 48); | ||
| 41 | guest_id |= (kernel_version << 16); | ||
| 42 | guest_id |= d_info2; | ||
| 43 | |||
| 44 | return guest_id; | ||
| 45 | } | ||
| 46 | |||
| 47 | |||
| 48 | /* Free the message slot and signal end-of-message if required */ | ||
| 49 | static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type) | ||
| 50 | { | ||
| 51 | /* | ||
| 52 | * On crash we're reading some other CPU's message page and we need | ||
| 53 | * to be careful: this other CPU may already had cleared the header | ||
| 54 | * and the host may already had delivered some other message there. | ||
| 55 | * In case we blindly write msg->header.message_type we're going | ||
| 56 | * to lose it. We can still lose a message of the same type but | ||
| 57 | * we count on the fact that there can only be one | ||
| 58 | * CHANNELMSG_UNLOAD_RESPONSE and we don't care about other messages | ||
| 59 | * on crash. | ||
| 60 | */ | ||
| 61 | if (cmpxchg(&msg->header.message_type, old_msg_type, | ||
| 62 | HVMSG_NONE) != old_msg_type) | ||
| 63 | return; | ||
| 64 | |||
| 65 | /* | ||
| 66 | * Make sure the write to MessageType (ie set to | ||
| 67 | * HVMSG_NONE) happens before we read the | ||
| 68 | * MessagePending and EOMing. Otherwise, the EOMing | ||
| 69 | * will not deliver any more messages since there is | ||
| 70 | * no empty slot | ||
| 71 | */ | ||
| 72 | mb(); | ||
| 73 | |||
| 74 | if (msg->header.message_flags.msg_pending) { | ||
| 75 | /* | ||
| 76 | * This will cause message queue rescan to | ||
| 77 | * possibly deliver another msg from the | ||
| 78 | * hypervisor | ||
| 79 | */ | ||
| 80 | wrmsrl(HV_X64_MSR_EOM, 0); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | #define hv_init_timer(timer, tick) \ | 15 | #define hv_init_timer(timer, tick) \ |
| 85 | wrmsrl(HV_X64_MSR_STIMER0_COUNT + (2*timer), tick) | 16 | wrmsrl(HV_X64_MSR_STIMER0_COUNT + (2*timer), tick) |
| 86 | #define hv_init_timer_config(timer, val) \ | 17 | #define hv_init_timer_config(timer, val) \ |
| @@ -97,6 +28,8 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type) | |||
| 97 | 28 | ||
| 98 | #define hv_get_vp_index(index) rdmsrl(HV_X64_MSR_VP_INDEX, index) | 29 | #define hv_get_vp_index(index) rdmsrl(HV_X64_MSR_VP_INDEX, index) |
| 99 | 30 | ||
| 31 | #define hv_signal_eom() wrmsrl(HV_X64_MSR_EOM, 0) | ||
| 32 | |||
| 100 | #define hv_get_synint_state(int_num, val) \ | 33 | #define hv_get_synint_state(int_num, val) \ |
| 101 | rdmsrl(HV_X64_MSR_SINT0 + int_num, val) | 34 | rdmsrl(HV_X64_MSR_SINT0 + int_num, val) |
| 102 | #define hv_set_synint_state(int_num, val) \ | 35 | #define hv_set_synint_state(int_num, val) \ |
| @@ -122,13 +55,6 @@ void hyperv_reenlightenment_vector(void); | |||
| 122 | #define trace_hyperv_callback_vector hyperv_callback_vector | 55 | #define trace_hyperv_callback_vector hyperv_callback_vector |
| 123 | #endif | 56 | #endif |
| 124 | void hyperv_vector_handler(struct pt_regs *regs); | 57 | void hyperv_vector_handler(struct pt_regs *regs); |
| 125 | void hv_setup_vmbus_irq(void (*handler)(void)); | ||
| 126 | void hv_remove_vmbus_irq(void); | ||
| 127 | |||
| 128 | void hv_setup_kexec_handler(void (*handler)(void)); | ||
| 129 | void hv_remove_kexec_handler(void); | ||
| 130 | void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs)); | ||
| 131 | void hv_remove_crash_handler(void); | ||
| 132 | 58 | ||
| 133 | /* | 59 | /* |
| 134 | * Routines for stimer0 Direct Mode handling. | 60 | * Routines for stimer0 Direct Mode handling. |
| @@ -136,8 +62,6 @@ void hv_remove_crash_handler(void); | |||
| 136 | */ | 62 | */ |
| 137 | void hv_stimer0_vector_handler(struct pt_regs *regs); | 63 | void hv_stimer0_vector_handler(struct pt_regs *regs); |
| 138 | void hv_stimer0_callback_vector(void); | 64 | void hv_stimer0_callback_vector(void); |
| 139 | int hv_setup_stimer0_irq(int *irq, int *vector, void (*handler)(void)); | ||
| 140 | void hv_remove_stimer0_irq(int irq); | ||
| 141 | 65 | ||
| 142 | static inline void hv_enable_stimer0_percpu_irq(int irq) {} | 66 | static inline void hv_enable_stimer0_percpu_irq(int irq) {} |
| 143 | static inline void hv_disable_stimer0_percpu_irq(int irq) {} | 67 | static inline void hv_disable_stimer0_percpu_irq(int irq) {} |
| @@ -282,14 +206,6 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size, | |||
| 282 | return status; | 206 | return status; |
| 283 | } | 207 | } |
| 284 | 208 | ||
| 285 | /* | ||
| 286 | * Hypervisor's notion of virtual processor ID is different from | ||
| 287 | * Linux' notion of CPU ID. This information can only be retrieved | ||
| 288 | * in the context of the calling CPU. Setup a map for easy access | ||
| 289 | * to this information. | ||
| 290 | */ | ||
| 291 | extern u32 *hv_vp_index; | ||
| 292 | extern u32 hv_max_vp_index; | ||
| 293 | extern struct hv_vp_assist_page **hv_vp_assist_page; | 209 | extern struct hv_vp_assist_page **hv_vp_assist_page; |
| 294 | 210 | ||
| 295 | static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu) | 211 | static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu) |
| @@ -300,63 +216,8 @@ static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu) | |||
| 300 | return hv_vp_assist_page[cpu]; | 216 | return hv_vp_assist_page[cpu]; |
| 301 | } | 217 | } |
| 302 | 218 | ||
| 303 | /** | ||
| 304 | * hv_cpu_number_to_vp_number() - Map CPU to VP. | ||
| 305 | * @cpu_number: CPU number in Linux terms | ||
| 306 | * | ||
| 307 | * This function returns the mapping between the Linux processor | ||
| 308 | * number and the hypervisor's virtual processor number, useful | ||
| 309 | * in making hypercalls and such that talk about specific | ||
| 310 | * processors. | ||
| 311 | * | ||
| 312 | * Return: Virtual processor number in Hyper-V terms | ||
| 313 | */ | ||
| 314 | static inline int hv_cpu_number_to_vp_number(int cpu_number) | ||
| 315 | { | ||
| 316 | return hv_vp_index[cpu_number]; | ||
| 317 | } | ||
| 318 | |||
| 319 | static inline int cpumask_to_vpset(struct hv_vpset *vpset, | ||
| 320 | const struct cpumask *cpus) | ||
| 321 | { | ||
| 322 | int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1; | ||
| 323 | |||
| 324 | /* valid_bank_mask can represent up to 64 banks */ | ||
| 325 | if (hv_max_vp_index / 64 >= 64) | ||
| 326 | return 0; | ||
| 327 | |||
| 328 | /* | ||
| 329 | * Clear all banks up to the maximum possible bank as hv_tlb_flush_ex | ||
| 330 | * structs are not cleared between calls, we risk flushing unneeded | ||
| 331 | * vCPUs otherwise. | ||
| 332 | */ | ||
| 333 | for (vcpu_bank = 0; vcpu_bank <= hv_max_vp_index / 64; vcpu_bank++) | ||
| 334 | vpset->bank_contents[vcpu_bank] = 0; | ||
| 335 | |||
| 336 | /* | ||
| 337 | * Some banks may end up being empty but this is acceptable. | ||
| 338 | */ | ||
| 339 | for_each_cpu(cpu, cpus) { | ||
| 340 | vcpu = hv_cpu_number_to_vp_number(cpu); | ||
| 341 | if (vcpu == VP_INVAL) | ||
| 342 | return -1; | ||
| 343 | vcpu_bank = vcpu / 64; | ||
| 344 | vcpu_offset = vcpu % 64; | ||
| 345 | __set_bit(vcpu_offset, (unsigned long *) | ||
| 346 | &vpset->bank_contents[vcpu_bank]); | ||
| 347 | if (vcpu_bank >= nr_bank) | ||
| 348 | nr_bank = vcpu_bank + 1; | ||
| 349 | } | ||
| 350 | vpset->valid_bank_mask = GENMASK_ULL(nr_bank - 1, 0); | ||
| 351 | return nr_bank; | ||
| 352 | } | ||
| 353 | |||
| 354 | void __init hyperv_init(void); | 219 | void __init hyperv_init(void); |
| 355 | void hyperv_setup_mmu_ops(void); | 220 | void hyperv_setup_mmu_ops(void); |
| 356 | void hyperv_report_panic(struct pt_regs *regs, long err); | ||
| 357 | void hyperv_report_panic_msg(phys_addr_t pa, size_t size); | ||
| 358 | bool hv_is_hyperv_initialized(void); | ||
| 359 | void hyperv_cleanup(void); | ||
| 360 | 221 | ||
| 361 | void hyperv_reenlightenment_intr(struct pt_regs *regs); | 222 | void hyperv_reenlightenment_intr(struct pt_regs *regs); |
| 362 | void set_hv_tscchange_cb(void (*cb)(void)); | 223 | void set_hv_tscchange_cb(void (*cb)(void)); |
| @@ -379,8 +240,6 @@ static inline void hv_apic_init(void) {} | |||
| 379 | 240 | ||
| 380 | #else /* CONFIG_HYPERV */ | 241 | #else /* CONFIG_HYPERV */ |
| 381 | static inline void hyperv_init(void) {} | 242 | static inline void hyperv_init(void) {} |
| 382 | static inline bool hv_is_hyperv_initialized(void) { return false; } | ||
| 383 | static inline void hyperv_cleanup(void) {} | ||
| 384 | static inline void hyperv_setup_mmu_ops(void) {} | 243 | static inline void hyperv_setup_mmu_ops(void) {} |
| 385 | static inline void set_hv_tscchange_cb(void (*cb)(void)) {} | 244 | static inline void set_hv_tscchange_cb(void (*cb)(void)) {} |
| 386 | static inline void clear_hv_tscchange_cb(void) {} | 245 | static inline void clear_hv_tscchange_cb(void) {} |
| @@ -397,4 +256,7 @@ static inline int hyperv_flush_guest_mapping_range(u64 as, | |||
| 397 | } | 256 | } |
| 398 | #endif /* CONFIG_HYPERV */ | 257 | #endif /* CONFIG_HYPERV */ |
| 399 | 258 | ||
| 259 | |||
| 260 | #include <asm-generic/mshyperv.h> | ||
| 261 | |||
| 400 | #endif | 262 | #endif |
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 72d5a7cde7ea..894da5abdc55 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c | |||
| @@ -2163,6 +2163,7 @@ static void __exit vmbus_exit(void) | |||
| 2163 | 2163 | ||
| 2164 | 2164 | ||
| 2165 | MODULE_LICENSE("GPL"); | 2165 | MODULE_LICENSE("GPL"); |
| 2166 | MODULE_DESCRIPTION("Microsoft Hyper-V VMBus Driver"); | ||
| 2166 | 2167 | ||
| 2167 | subsys_initcall(hv_acpi_init); | 2168 | subsys_initcall(hv_acpi_init); |
| 2168 | module_exit(vmbus_exit); | 2169 | module_exit(vmbus_exit); |
diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h new file mode 100644 index 000000000000..0becb7d9704d --- /dev/null +++ b/include/asm-generic/mshyperv.h | |||
| @@ -0,0 +1,180 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Linux-specific definitions for managing interactions with Microsoft's | ||
| 5 | * Hyper-V hypervisor. The definitions in this file are architecture | ||
| 6 | * independent. See arch/<arch>/include/asm/mshyperv.h for definitions | ||
| 7 | * that are specific to architecture <arch>. | ||
| 8 | * | ||
| 9 | * Definitions that are specified in the Hyper-V Top Level Functional | ||
| 10 | * Spec (TLFS) should not go in this file, but should instead go in | ||
| 11 | * hyperv-tlfs.h. | ||
| 12 | * | ||
| 13 | * Copyright (C) 2019, Microsoft, Inc. | ||
| 14 | * | ||
| 15 | * Author : Michael Kelley <mikelley@microsoft.com> | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef _ASM_GENERIC_MSHYPERV_H | ||
| 19 | #define _ASM_GENERIC_MSHYPERV_H | ||
| 20 | |||
| 21 | #include <linux/types.h> | ||
| 22 | #include <linux/atomic.h> | ||
| 23 | #include <linux/bitops.h> | ||
| 24 | #include <linux/cpumask.h> | ||
| 25 | #include <asm/ptrace.h> | ||
| 26 | #include <asm/hyperv-tlfs.h> | ||
| 27 | |||
| 28 | struct ms_hyperv_info { | ||
| 29 | u32 features; | ||
| 30 | u32 misc_features; | ||
| 31 | u32 hints; | ||
| 32 | u32 nested_features; | ||
| 33 | u32 max_vp_index; | ||
| 34 | u32 max_lp_index; | ||
| 35 | }; | ||
| 36 | extern struct ms_hyperv_info ms_hyperv; | ||
| 37 | |||
| 38 | extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr); | ||
| 39 | extern u64 hv_do_fast_hypercall8(u16 control, u64 input8); | ||
| 40 | |||
| 41 | |||
| 42 | /* Generate the guest OS identifier as described in the Hyper-V TLFS */ | ||
| 43 | static inline __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version, | ||
| 44 | __u64 d_info2) | ||
| 45 | { | ||
| 46 | __u64 guest_id = 0; | ||
| 47 | |||
| 48 | guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48); | ||
| 49 | guest_id |= (d_info1 << 48); | ||
| 50 | guest_id |= (kernel_version << 16); | ||
| 51 | guest_id |= d_info2; | ||
| 52 | |||
| 53 | return guest_id; | ||
| 54 | } | ||
| 55 | |||
| 56 | |||
| 57 | /* Free the message slot and signal end-of-message if required */ | ||
| 58 | static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type) | ||
| 59 | { | ||
| 60 | /* | ||
| 61 | * On crash we're reading some other CPU's message page and we need | ||
| 62 | * to be careful: this other CPU may already had cleared the header | ||
| 63 | * and the host may already had delivered some other message there. | ||
| 64 | * In case we blindly write msg->header.message_type we're going | ||
| 65 | * to lose it. We can still lose a message of the same type but | ||
| 66 | * we count on the fact that there can only be one | ||
| 67 | * CHANNELMSG_UNLOAD_RESPONSE and we don't care about other messages | ||
| 68 | * on crash. | ||
| 69 | */ | ||
| 70 | if (cmpxchg(&msg->header.message_type, old_msg_type, | ||
| 71 | HVMSG_NONE) != old_msg_type) | ||
| 72 | return; | ||
| 73 | |||
| 74 | /* | ||
| 75 | * The cmxchg() above does an implicit memory barrier to | ||
| 76 | * ensure the write to MessageType (ie set to | ||
| 77 | * HVMSG_NONE) happens before we read the | ||
| 78 | * MessagePending and EOMing. Otherwise, the EOMing | ||
| 79 | * will not deliver any more messages since there is | ||
| 80 | * no empty slot | ||
| 81 | */ | ||
| 82 | if (msg->header.message_flags.msg_pending) { | ||
| 83 | /* | ||
| 84 | * This will cause message queue rescan to | ||
| 85 | * possibly deliver another msg from the | ||
| 86 | * hypervisor | ||
| 87 | */ | ||
| 88 | hv_signal_eom(); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | void hv_setup_vmbus_irq(void (*handler)(void)); | ||
| 93 | void hv_remove_vmbus_irq(void); | ||
| 94 | void hv_enable_vmbus_irq(void); | ||
| 95 | void hv_disable_vmbus_irq(void); | ||
| 96 | |||
| 97 | void hv_setup_kexec_handler(void (*handler)(void)); | ||
| 98 | void hv_remove_kexec_handler(void); | ||
| 99 | void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs)); | ||
| 100 | void hv_remove_crash_handler(void); | ||
| 101 | |||
| 102 | #if IS_ENABLED(CONFIG_HYPERV) | ||
| 103 | /* | ||
| 104 | * Hypervisor's notion of virtual processor ID is different from | ||
| 105 | * Linux' notion of CPU ID. This information can only be retrieved | ||
| 106 | * in the context of the calling CPU. Setup a map for easy access | ||
| 107 | * to this information. | ||
| 108 | */ | ||
| 109 | extern u32 *hv_vp_index; | ||
| 110 | extern u32 hv_max_vp_index; | ||
| 111 | |||
| 112 | /* Sentinel value for an uninitialized entry in hv_vp_index array */ | ||
| 113 | #define VP_INVAL U32_MAX | ||
| 114 | |||
| 115 | /** | ||
| 116 | * hv_cpu_number_to_vp_number() - Map CPU to VP. | ||
| 117 | * @cpu_number: CPU number in Linux terms | ||
| 118 | * | ||
| 119 | * This function returns the mapping between the Linux processor | ||
| 120 | * number and the hypervisor's virtual processor number, useful | ||
| 121 | * in making hypercalls and such that talk about specific | ||
| 122 | * processors. | ||
| 123 | * | ||
| 124 | * Return: Virtual processor number in Hyper-V terms | ||
| 125 | */ | ||
| 126 | static inline int hv_cpu_number_to_vp_number(int cpu_number) | ||
| 127 | { | ||
| 128 | return hv_vp_index[cpu_number]; | ||
| 129 | } | ||
| 130 | |||
| 131 | static inline int cpumask_to_vpset(struct hv_vpset *vpset, | ||
| 132 | const struct cpumask *cpus) | ||
| 133 | { | ||
| 134 | int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1; | ||
| 135 | |||
| 136 | /* valid_bank_mask can represent up to 64 banks */ | ||
| 137 | if (hv_max_vp_index / 64 >= 64) | ||
| 138 | return 0; | ||
| 139 | |||
| 140 | /* | ||
| 141 | * Clear all banks up to the maximum possible bank as hv_tlb_flush_ex | ||
| 142 | * structs are not cleared between calls, we risk flushing unneeded | ||
| 143 | * vCPUs otherwise. | ||
| 144 | */ | ||
| 145 | for (vcpu_bank = 0; vcpu_bank <= hv_max_vp_index / 64; vcpu_bank++) | ||
| 146 | vpset->bank_contents[vcpu_bank] = 0; | ||
| 147 | |||
| 148 | /* | ||
| 149 | * Some banks may end up being empty but this is acceptable. | ||
| 150 | */ | ||
| 151 | for_each_cpu(cpu, cpus) { | ||
| 152 | vcpu = hv_cpu_number_to_vp_number(cpu); | ||
| 153 | if (vcpu == VP_INVAL) | ||
| 154 | return -1; | ||
| 155 | vcpu_bank = vcpu / 64; | ||
| 156 | vcpu_offset = vcpu % 64; | ||
| 157 | __set_bit(vcpu_offset, (unsigned long *) | ||
| 158 | &vpset->bank_contents[vcpu_bank]); | ||
| 159 | if (vcpu_bank >= nr_bank) | ||
| 160 | nr_bank = vcpu_bank + 1; | ||
| 161 | } | ||
| 162 | vpset->valid_bank_mask = GENMASK_ULL(nr_bank - 1, 0); | ||
| 163 | return nr_bank; | ||
| 164 | } | ||
| 165 | |||
| 166 | void hyperv_report_panic(struct pt_regs *regs, long err); | ||
| 167 | void hyperv_report_panic_msg(phys_addr_t pa, size_t size); | ||
| 168 | bool hv_is_hyperv_initialized(void); | ||
| 169 | void hyperv_cleanup(void); | ||
| 170 | #else /* CONFIG_HYPERV */ | ||
| 171 | static inline bool hv_is_hyperv_initialized(void) { return false; } | ||
| 172 | static inline void hyperv_cleanup(void) {} | ||
| 173 | #endif /* CONFIG_HYPERV */ | ||
| 174 | |||
| 175 | #if IS_ENABLED(CONFIG_HYPERV) | ||
| 176 | extern int hv_setup_stimer0_irq(int *irq, int *vector, void (*handler)(void)); | ||
| 177 | extern void hv_remove_stimer0_irq(int irq); | ||
| 178 | #endif | ||
| 179 | |||
| 180 | #endif | ||
