Re: [PATCH for-stable-5.4] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

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

 



On Mon, May 17, 2021 at 03:27:13PM +0100, Alexandru Elisei wrote:
> [ Upstream commit 263d6287da1433aba11c5b4046388f2cdf49675c ]
> 
> When a VCPU is created, the kvm_vcpu struct is initialized to zero in
> kvm_vm_ioctl_create_vcpu(). On VHE systems, the first time
> vcpu.arch.mdcr_el2 is loaded on hardware is in vcpu_load(), before it is
> set to a sensible value in kvm_arm_setup_debug() later in the run loop. The
> result is that KVM executes for a short time with MDCR_EL2 set to zero.
> 
> This has several unintended consequences:
> 
> * Setting MDCR_EL2.HPMN to 0 is constrained unpredictable according to ARM
>   DDI 0487G.a, page D13-3820. The behavior specified by the architecture
>   in this case is for the PE to behave as if MDCR_EL2.HPMN is set to a
>   value less than or equal to PMCR_EL0.N, which means that an unknown
>   number of counters are now disabled by MDCR_EL2.HPME, which is zero.
> 
> * The host configuration for the other debug features controlled by
>   MDCR_EL2 is temporarily lost. This has been harmless so far, as Linux
>   doesn't use the other fields, but that might change in the future.
> 
> Let's avoid both issues by initializing the VCPU's mdcr_el2 field in
> kvm_vcpu_vcpu_first_run_init(), thus making sure that the MDCR_EL2 register
> has a consistent value after each vcpu_load().
> 
> [ v5.4 backport: added stub for KVM/arm that fixes compilation errors ]

Thanks for both backports, now queued up.

greg k-h
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/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