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

RE: [PATCH] xen/arm: Hide PMU feature


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Date: Wed, 5 Aug 2026 04:31:33 +0000
  • Accept-language: ja-JP, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2Bngy3RvD5jAQEeCq3S+xlBbepXg3MzqbFfz4C23Ujg=; b=V/rGH+5eaGcmBXmuKVXUjMG51SfsoZvhxOlEI3ggrOnthAINDDMktTnPrvspxp7nKzmCZSOGL8J7bcETQD5JxQTQTJ5sW98v0z/cJBdfrOKA8LPv0vPjz5r1ldv8zo+rodNsyBcmEL9oLmkamToTeon7d8J+GNrxR5xwsZ2nDrREMqfu3lUhWVmUEIS7VFnl9ko9uu6EcTrVMptw4Tdb5TyycwqofirZMGgnoVvwVUx1vLQa3uKfVBBVUrRsxY/e4lPEYStQ8+9bd/It+mg7MBsvQcRYsTwpiwJa7UIXWQCc8/kz5uWPl4ICnjVeAdAcByJUfZBz4O6Y8Q2/AfdoSQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kK/iTdvDfV/p3i7iy1AGEslip0Q2W5J5X2MH9DNreQArwXN9JfG5eQSNdnJkNcxjMKOw9NggyD/donfIcAGZTZ8AF8ImE8aS0lIzgRV50nCHROj2Wxc6zUDA1+9lYurAgO/2Ub9DF1jU4WiqgoENluohVrKXuiQK9ZLThg5gVYRVBr3Wk05BwSzCVVtbu8Fk2YDv2ZV/L2ldVMyyqb1j5GXa9s3oXI7lY5kKkmspBs5rgkL6qtSevbud8sLYRJzu0byCg3eZxwjFHuF/pYld+tvL8AIWaZgrGCSUnuWqE+1D6hcJdcAeKFh7HOc/jMwMjhttyajv8apQ529nxpuqew==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 05 Aug 2026 04:31:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdIuEazfVQgCaihUe50qminMMbcraL5wiAgAL2WTA=
  • Thread-topic: [PATCH] xen/arm: Hide PMU feature

Hi,

Thank you for the comments.

> > During this probe, Linux accesses PMMIR_EL1, which causes unhandled
> > register traps and crashes the domain. Merely adding emulation code
> > for PMMIR_EL1 in Xen is insufficient to fix the issue, as the guest
> > PMU driver subsequently stalls during its initialization sequence.
> >
> > Fix this by explicitly masking PMU capability fields in
> > create_domain_cpuinfo(). Additionally, preemptively mask other
> > capability fields to prevent similar potential issues.
> 
> While I agree Xen doesn't support PMU capability for every guest, I
> believe we are still allowing to expose the PMU in some cases (see
> commit dbb948110a "xen: Expose the PMU to the guests"). So we can't
> simply mask the features. So I think ...

I will modify the sysreg trap handler for ID_AA64DFR0_EL1 to dynamically
mask the basic PMU capabilities based on the domain's vPMU
configuration.

> > Fixes: 3669a1cb9598 "xen/arm: create a cpuinfo structure for guest"
> > Signed-off-by: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
> > ---
> >   xen/arch/arm/cpufeature.c             | 16 ++++++++++++++++
> >   xen/arch/arm/include/asm/cpufeature.h | 10 ++++++----
> >   2 files changed, 22 insertions(+), 4 deletions(-)
> >
> > diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c
> > index 94d14fb6a9..71d745d3cb 100644
> > --- a/xen/arch/arm/cpufeature.c
> > +++ b/xen/arch/arm/cpufeature.c
> > @@ -219,8 +219,24 @@ static int __init create_domain_cpuinfo(void)
> >       domain_cpuinfo.isa64.api = 0;
> >       domain_cpuinfo.isa64.gpa = 0;
> >       domain_cpuinfo.isa64.gpi = 0;
> > +
> > +    /* Hide PMUv3 support as Xen does not support it */
> > +    domain_cpuinfo.dbg64.pmu_ver = 0;
> > +    domain_cpuinfo.dbg64.mtpmu = 0;
> > +    domain_cpuinfo.dbg64.pmss = 0;
> 
> ... this section needs to be conditional.

Okay.
 
> > +
> > +    /* Hide SPE, TRBE, BRBE, and Trace Extensions */
> > +    domain_cpuinfo.dbg64.pms_ver = 0;
> > +    domain_cpuinfo.dbg64.trace_ver = 0;
> > +    domain_cpuinfo.dbg64.trace_filt = 0;
> > +    domain_cpuinfo.dbg64.trace_buffer = 0;
> > +    domain_cpuinfo.dbg64.ext_trc_buff = 0;
> > +    domain_cpuinfo.dbg64.brbe = 0;
> 
> This section should be fine to unconditionally mask.

Okay.

> >   #endif
> >
> > +    /* Hide PMUv1,v2 support as Xen does not support it */
> > +    domain_cpuinfo.dbg32.perfmon = 0;
> > +
> >       /* Hide AMU support */
> >   #ifdef CONFIG_ARM_64
> >       domain_cpuinfo.pfr64.amu = 0;
> > diff --git a/xen/arch/arm/include/asm/cpufeature.h
> b/xen/arch/arm/include/asm/cpufeature.h
> > index bf902a3970..c92b2651c7 100644
> > --- a/xen/arch/arm/include/asm/cpufeature.h
> > +++ b/xen/arch/arm/include/asm/cpufeature.h
> > @@ -216,16 +216,18 @@ struct cpuinfo_arm {
> >               unsigned long trace_ver:4;
> >               unsigned long pmu_ver:4;
> >               unsigned long brps:4;
> > -            unsigned long __res0:4;
> > +            unsigned long pmss:4;
> >               unsigned long wrps:4;
> > -            unsigned long __res1:4;
> > +            unsigned long sebep:4;
> >               unsigned long ctx_cmps:4;
> >               unsigned long pms_ver:4;
> >               unsigned long double_lock:4;
> >               unsigned long trace_filt:4;
> > -            unsigned long __res2:4;
> > +            unsigned long trace_buffer:4;
> >               unsigned long mtpmu:4;
> > -            unsigned long __res3:12;
> > +            unsigned long brbe:4;
> > +            unsigned long ext_trc_buff:4;
> > +            unsigned long hpmn0:4;
> >
> >               /* DFR1 */
> >               unsigned long __res4:64;

Thak you,
Hirokazu Takahashi.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.