History

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull KVM fixes from Paolo Bonzini: "A somewhat bigger ARM update, and the usual smattering of x86 bug fixes" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: kvm: vmx: Fix entry number check for add_atomic_switch_msr() KVM: x86: Recompute PID.ON when clearing PID.SN KVM: nVMX: Restore a preemption timer consistency check x86/kvm/nVMX: read from MSR_IA32_VMX_PROCBASED_CTLS2 only when it is available KVM: arm64: Forbid kprobing of the VHE world-switch code KVM: arm64: Relax the restriction on using stage2 PUD huge mapping arm: KVM: Add missing kvm_stage2_has_pmd() helper KVM: arm/arm64: vgic: Always initialize the group of private IRQs arm/arm64: KVM: Don't panic on failure to properly reset system registers arm/arm64: KVM: Allow a VCPU to fully reset itself KVM: arm/arm64: Reset the VCPU without preemption and vcpu state loaded arm64: KVM: Don't generate UNDEF when LORegion feature is present KVM: arm/arm64: vgic: Make vgic_cpu->ap_list_lock a raw_spinlock KVM: arm/arm64: vgic: Make vgic_dist->lpi_list_lock a raw_spinlock KVM: arm/arm64: vgic: Make vgic_irq->irq_lock a raw_spinlock

Linus Torvalds committed 7 years ago

Commit ed0a0ec2 parents 64c0133 98ae70c26 files · +331 −193Browse files

Unified · Split

26 files
  1. arch/arm/include/asm/kvm_host.h +10 −0
  2. arch/arm/include/asm/stage2_pgtable.h +5 −0
  3. arch/arm/kvm/coproc.c +2 −2
  4. arch/arm/kvm/reset.c +24 −0
  5. arch/arm64/include/asm/kvm_host.h +11 −0
  6. arch/arm64/kvm/hyp/switch.c +5 −0
  7. arch/arm64/kvm/hyp/sysreg-sr.c +5 −0
  8. arch/arm64/kvm/reset.c +48 −2
  9. arch/arm64/kvm/sys_regs.c +32 −18
  10. arch/x86/kvm/vmx/nested.c +9 −3
  11. arch/x86/kvm/vmx/vmx.c +13 −16
  12. arch/x86/kvm/vmx/vmx.h +5 −5
  13. arch/x86/kvm/x86.c +1 −1
  14. include/kvm/arm_vgic.h +3 −3
  15. virt/kvm/arm/arm.c +10 −0
  16. virt/kvm/arm/mmu.c +6 −3
  17. virt/kvm/arm/psci.c +16 −20
  18. virt/kvm/arm/vgic/vgic-debug.c +2 −2
  19. virt/kvm/arm/vgic/vgic-init.c +18 −12
  20. virt/kvm/arm/vgic/vgic-its.c +11 −11
  21. virt/kvm/arm/vgic/vgic-mmio-v2.c +7 −7
  22. virt/kvm/arm/vgic/vgic-mmio-v3.c +6 −6
  23. virt/kvm/arm/vgic/vgic-mmio.c +17 −17
  24. virt/kvm/arm/vgic/vgic-v2.c +2 −2
  25. virt/kvm/arm/vgic/vgic-v3.c +4 −4
  26. virt/kvm/arm/vgic/vgic.c +59 −59
arch/arm/include/asm/kvm_host.h+10−0
@@ -48,6 +48,7 @@ · 47 unmodified lines
4848 #define KVM_REQ_SLEEP \
4949 KVM_ARCH_REQ_FLAGS(0, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
5050 #define KVM_REQ_IRQ_PENDING KVM_ARCH_REQ(1)
51+#define KVM_REQ_VCPU_RESET KVM_ARCH_REQ(2)
5152
5253 DECLARE_STATIC_KEY_FALSE(userspace_irqchip_in_use);
5354
@@ -147,6 +148,13 @@ struct kvm_cpu_context { · 93 unmodified lines
147148
148149 typedef struct kvm_cpu_context kvm_cpu_context_t;
149150
151+struct vcpu_reset_state {
152+ unsigned long pc;
153+ unsigned long r0;
154+ bool be;
155+ bool reset;
156+};
157+
150158 struct kvm_vcpu_arch {
151159 struct kvm_cpu_context ctxt;
152160
@@ -186,6 +194,8 @@ struct kvm_vcpu_arch { · 33 unmodified lines
186194 /* Cache some mmu pages needed inside spinlock regions */
187195 struct kvm_mmu_memory_cache mmu_page_cache;
188196
197+ struct vcpu_reset_state reset_state;
198+
189199 /* Detect first run of a vcpu */
190200 bool has_run_once;
191201 };
arch/arm/include/asm/stage2_pgtable.h+5−0
@@ -76,4 +76,9 @@ static inline bool kvm_stage2_has_pud(struct kvm *kvm) · 75 unmodified lines
7676 #define S2_PMD_MASK PMD_MASK
7777 #define S2_PMD_SIZE PMD_SIZE
7878
79+static inline bool kvm_stage2_has_pmd(struct kvm *kvm)
80+{
81+ return true;
82+}
83+
7984 #endif /* __ARM_S2_PGTABLE_H_ */
arch/arm/kvm/coproc.c+2−2
@@ -1450,6 +1450,6 @@ void kvm_reset_coprocs(struct kvm_vcpu *vcpu) · 1449 unmodified lines
14501450 reset_coproc_regs(vcpu, table, num);
14511451
14521452 for (num = 1; num < NR_CP15_REGS; num++)
1453− if (vcpu_cp15(vcpu, num) == 0x42424242)
1454− panic("Didn't reset vcpu_cp15(vcpu, %zi)", num);
1453+ WARN(vcpu_cp15(vcpu, num) == 0x42424242,
1454+ "Didn't reset vcpu_cp15(vcpu, %zi)", num);
14551455 }
arch/arm/kvm/reset.c+24−0
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include <asm/cputype.h>
2727 #include <asm/kvm_arm.h>
2828 #include <asm/kvm_coproc.h>
29+#include <asm/kvm_emulate.h>
2930
3031 #include <kvm/arm_arch_timer.h>
3132
@@ -69,6 +70,29 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) · 37 unmodified lines
6970 /* Reset CP15 registers */
7071 kvm_reset_coprocs(vcpu);
7172
73+ /*
74+ * Additional reset state handling that PSCI may have imposed on us.
75+ * Must be done after all the sys_reg reset.
76+ */
77+ if (READ_ONCE(vcpu->arch.reset_state.reset)) {
78+ unsigned long target_pc = vcpu->arch.reset_state.pc;
79+
80+ /* Gracefully handle Thumb2 entry point */
81+ if (target_pc & 1) {
82+ target_pc &= ~1UL;
83+ vcpu_set_thumb(vcpu);
84+ }
85+
86+ /* Propagate caller endianness */
87+ if (vcpu->arch.reset_state.be)
88+ kvm_vcpu_set_be(vcpu);
89+
90+ *vcpu_pc(vcpu) = target_pc;
91+ vcpu_set_reg(vcpu, 0, vcpu->arch.reset_state.r0);
92+
93+ vcpu->arch.reset_state.reset = false;
94+ }
95+
7296 /* Reset arch_timer context */
7397 return kvm_timer_vcpu_reset(vcpu);
7498 }
arch/arm64/include/asm/kvm_host.h+11−0
@@ -48,6 +48,7 @@ · 47 unmodified lines
4848 #define KVM_REQ_SLEEP \
4949 KVM_ARCH_REQ_FLAGS(0, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
5050 #define KVM_REQ_IRQ_PENDING KVM_ARCH_REQ(1)
51+#define KVM_REQ_VCPU_RESET KVM_ARCH_REQ(2)
5152
5253 DECLARE_STATIC_KEY_FALSE(userspace_irqchip_in_use);
5354
@@ -208,6 +209,13 @@ struct kvm_cpu_context { · 154 unmodified lines
208209
209210 typedef struct kvm_cpu_context kvm_cpu_context_t;
210211
212+struct vcpu_reset_state {
213+ unsigned long pc;
214+ unsigned long r0;
215+ bool be;
216+ bool reset;
217+};
218+
211219 struct kvm_vcpu_arch {
212220 struct kvm_cpu_context ctxt;
213221
@@ -297,6 +305,9 @@ struct kvm_vcpu_arch { · 83 unmodified lines
297305 /* Virtual SError ESR to restore when HCR_EL2.VSE is set */
298306 u64 vsesr_el2;
299307
308+ /* Additional reset state */
309+ struct vcpu_reset_state reset_state;
310+
300311 /* True when deferrable sysregs are loaded on the physical CPU,
301312 * see kvm_vcpu_load_sysregs and kvm_vcpu_put_sysregs. */
302313 bool sysregs_loaded_on_cpu;
arch/arm64/kvm/hyp/switch.c+5−0
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include <kvm/arm_psci.h>
2424
2525 #include <asm/cpufeature.h>
26+#include <asm/kprobes.h>
2627 #include <asm/kvm_asm.h>
2728 #include <asm/kvm_emulate.h>
2829 #include <asm/kvm_host.h>
@@ -107,6 +108,7 @@ static void activate_traps_vhe(struct kvm_vcpu *vcpu) · 78 unmodified lines
107108
108109 write_sysreg(kvm_get_hyp_vector(), vbar_el1);
109110 }
111+NOKPROBE_SYMBOL(activate_traps_vhe);
110112
111113 static void __hyp_text __activate_traps_nvhe(struct kvm_vcpu *vcpu)
112114 {
@@ -154,6 +156,7 @@ static void deactivate_traps_vhe(void) · 41 unmodified lines
154156 write_sysreg(CPACR_EL1_DEFAULT, cpacr_el1);
155157 write_sysreg(vectors, vbar_el1);
156158 }
159+NOKPROBE_SYMBOL(deactivate_traps_vhe);
157160
158161 static void __hyp_text __deactivate_traps_nvhe(void)
159162 {
@@ -513,6 +516,7 @@ int kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu) · 353 unmodified lines
513516
514517 return exit_code;
515518 }
519+NOKPROBE_SYMBOL(kvm_vcpu_run_vhe);
516520
517521 /* Switch to the guest for legacy non-VHE systems */
518522 int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu)
@@ -620,6 +624,7 @@ static void __hyp_call_panic_vhe(u64 spsr, u64 elr, u64 par, · 101 unmodified lines
620624 read_sysreg_el2(esr), read_sysreg_el2(far),
621625 read_sysreg(hpfar_el2), par, vcpu);
622626 }
627+NOKPROBE_SYMBOL(__hyp_call_panic_vhe);
623628
624629 void __hyp_text __noreturn hyp_panic(struct kvm_cpu_context *host_ctxt)
625630 {
arch/arm64/kvm/hyp/sysreg-sr.c+5−0
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 #include <linux/compiler.h>
1919 #include <linux/kvm_host.h>
2020
21+#include <asm/kprobes.h>
2122 #include <asm/kvm_asm.h>
2223 #include <asm/kvm_emulate.h>
2324 #include <asm/kvm_hyp.h>
@@ -98,12 +99,14 @@ void sysreg_save_host_state_vhe(struct kvm_cpu_context *ctxt) · 74 unmodified lines
9899 {
99100 __sysreg_save_common_state(ctxt);
100101 }
102+NOKPROBE_SYMBOL(sysreg_save_host_state_vhe);
101103
102104 void sysreg_save_guest_state_vhe(struct kvm_cpu_context *ctxt)
103105 {
104106 __sysreg_save_common_state(ctxt);
105107 __sysreg_save_el2_return_state(ctxt);
106108 }
109+NOKPROBE_SYMBOL(sysreg_save_guest_state_vhe);
107110
108111 static void __hyp_text __sysreg_restore_common_state(struct kvm_cpu_context *ctxt)
109112 {
@@ -188,12 +191,14 @@ void sysreg_restore_host_state_vhe(struct kvm_cpu_context *ctxt) · 78 unmodified lines
188191 {
189192 __sysreg_restore_common_state(ctxt);
190193 }
194+NOKPROBE_SYMBOL(sysreg_restore_host_state_vhe);
191195
192196 void sysreg_restore_guest_state_vhe(struct kvm_cpu_context *ctxt)
193197 {
194198 __sysreg_restore_common_state(ctxt);
195199 __sysreg_restore_el2_return_state(ctxt);
196200 }
201+NOKPROBE_SYMBOL(sysreg_restore_guest_state_vhe);
197202
198203 void __hyp_text __sysreg32_save_state(struct kvm_vcpu *vcpu)
199204 {
arch/arm64/kvm/reset.c+48−2
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include <asm/kvm_arm.h>
3333 #include <asm/kvm_asm.h>
3434 #include <asm/kvm_coproc.h>
35+#include <asm/kvm_emulate.h>
3536 #include <asm/kvm_mmu.h>
3637
3738 /* Maximum phys_shift supported for any VM on this host */
@@ -105,16 +106,33 @@ int kvm_arch_vm_ioctl_check_extension(struct kvm *kvm, long ext) · 67 unmodified lines
105106 * This function finds the right table above and sets the registers on
106107 * the virtual CPU struct to their architecturally defined reset
107108 * values.
109+ *
110+ * Note: This function can be called from two paths: The KVM_ARM_VCPU_INIT
111+ * ioctl or as part of handling a request issued by another VCPU in the PSCI
112+ * handling code. In the first case, the VCPU will not be loaded, and in the
113+ * second case the VCPU will be loaded. Because this function operates purely
114+ * on the memory-backed valus of system registers, we want to do a full put if
115+ * we were loaded (handling a request) and load the values back at the end of
116+ * the function. Otherwise we leave the state alone. In both cases, we
117+ * disable preemption around the vcpu reset as we would otherwise race with
118+ * preempt notifiers which also call put/load.
108119 */
109120 int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
110121 {
111122 const struct kvm_regs *cpu_reset;
123+ int ret = -EINVAL;
124+ bool loaded;
125+
126+ preempt_disable();
127+ loaded = (vcpu->cpu != -1);
128+ if (loaded)
129+ kvm_arch_vcpu_put(vcpu);
112130
113131 switch (vcpu->arch.target) {
114132 default:
115133 if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) {
116134 if (!cpu_has_32bit_el1())
117− return -EINVAL;
135+ goto out;
118136 cpu_reset = &default_regs_reset32;
119137 } else {
120138 cpu_reset = &default_regs_reset;
@@ -129,6 +147,29 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) · 8 unmodified lines
129147 /* Reset system registers */
130148 kvm_reset_sys_regs(vcpu);
131149
150+ /*
151+ * Additional reset state handling that PSCI may have imposed on us.
152+ * Must be done after all the sys_reg reset.
153+ */
154+ if (vcpu->arch.reset_state.reset) {
155+ unsigned long target_pc = vcpu->arch.reset_state.pc;
156+
157+ /* Gracefully handle Thumb2 entry point */
158+ if (vcpu_mode_is_32bit(vcpu) && (target_pc & 1)) {
159+ target_pc &= ~1UL;
160+ vcpu_set_thumb(vcpu);
161+ }
162+
163+ /* Propagate caller endianness */
164+ if (vcpu->arch.reset_state.be)
165+ kvm_vcpu_set_be(vcpu);
166+
167+ *vcpu_pc(vcpu) = target_pc;
168+ vcpu_set_reg(vcpu, 0, vcpu->arch.reset_state.r0);
169+
170+ vcpu->arch.reset_state.reset = false;
171+ }
172+
132173 /* Reset PMU */
133174 kvm_pmu_vcpu_reset(vcpu);
134175
@@ -137,7 +178,12 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) · 2 unmodified lines
137178 vcpu->arch.workaround_flags |= VCPU_WORKAROUND_2_FLAG;
138179
139180 /* Reset timer */
140− return kvm_timer_vcpu_reset(vcpu);
181+ ret = kvm_timer_vcpu_reset(vcpu);
182+out:
183+ if (loaded)
184+ kvm_arch_vcpu_load(vcpu, smp_processor_id());
185+ preempt_enable();
186+ return ret;
141187 }
142188
143189 void kvm_set_ipa_limit(void)
arch/arm64/kvm/sys_regs.c+32−18
@@ -314,12 +314,29 @@ static bool trap_raz_wi(struct kvm_vcpu *vcpu, · 313 unmodified lines
314314 return read_zero(vcpu, p);
315315 }
316316
317−static bool trap_undef(struct kvm_vcpu *vcpu,
318− struct sys_reg_params *p,
319− const struct sys_reg_desc *r)
317+/*
318+ * ARMv8.1 mandates at least a trivial LORegion implementation, where all the
319+ * RW registers are RES0 (which we can implement as RAZ/WI). On an ARMv8.0
320+ * system, these registers should UNDEF. LORID_EL1 being a RO register, we
321+ * treat it separately.
322+ */
323+static bool trap_loregion(struct kvm_vcpu *vcpu,
324+ struct sys_reg_params *p,
325+ const struct sys_reg_desc *r)
320326 {
321− kvm_inject_undefined(vcpu);
322− return false;
327+ u64 val = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1);
328+ u32 sr = sys_reg((u32)r->Op0, (u32)r->Op1,
329+ (u32)r->CRn, (u32)r->CRm, (u32)r->Op2);
330+
331+ if (!(val & (0xfUL << ID_AA64MMFR1_LOR_SHIFT))) {
332+ kvm_inject_undefined(vcpu);
333+ return false;
334+ }
335+
336+ if (p->is_write && sr == SYS_LORID_EL1)
337+ return write_to_read_only(vcpu, p, r);
338+
339+ return trap_raz_wi(vcpu, p, r);
323340 }
324341
325342 static bool trap_oslsr_el1(struct kvm_vcpu *vcpu,
@@ -1048,11 +1065,6 @@ static u64 read_id_reg(struct sys_reg_desc const *r, bool raz) · 722 unmodified lines
10481065 if (val & ptrauth_mask)
10491066 kvm_debug("ptrauth unsupported for guests, suppressing\n");
10501067 val &= ~ptrauth_mask;
1051− } else if (id == SYS_ID_AA64MMFR1_EL1) {
1052− if (val & (0xfUL << ID_AA64MMFR1_LOR_SHIFT))
1053− kvm_debug("LORegions unsupported for guests, suppressing\n");
1054−
1055− val &= ~(0xfUL << ID_AA64MMFR1_LOR_SHIFT);
10561068 }
10571069
10581070 return val;
@@ -1338,11 +1350,11 @@ static const struct sys_reg_desc sys_reg_descs[] = { · 279 unmodified lines
13381350 { SYS_DESC(SYS_MAIR_EL1), access_vm_reg, reset_unknown, MAIR_EL1 },
13391351 { SYS_DESC(SYS_AMAIR_EL1), access_vm_reg, reset_amair_el1, AMAIR_EL1 },
13401352
1341− { SYS_DESC(SYS_LORSA_EL1), trap_undef },
1342− { SYS_DESC(SYS_LOREA_EL1), trap_undef },
1343− { SYS_DESC(SYS_LORN_EL1), trap_undef },
1344− { SYS_DESC(SYS_LORC_EL1), trap_undef },
1345− { SYS_DESC(SYS_LORID_EL1), trap_undef },
1353+ { SYS_DESC(SYS_LORSA_EL1), trap_loregion },
1354+ { SYS_DESC(SYS_LOREA_EL1), trap_loregion },
1355+ { SYS_DESC(SYS_LORN_EL1), trap_loregion },
1356+ { SYS_DESC(SYS_LORC_EL1), trap_loregion },
1357+ { SYS_DESC(SYS_LORID_EL1), trap_loregion },
13461358
13471359 { SYS_DESC(SYS_VBAR_EL1), NULL, reset_val, VBAR_EL1, 0 },
13481360 { SYS_DESC(SYS_DISR_EL1), NULL, reset_val, DISR_EL1, 0 },
@@ -2596,7 +2608,9 @@ void kvm_reset_sys_regs(struct kvm_vcpu *vcpu) · 1247 unmodified lines
25962608 table = get_target_table(vcpu->arch.target, true, &num);
25972609 reset_sys_reg_descs(vcpu, table, num);
25982610
2599− for (num = 1; num < NR_SYS_REGS; num++)
2600− if (__vcpu_sys_reg(vcpu, num) == 0x4242424242424242)
2601− panic("Didn't reset __vcpu_sys_reg(%zi)", num);
2611+ for (num = 1; num < NR_SYS_REGS; num++) {
2612+ if (WARN(__vcpu_sys_reg(vcpu, num) == 0x4242424242424242,
2613+ "Didn't reset __vcpu_sys_reg(%zi)\n", num))
2614+ break;
2615+ }
26022616 }
arch/x86/kvm/vmx/nested.c+9−3
@@ -2473,6 +2473,10 @@ static int nested_check_vm_execution_controls(struct kvm_vcpu *vcpu, · 2472 unmodified lines
24732473 (nested_cpu_has_vpid(vmcs12) && !vmcs12->virtual_processor_id))
24742474 return -EINVAL;
24752475
2476+ if (!nested_cpu_has_preemption_timer(vmcs12) &&
2477+ nested_cpu_has_save_preemption_timer(vmcs12))
2478+ return -EINVAL;
2479+
24762480 if (nested_cpu_has_ept(vmcs12) &&
24772481 !valid_ept_address(vcpu, vmcs12->ept_pointer))
24782482 return -EINVAL;
@@ -5557,9 +5561,11 @@ void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, u32 ept_caps, · 3078 unmodified lines
55575561 * secondary cpu-based controls. Do not include those that
55585562 * depend on CPUID bits, they are added later by vmx_cpuid_update.
55595563 */
5560− rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2,
5561− msrs->secondary_ctls_low,
5562− msrs->secondary_ctls_high);
5564+ if (msrs->procbased_ctls_high & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)
5565+ rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2,
5566+ msrs->secondary_ctls_low,
5567+ msrs->secondary_ctls_high);
5568+
55635569 msrs->secondary_ctls_low = 0;
55645570 msrs->secondary_ctls_high &=
55655571 SECONDARY_EXEC_DESC |
arch/x86/kvm/vmx/vmx.c+13−16
@@ -863,7 +863,8 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr, · 862 unmodified lines
863863 if (!entry_only)
864864 j = find_msr(&m->host, msr);
865865
866− if (i == NR_AUTOLOAD_MSRS || j == NR_AUTOLOAD_MSRS) {
866+ if ((i < 0 && m->guest.nr == NR_AUTOLOAD_MSRS) ||
867+ (j < 0 && m->host.nr == NR_AUTOLOAD_MSRS)) {
867868 printk_once(KERN_WARNING "Not enough msr switch entries. "
868869 "Can't add msr %x\n", msr);
869870 return;
@@ -1193,21 +1194,6 @@ static void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) · 323 unmodified lines
11931194 if (!pi_test_sn(pi_desc) && vcpu->cpu == cpu)
11941195 return;
11951196
1196− /*
1197− * First handle the simple case where no cmpxchg is necessary; just
1198− * allow posting non-urgent interrupts.
1199− *
1200− * If the 'nv' field is POSTED_INTR_WAKEUP_VECTOR, do not change
1201− * PI.NDST: pi_post_block will do it for us and the wakeup_handler
1202− * expects the VCPU to be on the blocked_vcpu_list that matches
1203− * PI.NDST.
1204− */
1205− if (pi_desc->nv == POSTED_INTR_WAKEUP_VECTOR ||
1206− vcpu->cpu == cpu) {
1207− pi_clear_sn(pi_desc);
1208− return;
1209− }
1210−
12111197 /* The full case. */
12121198 do {
12131199 old.control = new.control = pi_desc->control;
@@ -1222,6 +1208,17 @@ static void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) · 8 unmodified lines
12221208 new.sn = 0;
12231209 } while (cmpxchg64(&pi_desc->control, old.control,
12241210 new.control) != old.control);
1211+
1212+ /*
1213+ * Clear SN before reading the bitmap. The VT-d firmware
1214+ * writes the bitmap and reads SN atomically (5.2.3 in the
1215+ * spec), so it doesn't really have a memory barrier that
1216+ * pairs with this, but we cannot do that and we need one.
1217+ */
1218+ smp_mb__after_atomic();
1219+
1220+ if (!bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS))
1221+ pi_set_on(pi_desc);
12251222 }
12261223
12271224 /*
arch/x86/kvm/vmx/vmx.h+5−5
@@ -337,16 +337,16 @@ static inline int pi_test_and_set_pir(int vector, struct pi_desc *pi_desc) · 336 unmodified lines
337337 return test_and_set_bit(vector, (unsigned long *)pi_desc->pir);
338338 }
339339
340−static inline void pi_clear_sn(struct pi_desc *pi_desc)
340+static inline void pi_set_sn(struct pi_desc *pi_desc)
341341 {
342− return clear_bit(POSTED_INTR_SN,
342+ return set_bit(POSTED_INTR_SN,
343343 (unsigned long *)&pi_desc->control);
344344 }
345345
346−static inline void pi_set_sn(struct pi_desc *pi_desc)
346+static inline void pi_set_on(struct pi_desc *pi_desc)
347347 {
348− return set_bit(POSTED_INTR_SN,
349− (unsigned long *)&pi_desc->control);
348+ set_bit(POSTED_INTR_ON,
349+ (unsigned long *)&pi_desc->control);
350350 }
351351
352352 static inline void pi_clear_on(struct pi_desc *pi_desc)
arch/x86/kvm/x86.c+1−1
@@ -7801,7 +7801,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) · 7800 unmodified lines
78017801 * 1) We should set ->mode before checking ->requests. Please see
78027802 * the comment in kvm_vcpu_exiting_guest_mode().
78037803 *
7804− * 2) For APICv, we should set ->mode before checking PIR.ON. This
7804+ * 2) For APICv, we should set ->mode before checking PID.ON. This
78057805 * pairs with the memory barrier implicit in pi_test_and_set_on
78067806 * (see vmx_deliver_posted_interrupt).
78077807 *
include/kvm/arm_vgic.h+3−3
@@ -100,7 +100,7 @@ enum vgic_irq_config { · 99 unmodified lines
100100 };
101101
102102 struct vgic_irq {
103− spinlock_t irq_lock; /* Protects the content of the struct */
103+ raw_spinlock_t irq_lock; /* Protects the content of the struct */
104104 struct list_head lpi_list; /* Used to link all LPIs together */
105105 struct list_head ap_list;
106106
@@ -256,7 +256,7 @@ struct vgic_dist { · 149 unmodified lines
256256 u64 propbaser;
257257
258258 /* Protects the lpi_list and the count value below. */
259− spinlock_t lpi_list_lock;
259+ raw_spinlock_t lpi_list_lock;
260260 struct list_head lpi_list_head;
261261 int lpi_list_count;
262262
@@ -307,7 +307,7 @@ struct vgic_cpu { · 44 unmodified lines
307307 unsigned int used_lrs;
308308 struct vgic_irq private_irqs[VGIC_NR_PRIVATE_IRQS];
309309
310− spinlock_t ap_list_lock; /* Protects the ap_list */
310+ raw_spinlock_t ap_list_lock; /* Protects the ap_list */
311311
312312 /*
313313 * List of IRQs that this VCPU should consider because they are either
virt/kvm/arm/arm.c+10−0
@@ -626,6 +626,13 @@ static void vcpu_req_sleep(struct kvm_vcpu *vcpu) · 625 unmodified lines
626626 /* Awaken to handle a signal, request we sleep again later. */
627627 kvm_make_request(KVM_REQ_SLEEP, vcpu);
628628 }
629+
630+ /*
631+ * Make sure we will observe a potential reset request if we've
632+ * observed a change to the power state. Pairs with the smp_wmb() in
633+ * kvm_psci_vcpu_on().
634+ */
635+ smp_rmb();
629636 }
630637
631638 static int kvm_vcpu_initialized(struct kvm_vcpu *vcpu)
@@ -639,6 +646,9 @@ static void check_vcpu_requests(struct kvm_vcpu *vcpu) · 7 unmodified lines
639646 if (kvm_check_request(KVM_REQ_SLEEP, vcpu))
640647 vcpu_req_sleep(vcpu);
641648
649+ if (kvm_check_request(KVM_REQ_VCPU_RESET, vcpu))
650+ kvm_reset_vcpu(vcpu);
651+
642652 /*
643653 * Clear IRQ_PENDING requests that were made to guarantee
644654 * that a VCPU sees new virtual interrupts.
virt/kvm/arm/mmu.c+6−3
@@ -1695,11 +1695,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, · 1694 unmodified lines
16951695
16961696 vma_pagesize = vma_kernel_pagesize(vma);
16971697 /*
1698− * PUD level may not exist for a VM but PMD is guaranteed to
1699− * exist.
1698+ * The stage2 has a minimum of 2 level table (For arm64 see
1699+ * kvm_arm_setup_stage2()). Hence, we are guaranteed that we can
1700+ * use PMD_SIZE huge mappings (even when the PMD is folded into PGD).
1701+ * As for PUD huge maps, we must make sure that we have at least
1702+ * 3 levels, i.e, PMD is not folded.
17001703 */
17011704 if ((vma_pagesize == PMD_SIZE ||
1702− (vma_pagesize == PUD_SIZE && kvm_stage2_has_pud(kvm))) &&
1705+ (vma_pagesize == PUD_SIZE && kvm_stage2_has_pmd(kvm))) &&
17031706 !force_pte) {
17041707 gfn = (fault_ipa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT;
17051708 }
virt/kvm/arm/psci.c+16−20
@@ -104,12 +104,10 @@ static void kvm_psci_vcpu_off(struct kvm_vcpu *vcpu) · 103 unmodified lines
104104
105105 static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
106106 {
107+ struct vcpu_reset_state *reset_state;
107108 struct kvm *kvm = source_vcpu->kvm;
108109 struct kvm_vcpu *vcpu = NULL;
109− struct swait_queue_head *wq;
110110 unsigned long cpu_id;
111− unsigned long context_id;
112− phys_addr_t target_pc;
113111
114112 cpu_id = smccc_get_arg1(source_vcpu) & MPIDR_HWID_BITMASK;
115113 if (vcpu_mode_is_32bit(source_vcpu))
@@ -130,32 +128,30 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) · 14 unmodified lines
130128 return PSCI_RET_INVALID_PARAMS;
131129 }
132130
133− target_pc = smccc_get_arg2(source_vcpu);
134− context_id = smccc_get_arg3(source_vcpu);
131+ reset_state = &vcpu->arch.reset_state;
135132
136− kvm_reset_vcpu(vcpu);
137−
138− /* Gracefully handle Thumb2 entry point */
139− if (vcpu_mode_is_32bit(vcpu) && (target_pc & 1)) {
140− target_pc &= ~((phys_addr_t) 1);
141− vcpu_set_thumb(vcpu);
142− }
133+ reset_state->pc = smccc_get_arg2(source_vcpu);
143134
144135 /* Propagate caller endianness */
145− if (kvm_vcpu_is_be(source_vcpu))
146− kvm_vcpu_set_be(vcpu);
136+ reset_state->be = kvm_vcpu_is_be(source_vcpu);
147137
148− *vcpu_pc(vcpu) = target_pc;
149138 /*
150139 * NOTE: We always update r0 (or x0) because for PSCI v0.1
151140 * the general puspose registers are undefined upon CPU_ON.
152141 */
153− smccc_set_retval(vcpu, context_id, 0, 0, 0);
154− vcpu->arch.power_off = false;
155− smp_mb(); /* Make sure the above is visible */
142+ reset_state->r0 = smccc_get_arg3(source_vcpu);
143+
144+ WRITE_ONCE(reset_state->reset, true);
145+ kvm_make_request(KVM_REQ_VCPU_RESET, vcpu);
156146
157− wq = kvm_arch_vcpu_wq(vcpu);
158− swake_up_one(wq);
147+ /*
148+ * Make sure the reset request is observed if the change to
149+ * power_state is observed.
150+ */
151+ smp_wmb();
152+
153+ vcpu->arch.power_off = false;
154+ kvm_vcpu_wake_up(vcpu);
159155
160156 return PSCI_RET_SUCCESS;
161157 }
virt/kvm/arm/vgic/vgic-debug.c+2−2
@@ -251,9 +251,9 @@ static int vgic_debug_show(struct seq_file *s, void *v) · 250 unmodified lines
251251 return 0;
252252 }
253253
254− spin_lock_irqsave(&irq->irq_lock, flags);
254+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
255255 print_irq_state(s, irq, vcpu);
256− spin_unlock_irqrestore(&irq->irq_lock, flags);
256+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
257257
258258 vgic_put_irq(kvm, irq);
259259 return 0;
virt/kvm/arm/vgic/vgic-init.c+18−12
@@ -64,7 +64,7 @@ void kvm_vgic_early_init(struct kvm *kvm) · 63 unmodified lines
6464 struct vgic_dist *dist = &kvm->arch.vgic;
6565
6666 INIT_LIST_HEAD(&dist->lpi_list_head);
67− spin_lock_init(&dist->lpi_list_lock);
67+ raw_spin_lock_init(&dist->lpi_list_lock);
6868 }
6969
7070 /* CREATION */
@@ -171,7 +171,7 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis) · 100 unmodified lines
171171
172172 irq->intid = i + VGIC_NR_PRIVATE_IRQS;
173173 INIT_LIST_HEAD(&irq->ap_list);
174− spin_lock_init(&irq->irq_lock);
174+ raw_spin_lock_init(&irq->irq_lock);
175175 irq->vcpu = NULL;
176176 irq->target_vcpu = vcpu0;
177177 kref_init(&irq->refcount);
@@ -206,7 +206,7 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) · 28 unmodified lines
206206 vgic_cpu->sgi_iodev.base_addr = VGIC_ADDR_UNDEF;
207207
208208 INIT_LIST_HEAD(&vgic_cpu->ap_list_head);
209− spin_lock_init(&vgic_cpu->ap_list_lock);
209+ raw_spin_lock_init(&vgic_cpu->ap_list_lock);
210210
211211 /*
212212 * Enable and configure all SGIs to be edge-triggered and
@@ -216,7 +216,7 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) · 3 unmodified lines
216216 struct vgic_irq *irq = &vgic_cpu->private_irqs[i];
217217
218218 INIT_LIST_HEAD(&irq->ap_list);
219− spin_lock_init(&irq->irq_lock);
219+ raw_spin_lock_init(&irq->irq_lock);
220220 irq->intid = i;
221221 irq->vcpu = NULL;
222222 irq->target_vcpu = vcpu;
@@ -231,13 +231,6 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) · 8 unmodified lines
231231 irq->config = VGIC_CONFIG_LEVEL;
232232 }
233233
234− /*
235− * GICv3 can only be created via the KVM_DEVICE_CREATE API and
236− * so we always know the emulation type at this point as it's
237− * either explicitly configured as GICv3, or explicitly
238− * configured as GICv2, or not configured yet which also
239− * implies GICv2.
240− */
241234 if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3)
242235 irq->group = 1;
243236 else
@@ -281,7 +274,7 @@ int vgic_init(struct kvm *kvm) · 37 unmodified lines
281274 {
282275 struct vgic_dist *dist = &kvm->arch.vgic;
283276 struct kvm_vcpu *vcpu;
284− int ret = 0, i;
277+ int ret = 0, i, idx;
285278
286279 if (vgic_initialized(kvm))
287280 return 0;
@@ -298,6 +291,19 @@ int vgic_init(struct kvm *kvm) · 10 unmodified lines
298291 if (ret)
299292 goto out;
300293
294+ /* Initialize groups on CPUs created before the VGIC type was known */
295+ kvm_for_each_vcpu(idx, vcpu, kvm) {
296+ struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
297+
298+ for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) {
299+ struct vgic_irq *irq = &vgic_cpu->private_irqs[i];
300+ if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3)
301+ irq->group = 1;
302+ else
303+ irq->group = 0;
304+ }
305+ }
306+
301307 if (vgic_has_its(kvm)) {
302308 ret = vgic_v4_init(kvm);
303309 if (ret)
virt/kvm/arm/vgic/vgic-its.c+11−11
@@ -65,7 +65,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid, · 64 unmodified lines
6565
6666 INIT_LIST_HEAD(&irq->lpi_list);
6767 INIT_LIST_HEAD(&irq->ap_list);
68− spin_lock_init(&irq->irq_lock);
68+ raw_spin_lock_init(&irq->irq_lock);
6969
7070 irq->config = VGIC_CONFIG_EDGE;
7171 kref_init(&irq->refcount);
@@ -73,7 +73,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid, · 1 unmodified line
7373 irq->target_vcpu = vcpu;
7474 irq->group = 1;
7575
76− spin_lock_irqsave(&dist->lpi_list_lock, flags);
76+ raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
7777
7878 /*
7979 * There could be a race with another vgic_add_lpi(), so we need to
@@ -101,7 +101,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid, · 21 unmodified lines
101101 dist->lpi_list_count++;
102102
103103 out_unlock:
104− spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
104+ raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
105105
106106 /*
107107 * We "cache" the configuration table entries in our struct vgic_irq's.
@@ -287,7 +287,7 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq, · 179 unmodified lines
287287 if (ret)
288288 return ret;
289289
290− spin_lock_irqsave(&irq->irq_lock, flags);
290+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
291291
292292 if (!filter_vcpu || filter_vcpu == irq->target_vcpu) {
293293 irq->priority = LPI_PROP_PRIORITY(prop);
@@ -299,7 +299,7 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq, · 5 unmodified lines
299299 }
300300 }
301301
302− spin_unlock_irqrestore(&irq->irq_lock, flags);
302+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
303303
304304 if (irq->hw)
305305 return its_prop_update_vlpi(irq->host_irq, prop, needs_inv);
@@ -332,7 +332,7 @@ int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr) · 26 unmodified lines
332332 if (!intids)
333333 return -ENOMEM;
334334
335− spin_lock_irqsave(&dist->lpi_list_lock, flags);
335+ raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
336336 list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) {
337337 if (i == irq_count)
338338 break;
@@ -341,7 +341,7 @@ int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr) · 2 unmodified lines
341341 continue;
342342 intids[i++] = irq->intid;
343343 }
344− spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
344+ raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
345345
346346 *intid_ptr = intids;
347347 return i;
@@ -352,9 +352,9 @@ static int update_affinity(struct vgic_irq *irq, struct kvm_vcpu *vcpu) · 4 unmodified lines
352352 int ret = 0;
353353 unsigned long flags;
354354
355− spin_lock_irqsave(&irq->irq_lock, flags);
355+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
356356 irq->target_vcpu = vcpu;
357− spin_unlock_irqrestore(&irq->irq_lock, flags);
357+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
358358
359359 if (irq->hw) {
360360 struct its_vlpi_map map;
@@ -455,7 +455,7 @@ static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu) · 94 unmodified lines
455455 }
456456
457457 irq = vgic_get_irq(vcpu->kvm, NULL, intids[i]);
458− spin_lock_irqsave(&irq->irq_lock, flags);
458+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
459459 irq->pending_latch = pendmask & (1U << bit_nr);
460460 vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
461461 vgic_put_irq(vcpu->kvm, irq);
@@ -612,7 +612,7 @@ static int vgic_its_trigger_msi(struct kvm *kvm, struct vgic_its *its, · 150 unmodified lines
612612 return irq_set_irqchip_state(irq->host_irq,
613613 IRQCHIP_STATE_PENDING, true);
614614
615− spin_lock_irqsave(&irq->irq_lock, flags);
615+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
616616 irq->pending_latch = true;
617617 vgic_queue_irq_unlock(kvm, irq, flags);
618618
virt/kvm/arm/vgic/vgic-mmio-v2.c+7−7
@@ -147,7 +147,7 @@ static void vgic_mmio_write_sgir(struct kvm_vcpu *source_vcpu, · 146 unmodified lines
147147
148148 irq = vgic_get_irq(source_vcpu->kvm, vcpu, intid);
149149
150− spin_lock_irqsave(&irq->irq_lock, flags);
150+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
151151 irq->pending_latch = true;
152152 irq->source |= 1U << source_vcpu->vcpu_id;
153153
@@ -191,13 +191,13 @@ static void vgic_mmio_write_target(struct kvm_vcpu *vcpu, · 37 unmodified lines
191191 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, NULL, intid + i);
192192 int target;
193193
194− spin_lock_irqsave(&irq->irq_lock, flags);
194+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
195195
196196 irq->targets = (val >> (i * 8)) & cpu_mask;
197197 target = irq->targets ? __ffs(irq->targets) : 0;
198198 irq->target_vcpu = kvm_get_vcpu(vcpu->kvm, target);
199199
200− spin_unlock_irqrestore(&irq->irq_lock, flags);
200+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
201201 vgic_put_irq(vcpu->kvm, irq);
202202 }
203203 }
@@ -230,13 +230,13 @@ static void vgic_mmio_write_sgipendc(struct kvm_vcpu *vcpu, · 26 unmodified lines
230230 for (i = 0; i < len; i++) {
231231 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
232232
233− spin_lock_irqsave(&irq->irq_lock, flags);
233+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
234234
235235 irq->source &= ~((val >> (i * 8)) & 0xff);
236236 if (!irq->source)
237237 irq->pending_latch = false;
238238
239− spin_unlock_irqrestore(&irq->irq_lock, flags);
239+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
240240 vgic_put_irq(vcpu->kvm, irq);
241241 }
242242 }
@@ -252,7 +252,7 @@ static void vgic_mmio_write_sgipends(struct kvm_vcpu *vcpu, · 9 unmodified lines
252252 for (i = 0; i < len; i++) {
253253 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
254254
255− spin_lock_irqsave(&irq->irq_lock, flags);
255+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
256256
257257 irq->source |= (val >> (i * 8)) & 0xff;
258258
@@ -260,7 +260,7 @@ static void vgic_mmio_write_sgipends(struct kvm_vcpu *vcpu, · 1 unmodified line
260260 irq->pending_latch = true;
261261 vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
262262 } else {
263− spin_unlock_irqrestore(&irq->irq_lock, flags);
263+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
264264 }
265265 vgic_put_irq(vcpu->kvm, irq);
266266 }
virt/kvm/arm/vgic/vgic-mmio-v3.c+6−6
@@ -169,13 +169,13 @@ static void vgic_mmio_write_irouter(struct kvm_vcpu *vcpu, · 168 unmodified lines
169169 if (!irq)
170170 return;
171171
172− spin_lock_irqsave(&irq->irq_lock, flags);
172+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
173173
174174 /* We only care about and preserve Aff0, Aff1 and Aff2. */
175175 irq->mpidr = val & GENMASK(23, 0);
176176 irq->target_vcpu = kvm_mpidr_to_vcpu(vcpu->kvm, irq->mpidr);
177177
178− spin_unlock_irqrestore(&irq->irq_lock, flags);
178+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
179179 vgic_put_irq(vcpu->kvm, irq);
180180 }
181181
@@ -281,7 +281,7 @@ static int vgic_v3_uaccess_write_pending(struct kvm_vcpu *vcpu, · 99 unmodified lines
281281 for (i = 0; i < len * 8; i++) {
282282 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
283283
284− spin_lock_irqsave(&irq->irq_lock, flags);
284+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
285285 if (test_bit(i, &val)) {
286286 /*
287287 * pending_latch is set irrespective of irq type
@@ -292,7 +292,7 @@ static int vgic_v3_uaccess_write_pending(struct kvm_vcpu *vcpu, · 4 unmodified lines
292292 vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
293293 } else {
294294 irq->pending_latch = false;
295− spin_unlock_irqrestore(&irq->irq_lock, flags);
295+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
296296 }
297297
298298 vgic_put_irq(vcpu->kvm, irq);
@@ -957,7 +957,7 @@ void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg, bool allow_group1) · 658 unmodified lines
957957
958958 irq = vgic_get_irq(vcpu->kvm, c_vcpu, sgi);
959959
960− spin_lock_irqsave(&irq->irq_lock, flags);
960+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
961961
962962 /*
963963 * An access targetting Group0 SGIs can only generate
@@ -968,7 +968,7 @@ void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg, bool allow_group1) · 4 unmodified lines
968968 irq->pending_latch = true;
969969 vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
970970 } else {
971− spin_unlock_irqrestore(&irq->irq_lock, flags);
971+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
972972 }
973973
974974 vgic_put_irq(vcpu->kvm, irq);
virt/kvm/arm/vgic/vgic-mmio.c+17−17
@@ -77,7 +77,7 @@ void vgic_mmio_write_group(struct kvm_vcpu *vcpu, gpa_t addr, · 76 unmodified lines
7777 for (i = 0; i < len * 8; i++) {
7878 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
7979
80− spin_lock_irqsave(&irq->irq_lock, flags);
80+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
8181 irq->group = !!(val & BIT(i));
8282 vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
8383
@@ -120,7 +120,7 @@ void vgic_mmio_write_senable(struct kvm_vcpu *vcpu, · 36 unmodified lines
120120 for_each_set_bit(i, &val, len * 8) {
121121 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
122122
123− spin_lock_irqsave(&irq->irq_lock, flags);
123+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
124124 irq->enabled = true;
125125 vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
126126
@@ -139,11 +139,11 @@ void vgic_mmio_write_cenable(struct kvm_vcpu *vcpu, · 12 unmodified lines
139139 for_each_set_bit(i, &val, len * 8) {
140140 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
141141
142− spin_lock_irqsave(&irq->irq_lock, flags);
142+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
143143
144144 irq->enabled = false;
145145
146− spin_unlock_irqrestore(&irq->irq_lock, flags);
146+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
147147 vgic_put_irq(vcpu->kvm, irq);
148148 }
149149 }
@@ -160,10 +160,10 @@ unsigned long vgic_mmio_read_pending(struct kvm_vcpu *vcpu, · 10 unmodified lines
160160 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
161161 unsigned long flags;
162162
163− spin_lock_irqsave(&irq->irq_lock, flags);
163+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
164164 if (irq_is_pending(irq))
165165 value |= (1U << i);
166− spin_unlock_irqrestore(&irq->irq_lock, flags);
166+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
167167
168168 vgic_put_irq(vcpu->kvm, irq);
169169 }
@@ -215,7 +215,7 @@ void vgic_mmio_write_spending(struct kvm_vcpu *vcpu, · 45 unmodified lines
215215 for_each_set_bit(i, &val, len * 8) {
216216 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
217217
218− spin_lock_irqsave(&irq->irq_lock, flags);
218+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
219219 if (irq->hw)
220220 vgic_hw_irq_spending(vcpu, irq, is_uaccess);
221221 else
@@ -262,14 +262,14 @@ void vgic_mmio_write_cpending(struct kvm_vcpu *vcpu, · 40 unmodified lines
262262 for_each_set_bit(i, &val, len * 8) {
263263 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
264264
265− spin_lock_irqsave(&irq->irq_lock, flags);
265+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
266266
267267 if (irq->hw)
268268 vgic_hw_irq_cpending(vcpu, irq, is_uaccess);
269269 else
270270 irq->pending_latch = false;
271271
272− spin_unlock_irqrestore(&irq->irq_lock, flags);
272+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
273273 vgic_put_irq(vcpu->kvm, irq);
274274 }
275275 }
@@ -311,7 +311,7 @@ static void vgic_mmio_change_active(struct kvm_vcpu *vcpu, struct vgic_irq *irq, · 35 unmodified lines
311311 unsigned long flags;
312312 struct kvm_vcpu *requester_vcpu = vgic_get_mmio_requester_vcpu();
313313
314− spin_lock_irqsave(&irq->irq_lock, flags);
314+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
315315
316316 if (irq->hw) {
317317 vgic_hw_irq_change_active(vcpu, irq, active, !requester_vcpu);
@@ -342,7 +342,7 @@ static void vgic_mmio_change_active(struct kvm_vcpu *vcpu, struct vgic_irq *irq, · 24 unmodified lines
342342 if (irq->active)
343343 vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
344344 else
345− spin_unlock_irqrestore(&irq->irq_lock, flags);
345+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
346346 }
347347
348348 /*
@@ -485,10 +485,10 @@ void vgic_mmio_write_priority(struct kvm_vcpu *vcpu, · 136 unmodified lines
485485 for (i = 0; i < len; i++) {
486486 struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
487487
488− spin_lock_irqsave(&irq->irq_lock, flags);
488+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
489489 /* Narrow the priority range to what we actually support */
490490 irq->priority = (val >> (i * 8)) & GENMASK(7, 8 - VGIC_PRI_BITS);
491− spin_unlock_irqrestore(&irq->irq_lock, flags);
491+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
492492
493493 vgic_put_irq(vcpu->kvm, irq);
494494 }
@@ -534,14 +534,14 @@ void vgic_mmio_write_config(struct kvm_vcpu *vcpu, · 39 unmodified lines
534534 continue;
535535
536536 irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
537− spin_lock_irqsave(&irq->irq_lock, flags);
537+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
538538
539539 if (test_bit(i * 2 + 1, &val))
540540 irq->config = VGIC_CONFIG_EDGE;
541541 else
542542 irq->config = VGIC_CONFIG_LEVEL;
543543
544− spin_unlock_irqrestore(&irq->irq_lock, flags);
544+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
545545 vgic_put_irq(vcpu->kvm, irq);
546546 }
547547 }
@@ -590,12 +590,12 @@ void vgic_write_irq_line_level_info(struct kvm_vcpu *vcpu, u32 intid, · 42 unmodified lines
590590 * restore irq config before line level.
591591 */
592592 new_level = !!(val & (1U << i));
593− spin_lock_irqsave(&irq->irq_lock, flags);
593+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
594594 irq->line_level = new_level;
595595 if (new_level)
596596 vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
597597 else
598− spin_unlock_irqrestore(&irq->irq_lock, flags);
598+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
599599
600600 vgic_put_irq(vcpu->kvm, irq);
601601 }
virt/kvm/arm/vgic/vgic-v2.c+2−2
@@ -84,7 +84,7 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu) · 83 unmodified lines
8484
8585 irq = vgic_get_irq(vcpu->kvm, vcpu, intid);
8686
87− spin_lock(&irq->irq_lock);
87+ raw_spin_lock(&irq->irq_lock);
8888
8989 /* Always preserve the active bit */
9090 irq->active = !!(val & GICH_LR_ACTIVE_BIT);
@@ -127,7 +127,7 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu) · 36 unmodified lines
127127 vgic_irq_set_phys_active(irq, false);
128128 }
129129
130− spin_unlock(&irq->irq_lock);
130+ raw_spin_unlock(&irq->irq_lock);
131131 vgic_put_irq(vcpu->kvm, irq);
132132 }
133133
virt/kvm/arm/vgic/vgic-v3.c+4−4
@@ -76,7 +76,7 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) · 75 unmodified lines
7676 if (!irq) /* An LPI could have been unmapped. */
7777 continue;
7878
79− spin_lock(&irq->irq_lock);
79+ raw_spin_lock(&irq->irq_lock);
8080
8181 /* Always preserve the active bit */
8282 irq->active = !!(val & ICH_LR_ACTIVE_BIT);
@@ -119,7 +119,7 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) · 36 unmodified lines
119119 vgic_irq_set_phys_active(irq, false);
120120 }
121121
122− spin_unlock(&irq->irq_lock);
122+ raw_spin_unlock(&irq->irq_lock);
123123 vgic_put_irq(vcpu->kvm, irq);
124124 }
125125
@@ -347,9 +347,9 @@ retry: · 221 unmodified lines
347347
348348 status = val & (1 << bit_nr);
349349
350− spin_lock_irqsave(&irq->irq_lock, flags);
350+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
351351 if (irq->target_vcpu != vcpu) {
352− spin_unlock_irqrestore(&irq->irq_lock, flags);
352+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
353353 goto retry;
354354 }
355355 irq->pending_latch = status;
virt/kvm/arm/vgic/vgic.c+59−59
@@ -54,11 +54,11 @@ struct vgic_global kvm_vgic_global_state __ro_after_init = { · 53 unmodified lines
5454 * When taking more than one ap_list_lock at the same time, always take the
5555 * lowest numbered VCPU's ap_list_lock first, so:
5656 * vcpuX->vcpu_id < vcpuY->vcpu_id:
57− * spin_lock(vcpuX->arch.vgic_cpu.ap_list_lock);
58− * spin_lock(vcpuY->arch.vgic_cpu.ap_list_lock);
57+ * raw_spin_lock(vcpuX->arch.vgic_cpu.ap_list_lock);
58+ * raw_spin_lock(vcpuY->arch.vgic_cpu.ap_list_lock);
5959 *
6060 * Since the VGIC must support injecting virtual interrupts from ISRs, we have
61− * to use the spin_lock_irqsave/spin_unlock_irqrestore versions of outer
61+ * to use the raw_spin_lock_irqsave/raw_spin_unlock_irqrestore versions of outer
6262 * spinlocks for any lock that may be taken while injecting an interrupt.
6363 */
6464
@@ -72,7 +72,7 @@ static struct vgic_irq *vgic_get_lpi(struct kvm *kvm, u32 intid) · 7 unmodified lines
7272 struct vgic_irq *irq = NULL;
7373 unsigned long flags;
7474
75− spin_lock_irqsave(&dist->lpi_list_lock, flags);
75+ raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
7676
7777 list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) {
7878 if (irq->intid != intid)
@@ -88,7 +88,7 @@ static struct vgic_irq *vgic_get_lpi(struct kvm *kvm, u32 intid) · 9 unmodified lines
8888 irq = NULL;
8989
9090 out_unlock:
91− spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
91+ raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
9292
9393 return irq;
9494 }
@@ -138,15 +138,15 @@ void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq) · 43 unmodified lines
138138 if (irq->intid < VGIC_MIN_LPI)
139139 return;
140140
141− spin_lock_irqsave(&dist->lpi_list_lock, flags);
141+ raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
142142 if (!kref_put(&irq->refcount, vgic_irq_release)) {
143− spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
143+ raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
144144 return;
145145 };
146146
147147 list_del(&irq->lpi_list);
148148 dist->lpi_list_count--;
149− spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
149+ raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
150150
151151 kfree(irq);
152152 }
@@ -244,8 +244,8 @@ static int vgic_irq_cmp(void *priv, struct list_head *a, struct list_head *b) · 91 unmodified lines
244244 bool penda, pendb;
245245 int ret;
246246
247− spin_lock(&irqa->irq_lock);
248− spin_lock_nested(&irqb->irq_lock, SINGLE_DEPTH_NESTING);
247+ raw_spin_lock(&irqa->irq_lock);
248+ raw_spin_lock_nested(&irqb->irq_lock, SINGLE_DEPTH_NESTING);
249249
250250 if (irqa->active || irqb->active) {
251251 ret = (int)irqb->active - (int)irqa->active;
@@ -263,8 +263,8 @@ static int vgic_irq_cmp(void *priv, struct list_head *a, struct list_head *b) · 11 unmodified lines
263263 /* Both pending and enabled, sort by priority */
264264 ret = irqa->priority - irqb->priority;
265265 out:
266− spin_unlock(&irqb->irq_lock);
267− spin_unlock(&irqa->irq_lock);
266+ raw_spin_unlock(&irqb->irq_lock);
267+ raw_spin_unlock(&irqa->irq_lock);
268268 return ret;
269269 }
270270
@@ -325,7 +325,7 @@ retry: · 54 unmodified lines
325325 * not need to be inserted into an ap_list and there is also
326326 * no more work for us to do.
327327 */
328− spin_unlock_irqrestore(&irq->irq_lock, flags);
328+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
329329
330330 /*
331331 * We have to kick the VCPU here, because we could be
@@ -347,12 +347,12 @@ retry: · 15 unmodified lines
347347 * We must unlock the irq lock to take the ap_list_lock where
348348 * we are going to insert this new pending interrupt.
349349 */
350− spin_unlock_irqrestore(&irq->irq_lock, flags);
350+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
351351
352352 /* someone can do stuff here, which we re-check below */
353353
354− spin_lock_irqsave(&vcpu->arch.vgic_cpu.ap_list_lock, flags);
355− spin_lock(&irq->irq_lock);
354+ raw_spin_lock_irqsave(&vcpu->arch.vgic_cpu.ap_list_lock, flags);
355+ raw_spin_lock(&irq->irq_lock);
356356
357357 /*
358358 * Did something change behind our backs?
@@ -367,10 +367,11 @@ retry: · 8 unmodified lines
367367 */
368368
369369 if (unlikely(irq->vcpu || vcpu != vgic_target_oracle(irq))) {
370− spin_unlock(&irq->irq_lock);
371− spin_unlock_irqrestore(&vcpu->arch.vgic_cpu.ap_list_lock, flags);
370+ raw_spin_unlock(&irq->irq_lock);
371+ raw_spin_unlock_irqrestore(&vcpu->arch.vgic_cpu.ap_list_lock,
372+ flags);
372373
373− spin_lock_irqsave(&irq->irq_lock, flags);
374+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
374375 goto retry;
375376 }
376377
@@ -382,8 +383,8 @@ retry: · 5 unmodified lines
382383 list_add_tail(&irq->ap_list, &vcpu->arch.vgic_cpu.ap_list_head);
383384 irq->vcpu = vcpu;
384385
385− spin_unlock(&irq->irq_lock);
386− spin_unlock_irqrestore(&vcpu->arch.vgic_cpu.ap_list_lock, flags);
386+ raw_spin_unlock(&irq->irq_lock);
387+ raw_spin_unlock_irqrestore(&vcpu->arch.vgic_cpu.ap_list_lock, flags);
387388
388389 kvm_make_request(KVM_REQ_IRQ_PENDING, vcpu);
389390 kvm_vcpu_kick(vcpu);
@@ -430,11 +431,11 @@ int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int intid, · 40 unmodified lines
430431 if (!irq)
431432 return -EINVAL;
432433
433− spin_lock_irqsave(&irq->irq_lock, flags);
434+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
434435
435436 if (!vgic_validate_injection(irq, level, owner)) {
436437 /* Nothing to see here, move along... */
437− spin_unlock_irqrestore(&irq->irq_lock, flags);
438+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
438439 vgic_put_irq(kvm, irq);
439440 return 0;
440441 }
@@ -494,9 +495,9 @@ int kvm_vgic_map_phys_irq(struct kvm_vcpu *vcpu, unsigned int host_irq, · 53 unmodified lines
494495
495496 BUG_ON(!irq);
496497
497− spin_lock_irqsave(&irq->irq_lock, flags);
498+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
498499 ret = kvm_vgic_map_irq(vcpu, irq, host_irq, get_input_level);
499− spin_unlock_irqrestore(&irq->irq_lock, flags);
500+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
500501 vgic_put_irq(vcpu->kvm, irq);
501502
502503 return ret;
@@ -519,11 +520,11 @@ void kvm_vgic_reset_mapped_irq(struct kvm_vcpu *vcpu, u32 vintid) · 16 unmodified lines
519520 if (!irq->hw)
520521 goto out;
521522
522− spin_lock_irqsave(&irq->irq_lock, flags);
523+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
523524 irq->active = false;
524525 irq->pending_latch = false;
525526 irq->line_level = false;
526− spin_unlock_irqrestore(&irq->irq_lock, flags);
527+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
527528 out:
528529 vgic_put_irq(vcpu->kvm, irq);
529530 }
@@ -539,9 +540,9 @@ int kvm_vgic_unmap_phys_irq(struct kvm_vcpu *vcpu, unsigned int vintid) · 9 unmodified lines
539540 irq = vgic_get_irq(vcpu->kvm, vcpu, vintid);
540541 BUG_ON(!irq);
541542
542− spin_lock_irqsave(&irq->irq_lock, flags);
543+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
543544 kvm_vgic_unmap_irq(irq);
544− spin_unlock_irqrestore(&irq->irq_lock, flags);
545+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
545546 vgic_put_irq(vcpu->kvm, irq);
546547
547548 return 0;
@@ -571,12 +572,12 @@ int kvm_vgic_set_owner(struct kvm_vcpu *vcpu, unsigned int intid, void *owner) · 23 unmodified lines
571572 return -EINVAL;
572573
573574 irq = vgic_get_irq(vcpu->kvm, vcpu, intid);
574− spin_lock_irqsave(&irq->irq_lock, flags);
575+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
575576 if (irq->owner && irq->owner != owner)
576577 ret = -EEXIST;
577578 else
578579 irq->owner = owner;
579− spin_unlock_irqrestore(&irq->irq_lock, flags);
580+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
580581
581582 return ret;
582583 }
@@ -597,13 +598,13 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu) · 14 unmodified lines
597598 DEBUG_SPINLOCK_BUG_ON(!irqs_disabled());
598599
599600 retry:
600− spin_lock(&vgic_cpu->ap_list_lock);
601+ raw_spin_lock(&vgic_cpu->ap_list_lock);
601602
602603 list_for_each_entry_safe(irq, tmp, &vgic_cpu->ap_list_head, ap_list) {
603604 struct kvm_vcpu *target_vcpu, *vcpuA, *vcpuB;
604605 bool target_vcpu_needs_kick = false;
605606
606− spin_lock(&irq->irq_lock);
607+ raw_spin_lock(&irq->irq_lock);
607608
608609 BUG_ON(vcpu != irq->vcpu);
609610
@@ -616,7 +617,7 @@ retry: · 6 unmodified lines
616617 */
617618 list_del(&irq->ap_list);
618619 irq->vcpu = NULL;
619− spin_unlock(&irq->irq_lock);
620+ raw_spin_unlock(&irq->irq_lock);
620621
621622 /*
622623 * This vgic_put_irq call matches the
@@ -631,14 +632,14 @@ retry: · 8 unmodified lines
631632
632633 if (target_vcpu == vcpu) {
633634 /* We're on the right CPU */
634− spin_unlock(&irq->irq_lock);
635+ raw_spin_unlock(&irq->irq_lock);
635636 continue;
636637 }
637638
638639 /* This interrupt looks like it has to be migrated. */
639640
640− spin_unlock(&irq->irq_lock);
641− spin_unlock(&vgic_cpu->ap_list_lock);
641+ raw_spin_unlock(&irq->irq_lock);
642+ raw_spin_unlock(&vgic_cpu->ap_list_lock);
642643
643644 /*
644645 * Ensure locking order by always locking the smallest
@@ -652,10 +653,10 @@ retry: · 7 unmodified lines
652653 vcpuB = vcpu;
653654 }
654655
655− spin_lock(&vcpuA->arch.vgic_cpu.ap_list_lock);
656− spin_lock_nested(&vcpuB->arch.vgic_cpu.ap_list_lock,
657− SINGLE_DEPTH_NESTING);
658− spin_lock(&irq->irq_lock);
656+ raw_spin_lock(&vcpuA->arch.vgic_cpu.ap_list_lock);
657+ raw_spin_lock_nested(&vcpuB->arch.vgic_cpu.ap_list_lock,
658+ SINGLE_DEPTH_NESTING);
659+ raw_spin_lock(&irq->irq_lock);
659660
660661 /*
661662 * If the affinity has been preserved, move the
@@ -675,9 +676,9 @@ retry: · 13 unmodified lines
675676 target_vcpu_needs_kick = true;
676677 }
677678
678− spin_unlock(&irq->irq_lock);
679− spin_unlock(&vcpuB->arch.vgic_cpu.ap_list_lock);
680− spin_unlock(&vcpuA->arch.vgic_cpu.ap_list_lock);
679+ raw_spin_unlock(&irq->irq_lock);
680+ raw_spin_unlock(&vcpuB->arch.vgic_cpu.ap_list_lock);
681+ raw_spin_unlock(&vcpuA->arch.vgic_cpu.ap_list_lock);
681682
682683 if (target_vcpu_needs_kick) {
683684 kvm_make_request(KVM_REQ_IRQ_PENDING, target_vcpu);
@@ -687,7 +688,7 @@ retry: · 3 unmodified lines
687688 goto retry;
688689 }
689690
690− spin_unlock(&vgic_cpu->ap_list_lock);
691+ raw_spin_unlock(&vgic_cpu->ap_list_lock);
691692 }
692693
693694 static inline void vgic_fold_lr_state(struct kvm_vcpu *vcpu)
@@ -741,10 +742,10 @@ static int compute_ap_list_depth(struct kvm_vcpu *vcpu, · 47 unmodified lines
741742 list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) {
742743 int w;
743744
744− spin_lock(&irq->irq_lock);
745+ raw_spin_lock(&irq->irq_lock);
745746 /* GICv2 SGIs can count for more than one... */
746747 w = vgic_irq_get_lr_count(irq);
747− spin_unlock(&irq->irq_lock);
748+ raw_spin_unlock(&irq->irq_lock);
748749
749750 count += w;
750751 *multi_sgi |= (w > 1);
@@ -770,7 +771,7 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu) · 19 unmodified lines
770771 count = 0;
771772
772773 list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) {
773− spin_lock(&irq->irq_lock);
774+ raw_spin_lock(&irq->irq_lock);
774775
775776 /*
776777 * If we have multi-SGIs in the pipeline, we need to
@@ -780,7 +781,7 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu) · 3 unmodified lines
780781 * the AP list has been sorted already.
781782 */
782783 if (multi_sgi && irq->priority > prio) {
783− spin_unlock(&irq->irq_lock);
784+ _raw_spin_unlock(&irq->irq_lock);
784785 break;
785786 }
786787
@@ -791,7 +792,7 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu) · 4 unmodified lines
791792 prio = irq->priority;
792793 }
793794
794− spin_unlock(&irq->irq_lock);
795+ raw_spin_unlock(&irq->irq_lock);
795796
796797 if (count == kvm_vgic_global_state.nr_lr) {
797798 if (!list_is_last(&irq->ap_list,
@@ -872,9 +873,9 @@ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) · 74 unmodified lines
872873
873874 DEBUG_SPINLOCK_BUG_ON(!irqs_disabled());
874875
875− spin_lock(&vcpu->arch.vgic_cpu.ap_list_lock);
876+ raw_spin_lock(&vcpu->arch.vgic_cpu.ap_list_lock);
876877 vgic_flush_lr_state(vcpu);
877− spin_unlock(&vcpu->arch.vgic_cpu.ap_list_lock);
878+ raw_spin_unlock(&vcpu->arch.vgic_cpu.ap_list_lock);
878879
879880 if (can_access_vgic_from_kernel())
880881 vgic_restore_state(vcpu);
@@ -918,20 +919,20 @@ int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu) · 37 unmodified lines
918919
919920 vgic_get_vmcr(vcpu, &vmcr);
920921
921− spin_lock_irqsave(&vgic_cpu->ap_list_lock, flags);
922+ raw_spin_lock_irqsave(&vgic_cpu->ap_list_lock, flags);
922923
923924 list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) {
924− spin_lock(&irq->irq_lock);
925+ raw_spin_lock(&irq->irq_lock);
925926 pending = irq_is_pending(irq) && irq->enabled &&
926927 !irq->active &&
927928 irq->priority < vmcr.pmr;
928− spin_unlock(&irq->irq_lock);
929+ raw_spin_unlock(&irq->irq_lock);
929930
930931 if (pending)
931932 break;
932933 }
933934
934− spin_unlock_irqrestore(&vgic_cpu->ap_list_lock, flags);
935+ raw_spin_unlock_irqrestore(&vgic_cpu->ap_list_lock, flags);
935936
936937 return pending;
937938 }
@@ -963,11 +964,10 @@ bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, unsigned int vintid) · 25 unmodified lines
963964 return false;
964965
965966 irq = vgic_get_irq(vcpu->kvm, vcpu, vintid);
966− spin_lock_irqsave(&irq->irq_lock, flags);
967+ raw_spin_lock_irqsave(&irq->irq_lock, flags);
967968 map_is_active = irq->hw && irq->active;
968− spin_unlock_irqrestore(&irq->irq_lock, flags);
969+ raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
969970 vgic_put_irq(vcpu->kvm, irq);
970971
971972 return map_is_active;
972973 }
973−