Received: by 10.192.165.156 with SMTP id m28csp299177imm; Sun, 15 Apr 2018 23:36:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Y6BsOvb540fXkL7kALlogHKPSz5yGEWA4JTwzKYdtr4Qx4ZS8TyAMoUipajRpxiwxR1sC X-Received: by 10.101.67.76 with SMTP id k12mr1190859pgq.109.1523860618342; Sun, 15 Apr 2018 23:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523860618; cv=none; d=google.com; s=arc-20160816; b=hNHFS/2C/WrUwIphgk7CMCDz1qFxF4yYvVC6pzS0OYaKIu7qtPXttO5AbcLicOtj6T lEfnQxm4x4gFyoQRsBZ9ZFIpJD4mE9Jaw74dOn/kq5G/k4+MHglTNY1MPrdkgyTWOao+ d+tXdFpcOF4Wdr+U+P05VHQX5pMEgpGraU9E9nsFOttyENczmbqPwvj9ttz6OpkcAvCB VLtb9RTqVbaQPqWCodATobBIujFfxI8MjaC188923kd76X5MPP8rIyR/au2RFBB5K8fp wAT15FkDIOF/PCjbQWQcStYM35K/xkTrCJEo6ifOv42Vs6Kn/LddfqDN7yFfoRlw8Cez uk8g== 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=i5sidaAdFNvlv7v7j1gXjqAG4H3MePTU6hE5v196q0Y=; b=J0kzP4fEEiiv3aVGMCDMGpg3oLq1I3lipuG5qaBPSPAj4P1XMG5x6rorzdt1x35rw4 JqM6NdNeAv1//8IPECfmZ8QVS5JYV0Uo2yxtzWGJZdihBPu/MCf3tU69/CQbTPWTgtQd ch+m2TKlQJFvvtCHPimLBNxUcTgO+3rYvCuoCNrXoAYvExZUXZFEKoNP/GTLERJYdT/H whQioQmERorePm+Ol7nhLFRUWXHX2C3hd3fVNdz8M5mWY1xJB0k4NEHLuOvjilafZpRA B6E7n+l9EOT1o75QaMg010QYAc+jTlGl8AXYwJkOD3A9jj0DoTiKsH5Cno32qRMxP3NL Z0Bw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6-v6si3372990plo.534.2018.04.15.23.36.43; Sun, 15 Apr 2018 23:36:58 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751884AbeDPGe1 (ORCPT + 99 others); Mon, 16 Apr 2018 02:34:27 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:45323 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750707AbeDPGe0 (ORCPT ); Mon, 16 Apr 2018 02:34:26 -0400 Received: from linux-l9pv.suse (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Mon, 16 Apr 2018 08:34:20 +0200 Date: Mon, 16 Apr 2018 14:34:14 +0800 From: joeyli To: Dave Young Cc: "Lee, Chun-Yi" , Ard Biesheuvel , linux-efi@vger.kernel.org, Takashi Iwai , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Randy Wright , Ingo Molnar , akpm@linux-foundation.org, Vivek Goyal Subject: Re: [PATCH] efi: Fix the size not consistent issue when unmapping memory map Message-ID: <20180416063414.GG16023@linux-l9pv.suse> References: <20180413062716.8040-1-jlee@suse.com> <20180416025734.GA26685@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180416025734.GA26685@dhcp-128-65.nay.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 16, 2018 at 10:57:34AM +0800, Dave Young wrote: > 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. > Thanks! > 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. > Takashi has another patch as you said. Finally I sent this patch because it's smaller. Thanks a lot! Joey Lee