Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp261073lqs; Thu, 13 Jun 2024 09:18:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUF+uatd57dDP04PY+7vpQpgcADJZqjW1jzzNp8+zos0sFTVQNc51Qf9zpm92lc782Yc98vkFMbhbR3VHjKnE9ob6aGpHpSi4E4Xol+Lg== X-Google-Smtp-Source: AGHT+IG0XCwoPMaAg131R4JV+0AQ6IOJPl0Zams7bT/PEj9+sxXo97H/FzVEiaNYb889/TOv30V7 X-Received: by 2002:a17:906:eb06:b0:a6f:6005:3293 with SMTP id a640c23a62f3a-a6f6005336fmr45250166b.15.1718295502277; Thu, 13 Jun 2024 09:18:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718295502; cv=pass; d=google.com; s=arc-20160816; b=ZieUjVeNXj7iES/ThPRjpA/1DrcdzB5Z1gAf8Gr/a+8mNwBWPbi4o/ue/eNDp3Ldz8 EEcVUuT4ZFMkvBhB3aTQkfXhysVYwSLNE80yM3LZCX3BdgabpdpL3JbGmAgMn9GfN9S+ 1YLBqbHEoZLR3+h5uf+nuzHsBPUurOfQq/c0MAvpF9f3QLm7wDIIx9ktO5qfXPrZaJ2V AfmOlyuiQZqQU0vE3OpXljqQ37bvCdX5xMblVlwVDlpMq4aAWbquNkFi7/Hrmi/dIzWp yD4CUWDr2MsvL6ck05tVifd+XUGSj9/Dq94OH1STumBT0FlJxbpa6TGLtxWlnMdD8x2Z 7yHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:content-disposition:references:message-id:subject:cc:to :from:date:dkim-signature; bh=Y3rT6DLE+dHOJaRI2CdWBzq1y0u3tAjCK1Syhh5F3Ng=; fh=0WN+7FgGJ7IsVO00gxCmYoCudk4DoD13apzwXisvbhs=; b=w4Q3tgWZskbRf9ZYZlxj9Ye+BKTqn4zyEARFEsz789wEWQ/JPf/A2KTtX4rIOJvwkK RRTBgwZQIOb9Vzbc0g26xMmyTOvMq3c0NFO7ewVvtf5p5evtCCUdCPLMBdho0BJyrvW2 IJ3LJFl9APKFSicciTtyWclpTPJxszqlswaDCV21S4d+7FCO0HQMTL/DG1Gj0mkaYXbR 4H6f4LFjum2ErbPOupK4GQpg9s6VZfRH8hnPm01Q/heZqu7qQbRC3OujYGScsJjectw3 RVvMOkL8ayfh23UtGbnfSSbRYwIrIGoL5dUTp8dcJBfiWtCYxhazzjqmgZFeCIxPUfUE Vgsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=Wl2lmBsW; arc=pass (i=1 spf=pass spfdomain=hpe.com dkim=pass dkdomain=hpe.com dmarc=pass fromdomain=hpe.com); spf=pass (google.com: domain of linux-kernel+bounces-213630-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213630-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hpe.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56e7ef81si82389666b.982.2024.06.13.09.18.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 09:18:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213630-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=Wl2lmBsW; arc=pass (i=1 spf=pass spfdomain=hpe.com dkim=pass dkdomain=hpe.com dmarc=pass fromdomain=hpe.com); spf=pass (google.com: domain of linux-kernel+bounces-213630-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213630-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hpe.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 am.mirrors.kernel.org (Postfix) with ESMTPS id D16F61F216EB for ; Thu, 13 Jun 2024 16:18:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DEEF145B3F; Thu, 13 Jun 2024 16:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hpe.com header.i=@hpe.com header.b="Wl2lmBsW" Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) (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 3205912F386 for ; Thu, 13 Jun 2024 16:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.147.86 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718295492; cv=none; b=dcTtuHXFxz6JfJ6WQU7/Pu569pVjWEoVthFcWP/V6dQe+Q3e59d4gI/RrFBEbfD79BcS3G2Q8TsF/ASu8+SdNXA/4RXBBc6EHDITcdG+GQ5mdsOGJo6ZXEzLBNXciIc3/9o5FDNSWRNhk6I84mzpcsR27VOSOY+mgwio/Ld9+Gk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718295492; c=relaxed/simple; bh=iBM4pmUdvLp0wJE+5dcbsfYPkB5DnRjbzC1GW3wslw4=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=CHc+tMTQJu2RlgFq0ufobpZYyxapp1bR9p95QBgObjT/zCCXWL+H4vn0T5CKPPnWHleNU8PB36N5IsV2e0U3BMNnPuyMWq7Ys0T63GG0JggIINWaIYhCg2VqE1ePGQlsr6ajOvCw5Qh169vLeLjoKRHdAFhVkfRXQdPWLhMgPUo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hpe.com; spf=pass smtp.mailfrom=hpe.com; dkim=pass (2048-bit key) header.d=hpe.com header.i=@hpe.com header.b=Wl2lmBsW; arc=none smtp.client-ip=148.163.147.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hpe.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hpe.com Received: from pps.filterd (m0148663.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 45DFWE6Y015627; Thu, 13 Jun 2024 16:16:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=cc : content-type : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pps0720; bh=Y3rT6DLE+dHOJaRI2CdWBzq1y0u3tAjCK1Syhh5F3Ng=; b=Wl2lmBsWmxvHwWIsAIoowr2ZAJCWzDS1SnpWYBC1OLSCD1QklXjJx1XCWlHv46NJXtTL Jv1Le2U+sM3MnlhnzX8cfSCiwrIMcX/g2fDZnINYwzM5KEQWXVmmkTsUblttQuXikOKs egpD2kZf/4pDrdGEGztu3wmQNWFeAEzNJYhpjTUkkQw3kWBZRTOLXvOhAhhr5q603UjA n5SsgL7wy6TR+z4ehrsDJ6YKBsYUbmjtDfLaQ4reUQF6ElNbsWWuGqrs05Mjus5U3UaH 6CY4u5jNmxDNWp8p7pka0ilYRqCh9AaQ31i/9A/CjKpcJryf22b3EErj9PfIcu4pAoW3 QQ== Received: from p1lg14879.it.hpe.com ([16.230.97.200]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3yr1yxha3y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 16:16:48 +0000 Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id C80C2147AA; Thu, 13 Jun 2024 16:16:44 +0000 (UTC) Received: from swahl-home.5wahls.com (unknown [16.231.227.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTPS id C7DC6809D02; Thu, 13 Jun 2024 16:16:38 +0000 (UTC) Date: Thu, 13 Jun 2024 11:16:36 -0500 From: Steve Wahl To: Borislav Petkov Cc: Steve Wahl , Ashish Kalra , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Pavin Joseph , Eric Hagberg , Simon Horman , Eric Biederman , Dave Young , Sarah Brofeldt , Russ Anderson , Dimitri Sivanich , Hou Wenlong , Andrew Morton , Baoquan He , Yuntao Wang , Bjorn Helgaas , Joerg Roedel , Michael Roth Subject: Re: [PATCH 0/3] Resolve problems with kexec identity mapping Message-ID: References: <20240520183633.1457687-1-steve.wahl@hpe.com> <20240613152826.GKZmsQGnO3OthLH3Vu@fat_crate.local> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240613152826.GKZmsQGnO3OthLH3Vu@fat_crate.local> X-Proofpoint-GUID: iau639vRooRc3lIOREaNeZ5DNksGBcka X-Proofpoint-ORIG-GUID: iau639vRooRc3lIOREaNeZ5DNksGBcka X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-13_09,2024-06-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 adultscore=0 malwarescore=0 impostorscore=0 phishscore=0 clxscore=1011 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406130115 On Thu, Jun 13, 2024 at 05:28:56PM +0200, Borislav Petkov wrote: Thank you for at least saying something on this! > On Mon, May 20, 2024 at 01:36:30PM -0500, Steve Wahl wrote: > > Although there was a previous fix to avoid early kernel access to the > > EFI config table on Intel systems, the problem can still exist on AMD > > systems that support SEV (Secure Encrypted Virtualization). The > > command line option "nogbpages" brings this bug to the surface. And > > this is what caused the regression with my earlier patch that > > attempted to reduce the use of gbpages. This patch series fixes that > > problem and restores my earlier patch. > > > > The following 2 commits caused the EFI config table, and the CC_BLOB > > entry in that table, to be accessed when enabling SEV at kernel > > startup. > > > > commit ec1c66af3a30 ("x86/compressed/64: Detect/setup SEV/SME features > > earlier during boot") > > commit c01fce9cef84 ("x86/compressed: Add SEV-SNP feature > > detection/setup") > > > > These accesses happen before the new kernel establishes its own > > identity map, and before establishing a routine to handle page faults. > > But the areas referenced are not explicitly added to the kexec > > identity map. > > > > This goes unnoticed when these areas happen to be placed close enough > > to others areas that are explicitly added to the identity map, but > > that is not always the case. > > > > Under certain conditions, for example Intel Atom processors that don't > > support 1GB pages, it was found that these areas don't end up mapped, > > and the SEV initialization code causes an unrecoverable page fault, > > and the kexec fails. > > What does Intel Atom have to do with SEV?! The Atom was the prominent example of a platform that the code introduced for SEV broke. Unfortunately, the fix currently implemented leaves things still broken for actual AMD SEV capable processors when nogbpages is used, and this problem is the reason for the apparent regression when my reduce-use-of-gbpages patch was accepted (later removed). Tau Liu's original patch fixed this problem, but was not accepted. The patch that was accepted does not fix this. > > Tau Liu had offered a patch to put the config table into the kexec > > identity map to avoid this problem: > > > > https://lore.kernel.org/all/20230601072043.24439-1-ltao@redhat.com/ > > > > But the community chose instead to avoid referencing this memory on > > non-AMD systems where the problem was reported. > > > > commit bee6cf1a80b5 ("x86/sev: Do not try to parse for the CC blob > > on non-AMD hardware") > > > > I later wanted to make a different change to kexec identity map > > creation, and had this patch accepted: > > > > commit d794734c9bbf ("x86/mm/ident_map: Use gbpages only where full GB page should be mapped.") > > > > but it quickly needed to be reverted because of problems on AMD systems. > > > > The reported regression problems on AMD systems were due to the above > > mentioned references to the EFI config table. In fact, on the same > > systems, the "nogbpages" command line option breaks kexec as well. > > > > So I resubmit Tau Liu's original patch that maps the EFI config > > table, add an additional patch by me that ensures that the CC blob is > > also mapped (if present), and also resubmit my earlier patch to use > > gpbages only when a full GB of space is requested to be mapped. > > > > I do not advocate for removing the earlier, non-AMD fix. With kexec, > > two different kernel versions can be in play, and the earlier fix > > still covers non-AMD systems when the kexec'd-from kernel doesn't have > > these patches applied. > > > > All three of the people who reported regression with my earlier patch > > have retested with this patch series and found it to work where my > > single patch previously did not. With current kernels, all fail to > > kexec when "nogbpages" is on the command line, but all succeed with > > "nogbpages" after the series is applied. > > > > Tao Liu (1): > > x86/kexec: Add EFI config table identity mapping for kexec kernel > > > > Steve Wahl (2): > > x86/kexec: Add EFI Confidential Computing blob to kexec identity > > mapping. > > x86/mm/ident_map: Use gbpages only where full GB page should be > > mapped. > > > > arch/x86/kernel/machine_kexec_64.c | 82 ++++++++++++++++++++++++++++-- > > arch/x86/mm/ident_map.c | 23 +++++++-- > > 2 files changed, 95 insertions(+), 10 deletions(-) > > Anyway, + Ashish who's been dealing with SNP kexec. We have identified one EFI > issue so far: > > https://lore.kernel.org/r/20240612135638.298882-2-ardb%2Bgit@google.com > > You could give it a try and report back. I will look at it, but a cursory inspection doesn't show anything that affects what I'm talking about here. Thanks! --> Steve -- Steve Wahl, Hewlett Packard Enterprise