Re: [PATCH 02/10] ARM: KVM: vgic: sanitize GICH_VMCR value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 21, 2012 at 1:15 PM, Marc Zyngier <marc.zyngier@xxxxxxx> wrote:
> We blindly use the GICH_VMCR value when initializing a new VCPU,
> happilly reusing whatever state was left in the register. Bad.
>
> Instead, sample a default value at hyp-init time, sanitize it,
> and use it when setting up a new VCPU.
>
> Reported-by: Will Deacon <will.deacon@xxxxxxx>
> Not-even-compile-tested-by: Marc Zyngier <marc.zyngier@xxxxxxx>
> Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
> ---
>  arch/arm/kvm/vgic.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/kvm/vgic.c b/arch/arm/kvm/vgic.c
> index f9478ea..ffe2260 100644
> --- a/arch/arm/kvm/vgic.c
> +++ b/arch/arm/kvm/vgic.c
> @@ -92,6 +92,8 @@ static void vgic_update_state(struct kvm *kvm);
>  static void vgic_kick_vcpus(struct kvm *kvm);
>  static void vgic_dispatch_sgi(struct kvm_vcpu *vcpu, u32 reg);
>
> +static u32 default_vmcr;
> +
>  static inline int vgic_irq_is_edge(struct vgic_dist *dist, int irq)
>  {
>         return vgic_bitmap_get_irq_val(&dist->irq_cfg, 0, irq);
> @@ -1073,8 +1075,7 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
>         reg = readl_relaxed(vcpu->kvm->arch.vgic.vctrl_base + GICH_VTR);
>         vgic_cpu->nr_lr = (reg & 0x1f) + 1;
>
> -       reg = readl_relaxed(vcpu->kvm->arch.vgic.vctrl_base + GICH_VMCR);
> -       vgic_cpu->vgic_vmcr = reg | (0x1f << 27); /* Priority */
> +       vgic_cpu->vgic_vmcr = default_vmcr;
>
>         vgic_cpu->vgic_hcr |= VGIC_HCR_EN; /* Get the show on the road... */
>
> @@ -1123,6 +1124,10 @@ int kvm_vgic_hyp_init(void)
>                 goto out_free_irq;
>         }
>
> +       default_vmcr  = readl_relaxed(vgic_vctrl_base + GICH_VMCR);
> +       default_vmcr |= (0x1f << 27); /* Priority */
> +       default_vmcr &= ~0x21f; /* Clear VEM, VMCPBR, VMFIQEn, VMAckCtl, VMGrp1En, VMGrp0En  */
> +

actually, why are we reading hardware state here at all? Don't we want
to run with a spceifically controlled setup that we can simply
compile-time define?

(granted teh meaning of all these fields has already faded far back in
my memory, so maybe this question is nonsense)

-Christoffer
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm


[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux