Received: by 10.192.165.156 with SMTP id m28csp344033imm; Thu, 12 Apr 2018 23:38:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Dku/eACQtHKgPADG89P6Msj9yPrJeR75gSQgZ+bc/USdDZPYNGtrAzr3tmkqMgO6O6Wxr X-Received: by 10.99.128.73 with SMTP id j70mr3135440pgd.12.1523601481557; Thu, 12 Apr 2018 23:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523601481; cv=none; d=google.com; s=arc-20160816; b=vVol1s6ZfObTfZGYYinnB8f0H9l5YTrn6WxEMr6u4BzQsVihpSYgzDdd5qEGY/gBuc XGbE3tPSuvs5si9mJCs4ELYLxOGeouFwDFDQLfEzXUQlmGhpidY55R4GRQ52UZBWJtDG OwxwiVOSkpxE7GyK1wlWIa2XRD9g4VsGn1qPCukvTJ2JOULx7KJ0ByL3PcNyst0Vz/M1 nEvIAnXrSia2a1au8AUJZb1v/ScEDsjuSgiTuZTs2fc3DDNCIfjPbL1HgQoNhUYR6D1x TEHTwCQwxmTxB2NEfnR/MJXyFO37J15R6n8ranvCU/ovdO4jUHYluBPw973nGPulo8sG aDMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=d+JtFWeLEoKw4HatQFd306HRGtS/48bVMiNrnayQgmM=; b=QdE5pQUXD8ntrc/lCJDy8BLTJVGoKVz2jLCZt/lswJ7YsCx0l1zc4nb4o/8EPZVQgC kxdnsRupelkYqZ2dtecWNUX8gzjJQgatjJH3qGxW+zSlDWG6hVbtslPJiysL9apktxRf K9ru7LL8UwQRDlIqTqOKyW8P0WPlhs9B70HqD/0kR5lygZ4ex7n5o7cKLtmuNsRiG0Mb 6Dr2Ru2RY+qVDKWwGUhlsCibnKLbxb2Lpwm0Q0rWR7vksbsnk3nh2wOHnbSPlePmpHq4 h8Jb+7rHZZHvc+gm7ruNzjvM/EvKMj2G7IrNYwg8VJ+hkTfJFIn3ksICRi71ent7INO/ IldQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ut08YBCU; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h89-v6si5049249pld.48.2018.04.12.23.37.46; Thu, 12 Apr 2018 23:38:01 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ut08YBCU; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753454AbeDMG1d (ORCPT + 99 others); Fri, 13 Apr 2018 02:27:33 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:34568 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751692AbeDMG1c (ORCPT ); Fri, 13 Apr 2018 02:27:32 -0400 Received: by mail-pl0-f65.google.com with SMTP id y12-v6so5527913plt.1; Thu, 12 Apr 2018 23:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=d+JtFWeLEoKw4HatQFd306HRGtS/48bVMiNrnayQgmM=; b=Ut08YBCUPsfYJWoD6s+TT25RDr43jSgmAXaxy2g5KeVV7MXfrZ/On8Eyc34n6dDNxM bc24RA1ftvW2E8kZkxfT/W38CK5WWryCv0h/UXN59Nol5Qgq/i98RYmIQRm/KnPIau3w 49VrfxCkOrpgS/1/3hx5b1yfUzhGp2Hk6Xn4gRLcfF/rky9ZCwE6+6H7Eqe0H8J51CeN XF6XkQBQzgi1osXF0vbGwwToD+MnnjDokOsg9Ur32v5provmu+az+Ffpw3BYla34B9JZ aRHofo5dOwjwz6jJxRzXp/f9cV2fwX3JC0xgLgK43IRmGG9LgS1xEC0c3IB9uAEK/YWt n7NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=d+JtFWeLEoKw4HatQFd306HRGtS/48bVMiNrnayQgmM=; b=kPElXBoFxfeD1VuLgiREhr1OgFLlErKs/lTdosBV82Yurhz7KQWE026+YFWei+WZ9h iXGL7HKoMqXBo9NICp7vgXTdXoaCK2GcPcKT9YgaXj7yosVsrzQvCx0oJfphHRGPFZ8S XRiE0Eskd/hWnM54rpDTDQTgcz8C9n9mbwzZOMrXjhQVaByAXKOIj2VJ33tJxEmR4lTq Qd3ea8jwHIvQUNSuA5/EXUR559ZyW1nfwRvzxtsGSW4lC7WjUizXOC7ik6eZblTXKsdh OrdIXEpr12FLmlSvFsbq+RcHns3Au5do2EpuJImoaJexFfd/HfPcrEO9BgEjVF683UzL F46A== X-Gm-Message-State: ALQs6tD9lXJEK2NsY5wNUcmI5uVrCy2FofOFUse4zCZeBIAZVr8E8cKo LOvzq2vCxyeh8pYHO3yOgal7yA== X-Received: by 2002:a17:902:7898:: with SMTP id q24-v6mr883216pll.76.1523600851829; Thu, 12 Apr 2018 23:27:31 -0700 (PDT) Received: from linux-l9pv.suse ([134.159.103.118]) by smtp.gmail.com with ESMTPSA id w10sm11236326pgc.61.2018.04.12.23.27.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 23:27:30 -0700 (PDT) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, akpm@linux-foundation.org, "Lee, Chun-Yi" , Randy Wright , Takashi Iwai , Vivek Goyal , Ingo Molnar Subject: [PATCH] efi: Fix the size not consistent issue when unmapping memory map Date: Fri, 13 Apr 2018 14:27:16 +0800 Message-Id: <20180413062716.8040-1-jlee@suse.com> X-Mailer: git-send-email 2.12.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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