Re: [PATCH v10 15/33] KVM: arm64: Construct mdcr_el2 in a local variable in kvm_arm_setup_mdcr_el2()

From: Colton Lewis

Date: Thu Dec 03 2026 - 14:13:09 EST


Oliver Upton <oupton@xxxxxxxxxx> writes:

> On Thu, Nov 19, 2026 at 06:51:57PM +0000, Colton Lewis wrote:
>> Construct the new MDCR_EL2 value in a local variable before writing it
>> once to vcpu->arch.mdcr_el2. This avoids exposing intermediate states in
>> vcpu->arch.mdcr_el2 to interrupt or NMI handlers that may inspect it,
>> and simplifies upcoming Partitioned PMU modifications to MDCR_EL2.
>
> Is this actually necessary? The number of PMCs is fixed for the lifetime
> of the VM.

It's not necessary. Sashiko suggested it initially but it's not needed
since patch 16 changed to local_daif_save() anyway.