Skip to content

Commit 982f31b

Browse files
committed
KVM: arm64: vgic-v3: Don't require IRQs be disabled for LPI xarray lock
Now that releases of LPIs have been unnested from the ap_list_lock there are no xarray writers that exist in a context where IRQs are already disabled. As such we can relax the locking to the non-IRQ disabling spinlock to guard the LPI xarray. Note that there are still readers of the LPI xarray where IRQs are disabled however the readers rely on RCU protection instead of the lock. Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent d54594a commit 982f31b

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

arch/arm64/kvm/vgic/vgic-init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void kvm_vgic_early_init(struct kvm *kvm)
5353
{
5454
struct vgic_dist *dist = &kvm->arch.vgic;
5555

56-
xa_init_flags(&dist->lpi_xa, XA_FLAGS_LOCK_IRQ);
56+
xa_init(&dist->lpi_xa);
5757
}
5858

5959
/* CREATION */

arch/arm64/kvm/vgic/vgic-its.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
7878
{
7979
struct vgic_dist *dist = &kvm->arch.vgic;
8080
struct vgic_irq *irq = vgic_get_irq(kvm, intid), *oldirq;
81-
unsigned long flags;
8281
int ret;
8382

8483
/* In this case there is no put, since we keep the reference. */
@@ -89,7 +88,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
8988
if (!irq)
9089
return ERR_PTR(-ENOMEM);
9190

92-
ret = xa_reserve_irq(&dist->lpi_xa, intid, GFP_KERNEL_ACCOUNT);
91+
ret = xa_reserve(&dist->lpi_xa, intid, GFP_KERNEL_ACCOUNT);
9392
if (ret) {
9493
kfree(irq);
9594
return ERR_PTR(ret);
@@ -104,7 +103,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
104103
irq->target_vcpu = vcpu;
105104
irq->group = 1;
106105

107-
xa_lock_irqsave(&dist->lpi_xa, flags);
106+
xa_lock(&dist->lpi_xa);
108107

109108
/*
110109
* There could be a race with another vgic_add_lpi(), so we need to
@@ -126,7 +125,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
126125
}
127126

128127
out_unlock:
129-
xa_unlock_irqrestore(&dist->lpi_xa, flags);
128+
xa_unlock(&dist->lpi_xa);
130129

131130
if (ret)
132131
return ERR_PTR(ret);

arch/arm64/kvm/vgic/vgic.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct vgic_global kvm_vgic_global_state __ro_after_init = {
2828
* kvm->arch.config_lock (mutex)
2929
* its->cmd_lock (mutex)
3030
* its->its_lock (mutex)
31-
* vgic_dist->lpi_xa.xa_lock must be taken with IRQs disabled
31+
* vgic_dist->lpi_xa.xa_lock
3232
* vgic_cpu->ap_list_lock must be taken with IRQs disabled
3333
* vgic_irq->irq_lock must be taken with IRQs disabled
3434
*
@@ -141,30 +141,29 @@ static __must_check bool vgic_put_irq_norelease(struct kvm *kvm, struct vgic_irq
141141
void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq)
142142
{
143143
struct vgic_dist *dist = &kvm->arch.vgic;
144-
unsigned long flags;
145144

146145
if (!__vgic_put_irq(kvm, irq))
147146
return;
148147

149-
xa_lock_irqsave(&dist->lpi_xa, flags);
148+
xa_lock(&dist->lpi_xa);
150149
vgic_release_lpi_locked(dist, irq);
151-
xa_unlock_irqrestore(&dist->lpi_xa, flags);
150+
xa_unlock(&dist->lpi_xa);
152151
}
153152

154153
static void vgic_release_deleted_lpis(struct kvm *kvm)
155154
{
156155
struct vgic_dist *dist = &kvm->arch.vgic;
157-
unsigned long flags, intid;
156+
unsigned long intid;
158157
struct vgic_irq *irq;
159158

160-
xa_lock_irqsave(&dist->lpi_xa, flags);
159+
xa_lock(&dist->lpi_xa);
161160

162161
xa_for_each(&dist->lpi_xa, intid, irq) {
163162
if (irq->pending_release)
164163
vgic_release_lpi_locked(dist, irq);
165164
}
166165

167-
xa_unlock_irqrestore(&dist->lpi_xa, flags);
166+
xa_unlock(&dist->lpi_xa);
168167
}
169168

170169
void vgic_flush_pending_lpis(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)