From nobody Wed Feb 5 12:49:00 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=quarantine dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1736793798; cv=none; d=zohomail.com; s=zohoarc; b=P1ZhcBVfI+T8ng0AYdrH7N+bZ4FPpWkyBJnLNZSyp5k4uYDABfyAtCi2854MCgEOhJ2mlMXwo7hPzzoupLovWqiUedb8JWu/cJE8gvCbnBJ492L+oxher0zjVPgE2esNDwDt/Ugz4LYxxNtSi+K9denSTeoHfb83F9McCY5c36s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736793798; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wg+x7oaTzShFDXw6vWNN7FZ7vOdFvBqAnQZMBsAgMMc=; b=B9ibqj1dzkdAqWyJcW+T5u55ODCUr2MYU3jZxHh+2OATs+bqbbJIlQoGVCcuFUqXGv3VW1supq8yxQN/TX+dIj+whTW7wFqPVaV/B8ZiS4j7dmVbDjB145m69oaNRQx5Edb1+GDjJ5u+rsQL/T9JsTMYrUOo42cBzFSTp+M5ZeE= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1736793798179103.10857639115648; Mon, 13 Jan 2025 10:43:18 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.870835.1281901 (Exim 4.92) (envelope-from ) id 1tXPOk-0006pC-0x; Mon, 13 Jan 2025 18:42:50 +0000 Received: by outflank-mailman (output) from mailman id 870835.1281901; Mon, 13 Jan 2025 18:42:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tXPOj-0006p5-UI; Mon, 13 Jan 2025 18:42:49 +0000 Received: by outflank-mailman (input) for mailman id 870835; Mon, 13 Jan 2025 18:42:48 +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 1tXPOi-0006oz-Kq for xen-devel@lists.xenproject.org; Mon, 13 Jan 2025 18:42:48 +0000 Received: from mail178-22.suw51.mandrillapp.com (mail178-22.suw51.mandrillapp.com [198.2.178.22]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2dc106be-d1de-11ef-a0e1-8be0dac302b0; Mon, 13 Jan 2025 19:42:46 +0100 (CET) Received: from pmta13.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail178-22.suw51.mandrillapp.com (Mailchimp) with ESMTP id 4YX1N45FqpzGlsp1y for ; Mon, 13 Jan 2025 18:42:44 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 90261c6b92024aab9ae729686576b553; Mon, 13 Jan 2025 18:42:44 +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: 2dc106be-d1de-11ef-a0e1-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1736793764; x=1737054264; bh=wg+x7oaTzShFDXw6vWNN7FZ7vOdFvBqAnQZMBsAgMMc=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=WbmG/egTqkRPEeiavbuDYgKp2RTQQBAvZt9xS3hP3dXQVacRO8LVNCzYwjeC37WjV ryQnFlfKe2UM9rrz2e8lGsTFAQyZ2yfFgyUcuWs+raY9ERp6o2PWavtEJ2CPu/lclT X8NRFnFbmCVm+LsZ3Z0kFAO01uX0DISnE/JBAur7pm/kL4+prPxsWnIuQFACZbFRwf M6THGHfxbpZhWQmBgxUGFFIA9NDCncnuF83sSH3yDI3gzsz7bsh2OFJ4rjLQGedqfk YqPCxokQ7c9Rwr1vq316a3/8bWDVQcWbpeVzojgdJtoEFuuUPTd5QmJiam+ukvNq5i Y19PQb+i055ew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1736793764; x=1737054264; i=teddy.astie@vates.tech; bh=wg+x7oaTzShFDXw6vWNN7FZ7vOdFvBqAnQZMBsAgMMc=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=X2ZP00huqKE4HYHIQErcoTn1XH0/lD8de53+0JJ5T827vkYF4NWRk3+Xspd2kZepG yUHIQDAUGnZHREbwq70zo45i6MKxVQSvuzBJNoISFYC49J0VHAaS2MF9Ec1oEYxAEx CeWwBiY5IxW1G/chciQDGR2TJSNY1iUlOiYGwaaXIgXo7TYOFvqjP9oPglUiC8EK6M eb5sjIW3fBpQHbv6Q77LYz31qEcOwTGS6xB7AxMxMs1isD8ma+niAyy92Y8zEkwCBE 8Y7f6KTIv/2+r4cmTzclE+rf9ypF/YpKnx6PcDA68Sx+OAdGLV0psANg71ymEsFmVP uXFq+ykEY2mfQ== From: "Teddy Astie" Subject: =?utf-8?Q?[XEN=20PATCH]=20intel/msr:=20Fix=20handling=20of=20MSR=5FRAPL=5FPOWER=5FUNIT?= X-Mailer: git-send-email 2.45.2 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1736793763637 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" , "Jan Beulich" , "Andrew Cooper" , "=?utf-8?Q?Roger=20Pau=20Monn=C3=A9?=" Message-Id: <0ac778dbcc7ab383447abe672225ff77b0d4802e.1736793323.git.teddy.astie@vates.tech> 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.90261c6b92024aab9ae729686576b553?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20250113:md Date: Mon, 13 Jan 2025 18:42:44 +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: 1736793799918019100 Content-Type: text/plain; charset="utf-8" Solaris 11.4 tries to access this MSR on some Intel platforms without prope= rly setting up a proper #GP handler, which leads to a immediate crash. Emulate the access of this MSR by giving it a legal value (all values set to default, as defined by Intel SDM "RAPL Interfaces"). Fixes: 84e848fd7a1 ('x86/hvm: disallow access to unknown MSRs') Signed-off-by: Teddy Astie --- Does it have a risk of negatively affecting other operating systems expecti= ng this MSR read to fail ? --- xen/arch/x86/include/asm/msr-index.h | 2 ++ xen/arch/x86/msr.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/xen/arch/x86/include/asm/msr-index.h b/xen/arch/x86/include/as= m/msr-index.h index 9cdb5b2625..2adcdf344f 100644 --- a/xen/arch/x86/include/asm/msr-index.h +++ b/xen/arch/x86/include/asm/msr-index.h @@ -144,6 +144,8 @@ #define MSR_RTIT_ADDR_A(n) (0x00000580 + (n) * 2) #define MSR_RTIT_ADDR_B(n) (0x00000581 + (n) * 2) =20 +#define MSR_RAPL_POWER_UNIT 0x00000606 + #define MSR_U_CET 0x000006a0 #define MSR_S_CET 0x000006a2 #define CET_SHSTK_EN (_AC(1, ULL) << 0) diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index 289cf10b78..b14d42dacf 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -169,6 +169,22 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t= *val) if ( likely(!is_cpufreq_controller(d)) || rdmsr_safe(msr, *val) = =3D=3D 0 ) break; goto gp_fault; + =20 + /* + * Solaris 11.4 DomU tries to use read this MSR without setting up= a + * proper #GP handler leading to a crash. Emulate this MSR by givi= ng a + * legal value. + */ + case MSR_RAPL_POWER_UNIT: + if ( !(cp->x86_vendor & (X86_VENDOR_INTEL | X86_VENDOR_CENTAUR)) ) + goto gp_fault; + + /* + * Return a legal register content with all default values defined= in + * Intel Architecture Software Developer Manual 16.10.1 RAPL Inter= faces + */ + *val =3D 0x0000A1003; + break; =20 case MSR_IA32_THERM_STATUS: if ( cp->x86_vendor !=3D X86_VENDOR_INTEL ) --=20 2.45.2 Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech