vcpu->arch.xen.timer.function = xen_timer_callback;
}
+/*
+ * With CONFIG_PREEMPT_RT, 'irqsave' locking doesn't really disable IRQs as
+ * "all IRQs are threaded" (except the hrtimer IRQs). So, open-coding a
+ * local_irq_save() before a read_trylock() is wrong for PREEMPT_RT.
+ */
+static inline bool read_trylock_irqsave(rwlock_t *lck, unsigned long *flags)
+{
+#ifndef CONFIG_PREEMPT_RT
+ local_irq_save(*flags);
+#endif
+ if (!read_trylock(lck)) {
+#ifndef CONFIG_PREEMPT_RT
+ local_irq_restore(*flags);
+#endif
+ return false;
+ }
+
+ return true;
+}
+
static void kvm_xen_update_runstate_guest(struct kvm_vcpu *v, bool atomic)
{
struct kvm_vcpu_xen *vx = &v->arch.xen;
* gfn_to_pfn caches that cover the region.
*/
if (atomic) {
- local_irq_save(flags);
- if (!read_trylock(&gpc1->lock)) {
- local_irq_restore(flags);
+ if (!read_trylock_irqsave(&gpc1->lock, &flags))
return;
- }
} else {
read_lock_irqsave(&gpc1->lock, flags);
}