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

[PATCH 0/2] xen/arm: report the correct number of PMU counters to guests


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Daisuke Nishimura <nishimura@xxxxxxxxxxxxx>
  • Date: Tue, 10 Nov 2026 14:29:11 +0900
  • 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=YZk5IpXnS8h5R2T4rluIKw2GVXyWFI3Zhl3+ooVncXw=; b=HsmU4hjDj0xHMtXuUt9n4iZnZRXyCSVuxxUTRw3+c2m9uq02Swd8u6AGC3ab/g5ADWbu4TI4k10mJLCLsOjAVv/8sUxYqENR1nQcrKcCVyc675yu9tuJbN2ZG+q5nwdJ70lIjFOmdQ7sOwTZkzvpsZoeZd2q108sBWn1GRqkRc1fgImu+ueWY0KEx5w3jDDVIqNgk6DzT+bkBDsPUt6d5GViWawEYnXrJBRZVKaW1mnIHSsMOWAq+TTQrbW+u5jc0RrOcIjrUzM5ptdOPuQX3bR+RUXwZoBtdyyDLvk7rX14yqTiikM0dCQi6GfWrLNtWrfXenJdr/0j397Vqc8l2g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z6BFL9v8XpJu8lYOqPS7QCGCzYdONAJo14L6p3TV/otzCo0K4iAeF30hCTofkswJAxsmbh6ybIl1Q2Ia2oym3GN9vVLskk1HYY2gh4Y6NC5iVM0+akR3H1xUALvJTiQydEv51rM1+tC7jlFbzgT2yZtAe5CCqcYe0K6ySnNoQmZdJkUvUEVv+HClg8YS4fillMJIfd6xNVQ51Hz0k26AkXP9co07WR/Bz16P2lggIm+Jx0szSsw20+HczAy8WmOj5I3ATcc/IQYYLH8mM9yfzNB4uv1PSbWV76gNVl1AH7sXM+7BhFZbbEe+hIGeIg6NofP7LDhXuL229v3jbl519A==
  • 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: mx.microsoft.com 1; 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>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Leonid Komarianskyi <leonid_komarianskyi@xxxxxxxx>, Daisuke Nishimura <nishimura@xxxxxxxxxxxxx>
  • Delivery-date: Tue, 10 Nov 2026 05:34:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

When the vPMU feature is enabled for a domain, guests running at EL0/EL1
read PMCR_EL0.N to discover the number of available PMU counters. Per
the Arm Architecture Registers, such reads return the value of
MDCR_EL2.HPMN, not the hardware-implemented count.

Xen currently never initializes HPMN, so it stays 0 and guests see no
usable counters even when vPMU is enabled. This series fills HPMN in
with the number of implemented counters so guests can use them.

Patch 1 adds the infrastructure: it reads PMCR_EL0.N once on the boot
CPU and once on each secondary CPU during bring-up, keeping the minimum
in 'system_pmu_num_cntrs'. The minimum is used because on heterogeneous
systems (e.g. big.LITTLE) the counter count may differ between cores,
and a vCPU may migrate to any of them. The update happens in
update_system_features(), which runs only for CPUs that stay online, so
cores parked during heterogeneous bring-up are excluded. To make the
code usable from common arm code, the PMCR_EL0.N field definitions are
moved to asm/processor.h and a PMCR_EL0 -> PMCR alias is provided for
arm32 builds, where READ_SYSREG() resolves to the AArch32 PMCR
coprocessor encoding.

Patch 2 then sets MDCR_EL2.HPMN from that value for vPMU domains. This
is a rework of a downstream patch by Leonid Komarianskyi (authorship
and Signed-off-by kept): instead of reading PMCR_EL0 in
arch_vcpu_create(), which would sample the CPU where the domain is
created rather than the CPUs the vCPU may run on, it uses the
system-wide minimum collected at boot. It is also adapted to the
upstream change b836ef686e ("xen/arm: Hide PMU registers from the
guest, when the vPMU feature is disabled"), which moved this code under
is_vpmu_domain().

Build-tested for arm32 and arm64 (x86 is unaffected: all touched code
lives under xen/arch/arm/).

Daisuke Nishimura (1):
  xen/arm: Track the minimum number of PMU counters across CPUs

Leonid Komarianskyi (1):
  xen/domain: Save PMU counters to mdcr_el2

 xen/arch/arm/arm64/cpufeature.c       |  6 ++++++
 xen/arch/arm/cpufeature.c             | 21 +++++++++++++++++++++
 xen/arch/arm/domain.c                 |  2 ++
 xen/arch/arm/include/asm/cpregs.h     |  1 +
 xen/arch/arm/include/asm/cpufeature.h |  7 ++++++-
 xen/arch/arm/include/asm/processor.h  |  4 ++++
 xen/arch/arm/setup.c                  |  1 +
 7 files changed, 41 insertions(+), 1 deletion(-)

--
2.43.0



 


Rackspace

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