[PATCH 2/2] KVM: arm64: vgic-v3: Rename VGIC_TO_MPIDR() to VGIC_TO_MPIDR_AFF()
Alexandru Elisei
alexandru.elisei at arm.com
Tue Jan 26 09:11:56 EST 2021
GICv3 doesn't have an MPIDR register, but it uses the affinity fields from
GICR_TYPER, which are also present in the MPIDR_EL1 register, to identify
the Redistributor associated with a PE.
The macro VGIC_TO_MPIDR() doesn't convert the affinity fields
originating from an userspace ioctl into a valid MPIDR_EL1 value like
its name would suggest (notably, the RES1 bit is missing); what it does
is to shift the affinity fields to the same positions as the fields from
the MPIDR_EL1 register. This value is then compared to the result of
kvm_vcpu_get_mpidr_aff() to find the corresponding VCPU.
Let's rename VGIC_TO_MPIDR() to VGIC_TO_MPIDR_AFF() to avoid any confusion
about what the macro does.
Signed-off-by: Alexandru Elisei <alexandru.elisei at arm.com>
---
arch/arm64/kvm/vgic/vgic-kvm-device.c | 12 ++++++------
arch/arm64/kvm/vgic/vgic.h | 10 +++++-----
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/arch/arm64/kvm/vgic/vgic-kvm-device.c b/arch/arm64/kvm/vgic/vgic-kvm-device.c
index 44419679f91a..043eeb264ed8 100644
--- a/arch/arm64/kvm/vgic/vgic-kvm-device.c
+++ b/arch/arm64/kvm/vgic/vgic-kvm-device.c
@@ -473,18 +473,18 @@ struct kvm_device_ops kvm_arm_vgic_v2_ops = {
int vgic_v3_parse_attr(struct kvm_device *dev, struct kvm_device_attr *attr,
struct vgic_reg_attr *reg_attr)
{
- unsigned long vgic_mpidr, mpidr_reg;
+ unsigned long vgic_aff, mpidr_aff;
/*
* For KVM_DEV_ARM_VGIC_GRP_DIST_REGS group,
- * attr might not hold MPIDR. Hence assume vcpu0.
+ * attr might not hold MPIDR affinity. Hence assume vcpu0.
*/
if (attr->group != KVM_DEV_ARM_VGIC_GRP_DIST_REGS) {
- vgic_mpidr = (attr->attr & KVM_DEV_ARM_VGIC_V3_MPIDR_MASK) >>
- KVM_DEV_ARM_VGIC_V3_MPIDR_SHIFT;
+ vgic_aff = (attr->attr & KVM_DEV_ARM_VGIC_V3_MPIDR_MASK) >>
+ KVM_DEV_ARM_VGIC_V3_MPIDR_SHIFT;
- mpidr_reg = VGIC_TO_MPIDR(vgic_mpidr);
- reg_attr->vcpu = kvm_mpidr_to_vcpu(dev->kvm, mpidr_reg);
+ mpidr_aff = VGIC_TO_MPIDR_AFF(vgic_aff);
+ reg_attr->vcpu = kvm_mpidr_to_vcpu(dev->kvm, mpidr_aff);
} else {
reg_attr->vcpu = kvm_get_vcpu(dev->kvm, 0);
}
diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h
index 64fcd7511110..66525b8e2aa4 100644
--- a/arch/arm64/kvm/vgic/vgic.h
+++ b/arch/arm64/kvm/vgic/vgic.h
@@ -34,12 +34,12 @@
/*
* The Userspace encodes the affinity differently from the MPIDR,
- * Below macro converts vgic userspace format to MPIDR reg format.
+ * Below macro converts vgic userspace format to MPIDR reg affinity format.
*/
-#define VGIC_TO_MPIDR(val) (VGIC_AFFINITY_LEVEL(val, 0) | \
- VGIC_AFFINITY_LEVEL(val, 1) | \
- VGIC_AFFINITY_LEVEL(val, 2) | \
- VGIC_AFFINITY_LEVEL(val, 3))
+#define VGIC_TO_MPIDR_AFF(val) (VGIC_AFFINITY_LEVEL(val, 0) | \
+ VGIC_AFFINITY_LEVEL(val, 1) | \
+ VGIC_AFFINITY_LEVEL(val, 2) | \
+ VGIC_AFFINITY_LEVEL(val, 3))
/*
* As per Documentation/virt/kvm/devices/arm-vgic-v3.rst,
--
2.30.0
More information about the linux-arm-kernel
mailing list