Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp732610lqp; Wed, 22 May 2024 19:54:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUM3L8V2mXgkPfPpkgeboCtSSUBGQLfH63rPfJd90uVG//MXPaUjHObFIRXSkE6jmzGPhz3OrKw1oIZeHjzXB5zZMwRN187Kx96ih0sIQ== X-Google-Smtp-Source: AGHT+IGdO6ObZHK0kVXDQD1rAFFAKunEsNWY2n1nH8mVjZYKO7Y2FAohPqayfw/X0sji+P6oVhoF X-Received: by 2002:a50:9ea9:0:b0:572:2f0d:f4cb with SMTP id 4fb4d7f45d1cf-578329fd443mr2089697a12.1.1716432864796; Wed, 22 May 2024 19:54:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716432864; cv=pass; d=google.com; s=arc-20160816; b=H56vPXii0iFTlqRubJgcyEeLjjatgNFIujABBg5puAdNmSn2QosHM4P87UdqBxRrYi F8fS7TNM/5cNlZJEWRT2CNehHh7HnFzJNk05McuhLtpMGXMzV1wyeART9c7vmZ9Rt/Rp e9xm11jvfVg++XGw+NK53YvSbKkWWCHhxKjUQH13KmDfrKILygdaTBJAR/S8OrMJDCT3 Ea3DUlsqQVMYp9rsPKdexD/a6zZPGKJ4PQVjZfXxhZtdcwf1kJr75+sDzC1M3KjD8za6 lPUi1f813PNnvkZ5+weAw6EqS56nXqSEkoqQ2bSRz91xR/JyE9UkvRU/r2Vrf2cSahc7 +Rdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=u7PAynGSneULEGsZEeUTDx10vqiJthWdZNRrBnIUivM=; fh=hkWB+joaqwLKWRYPVqIhLlMYqDHOwCtINjUAtL5dPv8=; b=BWz2WG0ih86V+QD8SGssrAxMDYrUVrAMwrV1ScYuiRe3Qu7FQu2ta0EM5oCuBZXLwl NkyPHoNt2QNas7cPvmEmuy5uqsDJbhiCZAjfo9B7VFvINhMmFbHQhzzlqsPqnzQNYYJT XW2g/DHT73Ln4LeshI9lurtTXgCz0j7MB8BvXzSKagR/obFWQ/27JB/r8ecJYxe/7V0k M/qc/Rs7oKAkWkca7eVwvWB9yEOkA9jUKrX/u22kr89R4Jb3/soyYSfw0MyXQMDu80eM 7z6FygwuRFcK4yCL1P7wTliqo5GlTZw3qkuZHeW+ulDZmyPSrY7lYfja4hJXAjL83tkw XXcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eNjISuj9; 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-186929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733bec19dbsi15515202a12.176.2024.05.22.19.54.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 19:54:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eNjISuj9; 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-186929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186929-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3220E1F21934 for ; Thu, 23 May 2024 02:54:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF45B13A879; Thu, 23 May 2024 02:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eNjISuj9" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 6F0781852 for ; Thu, 23 May 2024 02:54:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716432858; cv=none; b=TEgyqNMo+X3bC5HTcOmB6NFhizAwcbHvgJP7x7CT+TcOXQyP8g3SVxWte0DA4XL99UhWfzgz9B0yS45mrY7VxCyIdowZy3FnubyK4d84f0WBNRe+0jKROFmPp0S5eGgfsAXLwNAH9VYH7TjOv0SIEnLtooY2WcqwbvUjMJETKX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716432858; c=relaxed/simple; bh=KIPFXtgeVsYCx+TPE+Omq9vOJHTDlUHEkkIB6RiQCJ8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=T26a6QB+joZHeMiHqXOQOWcio6Z5dfuDW8Hs1IOdJJgrYbTg6pwliHQmmP+wyWU4WJr43vIYBg69ftrYxWqyvRUqB3Sl8h9aty+4cinB5DRjetFtrAr05WiisAJcSxb7UnLb9ZIe5WAb5tDiAiJOwzPthJ37ZOuSB8LbtSCX++E= 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=eNjISuj9; arc=none smtp.client-ip=170.10.133.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=1716432855; 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: in-reply-to:in-reply-to:references:references; bh=u7PAynGSneULEGsZEeUTDx10vqiJthWdZNRrBnIUivM=; b=eNjISuj9FmFbmLR00qRgQ/RzEJgw4r2Qt7Tcw7goUgAK5Dno6Yekhi3YROn2zACpE5P8Z2 x3Y1hyDv4PEMTmZ4vbQK712hCBqDNXP8okqLBKuWIyrxcU6x+khuEZKp9VK0cbG6zygk49 LPwmyDQGFdkyqmE3qt4Yb5bgrEglQsM= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-78-sEbJAKIZOseagIPaK37I7Q-1; Wed, 22 May 2024 22:54:13 -0400 X-MC-Unique: sEbJAKIZOseagIPaK37I7Q-1 Received: by mail-il1-f199.google.com with SMTP id e9e14a558f8ab-36c854ced78so4011325ab.3 for ; Wed, 22 May 2024 19:54:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716432853; x=1717037653; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u7PAynGSneULEGsZEeUTDx10vqiJthWdZNRrBnIUivM=; b=Nktsy5JGWSb4UgeqeoYg/5yvmKtwxG4R4r7w/zGnlHXbrqDJ+GcVAC76hMEzC7INXO ZgAc+dLACQFO89dbEpU3sD1injIH8/aOWG9ig1FgAWEF/sfHVIduxOyoMg9aYgIJaGuN X/GSvxZudNNHi97zlbmvVpisc8pcKWcvTK10akpG2c/rqG5eo7slofow3C//qaZDMbAg wQA99A1H203RtnbzepLbgAJdZF2IwSBiTkkr748qVOWauU4IAKVG/+4RSkL/yGBbOWLJ ujFz2t1yZNeC1u8RDIVpGt8iDDy67GAp+2I5dOO8ja/2WgTWqEWU7817OtWCGnHUjAvr kkwA== X-Forwarded-Encrypted: i=1; AJvYcCWC2jOMMNJmjubDGJJJEwCZOIfoxKwrcnR+HBjJ5aLWnpcxd8VXYg/V79BSE9rM2rAOGeJ+/KTnh4HmMnuXGJjCyg0VhpRQUQWsb/IL X-Gm-Message-State: AOJu0YyZ7DOE3HFz42/bcjo+M4qtlLoHTtSnwshgdRnSs2yRfMWdSBjo GT0tA3ynAoFrDgJs7ZHDQz9GaYJkVGWaiA+46NT5VuHW4LV0qdYmE/q4VIdVdqUaSPtsd19qeNj H01pccyjFccntsKkAzSRUh/cJFE2HmY2AWjmh9suuzEfUJUCqTSDdplvbFqHr6ZOnoi/aL0KUFA mJPIBrk9JWYCTamQ2EKX1E/AT1v2YFBtFJq0Yu X-Received: by 2002:a05:6e02:1447:b0:36c:3856:4386 with SMTP id e9e14a558f8ab-371f92ff411mr48838645ab.3.1716432852967; Wed, 22 May 2024 19:54:12 -0700 (PDT) X-Received: by 2002:a05:6e02:1447:b0:36c:3856:4386 with SMTP id e9e14a558f8ab-371f92ff411mr48838235ab.3.1716432852467; Wed, 22 May 2024 19:54:12 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240520183633.1457687-1-steve.wahl@hpe.com> In-Reply-To: From: Dave Young Date: Thu, 23 May 2024 10:54:33 +0800 Message-ID: Subject: Re: [PATCH 0/3] Resolve problems with kexec identity mapping To: Steve Wahl Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Pavin Joseph , Eric Hagberg , Simon Horman , Eric Biederman , Sarah Brofeldt , Russ Anderson , Dimitri Sivanich , Hou Wenlong , Andrew Morton , Baoquan He , Yuntao Wang , Bjorn Helgaas , Joerg Roedel , Michael Roth , Tao Liu , kexec@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Cc kexec list as well. On Thu, 23 May 2024 at 10:52, Dave Young wrote: > > Add Tao in the cc list. > > On Tue, 21 May 2024 at 02:37, 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. > > > > 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(-) > > > > -- > > 2.26.2 > >