Message ID | 20240131230902.1867092-1-pbonzini@redhat.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-47341-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp88607dyc; Wed, 31 Jan 2024 15:27:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFp6o0weKkVtJc8ZAdVgX7OfamoWGBfl1pR9lKvAliY05cDfB82wtKTTRpqQpvMOIVhL+Zp X-Received: by 2002:a17:90a:3481:b0:295:d09a:10d with SMTP id p1-20020a17090a348100b00295d09a010dmr3000614pjb.23.1706743623694; Wed, 31 Jan 2024 15:27:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706743623; cv=pass; d=google.com; s=arc-20160816; b=Rud3/Y1BAPQt3r98hMylYir3gx8GruVK+W9bdf/BuCZbLVyavhcKJBhmCdp6MCzCWB PHB2GxGo8zJwcDqH8wpHfqeSdsCp7aV21A7NTsXlNwpJ+Tl62RVqhHX4PjpVhqMDMlE/ S5EuKESH5Uc393DYkadp5ZqUz6QHC9Gp+FWj8kf0Y8l/DwobeezVRW4KQsEFZ0BUKfPV D1VolYPrvrUKcVb8zBzDNMujtFrubUEwmQqJ0wpvPqHpg0F8xDsHPfhjh55VJZYUoVkP H8dB01Kbgj5YtZxR1oHqlkYVRi63X62LWvzEKASF8+CTD/eaShS8hDa8PHq6QvBpVEgF BIgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=wn5H9c6FKbtv2kaoojksI6x/4GykFYB4EqXdTdRH6Pk=; fh=Ygv3xb4YzEHaCkl8PzNHXGDLixph7SfhanNDpAa8m6A=; b=KJuuPTpcOF20bUpIh0NGDgKFJnA2+X9UYx2YhAJocKYmKcETtZeiV1cqd3PtnM1EQN 9vQQNU5qn/20doYZlLo3FymDsINdtdlHO52sV0jQXtN0j7k0dFVPD3mXcuUOAOLUILN3 scc6RPC62OCfjETJfdZOOMqcDvRKcq/kyXOUJ+5BPlA6khziMvGrfZZhkPBK2Svd1Nwq PX/LhGR8OR17svdfVNVNQWjDVm4tY49HkpERrNFnycaJxwwpPBEVOyU5+fDFtRK39rak GNpvGE3qTOWE7vLpTUOgwTFkizgmWHZxqLax7V/KOYYZloQc7BMVwWIB0iEZKJ/Est3m LJUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SKvCUM5A; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-47341-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47341-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCWb7csVJzPnga3BiMfAoFEN78e6mKS7FcmHdr6HxGFeQfSVxIFkUiUbl63kdG5tnZVj1HSJ5JvqojYH8Sj1I0DFbpYFXA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t19-20020a17090aba9300b002900c676271si2245035pjr.14.2024.01.31.15.27.03 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:27:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47341-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SKvCUM5A; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-47341-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47341-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 715FA2A1D31 for <ouuuleilei@gmail.com>; Wed, 31 Jan 2024 23:27:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D170B47F52; Wed, 31 Jan 2024 23:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SKvCUM5A" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 517873B796 for <linux-kernel@vger.kernel.org>; Wed, 31 Jan 2024 23:09:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742550; cv=none; b=pqIarvjUEAsVcXkLHHAoYIk3SHK+1X4gY7iYQ4MKSjAi4JKo4lcRY1DHwQKRm3rU4Mxs5d/muJeJLsn3PTVykMNhw8184CxeeXLw/KP5o1IRhuKGLX33c6oZpgEKIEI+KA2EEjrOGCD1Fj53umeZ7jA7Rch8LzloPBZ550Up0H0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742550; c=relaxed/simple; bh=U3zze03rYR9J4ydeGjvVX+Qf6+csvmvvvlokpUg28Rg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Ibk2ysFMuQ0J2j8vTwJgoPuz/dt0bv0Qkd1c2a8CvFOkJQ168YkmJQeHqG3WY21h9i2hTa389yIVYXCn3BFHk3IsV6RNq4yyToxOWnfmV9ew6ugEElaK79QyO2pViUCYGUf1Sj0euFXlzP9m8A0moipJOzSHzI9qaeIBJEcXM0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SKvCUM5A; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706742548; h=from:from: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; bh=wn5H9c6FKbtv2kaoojksI6x/4GykFYB4EqXdTdRH6Pk=; b=SKvCUM5AvZxw2yRi0T2KlzGhtq77DTOGkcY/YgJm1tB6waUKRJHgDQrotZKWhbLKGcFIBw pIjxfAZvePJaBA++JWeNLORQ8wvG6Wj6X/eB9wSByss4ximdx14NWBhOK2JyDNqoL28S73 tTxXGAP1K0xmHcf6/TSuk26O77un1c0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-383-nazAgndcMJuUkmWQSzceBw-1; Wed, 31 Jan 2024 18:09:06 -0500 X-MC-Unique: nazAgndcMJuUkmWQSzceBw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-33af3a64df6so78260f8f.1 for <linux-kernel@vger.kernel.org>; Wed, 31 Jan 2024 15:09:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706742545; x=1707347345; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wn5H9c6FKbtv2kaoojksI6x/4GykFYB4EqXdTdRH6Pk=; b=shRRY0V9ggAsueUlpak4279VWEBCcSSD1vhDpRJxT1MEcPtR+VVDjXBTytD63Br1ve xvEQCU6UKfTpqdex3IbXjKOrgbxWluMOGSkzwyb8lM1oZfFo/MGap07yw77oeY1Ahmdi kNEoKMh2zp2CJve2btZb+TI5AaKy8vIULQL1tWUfE50Ho7rb9wcfu8g1K6H9i2owjqsV Du1BXC5sSqVSf02p/sncUfuZOKUyt/3/L9n/xv0Z4rSZ2wJQSJedkxzwKw5wqXCggfqT Csywx6zZXCsT5KhjyDlkrWdhaK/J6wJYJtyMYRNr8iOXBF0vO80ZnowEpw89aJfIOQ/D DmDw== X-Gm-Message-State: AOJu0YwxV/+qPUxZsNkruUrcMGKXh4yzF0O07K0KE5HLdJrVCx2QUhEr v2/9ASrccDgapkBwsrovvsxFwguLH2f1nGfy4eHKOHAFEOrWorEgxeGAGLw8Zs9+9FxANGbEUkO vD5vglVGlywDISN6uDhHxQl3VlJ2zJhc6/dqONOHPf5LZ12GpVRMD62TQoOiJEaIAPao7Gplp+d ibuQpXsLVUt0mbFQSWyZVpnfCjr46dYeedxc4V99G0N/5Wb6V6 X-Received: by 2002:adf:f851:0:b0:33b:146e:241f with SMTP id d17-20020adff851000000b0033b146e241fmr36424wrq.4.1706742544906; Wed, 31 Jan 2024 15:09:04 -0800 (PST) X-Received: by 2002:adf:f851:0:b0:33b:146e:241f with SMTP id d17-20020adff851000000b0033b146e241fmr36399wrq.4.1706742544417; Wed, 31 Jan 2024 15:09:04 -0800 (PST) Received: from [10.10.0.32] ([213.214.41.32]) by smtp.gmail.com with ESMTPSA id l10-20020a056000022a00b0033af350fb88sm7797114wrz.25.2024.01.31.15.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:09:03 -0800 (PST) From: Paolo Bonzini <pbonzini@redhat.com> To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Zixi Chen <zixchen@redhat.com>, Adam Dunlap <acdunlap@google.com>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, Xiaoyao Li <xiaoyao.li@intel.com>, Kai Huang <kai.huang@intel.com>, Dave Hansen <dave.hansen@linux.intel.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@kernel.org>, x86@kernel.org, stable@vger.kernel.org Subject: [PATCH v2 0/2] x86/cpu: fix invalid MTRR mask values for SEV or TME Date: Thu, 1 Feb 2024 00:09:00 +0100 Message-ID: <20240131230902.1867092-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789650401814321549 X-GMAIL-MSGID: 1789650401814321549 |
Series |
x86/cpu: fix invalid MTRR mask values for SEV or TME
|
|
Message
Paolo Bonzini
Jan. 31, 2024, 11:09 p.m. UTC
Supersedes: <20240130180400.1698136-1-pbonzini@redhat.com> MKTME repurposes the high bit of physical address to key id for encryption key and, even though MAXPHYADDR in CPUID[0x80000008] remains the same, the valid bits in the MTRR mask register are based on the reduced number of physical address bits. This breaks boot on machines that have TME enabled and do something to cleanup MTRRs, unless "disable_mtrr_cleanup" is passed on the command line. The fix is to move the check to early CPU initialization, which runs before Linux sets up MTRRs. However, as noticed by Kirill, the patch I sent as v1 actually works only until Linux 6.6. In Linux 6.7, commit fbf6449f84bf ("x86/sev-es: Set x86_virt_bits to the correct value straight away, instead of a two-phase approach") reorganized the initialization of c->x86_phys_bits in a way that broke the patch. But even in 6.7 AMD processors, which did try to reduce it in this_cpu->c_early_init(c), had their x86_phys_bits value overwritten by get_cpu_address_sizes(), so that early_identify_cpu() left the wrong value in x86_phys_bits. This probably went unnoticed because on AMD processors you need not apply the reduced MAXPHYADDR to MTRR masks. Therefore, this v2 prepends the fix for this issue in commit fbf6449f84bf. Apologies for the oversight. Tested on an AMD Epyc machine (where I resorted to dumping mtrr_state) and on the problematic Intel Emerald Rapids machine. Thanks, Paolo Paolo Bonzini (2): x86/cpu: allow reducing x86_phys_bits during early_identify_cpu() x86/cpu/intel: Detect TME keyid bits before setting MTRR mask registers arch/x86/kernel/cpu/common.c | 4 +- arch/x86/kernel/cpu/intel.c | 178 ++++++++++++++++++----------------- 2 files changed, 93 insertions(+), 89 deletions(-)
Comments
On 1/31/24 15:09, Paolo Bonzini wrote: > However, as noticed by Kirill, the patch I sent as v1 actually works only > until Linux 6.6. In Linux 6.7, commit fbf6449f84bf ("x86/sev-es: Set > x86_virt_bits to the correct value straight away, instead of a two-phase > approach") reorganized the initialization of c->x86_phys_bits in a way > that broke the patch. But even in 6.7 AMD processors, which did try to > reduce it in this_cpu->c_early_init(c), had their x86_phys_bits value > overwritten by get_cpu_address_sizes(), so that early_identify_cpu() > left the wrong value in x86_phys_bits. This probably went unnoticed > because on AMD processors you need not apply the reduced MAXPHYADDR to > MTRR masks. I really wanted get_cpu_address_sizes() to be the one and only spot where c->x86_phys_bits is established. That way, we don't get a bunch of code all of the place tweaking it and fighting for who "wins". We're not there yet, but the approach in this patch moves it back in the wrong direction because it permits the random tweaking of c->x86_phys_bits. Could we instead do something more like the (completely untested) attached patch? BTW, I'm pretty sure the WARN_ON() in the patch won't actually work, but it'd be nice to work toward a point when it does.
On 2/1/24 10:29, Dave Hansen wrote: > Could we instead do something more like the (completely untested) > attached patch? .. actually attaching it here
On Thu, Feb 1, 2024 at 7:29 PM Dave Hansen <dave.hansen@intel.com> wrote: > I really wanted get_cpu_address_sizes() to be the one and only spot > where c->x86_phys_bits is established. That way, we don't get a bunch > of code all of the place tweaking it and fighting for who "wins". > We're not there yet, but the approach in this patch moves it back in the > wrong direction because it permits the random tweaking of c->x86_phys_bits. I see your point; one of my earlier attempts added a ->c_detect_mem_encrypt() callback that basically amounted to either amd_detect_mem_encrypt() or detect_tme(). I bailed out of it mostly because these functions do more than adjusting phys_bits, and it seemed arbitrary to call them from get_cpu_address_sizes(). The two approaches share the idea of centralizing the computation of x86_phys_bits in get_cpu_address_sizes(). There is unfortunately an important hurdle for your patch, in that currently the BSP and AP flows are completely different. For the BSP the flow is ->c_early_init(), then get_cpu_address_sizes(), then again ->c_early_init() called by ->c_init(), then ->c_init(). For APs it is get_cpu_address_sizes(), then ->c_early_init() called by ->c_init(), then the rest of ->c_init(). And let's not even look at ->c_identify(). This difference is bad for your patch, because get_cpu_address_sizes() is called too early to see enc_phys_bits on APs. But it was also something that fbf6449f84bf didn't take into account, because it left behind the tentative initialization of x86_*_bits in identify_cpu(), while removing it from early_identify_cpu(). And TBH my first reaction after Kirill pointed me to fbf6449f84bf was to revert it. It's not like the code before was much less of a dumpster fire, but that commit made the BSP vs. AP mess even worse. But it fixed a real-world bug and it did remove most of the "first set then adjust" logic, at least for the BSP, so a revert wasn't on the table and patch 1 was what came out of it. I know that in general in Linux we prefer to fix things for good. Dancing one step behind and two ahead comes with the the risk that you only do the step behind. But in the end something like this patch 1 would have to be posted for stable branches (and Greg doesn't like one-off patches), and I am not even sure it's a step behind because it removes _some_ of the BSP vs. AP differences introduced by fbf6449f84bf. In a nutshell: I don't dislike the idea behind your patch, but the code is just not ready for it. I can look into cleaning up cpu/common.c though. I'm a natural procrastinator, it's my kind of thing to embark on a series of 30 patches to clean up 20 years old code... Paolo > Could we instead do something more like the (completely untested) > attached patch? > > BTW, I'm pretty sure the WARN_ON() in the patch won't actually work, but > it'd be nice to work toward a point when it does. >
On Fri, Feb 2, 2024 at 12:08 AM Paolo Bonzini <pbonzini@redhat.com> wrote: > > On Thu, Feb 1, 2024 at 7:29 PM Dave Hansen <dave.hansen@intel.com> wrote: > > I really wanted get_cpu_address_sizes() to be the one and only spot > > where c->x86_phys_bits is established. That way, we don't get a bunch > > of code all of the place tweaking it and fighting for who "wins". > > We're not there yet, but the approach in this patch moves it back in the > > wrong direction because it permits the random tweaking of c->x86_phys_bits. > > I see your point; one of my earlier attempts added a > ->c_detect_mem_encrypt() callback that basically amounted to either > amd_detect_mem_encrypt() or detect_tme(). I bailed out of it mostly > because these functions do more than adjusting phys_bits, and it > seemed arbitrary to call them from get_cpu_address_sizes(). The two > approaches share the idea of centralizing the computation of > x86_phys_bits in get_cpu_address_sizes(). > > There is unfortunately an important hurdle for your patch, in that > currently the BSP and AP flows are completely different. For the BSP > the flow is ->c_early_init(), then get_cpu_address_sizes(), then again > ->c_early_init() called by ->c_init(), then ->c_init(). For APs it is > get_cpu_address_sizes(), then ->c_early_init() called by ->c_init(), > then the rest of ->c_init(). And let's not even look at > ->c_identify(). > > This difference is bad for your patch, because get_cpu_address_sizes() > is called too early to see enc_phys_bits on APs. But it was also > something that fbf6449f84bf didn't take into account, because it left > behind the tentative initialization of x86_*_bits in identify_cpu(), > while removing it from early_identify_cpu(). And > > TBH my first reaction after Kirill pointed me to fbf6449f84bf was to > revert it. It's not like the code before was much less of a dumpster > fire, but that commit made the BSP vs. AP mess even worse. But it > fixed a real-world bug and it did remove most of the "first set then > adjust" logic, at least for the BSP, so a revert wasn't on the table > and patch 1 was what came out of it. > > I know that in general in Linux we prefer to fix things for good. > Dancing one step behind and two ahead comes with the the risk that you > only do the step behind. But in the end something like this patch 1 > would have to be posted for stable branches (and Greg doesn't like > one-off patches), and I am not even sure it's a step behind because it > removes _some_ of the BSP vs. AP differences introduced by > fbf6449f84bf. > > In a nutshell: I don't dislike the idea behind your patch, but the > code is just not ready for it. This is the diffstat before your patch can be applied more or less as is: $ git diffstat origin/master arch/x86/include/asm/processor.h | 1 + arch/x86/kernel/cpu/amd.c | 12 ++-- arch/x86/kernel/cpu/centaur.c | 13 ++--- arch/x86/kernel/cpu/common.c | 103 +++++++++++++++++++---------------- arch/x86/kernel/cpu/hygon.c | 2 - arch/x86/kernel/cpu/intel.c | 4 +- arch/x86/kernel/cpu/transmeta.c | 2 - arch/x86/kernel/cpu/zhaoxin.c | 1 - 8 files changed, 69 insertions(+), 69 deletions(-) $ git log --oneline --reverse origin/master.. d639afed02aa x86/cpu/common: move code up to early get_cpu_address_sizes() to a new function 40d34260a4ba x86/cpu/common: pull get_cpu_*() calls common to BSPs and APs to a new function 67b9839f9c38 x86/cpu/common: put all setup_force/clear capabilities together ebeae7f91cbc x86/cpu/centaur: do everything before early_init_centaur() in early_init_centaur() d62fa7400885 x86/cpu/cyrix: call early init function from init function 0aa0916cd7e0 x86/cpu/common: call early_init function on APs from common code d656b651d217 (HEAD) dave I still haven't tested very well, but anyway, what do you think? Paolo
On Sun, Feb 4, 2024 at 6:21 PM Paolo Bonzini <pbonzini@redhat.com> wrote: > On Fri, Feb 2, 2024 at 12:08 AM Paolo Bonzini <pbonzini@redhat.com> wrote: > > On Thu, Feb 1, 2024 at 7:29 PM Dave Hansen <dave.hansen@intel.com> wrote: > > > I really wanted get_cpu_address_sizes() to be the one and only spot > > > where c->x86_phys_bits is established. That way, we don't get a bunch > > > of code all of the place tweaking it and fighting for who "wins". > > > We're not there yet, but the approach in this patch moves it back in the > > > wrong direction because it permits the random tweaking of c->x86_phys_bits. > > > > There is unfortunately an important hurdle [...] in that > > currently the BSP and AP flows are completely different. For the BSP > > the flow is ->c_early_init(), then get_cpu_address_sizes(), then again > > ->c_early_init() called by ->c_init(), then ->c_init(). For APs it is > > get_cpu_address_sizes(), then ->c_early_init() called by ->c_init(), > > then the rest of ->c_init(). And let's not even look at > > ->c_identify(). [...] get_cpu_address_sizes() > > is called too early to see enc_phys_bits on APs. But it was also > > something that fbf6449f84bf didn't take into account, because it left > > behind the tentative initialization of x86_*_bits in identify_cpu(), > > while removing it from early_identify_cpu(). And Ping, either for applying the original patches or for guidance on how to proceed. Paolo
On 2/1/24 15:08, Paolo Bonzini wrote: > There is unfortunately an important hurdle for your patch, in that > currently the BSP and AP flows are completely different. Do we even _need_ c->x86_phys_bits for APs? I need to do a bit more grepping, but I only see it being read in show_cpuinfo(). Everything else seems to be boot_cpu_data.x86_phys_bits.
On 2/13/24 07:45, Paolo Bonzini wrote: > Ping, either for applying the original patches or for guidance on how > to proceed. Gah, all of the gunk that get_cpu_address_sizes() touches are out of control. They (phys/virt_bits and clflush) need to get consolidated back to a single copy that gets set up *once* in early boot and then read by everyone else. I've got a series to do that, but it's got its tentacles in quite a few places. They're not great backporting material. Your patches make things a wee bit worse in the meantime, but they pale in comparison to the random spaghetti that we've already got. Also, we probably need the early TME stuff regardless. I think I'll probably suck it up, apply them, then fix them up along with the greater mess. Anybody have any better ideas?
On Tue, Feb 13, 2024 at 11:02 PM Dave Hansen <dave.hansen@intel.com> wrote: > > On 2/13/24 07:45, Paolo Bonzini wrote: > > Ping, either for applying the original patches or for guidance on how > > to proceed. > > Gah, all of the gunk that get_cpu_address_sizes() touches are out of > control. > > They (phys/virt_bits and clflush) need to get consolidated back to a > single copy that gets set up *once* in early boot and then read by > everyone else. > > I've got a series to do that, but it's got its tentacles > in quite a few places. They're not great backporting material. Yes, same for mine. I probably digressed in a different direction than you, but there will be conflicts almost surely. I can post my stuff in the next few days. Paolo
On Tue, Feb 13, 2024 at 11:02 PM Dave Hansen <dave.hansen@intel.com> wrote: > Your patches make things a wee bit worse in the meantime, but they pale > in comparison to the random spaghetti that we've already got. Also, we > probably need the early TME stuff regardless. > > I think I'll probably suck it up, apply them, then fix them up along > with the greater mess. > > Anybody have any better ideas? Ping, in the end are we applying these patches for either 6.8 or 6.9? Paolo
On 2/20/24 04:22, Paolo Bonzini wrote: > On Tue, Feb 13, 2024 at 11:02 PM Dave Hansen <dave.hansen@intel.com> wrote: >> Your patches make things a wee bit worse in the meantime, but they pale >> in comparison to the random spaghetti that we've already got. Also, we >> probably need the early TME stuff regardless. >> >> I think I'll probably suck it up, apply them, then fix them up along >> with the greater mess. >> >> Anybody have any better ideas? > Ping, in the end are we applying these patches for either 6.8 or 6.9? Let me poke at them and see if we can stick them in x86/urgent early next week. They do fix an actual bug that's biting people, right?
On Thu, Feb 22, 2024 at 7:07 PM Dave Hansen <dave.hansen@intel.com> wrote: > > Ping, in the end are we applying these patches for either 6.8 or 6.9? > > Let me poke at them and see if we can stick them in x86/urgent early > next week. They do fix an actual bug that's biting people, right? Yes, I have gotten reports of {Sapphire,Emerald} Rapids machines that don't boot at all without either these patches or "disable_mtrr_cleanup". Paolo
On 2/23/24 02:08, Paolo Bonzini wrote: > On Thu, Feb 22, 2024 at 7:07 PM Dave Hansen <dave.hansen@intel.com> wrote: >>> Ping, in the end are we applying these patches for either 6.8 or 6.9? >> >> Let me poke at them and see if we can stick them in x86/urgent early >> next week. They do fix an actual bug that's biting people, right? > > Yes, I have gotten reports of {Sapphire,Emerald} Rapids machines that > don't boot at all without either these patches or > "disable_mtrr_cleanup". We tried platform other than Sapphire and Emerald. This patchset can fix boot issues on that platform also. Regards Yin, Fengwei > > Paolo > >
On 2/25/24 17:57, Yin Fengwei wrote: > On 2/23/24 02:08, Paolo Bonzini wrote: >> On Thu, Feb 22, 2024 at 7:07 PM Dave Hansen <dave.hansen@intel.com> wrote: >>>> Ping, in the end are we applying these patches for either 6.8 or 6.9? >>> Let me poke at them and see if we can stick them in x86/urgent early >>> next week. They do fix an actual bug that's biting people, right? >> Yes, I have gotten reports of {Sapphire,Emerald} Rapids machines that >> don't boot at all without either these patches or >> "disable_mtrr_cleanup". > We tried platform other than Sapphire and Emerald. This patchset can fix > boot issues on that platform also. Fengwei, could you also test this series on the troublesome hardware, please? > https://lore.kernel.org/all/20240222183926.517AFCD2@davehans-spike.ostc.intel.com/ If it _also_ fixes the problem, it'll be a strong indication that it's the right long-term approach.
On 2/27/24 00:21, Dave Hansen wrote: > On 2/25/24 17:57, Yin Fengwei wrote: >> On 2/23/24 02:08, Paolo Bonzini wrote: >>> On Thu, Feb 22, 2024 at 7:07 PM Dave Hansen <dave.hansen@intel.com> wrote: >>>>> Ping, in the end are we applying these patches for either 6.8 or 6.9? >>>> Let me poke at them and see if we can stick them in x86/urgent early >>>> next week. They do fix an actual bug that's biting people, right? >>> Yes, I have gotten reports of {Sapphire,Emerald} Rapids machines that >>> don't boot at all without either these patches or >>> "disable_mtrr_cleanup". >> We tried platform other than Sapphire and Emerald. This patchset can fix >> boot issues on that platform also. > > Fengwei, could you also test this series on the troublesome hardware, > please? Sure. I will try it on my env. I just didn't connected your patchset to this boot issue. :(. Regards Yin, Fengwei > >> https://lore.kernel.org/all/20240222183926.517AFCD2@davehans-spike.ostc.intel.com/ > > If it _also_ fixes the problem, it'll be a strong indication that it's > the right long-term approach. >
Hi Dave, On 2/27/24 00:21, Dave Hansen wrote: > On 2/25/24 17:57, Yin Fengwei wrote: >> On 2/23/24 02:08, Paolo Bonzini wrote: >>> On Thu, Feb 22, 2024 at 7:07 PM Dave Hansen <dave.hansen@intel.com> wrote: >>>>> Ping, in the end are we applying these patches for either 6.8 or 6.9? >>>> Let me poke at them and see if we can stick them in x86/urgent early >>>> next week. They do fix an actual bug that's biting people, right? >>> Yes, I have gotten reports of {Sapphire,Emerald} Rapids machines that >>> don't boot at all without either these patches or >>> "disable_mtrr_cleanup". >> We tried platform other than Sapphire and Emerald. This patchset can fix >> boot issues on that platform also. > > Fengwei, could you also test this series on the troublesome hardware, > please? > >> https://lore.kernel.org/all/20240222183926.517AFCD2@davehans-spike.ostc.intel.com/ > > If it _also_ fixes the problem, it'll be a strong indication that it's > the right long-term approach. I tried your patchset on a Sapphire machine which is the only one broken machine I can access today. The base commit is 45ec2f5f6ed3 from the latest linus tree. Without your patchset, the system boot hang. With your patchset, the system boot successfully. Regards Yin, Fengwei
On 2/26/24 22:08, Yin Fengwei wrote: >>> https://lore.kernel.org/all/20240222183926.517AFCD2@davehans-spike.ostc.intel.com/ >> If it _also_ fixes the problem, it'll be a strong indication that it's >> the right long-term approach. > I tried your patchset on a Sapphire machine which is the only one broken machine > I can access today. The base commit is 45ec2f5f6ed3 from the latest linus tree. > > Without your patchset, the system boot hang. > With your patchset, the system boot successfully. Yay! Thanks for testing.
On 2/27/24 21:30, Dave Hansen wrote: > On 2/26/24 22:08, Yin Fengwei wrote: >>>> https://lore.kernel.org/all/20240222183926.517AFCD2@davehans-spike.ostc.intel.com/ >>> If it _also_ fixes the problem, it'll be a strong indication that it's >>> the right long-term approach. >> I tried your patchset on a Sapphire machine which is the only one broken machine >> I can access today. The base commit is 45ec2f5f6ed3 from the latest linus tree. >> >> Without your patchset, the system boot hang. >> With your patchset, the system boot successfully. > > Yay! Thanks for testing. My pleasure. Regards Yin, Fengwei