Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp836395rwb; Thu, 1 Dec 2022 08:59:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6GKSB7H/Vw/afnRlJxSpC9u730rWvTuGDcga2PsoKI/TLfPlbjuBLzmIh/IXV19apQ8HRZ X-Received: by 2002:a05:6402:c0b:b0:463:a83c:e0af with SMTP id co11-20020a0564020c0b00b00463a83ce0afmr58726718edb.158.1669913986999; Thu, 01 Dec 2022 08:59:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669913986; cv=none; d=google.com; s=arc-20160816; b=iRlc+oZQiq7GgDVWH+PUeDqTiZdIErIhhjgcboHNQqJ2PqqlgN0RIkA/r0afAK518O IYFqC5t4FhR0ZDGJl/wB8izRiMVGZdq1ohZEu8RJTT1VlF+Bf9wUSjw3GESWgYpP6QkA 0ga6lMgyVuLY3All3CP32opr01GcI5nj/QA8LO604W2L8sBY4B+VEd59XSNsaMGqyiwd 1a/7got9ZFKrLZ/qmLBNlEKb0wROrMpdnkYdUxNBnlQqFnKqVX1E6145dTkSVP8hEdMj k+M4Iadeb1NOsq0I7NJFILbKv8ErKivsZZSyMkVpXgc+giktvUY4hvzZZ/6AZXuI1DD4 rZxg== 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=kK8tjfIpX7xXRH9wAV/NGprqCcNFpZBgtzVaZrvKOcQ=; b=q2YtODAHCO1pSXRaP4ku+RzJJRhex2wjBMB5UWE/TjeR9ex1ZZFITScCip3oeVwwdo vJvbw1MnGxjXCk3W2yFlF1OxKR+R2Sz1dodlZ1DEO5UV+kAa116tXtdjS+JkRW5JkZAZ A0AWa5GC2AOtFvY7wIHckxJVS9goqs2KyRfWX2eb2dVXYJcA5R4G4JRL20Te+oPlbi09 Uv/VJvgdrQaUcZOQafXAGMfINigeY2+3A7xl1Favz3Or212Yor5NCfRYLo1XSvY5rznh T9z0X9fbuifJ+b8CJ83/WcRu0lZXogwi8T65HlBkGOkj9dyjNVXmla8m42MwaiFpMC41 xVjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm3 header.b=AiTIC5dW; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=EUnC+kzc; 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 qw25-20020a1709066a1900b0078c4a772ea7si3970117ejc.11.2022.12.01.08.59.26; Thu, 01 Dec 2022 08:59:46 -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=AiTIC5dW; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=EUnC+kzc; 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 S232187AbiLAQ0s (ORCPT + 82 others); Thu, 1 Dec 2022 11:26:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231727AbiLAQ0q (ORCPT ); Thu, 1 Dec 2022 11:26:46 -0500 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E59309C637 for ; Thu, 1 Dec 2022 08:26:45 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 50E605C005C; Thu, 1 Dec 2022 11:26:44 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 01 Dec 2022 11:26:44 -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=1669912004; x=1669998404; bh=kK 8tjfIpX7xXRH9wAV/NGprqCcNFpZBgtzVaZrvKOcQ=; b=AiTIC5dWBp2wSd+Fnl 1jnJl3iAOWM2utMe00NeTzGV5y+oqpjxngq7X6E1mGEHbdMTgJ0sInHMkOMR+eVh mcZdXi7RQ6PinLl3mxoYSQaoJ4SZkdux7AHa7zzaELISN22zwT7k+Yzb2xzctTef +/iAgqLiaMNO/dyliTGss8SveDmPLR22y0XjARBk6y+KkUoxan6RsNmUGeBl05wo s+RPJJJTOA7TeZUBPlSX+pQj+gz7qhmXGAker7seoJZ5F0JH2VsQ1jPYl2caSd7w ZkSnq1VmEAv/WxgMODIH2zt73ATKf7BTrSaISZ1ZEcD2taoC42CaXNR2fskofejL M2Vw== 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=1669912004; x=1669998404; bh=kK8tjfIpX7xXRH9wAV/NGprqCcNF pZBgtzVaZrvKOcQ=; b=EUnC+kzcB7/9E4GLUTwYoUAVAn7yNQb6/c37Ygxf77G9 qxexz3cNkdwn/MozkQTG+QQWX7J8LnGfXs4fLDoSyo4/gtkHI01hXknCuEklO/4m y81AvfFF6xGfSvZ0RLIXhtXdNQWR9CFSATBHbOxwjqVne6GL2+nxMR4plazauZAd 0tWh+t5Ywtv4w7r7P53/N1x3WD+vt6HL17WgKiC2txju7+GFy2hRfGwzAVrKEBPZ 8ZU7KBRoww19mV13N/5mQjDjHwObK8YMZ1eIAHpSUUdiAP40A6aqrGsfeCtdoNX1 J0WdM//UHLTKmt15TDFOLf3KFnaNok2eZ+G5H7Bs4Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrtdehgdeklecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttddttddttddvnecuhfhrohhmpedfmfhirhhi lhhlucetrdcuufhhuhhtvghmohhvfdcuoehkihhrihhllhesshhhuhhtvghmohhvrdhnrg hmvgeqnecuggftrfgrthhtvghrnhepfeeileeffeeiteeljeekheetieehhffhfeeuheel tdetgfeuvddvffegvdelhfdunecuffhomhgrihhnpehinhhtvghlrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepkhhirhhilhhlsehs hhhuthgvmhhovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Dec 2022 11:26:42 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id ADFCE109781; Thu, 1 Dec 2022 19:26:39 +0300 (+03) Date: Thu, 1 Dec 2022 19:26:39 +0300 From: "Kirill A. Shutemov" To: Juergen Gross Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra Subject: Re: [PATCH v5 13/16] x86: decouple PAT and MTRR handling Message-ID: <20221201162639.omlr5ff55go7uhlf@box.shutemov.name> References: <20221102074713.21493-1-jgross@suse.com> <20221102074713.21493-14-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221102074713.21493-14-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, RCVD_IN_MSPIKE_H2,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 Wed, Nov 02, 2022 at 08:47:10AM +0100, Juergen Gross wrote: > Today PAT is usable only with MTRR being active, with some nasty tweaks > to make PAT usable when running as Xen PV guest, which doesn't support > MTRR. > > The reason for this coupling is, that both, PAT MSR changes and MTRR > changes, require a similar sequence and so full PAT support was added > using the already available MTRR handling. > > Xen PV PAT handling can work without MTRR, as it just needs to consume > the PAT MSR setting done by the hypervisor without the ability and need > to change it. This in turn has resulted in a convoluted initialization > sequence and wrong decisions regarding cache mode availability due to > misguiding PAT availability flags. > > Fix all of that by allowing to use PAT without MTRR and by reworking > the current PAT initialization sequence to match better with the newly > introduced generic cache initialization. > > This removes the need of the recently added pat_force_disabled flag, so > remove the remnants of the patch adding it. > > Signed-off-by: Juergen Gross This patch breaks boot for TDX guest. Kernel now tries to set CR0.CD which is forbidden in TDX guest[1] and causes #VE: tdx: Unexpected #VE: 28 VE fault: 0000 [#1] PREEMPT SMP NOPTI CPU: 0 PID: 0 Comm: swapper Not tainted 6.1.0-rc1-00015-gadfe7512e1d0 #2646 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:native_write_cr0 (arch/x86/kernel/cpu/common.c:427) Call Trace: ? cache_disable (arch/x86/include/asm/cpufeature.h:173 arch/x86/kernel/cpu/cacheinfo.c:1085) ? cache_cpu_init (arch/x86/kernel/cpu/cacheinfo.c:1132 (discriminator 3)) ? setup_arch (arch/x86/kernel/setup.c:1079) ? start_kernel (init/main.c:279 (discriminator 3) init/main.c:477 (discriminator 3) init/main.c:960 (discriminator 3)) ? load_ucode_bsp (arch/x86/kernel/cpu/microcode/core.c:155) ? secondary_startup_64_no_verify (arch/x86/kernel/head_64.S:358) Any suggestion how to fix it? [1] Section 10.6.1. "CR0", https://cdrdv2.intel.com/v1/dl/getContent/733568 -- Kiryl Shutsemau / Kirill A. Shutemov