From nobody Sat May 18 16:46:51 2024 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1670301294966858.9396658358113; Mon, 5 Dec 2022 20:34:54 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.454333.711866 (Exim 4.92) (envelope-from ) id 1p2Pf2-0005cy-9Z; Tue, 06 Dec 2022 04:34:28 +0000 Received: by outflank-mailman (output) from mailman id 454333.711866; Tue, 06 Dec 2022 04:34:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p2Pf2-0005cp-4k; Tue, 06 Dec 2022 04:34:28 +0000 Received: by outflank-mailman (input) for mailman id 454333; Tue, 06 Dec 2022 04:34:27 +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 1p2Pf0-0005MV-W5 for xen-devel@lists.xenproject.org; Tue, 06 Dec 2022 04:34:26 +0000 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 40728b0f-751f-11ed-91b6-6bf2151ebd3b; Tue, 06 Dec 2022 05:34:24 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 33F2132009EC; Mon, 5 Dec 2022 23:34:19 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 05 Dec 2022 23:34:20 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 23:34:17 -0500 (EST) 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: 40728b0f-751f-11ed-91b6-6bf2151ebd3b 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=fm1; t= 1670301258; x=1670387658; bh=zlnhba+jqrzVDvS+quM/AmBMchrjFNcXxGL gLEattQI=; b=nFaQ5l1IWz9DxPJTn5JP8Hs7JoaTE5YO3TXoSVCvC8kG+CsxIkG UH3MIXlrob/dE4Xn2XJBxBntU1fjUY/Rbb/z2txaMCl05jN2fzVCSX2CEmgWrYAk 0dWL02Ab/Z4ZyyjT0MB/vjl6lj9g7DGiTIiep5FROjfAXU8RXot8XY5pB65u7ozP EkBburedsDc8qX7V1P+cvQrQDhIzlHKIsC3U3y6ExOaidYlGsdQUrEE/u5qqOtvz tDAFc+5/4SmWqOiIJJiTOSrs5cT2KK8/Eg4FBdotBFubRH8Kc0J5GbxlswqXh5b7 mBgT23P4t+Tmy8rz8jsqecevI7bPUpywgIQ== 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=fm1; t=1670301258; x=1670387658; bh=zlnhba+jqrzVD vS+quM/AmBMchrjFNcXxGLgLEattQI=; b=F7rEKa4oJCZrWhn1UuwJRc9zBEMau f3sCGZjh+OHA/9Butny+yuM6ja+V2/AuUNKdvtrkDISlL3jrASJgmXcfIF66mpZP Wcrf5V+gd4gc0pao8wIPki8YrD6yuWzWK5bEqvdGHZJGgPzlMzLx1qpNcw6P81Fu hF7feGcuSvSHqlE/kcXbyTUwGPcR4VB76WcyblwKWy+pCKnILahukNg2WVmc/gY6 laO6xCod7gOP+dhwiVVNlRUBawbZeC/3PS2J6JXGySEDHOWXvRV6+7Kvw2p4FBdL GelVc4POd3JjfLUveOdrg676UfH6EpCxjmyvzbi4TMFyrrR6sI6tO/LwQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghmihcu ofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinhhgsh hlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefghefg hffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedtnecurf 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=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Tim Deegan Subject: [PATCH 1/8] x86/mm: Avoid hard-coding PAT in get_page_from_l1e() Date: Mon, 5 Dec 2022 23:33:30 -0500 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1670301296564100003 Content-Type: text/plain; charset="utf-8" This still hard-codes the assumption that the two spare values are mapped to UC. Removing this assumption would require a more complex patch. Signed-off-by: Demi Marie Obenour Reviewed-by: Andrew Cooper --- xen/arch/x86/mm.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 78b1972e4170cacccc9c37c6e64e76e66a7da87f..5d05399c3a841bf03991a3bed63= df9a815c1e891 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -961,13 +961,10 @@ get_page_from_l1e( =20 switch ( l1f & PAGE_CACHE_ATTRS ) { - case 0: /* WB */ - flip |=3D _PAGE_PWT | _PAGE_PCD; - break; - case _PAGE_PWT: /* WT */ - case _PAGE_PWT | _PAGE_PAT: /* WP */ - flip |=3D _PAGE_PCD | (l1f & _PAGE_PAT); - break; + case _PAGE_WB: + case _PAGE_WT: + case _PAGE_WP: + flip |=3D (l1f & PAGE_CACHE_ATTRS) ^ _PAGE_UC; } =20 return flip; --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat May 18 16:46:51 2024 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1670301296151238.02094790565718; Mon, 5 Dec 2022 20:34:56 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.454332.711855 (Exim 4.92) (envelope-from ) id 1p2Pf0-0005Mj-WA; Tue, 06 Dec 2022 04:34:26 +0000 Received: by outflank-mailman (output) from mailman id 454332.711855; Tue, 06 Dec 2022 04:34:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p2Pf0-0005Mc-T7; Tue, 06 Dec 2022 04:34:26 +0000 Received: by outflank-mailman (input) for mailman id 454332; Tue, 06 Dec 2022 04:34:25 +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 1p2Pez-00055j-N1 for xen-devel@lists.xenproject.org; Tue, 06 Dec 2022 04:34:25 +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 421df95f-751f-11ed-8fd2-01056ac49cbb; Tue, 06 Dec 2022 05:34:24 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 7345C32009EF; Mon, 5 Dec 2022 23:34:22 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 05 Dec 2022 23:34:23 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 23:34:21 -0500 (EST) 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: 421df95f-751f-11ed-8fd2-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=fm1; t= 1670301261; x=1670387661; bh=0QYKJqmbmxQ2VjZuUfTQ03pAcq4EP8MKf4w +fU+4RXw=; b=AjLxTJrLas+hiAl88t6W/GA7S314n8MsLVEYgtoJr9U3sv9ma8j 5OR509gTyKf4tViRvkjZAxBgkKB16/1GJTcloksswi6eyaNMwoRcALChtACoGovH oYPljHGSAohMS1tQ285DWHGyx897dwo2/4EG2CuBT6fEnWTSUiAIEopVEN28yuKZ 9EgM1TIQbJgdx08SO5rulSBKoeOqJzL8lf+Kb2OBUzgrH+BzSrQUD0wbpqlXv+dg s2hBoBAUrtyz9dLy8S8XY9Y7qomOqenr8ifK7Mxm/EtHdPdJn7PmeYwzimFsUl7r jq1TztJQDySMD3SQ6tAi78+Xpka6Crqq/7w== 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=fm1; t=1670301261; x=1670387661; bh=0QYKJqmbmxQ2V jZuUfTQ03pAcq4EP8MKf4w+fU+4RXw=; b=XNkFtiOSB7z0SPAeX7uFy5mOxTe33 qmHWmpNynA//zBS6K5iC8XN0ORvLdtMd/7Bly9ilu4rK1u/GqIbVjNrXmW1fMIpV 7sLRzqv7ypiqRQcR3v9gEc6+uV+JWaCLTN/+Q5DhhKQyrNYpwX/szRzENguP0HX8 /xPNcHU2vyxmV4OyJgJWKtJGM5jO3CTOOf2gSTXpo05x53mSYVjkgnM2tBaRacjT CJbY4NKBA7xVNQa1UIOIG0iwKXqh7qr2olZqbBH0uDvNRMkACykthkdeFiGkFzA2 IgPuj2wudZolUVoAYiKBvSJJWO+WTZ1mbfD99xx1o+pxTGwzUcwmuNhLg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghmihcu ofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinhhgsh hlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefghefg hffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedtnecurf 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=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Tim Deegan Subject: [PATCH 2/8] p2m-pt: Avoid hard-coding Xen's PAT Date: Mon, 5 Dec 2022 23:33:31 -0500 Message-Id: <94c76a8be13a592ef98c80525b6c016cee583e73.1670300446.git.demi@invisiblethingslab.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1670301296797100009 Content-Type: text/plain; charset="utf-8" This makes the code much easier to understand. Signed-off-by: Demi Marie Obenour --- xen/arch/x86/mm/p2m-pt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index eaba2b0fb4e6830f52b7d112fba8175dfe6d2770..cd1af33b6772ab1016e8d4c3284= a6bc5d282869d 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -99,13 +99,13 @@ static unsigned long p2m_type_to_flags(const struct p2m= _domain *p2m, return flags | P2M_BASE_FLAGS | _PAGE_RW | _PAGE_NX_BIT; case p2m_mmio_direct: if ( !rangeset_contains_singleton(mmio_ro_ranges, mfn_x(mfn)) ) - flags |=3D _PAGE_RW; + flags |=3D _PAGE_RW | _PAGE_UCM; else { - flags |=3D _PAGE_PWT; + flags |=3D _PAGE_UC; ASSERT(!level); } - return flags | P2M_BASE_FLAGS | _PAGE_PCD; + return flags | P2M_BASE_FLAGS; } } =20 --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat May 18 16:46:51 2024 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 167030129679939.12971456759146; Mon, 5 Dec 2022 20:34:56 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.454334.711876 (Exim 4.92) (envelope-from ) id 1p2Pf3-0005t2-F8; Tue, 06 Dec 2022 04:34:29 +0000 Received: by outflank-mailman (output) from mailman id 454334.711876; Tue, 06 Dec 2022 04:34:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p2Pf3-0005sr-CK; Tue, 06 Dec 2022 04:34:29 +0000 Received: by outflank-mailman (input) for mailman id 454334; Tue, 06 Dec 2022 04:34:28 +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 1p2Pf1-0005MV-U1 for xen-devel@lists.xenproject.org; Tue, 06 Dec 2022 04:34:28 +0000 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 43c27aec-751f-11ed-91b6-6bf2151ebd3b; Tue, 06 Dec 2022 05:34:27 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id BC38C32009F0; Mon, 5 Dec 2022 23:34:24 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 05 Dec 2022 23:34:25 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 23:34:23 -0500 (EST) 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: 43c27aec-751f-11ed-91b6-6bf2151ebd3b 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=fm1; t= 1670301264; x=1670387664; bh=2DJbvlN3MtrCNxWUxmi7jS5GZRlwreYino7 nE2TrQ8A=; b=pX4tF4v1k1eZYNu5zbN0bvxHj78cjeFoXlJnqzBOx+W5Q07E8Aw T4FFv51qysrQCghks8QTRzO2exdFD/G2czKEcUwPXmtIW+CUXJeJ+dVFrBRFYiMy uhb7eGRs8/UUiLT/oGOWix1GyTtbZ/Qaj5wAjWdasrR0tFLu9MrhVDAchrjsYhW8 H9d0kh0/KNuS+zSFHzafTGuKQwFJlp1ISz4sXULk6oynyMeVgMRV9Yf9sZexP3I0 o4Q/CW2UCIXsLw2bb480oBkpdhU02Sk60z7nrz14EpeCUkfHyoFYuPDqd2UV7HKd z4QNV28QARiY3JABsIPF3M28Gi+QrB4hmaA== 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=fm1; t=1670301264; x=1670387664; bh=2DJbvlN3MtrCN xWUxmi7jS5GZRlwreYino7nE2TrQ8A=; b=d7BWW/qi1soi+uBGNDBoALS9fwbuu 13EbDAx/H4mzrcP/FA6mtdd96ZWTqP+NrAlRb4IESvR9HEj1dOGu4SRb2GxJKwyk x+GbqiTy109XkCw74JT3fzmPZYAcY8edJdqqhlSTDggFLzVJxuknRzv05/toTIdp EAQiqeSgRDE1tAAqTyRw9P0GCTPLXSeNeMnVwraOPfW5ErPChSCb/lJItKL62hl2 qQDlZgEx9nIiRz7SxG2SUMNCG5zYAxobu+IMaiJrbZCg98pNWeUSfijMERwi1fQw 4KFgDhDkNSCXXOQ1XqVYlwNqv6FdSLn50Z0N8Iww7QZ/ZqXGKpzcenQaA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehgdejgecutefuodetggdotefrodftvf 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=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Tim Deegan Subject: [PATCH 3/8] x86/mm/shadow: avoid assuming a specific Xen PAT Date: Mon, 5 Dec 2022 23:33:32 -0500 Message-Id: <8fba8137ea2aa4fb5c61102342ad42ed8a9d0f66.1670300446.git.demi@invisiblethingslab.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1670301298577100015 Content-Type: text/plain; charset="utf-8" This makes the code easier to understand and more robust if Xen's PAT ever changes. Signed-off-by: Demi Marie Obenour Reviewed-by: Andrew Cooper --- xen/arch/x86/mm/shadow/multi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 2370b3060285fee895f335f2a82d3d22ca5d31ed..4e94fec3d50cde0e5a26ecb62ff= 4d00dd00f759d 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -629,8 +629,8 @@ _sh_propagate(struct vcpu *v, else if ( p2mt =3D=3D p2m_mmio_direct && rangeset_contains_singleton(mmio_ro_ranges, mfn_x(target_mfn= )) ) { - sflags &=3D ~(_PAGE_RW | _PAGE_PAT); - sflags |=3D _PAGE_PCD | _PAGE_PWT; + sflags &=3D ~(_PAGE_RW | PAGE_CACHE_ATTRS); + sflags |=3D _PAGE_UC; } =20 // protect guest page tables --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat May 18 16:46:51 2024 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1670301294595403.194474924706; Mon, 5 Dec 2022 20:34:54 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.454335.711888 (Exim 4.92) (envelope-from ) id 1p2Pf5-0006BC-Qa; Tue, 06 Dec 2022 04:34:31 +0000 Received: by outflank-mailman (output) from mailman id 454335.711888; Tue, 06 Dec 2022 04:34:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p2Pf5-0006Aq-LL; Tue, 06 Dec 2022 04:34:31 +0000 Received: by outflank-mailman (input) for mailman id 454335; Tue, 06 Dec 2022 04:34:30 +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 1p2Pf4-00055j-Cj for xen-devel@lists.xenproject.org; Tue, 06 Dec 2022 04:34:30 +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 44ebb0d0-751f-11ed-8fd2-01056ac49cbb; Tue, 06 Dec 2022 05:34:29 +0100 (CET) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 2C3A432009F5; Mon, 5 Dec 2022 23:34:27 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 05 Dec 2022 23:34:27 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 23:34:25 -0500 (EST) 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: 44ebb0d0-751f-11ed-8fd2-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=fm1; t= 1670301266; x=1670387666; bh=74iR55QTZEIoGrp/SIuOn2UKjLBB0nvCkho 9p4QDUpk=; b=kZHF3htozvEjILFcNmghVOiwiPahaARZZQnYB3OuQ/ch06nSado yG6NGCo0bVBBOkqFcYbDNuN8woNHVSIVoJAekDNpejUV4z+p7Tn0MuABYOOto9Lb ciobsBYRt1mrbiqR1gkqKwGWDkzPI6sYnKW2fxGz0YFjE1qYMg8R88hEMeO/qwYc RNegB14AdeJvY/h86+/ILyEPDew23GpOPKHi5l15r6F9KLUBruR0eSY8wkQIfDet eh6x1jJDztvZyR0WrDtoj02rTfehAZZH8MOuili0YEPJDsrT016eaYgpHRP3wXiw nE/IoM+hL/5GHy0wjENcpkvTaoViDzlYByA== 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=fm1; t=1670301266; x=1670387666; bh=74iR55QTZEIoG rp/SIuOn2UKjLBB0nvCkho9p4QDUpk=; b=rzwdaqZhIFWzdkO3L3vAIMiVKkza+ PvpV0SK0/QZ98K6juLjx8KgH/WOj2E57lpPvOeMue8fyC4ffDDSo/FTU9je/7oJL 0ijXbB36LW+VT1evFWFQZX9hFxnqfJ3O+7mOHsC/z6kIISyqLb41ugTE5T7vt3Aj xKgKmZExEVbAyUDOOQuFfFPBIVJv3fXbanETr4FvE5AQN87g85O5abduXDCnzqfP vGHRDqpGD6m+Zp5vfXnb3VLmEOsBU3525KqxE+M5Uxd2uo1kGtAT063VzdlJY0eR QkwA6uRieCHnvo2fcpNMjDeowdQJcfWwVaqy+WpN4uFjzB+cMM+NmgcGg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehgdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghmihcu ofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinhhgsh hlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefghefg hffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedtnecurf 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=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Tim Deegan Subject: [PATCH 4/8] efi: Avoid hard-coding the various PAT constants Date: Mon, 5 Dec 2022 23:33:33 -0500 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1670301296801100011 Content-Type: text/plain; charset="utf-8" This makes the code much easier to understand, and avoids problems if Xen's PAT ever changes in the future. Signed-off-by: Demi Marie Obenour Reviewed-by: Jan Beulich --- xen/common/efi/boot.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 8e880fe30c7541a202dec3e665300d6549953aa3..260997b251b09dae4b48c1b1db6= 65778e02d760a 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1746,21 +1746,21 @@ void __init efi_init_memory(void) if ( desc->Attribute & EFI_MEMORY_WB ) /* nothing */; else if ( desc->Attribute & EFI_MEMORY_WT ) - prot |=3D _PAGE_PWT | MAP_SMALL_PAGES; + prot |=3D _PAGE_WT | MAP_SMALL_PAGES; else if ( desc->Attribute & EFI_MEMORY_WC ) - prot |=3D _PAGE_PAT | MAP_SMALL_PAGES; + prot |=3D _PAGE_WC | MAP_SMALL_PAGES; else if ( desc->Attribute & (EFI_MEMORY_UC | EFI_MEMORY_UCE) ) - prot |=3D _PAGE_PWT | _PAGE_PCD | MAP_SMALL_PAGES; + prot |=3D _PAGE_UC | MAP_SMALL_PAGES; else if ( efi_bs_revision >=3D EFI_REVISION(2, 5) && (desc->Attribute & EFI_MEMORY_WP) ) - prot |=3D _PAGE_PAT | _PAGE_PWT | MAP_SMALL_PAGES; + prot |=3D _PAGE_WP | MAP_SMALL_PAGES; else { printk(XENLOG_ERR "Unknown cachability for MFNs %#lx-%#lx%s\n", smfn, emfn - 1, efi_map_uc ? ", assuming UC" : ""); if ( !efi_map_uc ) continue; - prot |=3D _PAGE_PWT | _PAGE_PCD | MAP_SMALL_PAGES; + prot |=3D _PAGE_UC | MAP_SMALL_PAGES; } =20 if ( desc->Attribute & (efi_bs_revision < EFI_REVISION(2, 5) --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat May 18 16:46:51 2024 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 167030129473479.77493533489132; Mon, 5 Dec 2022 20:34:54 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.454336.711899 (Exim 4.92) (envelope-from ) id 1p2Pf8-0006VT-8D; Tue, 06 Dec 2022 04:34:34 +0000 Received: by outflank-mailman (output) from mailman id 454336.711899; Tue, 06 Dec 2022 04:34:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p2Pf8-0006VG-4H; Tue, 06 Dec 2022 04:34:34 +0000 Received: by outflank-mailman (input) for mailman id 454336; Tue, 06 Dec 2022 04:34:32 +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 1p2Pf6-0005MV-NJ for xen-devel@lists.xenproject.org; Tue, 06 Dec 2022 04:34:32 +0000 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 46925a2f-751f-11ed-91b6-6bf2151ebd3b; Tue, 06 Dec 2022 05:34:31 +0100 (CET) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 7636E32009ED; Mon, 5 Dec 2022 23:34:29 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 05 Dec 2022 23:34:30 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 23:34:28 -0500 (EST) 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: 46925a2f-751f-11ed-91b6-6bf2151ebd3b 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=fm1; t= 1670301269; x=1670387669; bh=78iOTcLznyqVPzoEL9+P1QeIqoDr0D4mDgx uOJLHvyA=; b=mb+ZKJoBLlLQBUZp7OYLSBpBR50HvPmg/rxtbJyjmd41Wsl7290 +6ZSXrsjfu4ms8u6jOVsqOa10kWfy6TkRdh/FDFKfPy3WrT6NEDeqMYZbYGanPNS Dcb74+ahLONwoEDI6uhsg4tjiUAPKFLwfIWdTiHw4bE0vvpHtnCKGYCCqWGJGK15 MYtjgqDrzoSt2PKNej70oONKCZXIe92Z3vMu7TuTM0ZSMRmgSF/xludl4ZCKxYvM PYK1Yqk9/sC+SK83qnVaFIA8stvLyhMOpUZS2CwmihCooXchGVl87mAoXvn6zm+R PR4nsoojQfnF9tJiW78wYYmptBGTeyG83Kg== 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=fm1; t=1670301269; x=1670387669; bh=78iOTcLznyqVP zoEL9+P1QeIqoDr0D4mDgxuOJLHvyA=; b=OvWfbvRkBEGn+zvGrNGEUNi+eH01S te6mERJm3kOGumqu5wEoLdGSIf5EqF4m6LC58nh6/TproNyCY8NhsSsEzGAG3G/M yMBaWvTDQKYXax7A06t1HVaXkoGdemfw4sHlWDYNSPGIgaXG+u62H7T2m3w0xhH+ fAqjL1HD+zOHGfa2bVbiSBEzmIIQA9zLoQ41UuT2j3tB/s1TpymXvZ/WLIrlvcfn Dlr/EOjKDFtqGI4b8uKH8mmIT9uhB2+1OT58xLdifDmuYQ/uRWxkqRsU5W1TyMYl XCs5J9hA+D+p2kPPauLilP0ktGYsaDh2JpLuMeT4Tq4OdQCrbl0L4a7Ig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghmihcu ofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinhhgsh hlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefghefg hffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedtnecurf 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=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Tim Deegan Subject: [PATCH 5/8] x86/mm/shadow: do not open-code PAGE_CACHE_ATTRS Date: Mon, 5 Dec 2022 23:33:34 -0500 Message-Id: <52d04f14daca91597f78f60e3a16cce4069bf32f.1670300446.git.demi@invisiblethingslab.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1670301296581100004 Content-Type: text/plain; charset="utf-8" This makes the code easier to understand. Signed-off-by: Demi Marie Obenour Acked-by: Jan Beulich --- xen/arch/x86/mm/shadow/multi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 4e94fec3d50cde0e5a26ecb62ff4d00dd00f759d..6bb564b0145285afc93b72a60b7= 797fcfe8696dc 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -535,7 +535,7 @@ _sh_propagate(struct vcpu *v, if ( guest_nx_enabled(v) ) pass_thru_flags |=3D _PAGE_NX_BIT; if ( level =3D=3D 1 && !shadow_mode_refcounts(d) && mmio_mfn ) - pass_thru_flags |=3D _PAGE_PAT | _PAGE_PCD | _PAGE_PWT; + pass_thru_flags |=3D PAGE_CACHE_ATTRS; sflags =3D gflags & pass_thru_flags; =20 /* @@ -548,7 +548,7 @@ _sh_propagate(struct vcpu *v, { int type; =20 - ASSERT(!(sflags & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT))); + ASSERT(!(sflags & PAGE_CACHE_ATTRS)); =20 /* compute the PAT index for shadow page entry when VT-d is enabled * and device assigned. --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat May 18 16:46:51 2024 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1670301293754735.9888835715419; Mon, 5 Dec 2022 20:34:53 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.454337.711910 (Exim 4.92) (envelope-from ) id 1p2PfA-0006ou-FR; Tue, 06 Dec 2022 04:34:36 +0000 Received: by outflank-mailman (output) from mailman id 454337.711910; Tue, 06 Dec 2022 04:34:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p2PfA-0006of-C4; Tue, 06 Dec 2022 04:34:36 +0000 Received: by outflank-mailman (input) for mailman id 454337; Tue, 06 Dec 2022 04:34:35 +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 1p2Pf9-0005MV-37 for xen-devel@lists.xenproject.org; Tue, 06 Dec 2022 04:34:35 +0000 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4801db77-751f-11ed-91b6-6bf2151ebd3b; Tue, 06 Dec 2022 05:34:34 +0100 (CET) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id DCE3232009F0; Mon, 5 Dec 2022 23:34:31 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 05 Dec 2022 23:34:32 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 23:34:30 -0500 (EST) 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: 4801db77-751f-11ed-91b6-6bf2151ebd3b 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=fm1; t= 1670301271; x=1670387671; bh=7lJWDKXrQS1OHkVX4MNh9xF7acm6KU1f8nX 60aLC2AY=; b=FXoGyWGbu8ukOOMXW7SDT6Zp4wfM7Wz0PjvmGgudbPZL8WuF2Lk hFNlf/xqUD2RXkc4Ma0T/AX87VFdXudmCg5IEknWURFAYhcS8G5l63kycRCDxTuM sIW5jjKa7TAjhyNPPib6KlYjWIsXJBcVRqqeI9/T6rW8V9oVySKrRXbNitlR+9A9 UKgtwICXA2HZVqjaZEfFkWDNFpFegnF179PbWJ1vKioangaVRFZYCBU2aZkshPsI lNZdQDpidWr0b0bpFESSWihvm6+L89cdtnReOclxAAPL5tSBvyJNdMw/7kstC+oW 9yz3j7MYRAzh6HI2yO5xU23Znwxaz2mYc6w== 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=fm1; t=1670301271; x=1670387671; bh=7lJWDKXrQS1OH kVX4MNh9xF7acm6KU1f8nX60aLC2AY=; b=SXcYAt2A2Lw3XEMWMyxyHFgyfSI7O TejRkzGRaY2rMGexP5FqCUGr0Fns4aJ+fk6pwX+V5QTv3V19vi5s+KUqL18DaI+t BEOC4li7JvUR/7ys4pIJFzuloD/ouYnKugI2AnxMj8cLTPgS0MjWCjMBDGjnDgNO YvmsKSRwA5Pobh7383QRh1URp/RileedV0d/lJvsJD75gRPjrABnTwnd4o1EdHnB 8L3J99vA2HMvughqN8FloSVwTvc55+3mPk2qjYvh3uhS8xXrOeeLD/rQrCxwYuhj ZHWgUyvvA2a967MAkLmgryj3zvmk/Rmq7tmA3uUxF0u4+/LxqmOyWbxzw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehgdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghmihcu ofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinhhgsh hlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefghefg hffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedtnecurf 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=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Tim Deegan Subject: [PATCH 6/8] x86: Derive XEN_MSR_PAT from its individual entries Date: Mon, 5 Dec 2022 23:33:35 -0500 Message-Id: <5ddd32a453b098f277f2d4aa9e044a40183d4bff.1670300446.git.demi@invisiblethingslab.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1670301294862100001 Content-Type: text/plain; charset="utf-8" This avoids it being a magic constant that is difficult for humans to decode. Use a _Static_assert to check that the old and new values are identical. Signed-off-by: Demi Marie Obenour --- xen/arch/x86/include/asm/processor.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/as= m/processor.h index 8e2816fae9b97bd4e153a30cc3802971fe0355af..64b75e444947c64e2e5eba457de= ec92a873d7a63 100644 --- a/xen/arch/x86/include/asm/processor.h +++ b/xen/arch/x86/include/asm/processor.h @@ -92,13 +92,33 @@ X86_EFLAGS_NT|X86_EFLAGS_DF|X86_EFLAGS_IF| \ X86_EFLAGS_TF) =20 +/* Individual entries in IA32_CR_PAT */ +#define MSR_PAT_UC _AC(0x00, ULL) +#define MSR_PAT_WC _AC(0x01, ULL) +#define MSR_PAT_RESERVED_1 _AC(0x02, ULL) +#define MSR_PAT_RESERVED_2 _AC(0x03, ULL) +#define MSR_PAT_WT _AC(0x04, ULL) +#define MSR_PAT_WP _AC(0x05, ULL) +#define MSR_PAT_WB _AC(0x06, ULL) +#define MSR_PAT_UCM _AC(0x07, ULL) + /* * Host IA32_CR_PAT value to cover all memory types. This is not the defa= ult * MSR_PAT value, and is an ABI with PV guests. */ -#define XEN_MSR_PAT _AC(0x050100070406, ULL) +#define XEN_MSR_PAT (MSR_PAT_WB << 0x00 | \ + MSR_PAT_WT << 0x08 | \ + MSR_PAT_UCM << 0x10 | \ + MSR_PAT_UC << 0x18 | \ + MSR_PAT_WC << 0x20 | \ + MSR_PAT_WP << 0x28 | \ + MSR_PAT_UC << 0x30 | \ + MSR_PAT_UC << 0x38 | \ + 0) =20 #ifndef __ASSEMBLY__ +_Static_assert(XEN_MSR_PAT =3D=3D 0x050100070406ULL, + "wrong XEN_MSR_PAT breaks PV guests"); =20 struct domain; struct vcpu; --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat May 18 16:46:51 2024 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1670301295587814.6551093638651; Mon, 5 Dec 2022 20:34:55 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.454338.711921 (Exim 4.92) (envelope-from ) id 1p2PfC-00078u-PI; Tue, 06 Dec 2022 04:34:38 +0000 Received: by outflank-mailman (output) from mailman id 454338.711921; Tue, 06 Dec 2022 04:34:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p2PfC-00078V-Lw; Tue, 06 Dec 2022 04:34:38 +0000 Received: by outflank-mailman (input) for mailman id 454338; Tue, 06 Dec 2022 04:34:37 +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 1p2PfB-0005MV-ES for xen-devel@lists.xenproject.org; Tue, 06 Dec 2022 04:34:37 +0000 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 495bd197-751f-11ed-91b6-6bf2151ebd3b; Tue, 06 Dec 2022 05:34:36 +0100 (CET) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 29CEA32009EC; Mon, 5 Dec 2022 23:34:34 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 05 Dec 2022 23:34:34 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 23:34:32 -0500 (EST) 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: 495bd197-751f-11ed-91b6-6bf2151ebd3b 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=fm1; t= 1670301273; x=1670387673; bh=T0aIZzrDadhvtD5mn+zJFIJWFtiX5Pwc1wj o5NMXh6Y=; b=XWGDwmRGgv4X9ujc8J/B1bh8ZHZGgJnfenvzQ/pLXlTtGreDGiR DmrJHeTgYwKCaOykGxGDiFbtvPzc/B+9585OfNyIYskEGpVfIvgNweJsNCeNkcSx engG+MVH/TzexeDEp/20kWi+2bktePcZzALSyN4M96EfZY9pDS15NNqRd8K/Gkkk 4T3D3BiP4LzXeUJLXtTZukGVbRjvoLCKaRca/TFS9s010zW05q3D8JQ4TaRjRUYT gRV9cp5JU12z99fynPr0Hf4gistz9iky3hF+sumk6wjOkFTt+ip3mrtcyUPDztqO 7K50pVadSK4dCmarEWUixab8rPang62dFrg== 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=fm1; t=1670301273; x=1670387673; bh=T0aIZzrDadhvt D5mn+zJFIJWFtiX5Pwc1wjo5NMXh6Y=; b=MF+VpGM5Ugdy4jY8PXPP+4q7BCrPN Eezq3kVESbyXNxD2d3Nmw641a1LgaQ5W+iYyhLF6a+NY/kyhTBT8dLfxLYJSS2KH fm5MTFDWFrN21lQXsm3eTOPJnNqz/PIVoRy2loQsvSiyV1sOJuhdRL6oLbUnmioB nCfLEuoWoxCbCCuODbeMAMOlPAr94mTvPRKzmYJAIANZQvGD7Qi3f+APWE2/5Am2 S5PNNF/Y2HoZN/0J5QMpEYUEYjmU93nkNfyxE2ELPxx9H0Mc8vhQbFN4hFgj/258 QKgaXqcMo7DImZlE0R1uboX/dKDxLjJ/XNjvXEVQM7w6XP5rek/16uDNA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehgdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghmihcu ofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinhhgsh hlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefghefg hffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedunecurf 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=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Tim Deegan Subject: [PATCH 7/8] x86/mm: make code robust to future PAT changes Date: Mon, 5 Dec 2022 23:33:36 -0500 Message-Id: <33f3896ba4cdf50ceb0377f071682ac5d3f576c4.1670300446.git.demi@invisiblethingslab.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1670301296592100006 Content-Type: text/plain; charset="utf-8" It may be desirable to change Xen's PAT for various reasons. This requires changes to several _PAGE_* macros as well. Add static assertions to check that XEN_MSR_PAT is consistent with the _PAGE_* macros. Additionally, Xen has two unused entries in the PAT. Currently these are UC, but this will change if the hardware ever supports additional memory types. To avoid future problems, this adds a check in debug builds that injects #GP into a guest that tries to use one of these entries, along with returning -EINVAL from the hypercall. Future versions of Xen will refuse to use these entries even in release builds. Signed-off-by: Demi Marie Obenour --- xen/arch/x86/mm.c | 58 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 5d05399c3a841bf03991a3bed63df9a815c1e891..517fccee699b2a673ba537e4793= 3aefc80017aa5 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -849,6 +849,45 @@ static int cf_check print_mmio_emul_range( } #endif =20 +static void __init __maybe_unused build_assertions(void) +{ + /* A bunch of static assertions to check that the XEN_MSR_PAT is valid + * and consistent with the _PAGE_* macros */ +#define PAT_VALUE(v) (0xFF & (XEN_MSR_PAT >> (8 * (v)))) +#define BAD_VALUE(v) ((v) < 0 || (v) > 7 || = \ + (v) =3D=3D MSR_PAT_RESERVED_1 || (v) =3D=3D MSR_PAT_= RESERVED_2) +#define BAD_PAT_VALUE(v) BUILD_BUG_ON(BAD_VALUE(PAT_VALUE(v))) + BAD_PAT_VALUE(0); + BAD_PAT_VALUE(1); + BAD_PAT_VALUE(2); + BAD_PAT_VALUE(3); + BAD_PAT_VALUE(4); + BAD_PAT_VALUE(5); + BAD_PAT_VALUE(6); + BAD_PAT_VALUE(7); +#undef BAD_PAT_VALUE +#undef BAD_VALUE +#define PAT_SHIFT(page_value) (((page_value) & _PAGE_PAT) >> 5 | = \ + ((page_value) & (_PAGE_PCD | _PAGE_PWT)) >>= 3) +#define CHECK_PAGE_VALUE(page_value) do { = \ + /* Check that the _PAGE_* macros only use bits from PAGE_CACHE_ATTRS *= / \ + BUILD_BUG_ON(((_PAGE_##page_value) & PAGE_CACHE_ATTRS) !=3D = \ + (_PAGE_##page_value)); = \ + /* Check that the _PAGE_* are consistent with XEN_MSR_PAT */ = \ + BUILD_BUG_ON(PAT_VALUE(PAT_SHIFT(_PAGE_##page_value)) !=3D = \ + (MSR_PAT_##page_value)); = \ +} while (0) + CHECK_PAGE_VALUE(WT); + CHECK_PAGE_VALUE(WB); + CHECK_PAGE_VALUE(WC); + CHECK_PAGE_VALUE(UC); + CHECK_PAGE_VALUE(UCM); + CHECK_PAGE_VALUE(WP); +#undef CHECK_PAGE_VALUE +#undef PAT_SHIFT +#undef PAT_VALUE +} + /* * get_page_from_l1e returns: * 0 =3D> success (page not present also counts as such) @@ -961,13 +1000,24 @@ get_page_from_l1e( =20 switch ( l1f & PAGE_CACHE_ATTRS ) { - case _PAGE_WB: + default: +#ifndef NDEBUG + printk(XENLOG_G_WARNING + "d%d: Guest tried to use bad cachability attribute %u f= or MFN %lx\n", + l1e_owner->domain_id, l1f & PAGE_CACHE_ATTRS, mfn); + pv_inject_hw_exception(TRAP_gp_fault, 0); + return -EINVAL; +#endif case _PAGE_WT: case _PAGE_WP: - flip |=3D (l1f & PAGE_CACHE_ATTRS) ^ _PAGE_UC; + case _PAGE_WB: + /* Force this to be uncachable */ + return flip | ( (l1f & PAGE_CACHE_ATTRS) ^ _PAGE_UC ); + case _PAGE_WC: + case _PAGE_UC: + case _PAGE_UCM: + return flip; } - - return flip; } =20 if ( unlikely((real_pg_owner !=3D pg_owner) && --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat May 18 16:46:51 2024 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 167030130147446.757588561612124; Mon, 5 Dec 2022 20:35:01 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.454339.711932 (Exim 4.92) (envelope-from ) id 1p2PfG-0007Ya-4b; Tue, 06 Dec 2022 04:34:42 +0000 Received: by outflank-mailman (output) from mailman id 454339.711932; Tue, 06 Dec 2022 04:34: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 1p2PfF-0007Xf-UO; Tue, 06 Dec 2022 04:34:41 +0000 Received: by outflank-mailman (input) for mailman id 454339; Tue, 06 Dec 2022 04:34:39 +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 1p2PfD-00055j-Mm for xen-devel@lists.xenproject.org; Tue, 06 Dec 2022 04:34:39 +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 4a7720c1-751f-11ed-8fd2-01056ac49cbb; Tue, 06 Dec 2022 05:34:38 +0100 (CET) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 7687032009EF; Mon, 5 Dec 2022 23:34:36 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 05 Dec 2022 23:34:37 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 23:34:35 -0500 (EST) 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: 4a7720c1-751f-11ed-8fd2-01056ac49cbb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1670301276; x=1670387676; bh=eaRrvP4SZe AXAQhX3z3ddqTteySVMlc1fYZ86aRBSug=; b=n/JCDB2wJOvkbd7PJGVcRW8HTH P3W4jzApLDJdY0PCC6zeqMIsLr/V9FoSgyLaXdJIWwK0FtAjeLfl9leOFjm95Qbf WuNgMexdnAKM58ItXNWzqsEvPLycvHYMTCH9wJqsj8+4dFU5p6+Uj3UD0ZMXBXJp 1bRnhv/tsythoP9cw6P5aWdJv+p9waA5z/036Gzj3BbK3YPS0jYiXwfzA7JQnmF2 ErB2g1jXrhFb7G7Yj9E4fygFx1l2Ho/elKdCnCIXYiorXkSJLuXmnK0TbDZgfEQo qWffm+aSaPI4WuArlODzf1q10bn3MuyUhUYpkTX1tBzUIHRwLS4WJVVS0XkA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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=fm1; t=1670301276; x= 1670387676; bh=eaRrvP4SZeAXAQhX3z3ddqTteySVMlc1fYZ86aRBSug=; b=w vv61OGSx32RYIPS9Sb3D/JZM+QsAFBdROhnlTxT8uRgn1idjAF8psZnCU8TrfPdJ quUU3NN/3KqYpJuKCRI1epSYEs4FYF/k+F/wU8jI3a8QaRtJs1SMJTqvwJGophWx eks14YpxAxNxTJHWnHOm4nrXpKB6/1HehVZJ8+lfAnX1jqefifo8Roq2PswO9vr1 wXECQJZcH3lZA25rn+1vvmEEljkNTvopG10P8mZJHwdoQbjY8cf0XnrOngeqghyY VyuYDvOSdx2kIm059egNQgiDVV98pSQq+Pggk8oB586p+ijgZBcqZF20XP4MXgcy Qc/XoQyoKamPDd6ahtyjw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehgdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepffgvmhhi ucforghrihgvucfqsggvnhhouhhruceouggvmhhisehinhhvihhsihgslhgvthhhihhngh hslhgrsgdrtghomheqnecuggftrfgrthhtvghrnhepledukeelleejkeevkeefgefhffeg vdeigeelieegjefffeeiveeivdejgeevteeinecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepuggvmhhisehinhhvihhsihgslhgvthhhihhnghhs lhgrsgdrtghomh 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=20Marczykowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , George Dunlap , Tim Deegan Subject: [RFC PATCH 8/8] Use Linux's PAT Date: Mon, 5 Dec 2022 23:33:37 -0500 Message-Id: <9f0bd911ba6c7fe1b7285f232154d42807145ced.1670300446.git.demi@invisiblethingslab.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1670301302721100001 Content-Type: text/plain; charset="utf-8" This is purely for testing, to see if it works around a bug in i915. It is not intended to be merged. NOT-signed-off-by: DO NOT MERGE --- xen/arch/x86/include/asm/page.h | 4 ++-- xen/arch/x86/include/asm/processor.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/include/asm/page.h b/xen/arch/x86/include/asm/pag= e.h index b585235d064a567082582c8e92a4e8283fd949ca..ab9b46f1d0901e50a83fd035ff2= 8d1bda0b781a2 100644 --- a/xen/arch/x86/include/asm/page.h +++ b/xen/arch/x86/include/asm/page.h @@ -333,11 +333,11 @@ void efi_update_l4_pgtable(unsigned int l4idx, l4_pge= ntry_t); =20 /* Memory types, encoded under Xen's choice of MSR_PAT. */ #define _PAGE_WB ( 0) -#define _PAGE_WT ( _PAGE_PWT) +#define _PAGE_WC ( _PAGE_PWT) #define _PAGE_UCM ( _PAGE_PCD ) #define _PAGE_UC ( _PAGE_PCD | _PAGE_PWT) -#define _PAGE_WC (_PAGE_PAT ) #define _PAGE_WP (_PAGE_PAT | _PAGE_PWT) +#define _PAGE_WT (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT) =20 /* * Debug option: Ensure that granted mappings are not implicitly unmapped. diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/as= m/processor.h index 64b75e444947c64e2e5eba457deec92a873d7a63..7a27d19d1dc8aa9c102683985c3= 0fb85864303fa 100644 --- a/xen/arch/x86/include/asm/processor.h +++ b/xen/arch/x86/include/asm/processor.h @@ -107,18 +107,18 @@ * MSR_PAT value, and is an ABI with PV guests. */ #define XEN_MSR_PAT (MSR_PAT_WB << 0x00 | \ - MSR_PAT_WT << 0x08 | \ + MSR_PAT_WC << 0x08 | \ MSR_PAT_UCM << 0x10 | \ MSR_PAT_UC << 0x18 | \ - MSR_PAT_WC << 0x20 | \ + MSR_PAT_WB << 0x20 | \ MSR_PAT_WP << 0x28 | \ - MSR_PAT_UC << 0x30 | \ - MSR_PAT_UC << 0x38 | \ + MSR_PAT_UCM << 0x30 | \ + MSR_PAT_WT << 0x38 | \ 0) =20 #ifndef __ASSEMBLY__ -_Static_assert(XEN_MSR_PAT =3D=3D 0x050100070406ULL, - "wrong XEN_MSR_PAT breaks PV guests"); +_Static_assert(XEN_MSR_PAT =3D=3D 0x0407050600070106ULL, + "wrong XEN_MSR_PAT breaks i915 driver on PV Linux"); =20 struct domain; struct vcpu; --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab