From patchwork Tue Dec 20 01:07:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Demi Marie Obenour X-Patchwork-Id: 13077382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3197C001B2 for ; Tue, 20 Dec 2022 01:10:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.466407.725350 (Exim 4.92) (envelope-from ) id 1p7R9W-0006ee-Q8; Tue, 20 Dec 2022 01:10:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 466407.725350; Tue, 20 Dec 2022 01:10:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p7R9W-0006dv-Js; Tue, 20 Dec 2022 01:10:42 +0000 Received: by outflank-mailman (input) for mailman id 466407; Tue, 20 Dec 2022 01:10:41 +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 1p7R9V-0004T7-AB for xen-devel@lists.xenproject.org; Tue, 20 Dec 2022 01:10:41 +0000 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1d57d520-8003-11ed-8fd4-01056ac49cbb; Tue, 20 Dec 2022 02:10:39 +0100 (CET) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 35F233200916; Mon, 19 Dec 2022 20:10:37 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 19 Dec 2022 20:10:38 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 19 Dec 2022 20:10:36 -0500 (EST) 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: 1d57d520-8003-11ed-8fd4-01056ac49cbb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1671498636; x=1671585036; bh=mmWwiUKIb7PKGWRCiRecDTE1zKV4JKWsn7i luc16UuM=; b=mStWYdgNQql7gh33QrtSnuD/GPYeOwdy0tQoWGDcdM6j8JOX3+O wFrhh2RJsswfyPbKucVAtlyhKp60sujLAgav30AFFhFuY6iGA8+S8fcNcCxjZtzu iDn7g7/4nxj74a4IZz0xvtNPwjsvyFfXOvNR/JmzOJoz1STbXFmEkPLAOzyYtZ5B OWBY2mKi9St0jWTrM+GoXonuDOOkxNdJPHVvq4Irt+oBqARn0Xr5rDP4TTDXlrK2 D4d0rvbjY/mYnHPGb5aBrcZ//UJHD12usFf6QZTPsIUyF3oabjSezIGhnpvp4BFb Pd8nCxhGddDJnP0foFn5zis+R0yUUyJruBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1671498636; x=1671585036; bh=mmWwiUKIb7PKG WRCiRecDTE1zKV4JKWsn7iluc16UuM=; b=p9ek3Qdd5Fn/9SP4cGDijKonsSSYW BcCcQqcBuzN61DKYq+1onW4EIJYULeM3pPMXjmYY4aW3kIzkbhbyTA0tpBRqiAxE Emu2FLtBhzL8pjwzzrX770LdDZkajM0edELRcqHJZa2toxGAZ1e/JHhfTjhrx9zB GM9CmI4e08aelshDzaBt7zzLXMEtWO41zTHgH161l9CGSVl4QG5+cLmdVLrEdtHO +R+WuGbaYTEkPARpiREbAkRWYySqsk2qpcLQDKiNjgoKj1aW3xaOLRuhQuGn/k/b br9/TzswYMH4adK5BAkf7Ufl9uG0NKCjrAi4P2jQuHytBCrLPnGRfIaWg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeeggdefudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghmihcu ofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinhhgsh hlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefghefg hffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedvnecurf grrhgrmhepmhgrihhlfhhrohhmpeguvghmihesihhnvhhishhisghlvghthhhinhhgshhl rggsrdgtohhm X-ME-Proxy: Feedback-ID: iac594737:Fastmail From: Demi Marie Obenour To: xen-devel@lists.xenproject.org Cc: Demi Marie Obenour , =?utf-8?q?Marek_Marczy?= =?utf-8?q?kowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Jun Nakajima , Kevin Tian , George Dunlap , Tim Deegan Subject: [PATCH v5 07/10] x86: Derive XEN_MSR_PAT from its individual entries Date: Mon, 19 Dec 2022 20:07:09 -0500 Message-Id: <3f38d913e270fed69a336d08d689ac9268cc54c2.1671497984.git.demi@invisiblethingslab.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 This avoids it being a magic constant that is difficult for humans to decode. Use BUILD_BUG_ON to check that the old and new values are identical. Signed-off-by: Demi Marie Obenour Reviewed-by: Jan Beulich --- Changes since v4: - Explain that changing XEN_MSR_PAT breaks guests that rely on the API in xen.h instead of reading the PAT from Xen. --- xen/arch/x86/include/asm/processor.h | 9 ++++++++- xen/arch/x86/mm.c | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/asm/processor.h index 8e2816fae9b97bd4e153a30cc3802971fe0355af..60b902060914584957db8afa5c7c1e6abdad4d13 100644 --- a/xen/arch/x86/include/asm/processor.h +++ b/xen/arch/x86/include/asm/processor.h @@ -96,7 +96,14 @@ * Host IA32_CR_PAT value to cover all memory types. This is not the default * MSR_PAT value, and is an ABI with PV guests. */ -#define XEN_MSR_PAT _AC(0x050100070406, ULL) +#define XEN_MSR_PAT ((_AC(X86_MT_WB, ULL) << 0x00) | \ + (_AC(X86_MT_WT, ULL) << 0x08) | \ + (_AC(X86_MT_UCM, ULL) << 0x10) | \ + (_AC(X86_MT_UC, ULL) << 0x18) | \ + (_AC(X86_MT_WC, ULL) << 0x20) | \ + (_AC(X86_MT_WP, ULL) << 0x28) | \ + (_AC(X86_MT_UC, ULL) << 0x30) | \ + (_AC(X86_MT_UC, ULL) << 0x38)) #ifndef __ASSEMBLY__ diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index dba6c77ef2f7ed7fcb7f7e526583ccadd35e62cc..b40a575b61418ea1137299e68b64f7efd9efeced 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -6352,6 +6352,17 @@ unsigned long get_upper_mfn_bound(void) return min(max_mfn, 1UL << (paddr_bits - PAGE_SHIFT)) - 1; } +static void __init __maybe_unused build_assertions(void) +{ + /* + * If this trips, any guest that blindly rely on the public API in xen.h + * (instead of reading the PAT from Xen, as Linux 3.19+ does) will be + * broken. Furthermore, live migration of PV guests between Xen versions + * using different PATs will not work. + */ + BUILD_BUG_ON(XEN_MSR_PAT != 0x050100070406ULL); +} + /* * Local variables: * mode: C