[PATCH] KVM: arm64: Fix smp_processor_id() call in preemptible context

Sean Christopherson seanjc at google.com
Tue Jun 6 06:59:07 PDT 2023


On Tue, Jun 06, 2023, Sebastian Ott wrote:
> Fixes: 1c913a1c35aa ("KVM: arm64: Iterate arm_pmus list to probe for default PMU")
> Signed-off-by: Sebastian Ott <sebott at redhat.com>
> ---
>  arch/arm64/kvm/pmu-emul.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
> index 491ca7eb2a4c..f9e4e4334875 100644
> --- a/arch/arm64/kvm/pmu-emul.c
> +++ b/arch/arm64/kvm/pmu-emul.c
> @@ -700,6 +700,7 @@ static struct arm_pmu *kvm_pmu_probe_armpmu(void)
> 
>  	mutex_lock(&arm_pmus_lock);
> 
> +	preempt_disable();

get_cpu() + put_cpu() would be more succinct and self-documenting.

>  	cpu = smp_processor_id();
>  	list_for_each_entry(entry, &arm_pmus, entry) {
>  		tmp = entry->arm_pmu;
> @@ -709,7 +710,7 @@ static struct arm_pmu *kvm_pmu_probe_armpmu(void)
>  			break;
>  		}
>  	}
> -
> +	preempt_enable();
>  	mutex_unlock(&arm_pmus_lock);
> 
>  	return pmu;
> -- 
> 2.40.1
> 



More information about the linux-arm-kernel mailing list