From mboxrd@z Thu Jan 1 00:00:00 1970 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 1FFCCC4167B for ; Wed, 14 Dec 2022 23:12:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.462661.720829 (Exim 4.92) (envelope-from ) id 1p5avV-0000Wh-GT; Wed, 14 Dec 2022 23:12:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 462661.720829; Wed, 14 Dec 2022 23:12:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p5avV-0000WX-D3; Wed, 14 Dec 2022 23:12:37 +0000 Received: by outflank-mailman (input) for mailman id 462661; Wed, 14 Dec 2022 23:12:36 +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 1p5avU-0000Gw-F4 for xen-devel@lists.xenproject.org; Wed, 14 Dec 2022 23:12:36 +0000 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cae697d8-7c04-11ed-91b6-6bf2151ebd3b; Thu, 15 Dec 2022 00:12:35 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 448503200495; Wed, 14 Dec 2022 18:12:33 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 14 Dec 2022 18:12:34 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 14 Dec 2022 18:12:31 -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: cae697d8-7c04-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= 1671059552; x=1671145952; bh=e6bEQ7cyuv0fw5IP1zcDCnUrggycZ9qD2rR Jl6yeW5Y=; b=MWJa8k8uwjFe7AmLq/7HforeY9j6EuoB6uq2xIKaA1vTv//NQ+j WwuzEpRUn5yeV7Eq5K+ueyyQCwJeltc5fXtb1UZC/lXb53uI6TpY5hThYyDFoo3q ouSa6O7e9lCqPAD8jFU7BTcDgYs+OCV8ayOuIW4Ox/eHMMNLNmJjmgewcA00VhHg MBFy6eEHevwwFXdwnLeC1pm6sg6PMauDsVKLCEilc7d2ZgPCgMTdkLGgR6MFyWQ/ dWDar3FDXacJyjxZNqUH0FbKtYu2ZX29U1WgYom+CggwP4H/SeLsCfVnsfpRyzbJ FptjCbvOjsjJb6entBtYrlIVLb2EB3LkaCg== 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=1671059552; x=1671145952; bh=e6bEQ7cyuv0fw 5IP1zcDCnUrggycZ9qD2rRJl6yeW5Y=; b=cweWERN0Yq6xIQzjBlj62qz+4GH96 T7CGEm620X//ZkozuEn7dRweEqyDYzDudLz4Rs3tqRIvk3PLsBVdBadCS7s8ZvYA 9N2BrTsVoPPjsqOdscPWkoqJjuNesiMiAo4BFmReDa2HuBY0VzX2DoP9EI1PfYi6 owQbjF5jnlct83o/etUPe0hyhZvpymU90ABCryGheXmkWTjl9Oi4gijE5mpNB1qt tLEyTait9haHncrijfw9/1dfO/gRvltWDZMqlrJLE787ECSbJiyvyO35o6jy4591 ybKkionLTjCThXku2Rz5+dyivh/e/TVEhW1gL+IWSsLDrgaNW2OI03Q2g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeggddtgecutefuodetggdotefrodftvf 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 , Jun Nakajima , Kevin Tian , George Dunlap , Tim Deegan Subject: [PATCH v3 01/12] x86/mm: Avoid hard-coding PAT in get_page_from_l1e() Date: Wed, 14 Dec 2022 18:11:51 -0500 Message-Id: <6a0d969d0aade0258e108009ef33ad5d2663e969.1671057808.git.demi@invisiblethingslab.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit get_page_from_l1e() relied on Xen's choice of PAT, which is brittle in the face of future PAT changes. Use the proper _PAGE_* constants instead. Also, treat the two unused cases as if they are cacheable, as future changes may make them cacheable. Signed-off-by: Demi Marie Obenour --- xen/arch/x86/mm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 78b1972e4170cacccc9c37c6e64e76e66a7da87f..b73cb29327ba49703673886d09d79f2f8928a6c0 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -959,14 +959,19 @@ get_page_from_l1e( flip = _PAGE_RW; } + /* Force cacheable memtypes to UC */ switch ( l1f & PAGE_CACHE_ATTRS ) { - case 0: /* WB */ - flip |= _PAGE_PWT | _PAGE_PCD; + case _PAGE_UC: + case _PAGE_UCM: + case _PAGE_WC: + /* not cached */ break; - case _PAGE_PWT: /* WT */ - case _PAGE_PWT | _PAGE_PAT: /* WP */ - flip |= _PAGE_PCD | (l1f & _PAGE_PAT); + case _PAGE_WB: + case _PAGE_WT: + case _PAGE_WP: + default: + flip |= (l1f & PAGE_CACHE_ATTRS) ^ _PAGE_UC; break; } -- Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab