summaryrefslogtreecommitdiff
path: root/arch/arm64/kvm/vgic-sys-reg-v3.c
diff options
context:
space:
mode:
authorMarc Zyngier <maz@kernel.org>2022-07-03 16:57:29 +0300
committerMarc Zyngier <maz@kernel.org>2022-07-17 13:55:33 +0300
commitb61fc0857a3ad4cdee44128ad13685033e237367 (patch)
treea08fc3992d72e47139d9df23ca1915e295fa291d /arch/arm64/kvm/vgic-sys-reg-v3.c
parent5a420ed9646a934e983358aeba1bf3cd993d1cc5 (diff)
downloadlinux-b61fc0857a3ad4cdee44128ad13685033e237367.tar.xz
KVM: arm64: vgic-v3: Simplify vgic_v3_has_cpu_sysregs_attr()
Finding out whether a sysreg exists has little to do with that register being accessed, so drop the is_write parameter. Also, the reg pointer is completely unused, and we're better off just passing the attr pointer to the function. This result in a small cleanup of the calling site, with a new helper converting the vGIC view of a sysreg into the canonical one (this is purely cosmetic, as the encoding is the same). Reviewed-by: Reiji Watanabe <reijiw@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org>
Diffstat (limited to 'arch/arm64/kvm/vgic-sys-reg-v3.c')
-rw-r--r--arch/arm64/kvm/vgic-sys-reg-v3.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/arm64/kvm/vgic-sys-reg-v3.c b/arch/arm64/kvm/vgic-sys-reg-v3.c
index 644acda33c7c..85a5e1d15e9f 100644
--- a/arch/arm64/kvm/vgic-sys-reg-v3.c
+++ b/arch/arm64/kvm/vgic-sys-reg-v3.c
@@ -260,12 +260,18 @@ static const struct sys_reg_desc gic_v3_icc_reg_descs[] = {
{ SYS_DESC(SYS_ICC_IGRPEN1_EL1), access_gic_grpen1 },
};
-int vgic_v3_has_cpu_sysregs_attr(struct kvm_vcpu *vcpu, bool is_write, u64 id,
- u64 *reg)
+static u64 attr_to_id(u64 attr)
{
- u64 sysreg = (id & KVM_DEV_ARM_VGIC_SYSREG_MASK) | KVM_REG_SIZE_U64;
+ return ARM64_SYS_REG(FIELD_GET(KVM_REG_ARM_VGIC_SYSREG_OP0_MASK, attr),
+ FIELD_GET(KVM_REG_ARM_VGIC_SYSREG_OP1_MASK, attr),
+ FIELD_GET(KVM_REG_ARM_VGIC_SYSREG_CRN_MASK, attr),
+ FIELD_GET(KVM_REG_ARM_VGIC_SYSREG_CRM_MASK, attr),
+ FIELD_GET(KVM_REG_ARM_VGIC_SYSREG_OP2_MASK, attr));
+}
- if (get_reg_by_id(sysreg, gic_v3_icc_reg_descs,
+int vgic_v3_has_cpu_sysregs_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr)
+{
+ if (get_reg_by_id(attr_to_id(attr->attr), gic_v3_icc_reg_descs,
ARRAY_SIZE(gic_v3_icc_reg_descs)))
return 0;