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

RE: [PATCH v3] xen/arm: Hide PMU registers from the guest, when the vPMU feature is disabled.


  • To: "Orzel, Michal" <michal.orzel@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Date: Tue, 25 Aug 2026 04:33:53 +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=aSXJLd3NZY45/QGN9d/73fOosRtWj4l059gGuSH6Wzs=; b=jnm/XYkNrd+V5gtwUqtAcCAkkYxHWg2RVgWLxuiLyXOLksKullbRF1aIqEOAoVF6Szx9WgNkuSLUaCTfRiiFpr/NtMgo+4Rv8+cmPjrAoBwRTJuWUGWPAm/hGYx79l4wu52gO5FPPgAIrxYRTAYIquOJNEgkmICZncvMK/wGHQ2RyAdc2As4Nj8iXz/NKja++Zwo9J6XTPYb0yHmfwv7kbG0XtHUN8Yq8FltpYVdjNPV11/ZR6yxH7YWjvw4yLJqh9flIVvqXibsNaqxDYkaoVI7RQGw5xGKrx1Xoaobfg2xquXZbqPQEDgXCy7S815wB0Tj9T4YmyZtORmYWqxfgw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mmESx522xrtaBhsQ5l84SFnJKJt7bl4ywWcBkQQI7pQzOfPortHdaFpM6WXPRJ2o54F8IQS+LKpNEnrZbJ46QrO5LxeRX+vaeGo1AYAO7xaAgJ1cZMmI2eXFPrO6wd9xdzNd8nAQejOtEX8xXxM3Svcrge5qNrf4wh7xv3UgumwzbzhJXUnOE6iJd47orluZwMkoWUFxUtpvUwlPmA9+zeTOponDABjDX1w581hvJXQbiaNoQ/xopDe6BkF/f3AhmgCEpOXnaM8f9Y4VhdD+Doyy/RaOoECunMBCpib1fzsWCMmnzFxKD9ovhEEidQSevwBIs7YrEwrCDsHzzbbR0A==
  • 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>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>
  • Delivery-date: Tue, 25 Aug 2026 04:34:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdM4NyLvQAa8Bus0iwWtzTdZAy7ras3w4AgAENCoA=
  • Thread-topic: [PATCH v3] xen/arm: Hide PMU registers from the guest, when the vPMU feature is disabled.

Hi Michal,

> > --- a/xen/arch/arm/arm64/vsysreg.c
> > +++ b/xen/arch/arm/arm64/vsysreg.c
> > @@ -227,6 +227,11 @@ void do_sysreg(struct cpu_user_regs *regs,
> >       */
> >      case HSR_SYSREG_PMINTENSET_EL1:
> >      case HSR_SYSREG_PMINTENCLR_EL1:
> > +    case HSR_SYSREG_PMMIR_EL1:
> > +        /*
> > +         * Accessible from EL1 only, but if EL0 trap happens handle as
> > +         * undef.
> > +         */
> This comment was recently removed, so please do not re-introduce it.

Okay.

> >          return handle_raz_wi(regs, regidx, hsr.sysreg.read, hsr, 1);
> >      case HSR_SYSREG_PMUSERENR_EL0:
> >          /* RO at EL0. RAZ/WI at EL1 */


> > -    GENERATE_TID3_INFO(ID_DFR0_EL1, dbg32, 0)
> > -    GENERATE_TID3_INFO(ID_DFR1_EL1, dbg32, 1)
> > +
> > +    case HSR_SYSREG_ID_DFR0_EL1:
> > +    {
> > +        struct domain *d = v->domain;
> There is no need for a separate local variable if it's only used once. In this
> series, please just use `v->domain` for `is_vpmu_domain()`.

Okay.

> > +        union cpuinfo_dbg32 info_dbg32 = domain_cpuinfo.dbg32;
> > +
> > +        if ( !is_vpmu_domain(d) )
> > +        {
> Please omit the braces for a single line `if` block.

Okay.

> > +            info_dbg32.perfmon = 0;
> > +        }
> > +
> > +        return handle_ro_read_val(regs, regidx, hsr.sysreg.read, hsr, 1,
> > +                                  info_dbg32.bits[0]);
> > +    }

> > -    GENERATE_TID3_INFO(ID_AA64DFR0_EL1, dbg64, 0)
> > -    GENERATE_TID3_INFO(ID_AA64DFR1_EL1, dbg64, 1)
> > +
> > +    case HSR_SYSREG_ID_AA64DFR0_EL1:
> > +    {
> > +        struct domain *d = v->domain;
> > +        union cpuinfo_dbg64 info_dbg64 = domain_cpuinfo.dbg64;
> > +
> > +        if ( !is_vpmu_domain(d) )
> > +        {
> > +            info_dbg64.pmu_ver = 0;
> > +            info_dbg64.pmss = 0;
> > +            info_dbg64.mtpmu = 0;
> Why don't you clear hpmn0?

Okay, I will also clear hpmn0.

> > +        }
> > +
> > +        return handle_ro_read_val(regs, regidx, hsr.sysreg.read, hsr, 1,
> > +                                  info_dbg64.bits[0]);
> > +    }
> > +
> > +    case HSR_SYSREG_ID_AA64DFR1_EL1:
> > +    {
> > +        struct domain *d = v->domain;
> > +        union cpuinfo_dbg64 info_dbg64 = domain_cpuinfo.dbg64;
> > +
> > +        if ( !is_vpmu_domain(d) )
> > +        {
> > +            info_dbg64.syspmuid = 0;
> > +            info_dbg64.spmu = 0;
> System PMU accesses undef for a vPMU-enabled domain too. Clear them together
> with SPE, TRBE, etc.

Understood.

> > +            info_dbg64.pmicntr = 0;
> > +            info_dbg64.ebep = 0;
> FEAT_EBEP is Armv9 just like SEBEP, so you should apply my comments to it as 
> well.

Okay.
 
> > +            info_dbg64.dpfzs = 0;
> > +        }
> > +
> > +        return handle_ro_read_val(regs, regidx, hsr.sysreg.read, hsr, 1,
> > +                                  info_dbg64.bits[1]);
> > +    }

> > --- a/xen/arch/arm/include/asm/cpregs.h
> > +++ b/xen/arch/arm/include/asm/cpregs.h
> > @@ -246,6 +246,7 @@
> >  #define PMINTENSET      p15,0,c9,c14,1  /* Perf. Mon. Interrupt Enable
> Set Register */
> >  #define PMINTENCLR      p15,0,c9,c14,2  /* Perf. Mon. Interrupt Enable
> Clear Register */
> >  #define PMOVSSET        p15,0,c9,c14,3  /* Perf. Mon. Overflow Flag
> Status Set register */
> > +#define PMMIR           p15,0,c9,c14,6  /* Perf. Mon. Performance
> Monitors Machine Identification Register */
> Please drop "Performance Monitors". It's the same as "Perf. Mon".

Okay

> > --- a/xen/arch/arm/vcpreg.c
> > +++ b/xen/arch/arm/vcpreg.c
> > @@ -305,6 +305,7 @@ void do_cp15_32(struct cpu_user_regs *regs, const
> union hsr hsr)
> >      case HSR_CPREG32(PMXEVTYPER):
> >      case HSR_CPREG32(PMXEVCNTR):
> >      case HSR_CPREG32(PMOVSSET):
> > +    case HSR_CPREG32(PMMIR):
> PMMIR is EL1 only, so it does not belong to this block and this comment. Place
> it next to PMINTENCLR.

Okay

> > @@ -320,8 +321,36 @@ void do_cp15_32(struct cpu_user_regs *regs, const
> union hsr hsr)
> >      GENERATE_TID3_INFO(ID_PFR0, pfr32, 0)
> >      GENERATE_TID3_INFO(ID_PFR1, pfr32, 1)
> >      GENERATE_TID3_INFO(ID_PFR2, pfr32, 2)
> > -    GENERATE_TID3_INFO(ID_DFR0, dbg32, 0)
> > -    GENERATE_TID3_INFO(ID_DFR1, dbg32, 1)
> > +
> > +    case HSR_CPREG32(ID_DFR0):
> > +    {
> > +        struct domain *d = v->domain;
> > +        union cpuinfo_dbg32 info_dbg32 = domain_cpuinfo.dbg32;
> > +
> > +        if ( !is_vpmu_domain(d) )
> > +        {
> > +            info_dbg32.perfmon = 0;
> > +        }
> > +
> > +        return handle_ro_read_val(regs, regidx, hsr.sysreg.read, hsr, 1,
> This breaks the arm32 build (you should always at least build test the 
> patches):
> s/hsr.sysreg.read/cp32.read/

I will fix it.

> > +                                  info_dbg32.bits[0]);
> > +    }
> > +

Thank you,
Hirokazu Takahashi.

 


Rackspace

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