Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8104099rwl; Tue, 10 Jan 2023 09:05:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXuKffzwNSU++x70ZbPF/k6d1uBxSomkIOaxd79OzN4u7Df6c47PWLP4XptevpFph7g8VvHf X-Received: by 2002:a17:906:c0ce:b0:7ad:d7a4:4346 with SMTP id bn14-20020a170906c0ce00b007add7a44346mr71578907ejb.66.1673370343960; Tue, 10 Jan 2023 09:05:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673370343; cv=none; d=google.com; s=arc-20160816; b=vuhZS3JXvrRdzcc83wqvAUnZ/KewIV/Vq+6k8pb/qj4l1ktfm1FVqJ8JevrNe2fYsw sLLLPTgrfr1cZcGDzBhUe50P6UqfUQw0E3XZbiV8MqSVYgZVIWy5fCS+ag7g4Qx9JhU8 H+iKGlqIa7CBSQ/wptVrQttUSqeAYJIBJW9lwKphXB4FBS6qgQ6ylenL0cIk+3Uace94 hM1/mO2jTQ4/hObXZvLSt4A3LuKAXVMhpLuoEVveXjFqm51VO3FBc6arEwksjZTwaET6 /sYXKprZpEWQvbY5//dgS+8ONkTP2+9DZuD7sSrqH0vx5B/XSdRThHaLDImq2lVv6BGC yigQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=ttxt13H5J51Gqr1Xn/jMJHwCS/g2F1Jlbgm/N+cRYAM=; b=G/1SUDtaXTWBfHvFXi9qzWlPIGY7ueO7v5iLTOBm8SWOmnqMBL2pHt52xArLh/T5/0 7oKMuNo4JD1xpR9o+cUSsI/k3s0q7oEBrLwdV4JjoG1bN9IIC9+8rsW/hQo4dd/oicUt G0Hd7/n4byWTTCKMrgX75ooqOYTmGNzLzJY1VTS4dVw8rYuod5rA0Zv3lOBg8ZkQC/q3 pEjUDn8xF85LV8krr1B5FfZNycFBhfl0z+DVIehgsob3Qm3scuctIdm+r3PVYm8vt2R1 HyeG9i71YaxtHPSM9r8Pvy1no2eCxWrtQPvg23t+Isw4aWGG8MLYIG/mtHNb22O2aSuh e1Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GziND44N; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a05640240d000b0044f1b7b8713si14613006edb.281.2023.01.10.09.05.31; Tue, 10 Jan 2023 09:05:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GziND44N; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238529AbjAJQcW (ORCPT + 53 others); Tue, 10 Jan 2023 11:32:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238880AbjAJQcD (ORCPT ); Tue, 10 Jan 2023 11:32:03 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 328ED84099; Tue, 10 Jan 2023 08:32:01 -0800 (PST) Date: Tue, 10 Jan 2023 16:31:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673368319; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ttxt13H5J51Gqr1Xn/jMJHwCS/g2F1Jlbgm/N+cRYAM=; b=GziND44NHtHJpTpTJI4rkQlAVdumD7TbsumT9wqcOvkijawpUThT5zg7u9calm0ntwPLG2 Vs9sg/Xdr/waj3vi5xdUf6suWHFVHEYSute4Sot8/jszcw8p8cO0iqIW0GJYNpwY4yJHEv x3nqSJQGTiBYbBk8LbaYf1YUQbr2ez2qmjPZ9U4ruVOVM8rlP1RotXmCeYIIFIjFYC0qvH tOjPL5zkgRrPff0sxhEnNKOV8jEtIgUfJWyDfhA6G/G5SK6TJkJnJXVo6fCGx+jtYLutYa 3meVv/zZe5SUnkyir2aOc72Ve8izqmGWRFrleuOp+1IdP3QiFcOLql9GS/8r/w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673368319; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ttxt13H5J51Gqr1Xn/jMJHwCS/g2F1Jlbgm/N+cRYAM=; b=wZF48rBvO2VBvLT70dlkh7zQyyD0v5rNFM1p8m+F6n+LZ7qD6INSMJ5MdcXD7ifVL6ztpu myMdW2zdLUZtEEBA== From: "tip-bot2 for Juergen Gross" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/pat: Fix pat_x_mtrr_type() for MTRR disabled case Cc: "Michael Kelley (LINUX)" , Juergen Gross , "Borislav Petkov (AMD)" , , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230110065427.20767-1-jgross@suse.com> References: <20230110065427.20767-1-jgross@suse.com> MIME-Version: 1.0 Message-ID: <167336831878.4906.1036202649956155536.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 90b926e68f500844dff16b5bcea178dc55cf580a Gitweb: https://git.kernel.org/tip/90b926e68f500844dff16b5bcea178dc55cf580a Author: Juergen Gross AuthorDate: Tue, 10 Jan 2023 07:54:27 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 10 Jan 2023 17:21:53 +01:00 x86/pat: Fix pat_x_mtrr_type() for MTRR disabled case Since 72cbc8f04fe2 ("x86/PAT: Have pat_enabled() properly reflect state when running on Xen") PAT can be enabled without MTRR. This has resulted in problems e.g. for a SEV-SNP guest running under Hyper-V, when trying to establish a new mapping via memremap() with WB caching mode, as pat_x_mtrr_type() will call mtrr_type_lookup(), which in turn is returning MTRR_TYPE_INVALID due to MTRR being disabled in this configuration. The result is a mapping with UC- caching, leading to severe performance degradation. Fix that by handling MTRR_TYPE_INVALID the same way as MTRR_TYPE_WRBACK in pat_x_mtrr_type() because MTRR_TYPE_INVALID means MTRRs are disabled. [ bp: Massage commit message. ] Fixes: 72cbc8f04fe2 ("x86/PAT: Have pat_enabled() properly reflect state when running on Xen") Reported-by: Michael Kelley (LINUX) Signed-off-by: Juergen Gross Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Michael Kelley Tested-by: Michael Kelley Cc: Link: https://lore.kernel.org/r/20230110065427.20767-1-jgross@suse.com --- arch/x86/mm/pat/memtype.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c index 46de9cf..fb4b1b5 100644 --- a/arch/x86/mm/pat/memtype.c +++ b/arch/x86/mm/pat/memtype.c @@ -387,7 +387,8 @@ static unsigned long pat_x_mtrr_type(u64 start, u64 end, u8 mtrr_type, uniform; mtrr_type = mtrr_type_lookup(start, end, &uniform); - if (mtrr_type != MTRR_TYPE_WRBACK) + if (mtrr_type != MTRR_TYPE_WRBACK && + mtrr_type != MTRR_TYPE_INVALID) return _PAGE_CACHE_MODE_UC_MINUS; return _PAGE_CACHE_MODE_WB;