Received: by 10.192.165.156 with SMTP id m28csp166515imm; Sun, 15 Apr 2018 19:59:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx48pYc1JPUgaQDOEeG3QcEFzeidYg3qikE6oeEuZs1z+FTAW2INUDHB8shVcRga+nqYcFqUS X-Received: by 2002:a17:902:da4:: with SMTP id 33-v6mr13661621plv.52.1523847592096; Sun, 15 Apr 2018 19:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523847592; cv=none; d=google.com; s=arc-20160816; b=fiaWHa1jLZz8RttvhJMgmzh5E+e30pJv/a+Ae8xqIKUeIyxN2L1swbGPdFhba/XPiQ iiuKukOLd3L/X8Dj+doPs1jF15U4KY8Mo3KjSC5RTs8qu5o/wlzQ6E/c8q+4yd7fM8dn bmUsssQcUyAROTKq8pbtF8u3ABKwe9vdCr4H6tJzYZSGV+b3ZBGiRr43SyLAcvNm5cnZ ReIz2EeadCIRfodZRLAmjZhXdJBjolHu/buZRqMX7tg10rSOWCfkR4m7JcyQuH2dmrZ6 DlCWuhPNFxuspsyqiVMJ3wBvgIr2DRtHgR7T3eQVtOuQFhnWISfwjtMmPB/hL3jJ63eE X5pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=ckbQI8NyPLlk49+26jxEeIW+4uCaZ2E1UEPOtLMoHiU=; b=vnVZiwxQ0npjBgE9y8YfkKRMJVnz9EN2Drg6OBuANXqNONK8fYbNZ0zYkqWBQiaJ41 3D7S4Tj/yEATS3bSSIFyP8vZ4tWgmWKIHsJFGK3PyGZG5kiCoEWRgFIJUEqw9xO05upW v33ilSSZO1Xud5uYhqA1ClmddIuGfSyE6W8rPwOgZJTlhfXRc/pfADv+OowhBYrzYvSv 8qC80e2871EHTVzvR3NlOcV5muW+vQTWKyGFFi41kXrUahoU9DNuho8FEY/GxNtYEjmT YtOYuKZVqt2VsKqrA9ye5cgH24wyJTrxSGLvxW8sj1/5p6yDgdHenZsJBw3ZiNVQJ8Hc OLng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23si30823pfi.282.2018.04.15.19.59.26; Sun, 15 Apr 2018 19:59:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752788AbeDPC5o (ORCPT + 99 others); Sun, 15 Apr 2018 22:57:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34660 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751774AbeDPC5n (ORCPT ); Sun, 15 Apr 2018 22:57:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8644D4068024; Mon, 16 Apr 2018 02:57:42 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-42.pek2.redhat.com [10.72.12.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C6F2215CDCB; Mon, 16 Apr 2018 02:57:37 +0000 (UTC) Date: Mon, 16 Apr 2018 10:57:34 +0800 From: Dave Young To: "Lee, Chun-Yi" Cc: Ard Biesheuvel , linux-efi@vger.kernel.org, Takashi Iwai , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Randy Wright , "Lee, Chun-Yi" , Ingo Molnar , akpm@linux-foundation.org, Vivek Goyal Subject: Re: [PATCH] efi: Fix the size not consistent issue when unmapping memory map Message-ID: <20180416025734.GA26685@dhcp-128-65.nay.redhat.com> References: <20180413062716.8040-1-jlee@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180413062716.8040-1-jlee@suse.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 16 Apr 2018 02:57:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 16 Apr 2018 02:57:42 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dyoung@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/13/18 at 02:27pm, Lee, Chun-Yi wrote: > When using kdump, SOMETIMES the "size not consistent" warning message > shows up when the crash kernel boots with early_ioremap_debug parameter: > > WARNING: CPU: 0 PID: 0 at ../mm/early_ioremap.c:182 early_iounmap+0x4f/0x12c() > early_iounmap(ffffffffff200180, 00000118) [0] size not consistent 00000120 > > The root cause is that the unmapping size of memory map doesn't > match with the original size when mapping: > > in __efi_memmap_init() > map.map = early_memremap(phys_map, data->size); > > in efi_memmap_unmap() > size = efi.memmap.desc_size * efi.memmap.nr_map; > early_memunmap(efi.memmap.map, size); > > But the efi.memmap.nr_map is from __efi_memmap_init(). The remainder > of size was discarded when calculating the nr_map: > map.nr_map = data->size / data->desc_size; > > When the original size of memory map region does not equal to the > result of multiplication. The "size not consistent" warning > will be triggered. > > This issue sometimes was hit by kdump because kexec set the efi map > size to align with 16 when loading crash kernel image: > > in bzImage64_load() > efi_map_sz = efi_get_runtime_map_size(); > efi_map_sz = ALIGN(efi_map_sz, 16); > > This patch changes the logic in the unmapping function. Using the > end address of map to calcuate original size. > > Thank Randy Wright for his report and testing. And also thank > Takashi Iwai for his help to trace issue. Good catch. The kexec code need to be fixed to use a separate buffer so avoid the alignment like what kexec-tools did. I can submit a fix for that. But this issue could be a potential issue even if kexec get fixed so it looks worth a fix in efi code as well. How about mapping only nr_maps *desc_size in __efi_memmap_init? It looks easier to understand. > > Cc: Ard Biesheuvel > Cc: Randy Wright > Cc: Takashi Iwai > Cc: Vivek Goyal > Cc: Ingo Molnar > Signed-off-by: "Lee, Chun-Yi" > --- > drivers/firmware/efi/memmap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c > index 5fc7052..1f592d8 100644 > --- a/drivers/firmware/efi/memmap.c > +++ b/drivers/firmware/efi/memmap.c > @@ -121,7 +121,7 @@ void __init efi_memmap_unmap(void) > if (!efi.memmap.late) { > unsigned long size; > > - size = efi.memmap.desc_size * efi.memmap.nr_map; > + size = efi.memmap.map_end - efi.memmap.map; > early_memunmap(efi.memmap.map, size); > } else { > memunmap(efi.memmap.map); > -- > 2.10.2 > > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec Thanks Dave