Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5871676rwb; Mon, 5 Dec 2022 05:20:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf5bK+F4bxUlEXMi3AnmIUYfrrOj0GLkULGKzJ/3J5NkFST6g33QnOpWpsuQvMgdwYxa1DBn X-Received: by 2002:a17:906:114a:b0:7c0:c836:e586 with SMTP id i10-20020a170906114a00b007c0c836e586mr11321061eja.750.1670246452434; Mon, 05 Dec 2022 05:20:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670246452; cv=none; d=google.com; s=arc-20160816; b=LREiO2AaHRIdMyqQrqm030q/9HXA0b9YzekYxvR15DdGIHFRvadOc5nTbRXtO72kY7 sFbGWZs7eMJ7rHzGgc+jy5mFd7x7DE6g068h6BKhC7qdqMROkkqtIEpXY5eScSGR9y30 tUmVUP7IFvEuNSdKJ4rEx4003+m50yJh+J1TrVRQ3rl8bM6rJUtDnq971OCcSyC3GFCK OMK6XPLNkWq6pwMC+AiqtDgJO5DQmDY+Py2GOvdLi8K1zv27npybS/i8RIGXGa4Za3FJ GnnfwVqgu3a7FWeR31XmNpZNwyxqJXAxSr6Yb5WgkHs/8zoylFRLURPHv4k+uiPgXK7/ V9KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=yIqDSI5A7PcdM3ZE7CaXgNn6948WUVwhu1z8w40I5rg=; b=xucCHqXUyfc10caZjIABb+WxEqaOmtkw2wxxnmjpjhn5XbYXZpXlbuPOdgflNSjBOE SxD9XAN59F29SEoa3jd6EEcjgOFA+/S94gBKBSWEz53opHfeWwIxqWGLRbSaSX4NYxR7 gyNYoCQ5O197XWXL4w3G6R+gLOCXS8Y0CFqlRfs6Hk1BhIiaqjN/XaNpiWbRqSik5Q9g nFCqGh+An40kRR9mlKKTtnhDAPNnZfWJrwEhB51n50uZh5jbveXGL4O/myNkfvkXP6RE qACLHzHRdvDpMWQ3c9YO+vMAj3X+2F+J+JxWlftx2INp63Bzv3Fe9kIoigRssdRkXd6F UOZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm3 header.b=IA2A3+3W; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=NN5tv1jV; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a056402524b00b0046cb20e357esi2938071edd.366.2022.12.05.05.20.30; Mon, 05 Dec 2022 05:20:52 -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=@shutemov.name header.s=fm3 header.b=IA2A3+3W; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=NN5tv1jV; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231756AbiLEM0a (ORCPT + 82 others); Mon, 5 Dec 2022 07:26:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230262AbiLEM02 (ORCPT ); Mon, 5 Dec 2022 07:26:28 -0500 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D97F25CA for ; Mon, 5 Dec 2022 04:26:27 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 145E23200933; Mon, 5 Dec 2022 07:26:25 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 05 Dec 2022 07:26:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc: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=fm3; t=1670243185; x=1670329585; bh=yI qDSI5A7PcdM3ZE7CaXgNn6948WUVwhu1z8w40I5rg=; b=IA2A3+3Wqw8RQ6OgvL yOJ5SwtfZBLQQqxVdeDMbr5HdzZNjqj7dZp8e0ayopPkhgSZ/o34pFoYCAQIOZxK dzHx3gep5tN5i8CgzVL5jZMASo4VSbQJzjiRf5H+3gmt/erfirSlNrDxRid4A8YM rPs6tMNRrqsVbUMI/vLFi3bso5vvQV+q7x65fP6M1p25kVBTVB3GCsfX5JeONQyi XHpQPlyL27zHoykFk8nVkad2VGUq5UzeuU0DwlKPDD/pKLFWmBBFpzQQqQs/2A6D 98RL3P6/wRcO59ICi9TxMfEhYjfIVFU2zrUq5ZtvN2ZOGLVpFOIA2/4nvh05N/XG juxg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=1670243185; x=1670329585; bh=yIqDSI5A7PcdM3ZE7CaXgNn6948W UVwhu1z8w40I5rg=; b=NN5tv1jVYxtA5KaIMk8Wfi53JTDEVgD7/td7Yg2+K1Hl +cIBnk+MvuXb7S7NGkzYbrwH6VEoN5KzTTYovLA85qTRtbpDO2TwWCuAQni5Dhxw MHVbWEr34yin0msM+sCIBdlwKpU6eTb/s/+sS3VXqLmBcqquzMquTPE1Ax7BPJu8 aii2jCBviaR3Rfp+tDMgZqPz/3UG3opcQjY8uxVTeiuEvAT0Az7wpJAvuaCWcun5 HsQvMtb9lYVkRZnF/aQnqDkz0GAx1hFKJDrUUycPEFzb6tl8miujbLwlQRQjj9km MbTTZpUHtD8/EBtcqYs0OAteIFl5IshgBqB/iWqqOw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudeggdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttddttddttddvnecuhfhrohhmpehkihhrihhl lhesshhhuhhtvghmohhvrdhnrghmvgenucggtffrrghtthgvrhhnpeehleevveejudejke evueevteevfffhkeejgfehleethefhueejvdehieejgffhhfenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmoh hvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Dec 2022 07:26:24 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id 0C37B10948F; Mon, 5 Dec 2022 15:26:23 +0300 (+03) Date: Mon, 5 Dec 2022 15:26:23 +0300 From: kirill@shutemov.name To: Juergen Gross Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" Subject: Re: [PATCH 1/2] x86/pat: fix TDX guest PAT initialization Message-ID: <20221205122623.2px6y63rkkgvpxo5@box.shutemov.name> References: <20221205080433.16643-1-jgross@suse.com> <20221205080433.16643-2-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221205080433.16643-2-jgross@suse.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, 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 On Mon, Dec 05, 2022 at 09:04:32AM +0100, Juergen Gross wrote: > With the decoupling of PAT and MTRR initialization, PAT will be used > even with MTRRs disabled. This seems to break booting up as TDX guest, > as the recommended sequence to set the PAT MSR across CPUs can't work > in TDX guests due to disabling caches via setting CR0.CD isn't allowed > in TDX mode. > > This is an inconsistency in the Intel documentation between the SDM > and the TDX specification. For now handle TDX mode the same way as Xen > PV guest mode by just accepting the current PAT MSR setting without > trying to modify it. > > Signed-off-by: Juergen Gross Good enough for now. I will follow up if something comes up from the discussion around the topic. Acked-by: Kirill A. Shutemov > --- > arch/x86/mm/pat/memtype.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c > index 9aab17d660cd..4e50add760ad 100644 > --- a/arch/x86/mm/pat/memtype.c > +++ b/arch/x86/mm/pat/memtype.c > @@ -296,8 +296,12 @@ void __init pat_bp_init(void) > /* > * Xen PV doesn't allow to set PAT MSR, but all cache modes are > * supported. > + * When running as TDX guest setting the PAT MSR won't work either > + * due to the requirement to set CR0.CD when doing so. Rely on > + * firmware to have set the PAT MSR correctly. s/firmware/TDX module/ > */ > - if (pat_disabled || cpu_feature_enabled(X86_FEATURE_XENPV)) { > + if (pat_disabled || cpu_feature_enabled(X86_FEATURE_XENPV) || > + cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) { > init_cache_modes(pat_msr_val); > return; > } -- Kiryl Shutsemau / Kirill A. Shutemov