From nobody Fri Dec 12 19:30:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1765300774; cv=none; d=zohomail.com; s=zohoarc; b=AC/cWvBgoP2tIXedbbJjPz4gPf3KWYbUmXHbf4dUXKt3i7yAha/E3Igk3CaAaezMFz4afWV6DC+yUiBCdwkPd9MHQDUK2zBRnnKhCh4ozipzpdriBkZWvTvEPpNVeYFVS0foSLz5ZgN3fhn/dCVY0ZHxo14SBcdzI8+7SBZ33+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765300774; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zb7G5zIrK8ZCQZTkyb087CIMe6mjbmKnl+xgf9D+q6E=; b=N3Z6Isi/EV7EjvLnoRXa9OM4GyA/ADJPVcbtmCs3c+S6uCtYWjWZNhDW2PAw3k50DHVv10zHbWDxCW5FWUbtUozcdGzbuj6TOqswoDRIypV3CLguNsNRaOvFqDskMXIqlElQ+E5XrhGmdiKTZCfw/F6XB5miW46pvl+KZSU8Uxw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1765300774131840.8800404971433; Tue, 9 Dec 2025 09:19:34 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1182035.1504974 (Exim 4.92) (envelope-from ) id 1vT1Ml-0005cV-Lf; Tue, 09 Dec 2025 17:19:11 +0000 Received: by outflank-mailman (output) from mailman id 1182035.1504974; Tue, 09 Dec 2025 17:19:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vT1Ml-0005cN-II; Tue, 09 Dec 2025 17:19:11 +0000 Received: by outflank-mailman (input) for mailman id 1182035; Tue, 09 Dec 2025 17:19:10 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vT1Mk-0005c7-AC for xen-devel@lists.xenproject.org; Tue, 09 Dec 2025 17:19:10 +0000 Received: from mail187-28.suw11.mandrillapp.com (mail187-28.suw11.mandrillapp.com [198.2.187.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2b7099d3-d523-11f0-b15b-2bf370ae4941; Tue, 09 Dec 2025 18:19:08 +0100 (CET) Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail187-28.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4dQlvH0WMTzMQxgGn for ; Tue, 9 Dec 2025 17:19:07 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 1005dcf71bf14d459bc070e2aa73c258; Tue, 09 Dec 2025 17:19:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2b7099d3-d523-11f0-b15b-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1765300747; x=1765570747; bh=zb7G5zIrK8ZCQZTkyb087CIMe6mjbmKnl+xgf9D+q6E=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=G89TV/4FcDCDatAVS6dkUS+8RvWPXiw3Wmb8RlhcEFEm390eQXyGlsOysrsbc83Oq 6fRnmahPqykuxYerWemjO5nSmbgTb9Ul9Zx2qgaOQQyaTFLn5iQCKj9QIn9P8ew9CB rNFFAZ8BA3XyEN3jxLIjOPXpffoNrW6NR38y/GZF20D645zlFS4JTJIF0hPl/xf+Iv aJXkFgp7eE2kISfX3ubHlfYax09vrhT4KY35Cc7uJBDZa5xHHtNckozWp3Ohz3/9TF 8S97UktcLP+E4nGahwyoyQoWarzzboZ0c1hMG/SufYavuf+k9HJ0RfjbEXj4YdEmD8 D98BrmCrpl7pw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1765300747; x=1765561247; i=teddy.astie@vates.tech; bh=zb7G5zIrK8ZCQZTkyb087CIMe6mjbmKnl+xgf9D+q6E=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=gQg0wgiVVTh53uodaTza/Uf2EnvQVbuGtBHczxZ8RcYbxOHi3A8io2z4ArQEBxJsr 6Pnxa05jUXMvDOK/lwgoV/eAvyKOG+p8pCA9g/5/aiNCNFMFwC8ilmVTCn28gXLBVL cdpo1GwQhw2GwG4Yzz6ttzm0KS/lMFgLM0SldTq9Rxne6g15EwbqcfYFvI+Mb8jg4f ydvDngw1Ear5OABu41Ppx4eY57NieV7VHBfa8ShXNhauG9u66ZhLH3dovEhCXGMOCm XHAYP/GXoPJmfhU+xYtbuin/Pqlks+UDoQJZ3IHpekNK8bsp2+HmWvnlbgvDuC+Rpr bxwuLlEi/Y1Qw== From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=20v3=201/3]=20x86/cpu-policy:=20Infrastructure=20for=20CPUID=20leaf=200x6?= X-Mailer: git-send-email 2.51.2 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1765300746124 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" , "Jan Beulich" , "Andrew Cooper" , "=?utf-8?Q?Roger=20Pau=20Monn=C3=A9?=" Message-Id: In-Reply-To: References: X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.1005dcf71bf14d459bc070e2aa73c258?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20251209:md Date: Tue, 09 Dec 2025 17:19:07 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity teddy.astie@vates.tech) (identity @mandrillapp.com) X-ZM-MESSAGEID: 1765301698143158501 Content-Type: text/plain; charset="utf-8" From: Jan Beulich Signed-off-by: Jan Beulich Signed-off-by: Teddy Astie --- xen/include/xen/lib/x86/cpu-policy.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86= /cpu-policy.h index f94f23e159..c721c986cc 100644 --- a/xen/include/xen/lib/x86/cpu-policy.h +++ b/xen/include/xen/lib/x86/cpu-policy.h @@ -121,7 +121,32 @@ struct cpu_policy uint64_t :64, :64; /* Leaf 0x3 - PSN. */ uint64_t :64, :64; /* Leaf 0x4 - Structured Cache. */ uint64_t :64, :64; /* Leaf 0x5 - MONITOR. */ - uint64_t :64, :64; /* Leaf 0x6 - Therm/Perf. */ + + /* Leaf 0x6 - Therm/Perf. */ + struct { + uint32_t /* a */ + dts:1, + turbo:1, + arat:1, + :4, + hwp:1, + hwp_notification:1, + hwp_activity_window:1, + hwp_epp:1, + hwp_plr:1, + :1, + hdc:1, + :2, + hwp_peci:1, + :2, + hw_feedback:1, + :12; + uint32_t /* b */:32; + uint32_t /* c */ aperfmperf:1,=20 + :31; + uint32_t /* d */:32; + } pm; + uint64_t :64, :64; /* Leaf 0x7 - Structured Features. */ uint64_t :64, :64; /* Leaf 0x8 - rsvd */ uint64_t :64, :64; /* Leaf 0x9 - DCA */ --=20 2.51.2 -- Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech From nobody Fri Dec 12 19:30:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1765300776; cv=none; d=zohomail.com; s=zohoarc; b=GpN63VDiga8/pDs8llDJg19G1AR86G/j07LmAbkJ3l4351jgK1KhDk91eVxBQEKVFEZFa91fU9DVKKDRyaluQwSoqpblMfnvnPNtf3upJ7ua70N3piSiIytMSyHFmAczlnUFkaZP8QtESrtYlYgYT7XxJ4f3U+5r+eiQ/NmCptI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765300776; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bXiyzxs3iUF4ajO5dnSngv/r6PHtcuT4FUiRa2n+DuM=; b=OSqu4wKQ/qQSiHPaCG8U3MCWsRpU+TEnbDq7dqMnkn0z40lQRyPIHfNFg7NYmpBFtW9LFUchJPj/F8cp0JM+8so4WRLqaym2AOUNcNpBqos3rPDMjYrG0yJlSaJNCAmGfmK+6ffOjLJo4jzZb4El5QogdhLopkbhEHPBhlrqEoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1765300776972200.13938336886486; Tue, 9 Dec 2025 09:19:36 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1182037.1504994 (Exim 4.92) (envelope-from ) id 1vT1Mn-00063V-3I; Tue, 09 Dec 2025 17:19:13 +0000 Received: by outflank-mailman (output) from mailman id 1182037.1504994; Tue, 09 Dec 2025 17:19:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vT1Mm-00063M-WA; Tue, 09 Dec 2025 17:19:13 +0000 Received: by outflank-mailman (input) for mailman id 1182037; Tue, 09 Dec 2025 17:19:11 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vT1Ml-0005cC-DS for xen-devel@lists.xenproject.org; Tue, 09 Dec 2025 17:19:11 +0000 Received: from mail132-20.atl131.mandrillapp.com (mail132-20.atl131.mandrillapp.com [198.2.132.20]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2bc3a4c7-d523-11f0-9cce-f158ae23cfc8; Tue, 09 Dec 2025 18:19:09 +0100 (CET) Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1]) by mail132-20.atl131.mandrillapp.com (Mailchimp) with ESMTP id 4dQlvH2ftLzFCWZgT for ; Tue, 9 Dec 2025 17:19:07 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 71b45fdb3d9c48168c0d6ddc909dd279; Tue, 09 Dec 2025 17:19:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2bc3a4c7-d523-11f0-9cce-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1765300747; x=1765570747; bh=bXiyzxs3iUF4ajO5dnSngv/r6PHtcuT4FUiRa2n+DuM=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=xK2cfOkseAdXCm8DGf4afVYKn+Rdd7KajWw3YoRcQH0EJKOg3vvmE6IC2IZDU+h2i nyR1selZQpnbjt0U6HK8jY0fywgRc/kZMdNQpmN7PW1vrvZ+HOApvq7cKVJScKA3Rg UUzUwASoxbhvD3ChaMBAavYU+FV8TjyjmSZAtN9aqDwlqjfxq8y77RRRgMLugrGPwb J0wFHUQ6AlvnmDjT99UEbaj4QZnJUmHWfP+b09UuGIzJoY6MC+1/e9hm14oMG+EPcm /fCxmKyYR1LGHY8BQGBsGVzDlTFBhWxtsRK/TjC2o5Jimm9UWVQwFjYQhEBZ6pjoUR gjd4f0csS3pZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1765300747; x=1765561247; i=teddy.astie@vates.tech; bh=bXiyzxs3iUF4ajO5dnSngv/r6PHtcuT4FUiRa2n+DuM=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=YPtwBke41cGNUfV2fiFNntSdV2wj6epbTM/idYUPN3X+hC7quYux7sSER6rXUUxTs f8zh7ht8bpAZn1yp8/gTR3EnFHdEGsVzhq6tfpR8KXP+9vAQnNPVzDsyQ0R5Pu1bvK Lw9kyNptTPz37K3w4gWrGK9JfOuECsVYiorP3bdjf+ug1LaKVlK7TrTKWXaVH6htQJ uHeQxadSfMH5k4Zl+65xJshZQHuJNZ3p9ckYFWvJHz3H5WTFfASEvhKSgW0/XiSz6o Mw7uYN8sk9IX7WdxQLL7FyueszTDztDp9fgWegWbn66SQFRpr4i5mfgEXDOCEM0fum 4waeldQ1PMHAQ== From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=20v3=202/3]=20x86/platform:=20Expose=20DTS=20sensors=20MSR?= X-Mailer: git-send-email 2.51.2 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1765300746413 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" , "Jan Beulich" , "Andrew Cooper" , "=?utf-8?Q?Roger=20Pau=20Monn=C3=A9?=" Message-Id: <5ae285cb5c494651c1f4842f36891eaf6dc28355.1765300623.git.teddy.astie@vates.tech> In-Reply-To: References: X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.71b45fdb3d9c48168c0d6ddc909dd279?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20251209:md Date: Tue, 09 Dec 2025 17:19:07 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity teddy.astie@vates.tech) (identity @mandrillapp.com) X-ZM-MESSAGEID: 1765301698184158500 Content-Type: text/plain; charset="utf-8" Intel provide CPU sensors through "DTS" MSRs. As there MSR are core-specific (or package-specific), we can't reliably fetch them from Dom0 directly. Expose these MSR (if supported) through XENPF_resource_op so that it is accessible through hypercall. Suggested-by: Jan Beulich Signed-off-by: Teddy Astie --- xen/arch/x86/include/asm/msr-index.h | 3 +++ xen/arch/x86/platform_hypercall.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/xen/arch/x86/include/asm/msr-index.h b/xen/arch/x86/include/as= m/msr-index.h index df52587c85..b92a278611 100644 --- a/xen/arch/x86/include/asm/msr-index.h +++ b/xen/arch/x86/include/asm/msr-index.h @@ -115,6 +115,9 @@ #define MCU_OPT_CTRL_GDS_MIT_DIS (_AC(1, ULL) << 4) #define MCU_OPT_CTRL_GDS_MIT_LOCK (_AC(1, ULL) << 5) =20 +#define MSR_TEMPERATURE_TARGET 0x000001a2 +#define MSR_PACKAGE_THERM_STATUS 0x000001b1 + #define MSR_FRED_RSP_SL0 0x000001cc #define MSR_FRED_RSP_SL1 0x000001cd #define MSR_FRED_RSP_SL2 0x000001ce diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hype= rcall.c index 79bb99e0b6..237340ee42 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -86,6 +87,11 @@ static bool msr_read_allowed(unsigned int msr) =20 case MSR_MCU_OPT_CTRL: return cpu_has_srbds_ctrl; + =20 + case MSR_IA32_THERM_STATUS: + case MSR_TEMPERATURE_TARGET: + case MSR_PACKAGE_THERM_STATUS: + return raw_cpu_policy.basic.pm.dts; } =20 if ( ppin_msr && msr =3D=3D ppin_msr ) --=20 2.51.2 -- Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech From nobody Fri Dec 12 19:30:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1765300770; cv=none; d=zohomail.com; s=zohoarc; b=UedUFKwqGNzw3suCyGQT7yYNF3FQ0Fws0HPJ8r6tEu1QcUk7rg0VZobC67zMH5ZH1VUuXeBUjaoGhYI+w9bJkH5H5Qs4BLD/VqVYztO7j/H8novZkDigmqxM4kZdPMVK6RmOLmmN5l3SJXmCyLVgHFpYH59k9Q9sXg9cfchgxmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765300770; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zvMOjJbC3NJhvuZJArpCM9fymz4oseW7zzXMIWEo6DE=; b=kO6M1HgezPUt13cYObPjdngwZ85tKtO2Rl9qbaImQL0FX8Fb7VSd/zP63gn1L0aaCO6gRpnTQ5QrOQpnPfk9bjqpBW1L5na+CHEfNESc6UZ7Snm2XZ545UldPUnwVxHb0xKBcBI57XsdS6B/OHlXmXhrtgVI3OAtplVt2Tj2ufE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1765300770006945.9232829566497; Tue, 9 Dec 2025 09:19:30 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1182038.1505004 (Exim 4.92) (envelope-from ) id 1vT1Mo-0006Hn-C3; Tue, 09 Dec 2025 17:19:14 +0000 Received: by outflank-mailman (output) from mailman id 1182038.1505004; Tue, 09 Dec 2025 17:19:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vT1Mo-0006He-84; Tue, 09 Dec 2025 17:19:14 +0000 Received: by outflank-mailman (input) for mailman id 1182038; Tue, 09 Dec 2025 17:19:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vT1Mm-0005cC-Dc for xen-devel@lists.xenproject.org; Tue, 09 Dec 2025 17:19:12 +0000 Received: from mail132-20.atl131.mandrillapp.com (mail132-20.atl131.mandrillapp.com [198.2.132.20]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2bc38c9e-d523-11f0-9cce-f158ae23cfc8; Tue, 09 Dec 2025 18:19:09 +0100 (CET) Received: from pmta09.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1]) by mail132-20.atl131.mandrillapp.com (Mailchimp) with ESMTP id 4dQlvH1CywzFCWZfk for ; Tue, 9 Dec 2025 17:19:07 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 21d2e1777ca04a7091d0d35e25548d7b; Tue, 09 Dec 2025 17:19:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2bc38c9e-d523-11f0-9cce-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1765300747; x=1765570747; bh=zvMOjJbC3NJhvuZJArpCM9fymz4oseW7zzXMIWEo6DE=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=f42K+JBGBAh1On1+4KXoKqwd9f1LV089sGWOfN52Xo/zdkDSKE/A+IuGhoCett1LV d8OMOPqoeVPeti9o44IcuhBX8MhOQZSaju7fsKsBs+L/+nlW9Jq/H6Ymy1s+hhfTlN 9CLOkSfN/XXdRfxCfBlDy8lS8CWWKBoxY2q1e//BftCkvwu99xbRL+CENcO7dBk9zu L0rG+1/e/uacvxBmXCWqDS1KVvpwhXU91mNvXXFfnBVEQD+dW9HDGXW1gQuXrPM0Cf 5ZjbhYmAM+EEYoZ6MpYJl5u+2+Jg3U1UrKEHhMl8gQaw9NJhmwPp1DjVJFaQII7yoB xuMX7AZXsTKGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1765300747; x=1765561247; i=teddy.astie@vates.tech; bh=zvMOjJbC3NJhvuZJArpCM9fymz4oseW7zzXMIWEo6DE=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=eQlqKyqHNdvdxSkCrI14GMPJprROGJWDff06mKwIVBL3LgDFCCXwo9Oh8DWd5SuFk 3AjE2FOpLh7zKjwiZqXiFvZF0usGrrWwn1keqLgCoMPjYkBBZhGACntPYVwknEGSi2 c3//bPOc1IoIkY0kxFUJbZ1iMrwyCHBZnwmjGYLqRmbSr7VbQQRF7KBC9s6suV8gHb mHYvSs2MPao/o6XglU0XJ2rraeHOCFFRVyCDzDjbIq8+ATA2UM7K1IdFHkopkNzFB3 UW/ENX7cPNal1Nq8cUH8/SMHCAC7I+KYEuRBJWWJjBICwd6d2yM7zRoWMLuMr8Wrz7 PrCoTXy30vHHQ== From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=20v3=203/3]=20xenpm:=20Add=20get-intel-temp=20subcommand?= X-Mailer: git-send-email 2.51.2 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1765300746610 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" , "Anthony PERARD" Message-Id: <6fcfea5d3f6be1bcf1d34ea5ccec40a477100472.1765300623.git.teddy.astie@vates.tech> In-Reply-To: References: X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.21d2e1777ca04a7091d0d35e25548d7b?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20251209:md Date: Tue, 09 Dec 2025 17:19:07 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @mandrillapp.com) (identity teddy.astie@vates.tech) X-ZM-MESSAGEID: 1765300770481158500 Content-Type: text/plain; charset="utf-8" get-intel-temp allows querying the per-core CPU temperature and per-package one on Intel processors (as usual Dom0 drivers cannot work due to misalignment between Dom0 vCPU and pCPUs). Signed-off-by: Teddy Astie --- tools/misc/xenpm.c | 91 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index 682d092479..1558f6c250 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -30,6 +30,7 @@ #include #include =20 +#include #include =20 #define MAX_PKG_RESIDENCIES 12 @@ -37,6 +38,7 @@ =20 static xc_interface *xc_handle; static unsigned int max_cpu_nr; +static xc_physinfo_t physinfo; =20 /* help message */ void show_help(void) @@ -93,6 +95,7 @@ void show_help(void) " units default to \= "us\" if unspecified.\n" " truncates un-repre= sentable values.\n" " 0 lets the hardwar= e decide.\n" + " get-intel-temp [cpuid] get Intel CPU temperatur= e of or all\n" " start [seconds] start collect Cx/Px stat= istics,\n" " output after CTRL-C or S= IGINT or several seconds.\n" " enable-turbo-mode [cpuid] enable Turbo Mode for pr= ocessors that support it.\n" @@ -1354,6 +1357,92 @@ void enable_turbo_mode(int argc, char *argv[]) errno, strerror(errno)); } =20 +static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, i= nt *temp) +{ + xc_resource_entry_t entries[2] =3D { + (xc_resource_entry_t){ + .idx =3D package ? MSR_PACKAGE_THERM_STATUS : MSR_IA32_THERM_S= TATUS + }, + (xc_resource_entry_t){ .idx =3D MSR_TEMPERATURE_TARGET }, + }; + struct xc_resource_op ops =3D { + .cpu =3D cpu, + .entries =3D entries, + .nr_entries =3D 2, + }; + int tjmax; + + int ret =3D xc_resource_op(xch, 1, &ops); + + if ( ret <=3D 0 ) + /* This CPU isn't online or can't query this MSR */ + return ret ?: -EOPNOTSUPP; + + if ( ret =3D=3D 2 ) + tjmax =3D (entries[1].val >> 16) & 0xff; + else + { + /* + * The CPU doesn't support MSR_IA32_TEMPERATURE_TARGET, we assume = it's 100 which + * is correct aside a few selected Atom CPUs. Check coretemp sourc= e code for more + * information. + */ + fprintf(stderr, "[CPU%d] MSR_IA32_TEMPERATURE_TARGET is not suppor= ted, assume " + "tjmax=3D100=C2=B0C, readings may be incorrect\n", cpu); + tjmax =3D 100; + } + =20 + *temp =3D tjmax - ((entries[0].val >> 16) & 0xff); + return 0; +} + + +void get_intel_temp(int argc, char *argv[]) +{ + int temp, cpu =3D -1; + unsigned int socket; + bool has_data =3D false; + + if ( argc > 0 ) + parse_cpuid(argv[0], &cpu); + + if ( cpu !=3D -1 ) + { + if ( !fetch_dts_temp(xc_handle, cpu, false, &temp) ) + printf("CPU%d: %d=C2=B0C\n", cpu, temp); + else + printf("No data\n"); + return; + } + + /* Per socket measurement */ + for ( socket =3D 0, cpu =3D 0; cpu < max_cpu_nr; + socket++, cpu +=3D physinfo.cores_per_socket * physinfo.threads_= per_core ) + { + if ( !fetch_dts_temp(xc_handle, cpu, true, &temp) ) + { + has_data =3D true; + printf("Package%d: %d=C2=B0C\n", socket, temp); + } + } + + if ( has_data ) + /* Avoid inserting a trailing line if we have nothing */ + printf("\n"); + + for ( cpu =3D 0; cpu < max_cpu_nr; cpu +=3D physinfo.threads_per_core ) + { + if ( fetch_dts_temp(xc_handle, cpu, false, &temp) ) + continue; + + has_data =3D true; + printf("CPU%d: %d=C2=B0C\n", cpu, temp); + } + + if ( !has_data ) + printf("No data\n"); +} + void disable_turbo_mode(int argc, char *argv[]) { int cpuid =3D -1; @@ -1618,12 +1707,12 @@ struct { { "set-max-cstate", set_max_cstate_func}, { "enable-turbo-mode", enable_turbo_mode }, { "disable-turbo-mode", disable_turbo_mode }, + { "get-intel-temp", get_intel_temp }, }; =20 int main(int argc, char *argv[]) { int i, ret =3D 0; - xc_physinfo_t physinfo; int nr_matches =3D 0; int matches_main_options[ARRAY_SIZE(main_options)]; =20 --=20 2.51.2 -- Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech