]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: arm/arm64: Get rid of vgic_elrsr
authorChristoffer Dall <christoffer.dall@linaro.org>
Wed, 4 Oct 2017 22:02:41 +0000 (00:02 +0200)
committerMarc Zyngier <marc.zyngier@arm.com>
Mon, 19 Mar 2018 10:53:20 +0000 (10:53 +0000)
There is really no need to store the vgic_elrsr on the VGIC data
structures as the only need we have for the elrsr is to figure out if an
LR is inactive when we save the VGIC state upon returning from the
guest.  We can might as well store this in a temporary local variable.

Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
include/kvm/arm_vgic.h
virt/kvm/arm/hyp/vgic-v2-sr.c
virt/kvm/arm/hyp/vgic-v3-sr.c
virt/kvm/arm/vgic/vgic-v2.c
virt/kvm/arm/vgic/vgic-v3.c

index cdbd142ca7f2ea4513a7bcf44f877f9b3bbbebc3..ac98ae46bfb7353b53d6eb82dd1f1e3093427ac2 100644 (file)
@@ -263,7 +263,6 @@ struct vgic_dist {
 struct vgic_v2_cpu_if {
        u32             vgic_hcr;
        u32             vgic_vmcr;
-       u64             vgic_elrsr;     /* Saved only */
        u32             vgic_apr;
        u32             vgic_lr[VGIC_V2_MAX_LRS];
 };
@@ -272,7 +271,6 @@ struct vgic_v3_cpu_if {
        u32             vgic_hcr;
        u32             vgic_vmcr;
        u32             vgic_sre;       /* Restored only, change ignored */
-       u32             vgic_elrsr;     /* Saved only */
        u32             vgic_ap0r[4];
        u32             vgic_ap1r[4];
        u64             vgic_lr[VGIC_V3_MAX_LRS];
index 4fe6e797e8b3c5f19b43049303d616175fe3af47..a91b0d2b9249803c91723bd4d1de210a94b83376 100644 (file)
 #include <asm/kvm_hyp.h>
 #include <asm/kvm_mmu.h>
 
-static void __hyp_text save_elrsr(struct kvm_vcpu *vcpu, void __iomem *base)
-{
-       struct vgic_v2_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v2;
-       int nr_lr = (kern_hyp_va(&kvm_vgic_global_state))->nr_lr;
-       u32 elrsr0, elrsr1;
-
-       elrsr0 = readl_relaxed(base + GICH_ELRSR0);
-       if (unlikely(nr_lr > 32))
-               elrsr1 = readl_relaxed(base + GICH_ELRSR1);
-       else
-               elrsr1 = 0;
-
-       cpu_if->vgic_elrsr = ((u64)elrsr1 << 32) | elrsr0;
-}
-
 static void __hyp_text save_lrs(struct kvm_vcpu *vcpu, void __iomem *base)
 {
        struct vgic_v2_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v2;
-       int i;
        u64 used_lrs = vcpu->arch.vgic_cpu.used_lrs;
+       u64 elrsr;
+       int i;
+
+       elrsr = readl_relaxed(base + GICH_ELRSR0);
+       if (unlikely(used_lrs > 32))
+               elrsr |= ((u64)readl_relaxed(base + GICH_ELRSR1)) << 32;
 
        for (i = 0; i < used_lrs; i++) {
-               if (cpu_if->vgic_elrsr & (1UL << i))
+               if (elrsr & (1UL << i))
                        cpu_if->vgic_lr[i] &= ~GICH_LR_STATE;
                else
                        cpu_if->vgic_lr[i] = readl_relaxed(base + GICH_LR0 + (i * 4));
@@ -68,13 +58,9 @@ void __hyp_text __vgic_v2_save_state(struct kvm_vcpu *vcpu)
 
        if (used_lrs) {
                cpu_if->vgic_apr = readl_relaxed(base + GICH_APR);
-
-               save_elrsr(vcpu, base);
                save_lrs(vcpu, base);
-
                writel_relaxed(0, base + GICH_HCR);
        } else {
-               cpu_if->vgic_elrsr = ~0UL;
                cpu_if->vgic_apr = 0;
        }
 }
index f5c3d6d7019ea63a7d2376c68f6c392cd2036aaf..9abf2f3c12b5dabf596e37d409ce29709a0ef6c7 100644 (file)
@@ -222,15 +222,16 @@ void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu)
        if (used_lrs) {
                int i;
                u32 nr_pre_bits;
+               u32 elrsr;
 
-               cpu_if->vgic_elrsr = read_gicreg(ICH_ELSR_EL2);
+               elrsr = read_gicreg(ICH_ELSR_EL2);
 
                write_gicreg(0, ICH_HCR_EL2);
                val = read_gicreg(ICH_VTR_EL2);
                nr_pre_bits = vtr_to_nr_pre_bits(val);
 
                for (i = 0; i < used_lrs; i++) {
-                       if (cpu_if->vgic_elrsr & (1 << i))
+                       if (elrsr & (1 << i))
                                cpu_if->vgic_lr[i] &= ~ICH_LR_STATE;
                        else
                                cpu_if->vgic_lr[i] = __gic_v3_get_lr(i);
@@ -262,7 +263,6 @@ void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu)
                    cpu_if->its_vpe.its_vm)
                        write_gicreg(0, ICH_HCR_EL2);
 
-               cpu_if->vgic_elrsr = 0xffff;
                cpu_if->vgic_ap0r[0] = 0;
                cpu_if->vgic_ap0r[1] = 0;
                cpu_if->vgic_ap0r[2] = 0;
index c32d7b93ffd194313f8cc062d2960d6a04a38d16..bb305d49cfddeea67dd5cbddb28f9a8d5d715d3d 100644 (file)
@@ -265,7 +265,6 @@ void vgic_v2_enable(struct kvm_vcpu *vcpu)
         * anyway.
         */
        vcpu->arch.vgic_cpu.vgic_v2.vgic_vmcr = 0;
-       vcpu->arch.vgic_cpu.vgic_v2.vgic_elrsr = ~0;
 
        /* Get the show on the road... */
        vcpu->arch.vgic_cpu.vgic_v2.vgic_hcr = GICH_HCR_EN;
index 6b329414e57a3c16207ab8e5ad81a0cc002b7f51..b76e21f3e6bd76b5685a87058a37d65ece38705a 100644 (file)
@@ -267,7 +267,6 @@ void vgic_v3_enable(struct kvm_vcpu *vcpu)
         * anyway.
         */
        vgic_v3->vgic_vmcr = 0;
-       vgic_v3->vgic_elrsr = ~0;
 
        /*
         * If we are emulating a GICv3, we do it in an non-GICv2-compatible