[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1521451220-27754-7-git-send-email-eric.auger@redhat.com>
Date: Mon, 19 Mar 2018 10:20:14 +0100
From: Eric Auger <eric.auger@...hat.com>
To: eric.auger.pro@...il.com, eric.auger@...hat.com,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
kvmarm@...ts.cs.columbia.edu, marc.zyngier@....com,
cdall@...nel.org, peter.maydell@...aro.org
Cc: andre.przywara@....com, drjones@...hat.com, wei@...hat.com
Subject: [RFC 06/12] KVM: arm/arm64: Helper to detect whether an RDIST is the last one
The TYPER of an redistributor needs to reflect whether the rdist is
the last one of the redistributor region. With a single region we compared
the vcpu id against the number of online vcpus. With multiple regions,
we also need to check the region is not full.
Signed-off-by: Eric Auger <eric.auger@...hat.com>
---
virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 +--
virt/kvm/arm/vgic/vgic.h | 9 +++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
index 227b8b6..5768034 100644
--- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
+++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
@@ -637,8 +637,7 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)
}
rdreg->free_pfn_offset += 2;
- vgic_cpu->rdist_last =
- (vcpu->vcpu_id == atomic_read(&vcpu->kvm->online_vcpus) - 1);
+ vgic_cpu->rdist_last = vgic_v3_last_rdist(vcpu, rdreg);
out:
mutex_unlock(&kvm->slots_lock);
return ret;
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h
index 38b2406..04456d3 100644
--- a/virt/kvm/arm/vgic/vgic.h
+++ b/virt/kvm/arm/vgic/vgic.h
@@ -254,6 +254,15 @@ vgic_v3_redist_region_full(struct vgic_redist_region *region)
return (region->free_pfn_offset > region->pfns - 2);
}
+static inline bool
+vgic_v3_last_rdist(struct kvm_vcpu *vcpu, struct vgic_redist_region *region)
+{
+ if (vcpu->vcpu_id == atomic_read(&vcpu->kvm->online_vcpus) - 1)
+ return true;
+
+ return vgic_v3_redist_region_full(region);
+}
+
struct vgic_redist_region *vgic_v3_rdist_free_slot(struct list_head *rd_regions,
uint32_t *free_pfn_offset);
--
2.5.5
Powered by blists - more mailing lists