aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kvm/vgic-sys-reg-v3.c
diff options
context:
space:
mode:
authorChristoffer Dall <cdall@linaro.org>2017-09-01 11:41:52 +0200
committerChristoffer Dall <cdall@linaro.org>2017-09-05 17:33:39 +0200
commit50f5bd5718df9e71d1f4ba69a6480dbad54b2f24 (patch)
treef535a6172455ef91c6327acbb0bf8fd663e79630 /arch/arm64/kvm/vgic-sys-reg-v3.c
parentKVM: arm/arm64: vITS: Drop its_ite->lpi field (diff)
downloadlinux-dev-50f5bd5718df9e71d1f4ba69a6480dbad54b2f24.tar.xz
linux-dev-50f5bd5718df9e71d1f4ba69a6480dbad54b2f24.zip
KVM: arm/arm64: Extract GICv3 max APRn index calculation
As we are about to access the APRs from the GICv2 uaccess interface, make this logic generally available. Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <cdall@linaro.org>
Diffstat (limited to 'arch/arm64/kvm/vgic-sys-reg-v3.c')
-rw-r--r--arch/arm64/kvm/vgic-sys-reg-v3.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/arch/arm64/kvm/vgic-sys-reg-v3.c b/arch/arm64/kvm/vgic-sys-reg-v3.c
index 116786d2e8e8..c77d508b7462 100644
--- a/arch/arm64/kvm/vgic-sys-reg-v3.c
+++ b/arch/arm64/kvm/vgic-sys-reg-v3.c
@@ -208,29 +208,12 @@ static void vgic_v3_access_apr_reg(struct kvm_vcpu *vcpu,
static bool access_gic_aprn(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
const struct sys_reg_desc *r, u8 apr)
{
- struct vgic_cpu *vgic_v3_cpu = &vcpu->arch.vgic_cpu;
u8 idx = r->Op2 & 3;
- /*
- * num_pri_bits are initialized with HW supported values.
- * We can rely safely on num_pri_bits even if VM has not
- * restored ICC_CTLR_EL1 before restoring APnR registers.
- */
- switch (vgic_v3_cpu->num_pri_bits) {
- case 7:
- vgic_v3_access_apr_reg(vcpu, p, apr, idx);
- break;
- case 6:
- if (idx > 1)
- goto err;
- vgic_v3_access_apr_reg(vcpu, p, apr, idx);
- break;
- default:
- if (idx > 0)
- goto err;
- vgic_v3_access_apr_reg(vcpu, p, apr, idx);
- }
+ if (idx > vgic_v3_max_apr_idx(vcpu))
+ goto err;
+ vgic_v3_access_apr_reg(vcpu, p, apr, idx);
return true;
err:
if (!p->is_write)