summaryrefslogtreecommitdiffstats
path: root/virt/kvm
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 /virt/kvm
parent7c7d2fa1cd1e9aa9b925bac409e91544eee52c03 (diff)
downloadop-kernel-dev-50f5bd5718df9e71d1f4ba69a6480dbad54b2f24.zip
op-kernel-dev-50f5bd5718df9e71d1f4ba69a6480dbad54b2f24.tar.gz
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 'virt/kvm')
-rw-r--r--virt/kvm/arm/vgic/vgic.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h
index bba7fa2..bf9ceab 100644
--- a/virt/kvm/arm/vgic/vgic.h
+++ b/virt/kvm/arm/vgic/vgic.h
@@ -220,4 +220,20 @@ int vgic_debug_destroy(struct kvm *kvm);
bool lock_all_vcpus(struct kvm *kvm);
void unlock_all_vcpus(struct kvm *kvm);
+static inline int vgic_v3_max_apr_idx(struct kvm_vcpu *vcpu)
+{
+ struct vgic_cpu *cpu_if = &vcpu->arch.vgic_cpu;
+
+ /*
+ * 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 (cpu_if->num_pri_bits) {
+ case 7: return 3;
+ case 6: return 1;
+ default: return 0;
+ }
+}
+
#endif
OpenPOWER on IntegriCloud