[PATCH v3 14/44] arm64: replace local_daif helpers

Vladimir Murzin vladimir.murzin at arm.com
Thu Dec 3 07:36:02 PST 2026


On 12/2/26 21:31, Ashok Raj wrote:
>>  int __kvm_vcpu_run(struct kvm_vcpu *vcpu)
>>  {
>> +	arm64_exc_hwstates_t hwstate;
>>  	int ret;
>>  
>> -	local_daif_mask();
>> +	hwstate = local_exceptions_save_mask(CRITICAL_CONTEXT);
>>  
>>  	/*
>>  	 * Having IRQs masked via PMR when entering the guest means the GIC
>> @@ -683,18 +685,18 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu)
>>  	 * only way to get out will be via guest exceptions.
>>  	 * Naturally, we want to avoid this.
>>  	 *
>> -	 * local_daif_mask() already sets GIC_PRIO_PSR_I_SET, we just need a
>> -	 * dsb to ensure the redistributor is forwards EL2 IRQs to the CPU.
>> +	 * local_exceptions_save_mask(), via helpers, sets
>> +	 * GIC_PRIO_IRQON along with pmr_sync(), so we can be sure
>> +	 * that redistributor forwards EL2 IRQs to the CPU.
>>  	 */
>> -	pmr_sync();
> The comment seems to imply that the helper always sets PMR is IRQON, rather
> than implying that it always writes PMR and executes pmr_sync()?
> 
> The comment seems to imply the helper is always setting PMR is IRQON
> But local_exceptions_save_mask() seems to pass force=false when the current PMR
> already matches the target; __arm64_update_exc_hwstate() and skips
> the PMR write and pmr_sync(). ?
> 

Perhaps whole comment block need to be taking into context:

 * "Having IRQs masked via PMR" implies PMR state is GIC_PRIO_IRQON
 * "Naturally, we want to avoid this"
 * "local_exceptions_save_mask(), via helpers, sets GIC_PRIO_IRQON"
 * that implies that force flag in local_exceptions_save_mask() is true
 * To make sure it propagates to distributor we need pmr_sync(), yet...
 * ... __arm64_update_exc_hwstate() would already do pmr_sync() since PMR
   is GIC_PRIO_IRQON and force is true
 * Thus we do not need explicit pmr_sync()
 * Note that local_daif_mask() even has comment saying that it doesn't do
   synchronisation, that's the reason old code has to do it explicitly.

Does is make it clear? Anything I can do to improve comment?

Thanks
Vladimir

> Cheers,
> Ashok
> 




More information about the linux-arm-kernel mailing list