mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Clark <james.clark@linaro.org>
To: Marc Zyngier <maz@kernel.org>
Cc: Oliver Upton <oupton@kernel.org>, Joey Gouly <joey.gouly@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Colton Lewis <coltonlewis@google.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: arm64: Read PMUVer as unsigned
Date: Thu, 5 Mar 2026 13:10:06 +0000	[thread overview]
Message-ID: <208aebfe-3b25-4bf5-8c82-71f323f57847@linaro.org> (raw)
In-Reply-To: <86pl5i7ahj.wl-maz@kernel.org>



On 05/03/2026 11:59 am, Marc Zyngier wrote:
> On Thu, 05 Mar 2026 11:50:01 +0000,
> James Clark <james.clark@linaro.org> wrote:
>>
>> ID_AA64DFR0_EL1.PMUVer is an unsigned field, so this skips
>> initialization of host_data_ptr(nr_event_counters) for PMUv3 for Armv8.8
>> onwards as they appear as negative values.
>>
>> Fix it by reading it as unsigned.
>>
>> Fixes: 2417218f2f23 ("KVM: arm64: Get rid of __kvm_get_mdcr_el2() and related warts")
>> Signed-off-by: James Clark <james.clark@linaro.org>
>> ---
>>   arch/arm64/kvm/debug.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c
>> index 3ad6b7c6e4ba..b8632edba9a3 100644
>> --- a/arch/arm64/kvm/debug.c
>> +++ b/arch/arm64/kvm/debug.c
>> @@ -76,7 +76,7 @@ void kvm_init_host_debug_data(void)
>>   {
>>   	u64 dfr0 = read_sysreg(id_aa64dfr0_el1);
>>   
>> -	if (cpuid_feature_extract_signed_field(dfr0, ID_AA64DFR0_EL1_PMUVer_SHIFT) > 0)
>> +	if (cpuid_feature_extract_unsigned_field(dfr0, ID_AA64DFR0_EL1_PMUVer_SHIFT) > 0)
>>   		*host_data_ptr(nr_event_counters) = FIELD_GET(ARMV8_PMU_PMCR_N,
>>   							      read_sysreg(pmcr_el0));
>>   
> 
> How does this work on a system that advertises a non-architected PMU?
> 
> 	M.
> 

Hmmm yeah I suppose it doesn't, there's actually already 
pmuv3_implemented() and has_pmuv3() which open code the same check 
again. Maybe I can try re-using something and tidying it up.


      reply	other threads:[~2026-03-05 13:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-05 11:50 James Clark
2026-03-05 11:59 ` Marc Zyngier
2026-03-05 13:10   ` James Clark [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=208aebfe-3b25-4bf5-8c82-71f323f57847@linaro.org \
    --to=james.clark@linaro.org \
    --cc=alexandru.elisei@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=coltonlewis@google.com \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®