Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp25964lqr; Tue, 4 Jun 2024 19:28:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUROC3ZHkgiRAKhEuN50o0i2bZQp+W2zybMrr9qqs7cvIehjgsqrO0MymWwnz4EVuOJTKZ4MI9vZnfjiV6pvv0XLiO8rLRJfOeTwAACGA== X-Google-Smtp-Source: AGHT+IGkCZLHnPSEv7fgmRhsc5XmMad6kHFYAJA4Gpsg+vH8c2h4DQqNsPlgmyngktA0lotutVxG X-Received: by 2002:ac8:590d:0:b0:43f:f13e:7e79 with SMTP id d75a77b69052e-4402b617b90mr12382471cf.16.1717554493350; Tue, 04 Jun 2024 19:28:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717554493; cv=pass; d=google.com; s=arc-20160816; b=YWEL7i9crz0KbzSD7Aq/UdUJgPGNxOH1HfwYdLGwirMBG3miznebfMPBX8QkmjrK1U 7cIDL3/cZLBWcwnPqHktjgRej41meBlZE6b/6donx/O+hEMFg+g999k7epctrO765046 BTlHg0yqVS9UeI2ugfnhqPda3y8pj5Bj6SfMaOBbJTR45FFyAKT6reBQDYcBQPIHWKEV d3q601sqNbPp9Dc1qQumFAyW4jYOCi0ErdwBGOVfD9XEvCHxBdEIcvu165dcu40KGvhd 9sfzBGOEXDb9PE/kVOf5QqpEfSaKcmVtxDL/W09iabAGDq9r5z2pEoZGv05HDt9GmLoA XkwA== 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=lOA1MCZJzoxt6GCkNRp4+h7p2tW8g2r7m2il3+oTwSQ=; fh=8VNd/pUFyaGK+ts7u1E+fbDyfSjMZiYBQhzYHgP+80I=; b=yqEM1kxRq+r4hP3y9j+ipPGyEewRgGfg6rDStDtO77ETc5sMo7Nn00mAPo9qd+6mHg UVdVI4VPrJbKenWW6m7DET3FJIoqn5FI+TOCnSTLhrTTMMVt9pcsM43pnqiVGpNtFITV bqWoy22JWZZPqIrLzuDaIKdrADkxA+MJ6Q1qnlvvUOTU4l5LTWS+ldhQA+PY745TeZ0+ Sf08g9H2O1rtDZ6Etb2So+M1tYhmMovhUX3j4DL0/OrWa4w2MHHWnhJsNgpl8PNCmTAB 6o7xGFvyrXnZi0gXgfGwGkHwFOP4ZovHzSoHi5FrirRBKyd7PDqzhvWfETT8u5wcITQm rVCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SveVeORI; 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-201687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201687-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43ff259c818si106266501cf.611.2024.06.04.19.28.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 19:28:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SveVeORI; 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-201687-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201687-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 006CB1C22B81 for ; Wed, 5 Jun 2024 02:28:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5122360B96; Wed, 5 Jun 2024 02:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SveVeORI" 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 8D66E17C79 for ; Wed, 5 Jun 2024 02:28:04 +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=1717554486; cv=none; b=DSse8pnx+SpTmBM1FDKPDCIAfExuSrclATl6kVSBnAdeiPMjZB3+JVXfDx/fDlumgBPSKk4ZBfEIjylFLmQ9X9bk2xjtDmnbESp9pwEhh/wN4F4/0ra3gURtN8NBRThmMH5m9KB/a+gpOOZK+bvFfEUzrDmdbM4nao/2BbNoBBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717554486; c=relaxed/simple; bh=R0Q+d0KNdIo4/1UDPQUotxY23fZjm0IKelJnw2zPQ2k=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BnHIhX3mqdYPvFU6+UPDshF84EGHsJ5Pz4We4z+ZkyuQd8dF3xAEPef1Z8x5FQzwf8fpXqEvph1S4sa+i/nFvubf1GBAlCEGDYfORb6KIIMfHzbcrqibNNjWWp5vxmLOlVlff3K87Z+td4jbaVx3RPHg91j+6k9vQe1Zxf7QV9U= 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=SveVeORI; 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=1717554483; 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=lOA1MCZJzoxt6GCkNRp4+h7p2tW8g2r7m2il3+oTwSQ=; b=SveVeORIIC+GTcMK2S+5KhO7gCOruTog1RuBVUD0rl2wpmR4/VXyM0F3HOxvIs4vk3YoUi KL0IpKm6Opu4Xi+IUrd8t5/JGwHjIbVMmUNJbtaiFlLtW2ic8d43vYS6qaRRJAarYtIlG1 tY00mPUnxJyHQwzhoXQfFPrDqFprWAY= Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-365-foaYi1qzNm-Xm3UWhLBsgg-1; Tue, 04 Jun 2024 22:28:01 -0400 X-MC-Unique: foaYi1qzNm-Xm3UWhLBsgg-1 Received: by mail-il1-f198.google.com with SMTP id e9e14a558f8ab-374ae94e856so2181825ab.0 for ; Tue, 04 Jun 2024 19:28:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717554481; x=1718159281; 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=lOA1MCZJzoxt6GCkNRp4+h7p2tW8g2r7m2il3+oTwSQ=; b=Ds1Yh6jdKAeUmq6QZEGMzmPvLvgmifEw3dMSM0aPYCDPrmO3Ot1wrgd3bIWQulzAvb KBDSL9VFs/oGuOY072529OUr6KAek0DOJd0MyLRN01mYNG6D4TsbZZAUE3dhXILNtmvt q/P9yg9M7S9zvIDFNstPDWcmkt0DHYFdU19zwIHpkaJ997ERklEzBC/d5vA/q2+9HEaa pdYhzq2C6zdxFENaV+KB5Lj1gxGUOixpw9rToURY8x2nIcGWDea8BzegQEd06nc4wjU9 7EOabsLVjh5avr2dYp5nFhOorfUwfHhn8Gi6afLyyQ0OXOYkTpASvr+sOCAIlDCggZbp Ei+Q== X-Forwarded-Encrypted: i=1; AJvYcCV1qB1C8LtRQygNU9eEnJq1xeMWuFI6bTPKcGs7ywYjRf+dpMQTLFRMjzgXqvtKi+/HBLHssx1lnIafe+KB3L+qe9/oTUJl76cSiWPA X-Gm-Message-State: AOJu0YwyhRMaPqmZeAF+aRcsLCe1Xnv7lGS2cmy7oGjwQqELyveElriB sUYlbIHktpWUbaoKHCzbksA613Vj8ewY1s7pYFfEZ7UDqIH6dQKwaFfgnyhk6gqrTS7DMRdUV+Z hdHps50bAXlcft5xc0p3gm1odH/AcJmjorijg3zSjR68hRdmbocP3lT436z5jlL9BOeWIUENvCT FQsl79bBxylTeLls9XhIFmkTPixKdD381JFQT6 X-Received: by 2002:a05:6e02:2186:b0:374:9916:67 with SMTP id e9e14a558f8ab-374b1f581b2mr11523755ab.3.1717554480535; Tue, 04 Jun 2024 19:28:00 -0700 (PDT) X-Received: by 2002:a05:6e02:2186:b0:374:9916:67 with SMTP id e9e14a558f8ab-374b1f581b2mr11523595ab.3.1717554480186; Tue, 04 Jun 2024 19:28:00 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240603085654.GBZl2FVjPd-gagt-UA@fat_crate.local> <8e3dfc15-f609-4839-85c7-1cc8cefd7acc@amd.com> <1ef36309-8d7f-447b-a54a-3cdafeccca64@amd.com> <20240603144639.GCZl3XTwmFHwi-KUZW@fat_crate.local> <7eb4ca99-679c-4f23-9562-a39b966c28a0@amd.com> <20240603165747.GGZl32C9yrmXJ4nhPT@fat_crate.local> <2343889c-887a-49ce-86df-343737d70d37@amd.com> <20240603171231.GJZl35f-BHvU2Pk3lb@fat_crate.local> <41e085b8-2b45-40ab-9a6f-f4ad975a0b06@amd.com> In-Reply-To: <41e085b8-2b45-40ab-9a6f-f4ad975a0b06@amd.com> From: Dave Young Date: Wed, 5 Jun 2024 10:28:18 +0800 Message-ID: Subject: Re: [PATCH v7 1/3] efi/x86: Fix EFI memory map corruption with kexec To: "Kalra, Ashish" Cc: Borislav Petkov , Mike Rapoport , tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, rafael@kernel.org, hpa@zytor.com, peterz@infradead.org, adrian.hunter@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, jun.nakajima@intel.com, rick.p.edgecombe@intel.com, thomas.lendacky@amd.com, michael.roth@amd.com, seanjc@google.com, kai.huang@intel.com, bhe@redhat.com, kirill.shutemov@linux.intel.com, bdas@redhat.com, vkuznets@redhat.com, dionnaglaze@google.com, anisinha@redhat.com, jroedel@suse.de, ardb@kernel.org, kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, dan.j.williams@intel.com Content-Type: text/plain; charset="UTF-8" On Wed, 5 Jun 2024 at 10:09, Kalra, Ashish wrote: > > Hello Dave, > > On 6/4/2024 8:58 PM, Dave Young wrote: > > On Wed, 5 Jun 2024 at 09:52, Dave Young wrote: > >>>> ... > >>>> if (efi.memmap.flags & (EFI_MEMMAP_MEMBLOCK | EFI_MEMMAP_SLAB)) { > >>>> __efi_memmap_free(efi.memmap.phys_map, > >>>> efi.memmap.desc_size * efi.memmap.nr_map, efi.memmap.flags); > >>>> } > >>> From your debugging the memmap should not be freed. This piece of > >>> code was added in below commit, added Dan Williams in cc list: > >>> commit f0ef6523475f18ccd213e22ee593dfd131a2c5ea > >>> Author: Dan Williams > >>> Date: Mon Jan 13 18:22:44 2020 +0100 > >>> > >>> efi: Fix efi_memmap_alloc() leaks > >>> > >>> With efi_fake_memmap() and efi_arch_mem_reserve() the efi table may be > >>> updated and replaced multiple times. When that happens a previous > >>> dynamically allocated efi memory map can be garbage collected. Use the > >>> new EFI_MEMMAP_{SLAB,MEMBLOCK} flags to detect when a dynamically > >>> allocated memory map is being replaced. > >>> > >> Dan, probably those regions should be freed only for "fake" memmap? > > Ashish, can you comment out the __efi_memmap_free see if it works for > > you just confirm about the behavior. > > Yes, i have already tried and tested that, if i avoid __efi_memmap_free(), then i don't see this memory map corruption. Ok, thanks! I think the right way is creating two patches, one to remove the __efi_memmap_free, another is skip efi_arch_mem_reserve when the EFI_MEMORY_RUNTIME bit was set already. But the first one should be the fix for the root cause. efi fake mem is only for debugging purposes, the "memleak" mentioned in commit 0f96a99dab36 should be solved in another way if needed (are they really leaked? or just not useful anymore) Anyway this is my opinion, please wait for x86 and efi reviewer's inputs. > > Thanks, Ashish >