From patchwork Thu Dec 22 22:31:47 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: 13080406 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 D28D3C3DA7D for ; Thu, 22 Dec 2022 22:32:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.468694.727884 (Exim 4.92) (envelope-from ) id 1p8U6j-0003fz-RZ; Thu, 22 Dec 2022 22:32:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 468694.727884; Thu, 22 Dec 2022 22:32:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p8U6j-0003fp-NP; Thu, 22 Dec 2022 22:32:09 +0000 Received: by outflank-mailman (input) for mailman id 468694; Thu, 22 Dec 2022 22:32:08 +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 1p8U6i-0003ch-3O for xen-devel@lists.xenproject.org; Thu, 22 Dec 2022 22:32:08 +0000 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 74bb5547-8248-11ed-8fd4-01056ac49cbb; Thu, 22 Dec 2022 23:32:04 +0100 (CET) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 7521E5C00BE; Thu, 22 Dec 2022 17:32:02 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 22 Dec 2022 17:32:02 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Dec 2022 17:32:01 -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: 74bb5547-8248-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= 1671748322; x=1671834722; bh=lFRjAyz2V8QJ7yU1YRzmTT1WULJJ6rEk/i2 CB/Rdt1o=; b=CmjweiydWEPzaPijrx7yD0axzlmqvWGg7p6Xy5g7F+6ZBN9b1j5 oSoz5BSyld6drG6klTB2aPG0nGAABBhNrWG82WoMm8QTPkeOO0fi8CnB5TlmAWxL DgK+3jvl64jvb8oZ3aw8e+G9U/m7hu8W1NmJNstH6TJXXGt4MIqcdt7RMFoiUk+7 Yq5WqkQtsmhIMQdB5H5UHZyAnOj1BnObo6wf3RCyoO8DrddTtBlg3oWCSMvLnMjo X1h/n2fyorTyLJewMry+odjTXHvR3rv7ghINeFOfMB4sSgn6eSX5Oq3QJyMMKV8a j/aSs4AyE4otbI/yS5GVlrgGrRHf3fMNHjw== 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=1671748322; x=1671834722; bh=lFRjAyz2V8QJ7 yU1YRzmTT1WULJJ6rEk/i2CB/Rdt1o=; b=rQY+7/wZda7tED0EbKq0qrQyOV0C3 ZZQQVSiTlkdLHtwRuYw5qyOebCgCwgWb63tNUxykPKPPKVsLfDdGIuwIpeCFk0O0 X65hDIT2Z1jiV1pk0ETVV+dCkdshzg350xgcDzP/OwU9L5vJ14aRwRsq0plj7VtL K+PDWzZaL42iYwLtL8Tz1hVQ0L3mxBI3LE1S3yd3O/KtZJSnST9tqYbNLN9xM+OX zUPNwvtIzn5E4BMZLked7aQoVeHO/Yzl3+yqADzFcvaRw5UpzIo8pPvAy/aGxh1U BCHABYmFQ7JcsWB4ELKxY6h5EVOq6StI6+vDRG0lZ5fyE9Ue2xtLh+1tg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrhedtgdduieefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgvmhhi ucforghrihgvucfqsggvnhhouhhruceouggvmhhisehinhhvihhsihgslhgvthhhihhngh hslhgrsgdrtghomheqnecuggftrfgrthhtvghrnhepjeffjefggfeugeduvedvjeekgfeh gffhhfffjeetkeelueefffetfffhtdduheetnecuvehluhhsthgvrhfuihiivgeptdenuc 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_Marczy?= =?utf-8?q?kowski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Tim Deegan , George Dunlap Subject: [PATCH v6 2/5] x86: Remove MEMORY_NUM_TYPES and NO_HARDCODE_MEM_TYPE Date: Thu, 22 Dec 2022 17:31:47 -0500 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 No functional change intended. Signed-off-by: Demi Marie Obenour --- Changes since v2: - Keep MTRR_NUM_TYPES and adjust commit message accordingly --- xen/arch/x86/hvm/mtrr.c | 18 +++++++++--------- xen/arch/x86/include/asm/mtrr.h | 2 -- xen/arch/x86/mm/shadow/multi.c | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c index 093103f6c768cf64f880d1b20e1c14f5918c1250..05e978041d62fd0d559462de181a04bef8a5bca9 100644 --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86/hvm/mtrr.c @@ -38,7 +38,7 @@ static const uint8_t pat_entry_2_pte_flags[8] = { /* Effective mm type lookup table, according to MTRR and PAT. */ static const uint8_t mm_type_tbl[MTRR_NUM_TYPES][X86_NUM_MT] = { -#define RS MEMORY_NUM_TYPES +#define RS MTRR_NUM_TYPES #define UC X86_MT_UC #define WB X86_MT_WB #define WC X86_MT_WC @@ -66,9 +66,9 @@ static const uint8_t mm_type_tbl[MTRR_NUM_TYPES][X86_NUM_MT] = { * Reverse lookup table, to find a pat type according to MTRR and effective * memory type. This table is dynamically generated. */ -static uint8_t __read_mostly mtrr_epat_tbl[MTRR_NUM_TYPES][MEMORY_NUM_TYPES] = - { [0 ... MTRR_NUM_TYPES-1] = - { [0 ... MEMORY_NUM_TYPES-1] = INVALID_MEM_TYPE } +static uint8_t __read_mostly mtrr_epat_tbl[MTRR_NUM_TYPES][MTRR_NUM_TYPES] = + { [0 ... MTRR_NUM_TYPES - 1] = + { [0 ... MTRR_NUM_TYPES - 1] = INVALID_MEM_TYPE } }; /* Lookup table for PAT entry of a given PAT value in host PAT. */ @@ -85,7 +85,7 @@ static int __init cf_check hvm_mtrr_pat_init(void) { unsigned int tmp = mm_type_tbl[i][j]; - if ( tmp < MEMORY_NUM_TYPES ) + if ( tmp < MTRR_NUM_TYPES ) mtrr_epat_tbl[i][tmp] = j; } } @@ -317,11 +317,11 @@ static uint8_t effective_mm_type(struct mtrr_state *m, uint8_t gmtrr_mtype) { uint8_t mtrr_mtype, pat_value; - + /* if get_pat_flags() gives a dedicated MTRR type, * just use it - */ - if ( gmtrr_mtype == NO_HARDCODE_MEM_TYPE ) + */ + if ( gmtrr_mtype == MTRR_NUM_TYPES ) mtrr_mtype = mtrr_get_type(m, gpa, 0); else mtrr_mtype = gmtrr_mtype; @@ -346,7 +346,7 @@ uint32_t get_pat_flags(struct vcpu *v, /* 1. Get the effective memory type of guest physical address, * with the pair of guest MTRR and PAT */ - guest_eff_mm_type = effective_mm_type(g, pat, gpaddr, + guest_eff_mm_type = effective_mm_type(g, pat, gpaddr, gl1e_flags, gmtrr_mtype); /* 2. Get the memory type of host physical address, with MTRR */ shadow_mtrr_type = mtrr_get_type(&mtrr_state, spaddr, 0); diff --git a/xen/arch/x86/include/asm/mtrr.h b/xen/arch/x86/include/asm/mtrr.h index e4f6ca6048334b2094a1836cc2f298453641232f..4b7f840a965954cc4b59698327a37e47026893a4 100644 --- a/xen/arch/x86/include/asm/mtrr.h +++ b/xen/arch/x86/include/asm/mtrr.h @@ -4,8 +4,6 @@ #include #define MTRR_NUM_TYPES X86_MT_UCM -#define MEMORY_NUM_TYPES MTRR_NUM_TYPES -#define NO_HARDCODE_MEM_TYPE MTRR_NUM_TYPES #define NORMAL_CACHE_MODE 0 #define NO_FILL_CACHE_MODE 2 diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index f5f7ff021bd9e057c5b6f6329de7acb5ef05d58f..1faf9940db6b0afefc5977c00c00fb6a39cd27d2 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -578,7 +578,7 @@ _sh_propagate(struct vcpu *v, gflags, gfn_to_paddr(target_gfn), mfn_to_maddr(target_mfn), - NO_HARDCODE_MEM_TYPE); + MTRR_NUM_TYPES); } }