This source file includes following definitions.
- hv_qlock_kick
- hv_qlock_wait
- hv_vcpu_is_preempted
- hv_init_spinlocks
- hv_parse_nopvspin
1
2
3
4
5
6
7
8
9
10
11 #define pr_fmt(fmt) "Hyper-V: " fmt
12
13 #include <linux/spinlock.h>
14
15 #include <asm/mshyperv.h>
16 #include <asm/paravirt.h>
17 #include <asm/apic.h>
18
19 static bool __initdata hv_pvspin = true;
20
21 static void hv_qlock_kick(int cpu)
22 {
23 apic->send_IPI(cpu, X86_PLATFORM_IPI_VECTOR);
24 }
25
26 static void hv_qlock_wait(u8 *byte, u8 val)
27 {
28 unsigned long msr_val;
29 unsigned long flags;
30
31 if (in_nmi())
32 return;
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 local_irq_save(flags);
48
49
50
51 if (READ_ONCE(*byte) == val)
52 rdmsrl(HV_X64_MSR_GUEST_IDLE, msr_val);
53 local_irq_restore(flags);
54 }
55
56
57
58
59 __visible bool hv_vcpu_is_preempted(int vcpu)
60 {
61 return false;
62 }
63 PV_CALLEE_SAVE_REGS_THUNK(hv_vcpu_is_preempted);
64
65 void __init hv_init_spinlocks(void)
66 {
67 if (!hv_pvspin || !apic ||
68 !(ms_hyperv.hints & HV_X64_CLUSTER_IPI_RECOMMENDED) ||
69 !(ms_hyperv.features & HV_X64_MSR_GUEST_IDLE_AVAILABLE)) {
70 pr_info("PV spinlocks disabled\n");
71 return;
72 }
73 pr_info("PV spinlocks enabled\n");
74
75 __pv_init_lock_hash();
76 pv_ops.lock.queued_spin_lock_slowpath = __pv_queued_spin_lock_slowpath;
77 pv_ops.lock.queued_spin_unlock = PV_CALLEE_SAVE(__pv_queued_spin_unlock);
78 pv_ops.lock.wait = hv_qlock_wait;
79 pv_ops.lock.kick = hv_qlock_kick;
80 pv_ops.lock.vcpu_is_preempted = PV_CALLEE_SAVE(hv_vcpu_is_preempted);
81 }
82
83 static __init int hv_parse_nopvspin(char *arg)
84 {
85 hv_pvspin = false;
86 return 0;
87 }
88 early_param("hv_nopvspin", hv_parse_nopvspin);