[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] xen/domain: Save PMU counters to mdcr_el2
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Daisuke Nishimura <nishimura@xxxxxxxxxxxxx>
- Date: Tue, 10 Nov 2026 14:31:42 +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=CO/BlyspGW8/fljNwHLFGQiJUQ2rs7BIXzcynWWSm3U=; b=xoikGSTy4CoHe7kHd2OJPOr+hM5nNWVH7fj/QQcBuQuR4xxkkkVi9kT5ZpZIHNDUPBf6XwuPUtidSDtxzD4kx/XVfcQdiXhpJ/7toh0oY6teeXwmYaLYzNNixaQ1zqW64u8R2dDciJERYNSA2WsM8ghyYEfVLaHnmxLBjvtw3wOua6Cp6tR/sA4rXQDsINkrh/XblTIum/L+XitN+vrzKtreBd/3fCIZwCek47d1iU0sgIwSuADoZzoTafaL9RrfDaAchKPXiYWDHECCtMqxb+0GEilrBXkp45WQwjJmwIA+6QKHhnW6d8nIUEcfrmyMXwJ+jT0khWEV1zmoyKedyQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i4oE5+qbSAQXOujbtgnVYzxHOPm04GoDnhwPnnEstLiynDtqYs40MqokW2JxUc40cDWAktCxJINb5PXfqzplrW6l2CzUXliGI51g1Z7otr7rv8aj62f4G/nO7x18vG4Md4w8OKMPFBtiZYnD4NIZ9DpTvi5Iab+xRWl3v/9qwSPJrfZWp8d3YLPa1/mURXfU0UqOMAg5k6ewdjuMaibMS/eOmxtOr2QHDcId4ix6S7FA1xxQ3O3KM+YwSZoZZ8CQKZnjSiPoIcTXVzXVH6R26Ht59ig3bNz/n6yXg9YHSjkCBOPD69mJ9VKFAS5Sfwp7ciITsPXawLG5nV3OsxsaeA==
- 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>
- Delivery-date: Tue, 10 Nov 2026 05:34:11 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
From: Leonid Komarianskyi <leonid_komarianskyi@xxxxxxxx>
According to arm documentation
"When EL2 is implemented and enabled for the current
Security state, reads of this field from EL1
and EL0 return the value of MDCR_EL2.HPMN."
To be able to use PMU counters from guest domain, the
counters should be read from pmcr_el0 register and saved
to mdcr_el2.
Signed-off-by: Leonid Komarianskyi <leonid_komarianskyi@xxxxxxxx>
Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
Signed-off-by: Daisuke Nishimura <nishimura@xxxxxxxxxxxxx>
---
(cherry picked from commit 8711910a8fb66eb454172a9e6427aaf62bfc3a80
xen-troops) [Daisuke: modified to follow the upstream changes:
- adapted to b836ef686e ("xen/arm: Hide PMU registers from the
guest, when the vPMU feature is disabled"), which moved this
code under is_vpmu_domain()
- instead of reading PMCR_EL0 per vCPU here, use
system_pmu_num_cntrs, the minimum number of counters across
all online CPUs, so the reported value is valid no matter
which CPU the vCPU runs on]
---
xen/arch/arm/domain.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 34b5a85f9f..f864327006 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -503,6 +503,8 @@ int arch_vcpu_create(struct vcpu *v)
v->arch.mdcr_el2 = HDCR_TDRA | HDCR_TDOSA | HDCR_TDA;
if ( !is_vpmu_domain(v->domain) )
v->arch.mdcr_el2 |= HDCR_TPM | HDCR_TPMCR;
+ else
+ v->arch.mdcr_el2 |= system_pmu_num_cntrs;
if ( (rc = vcpu_vgic_init(v)) != 0 )
goto fail;
--
2.43.0
|