Received: by 10.192.165.148 with SMTP id m20csp273776imm; Tue, 1 May 2018 23:18:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZonLuWPob2VUs3PX2AZrx4XgkwnlrN4ElBdbhWAd8YGV3tL01iLeDPEuUWJm1Wr1sGY6gTa X-Received: by 2002:a63:b908:: with SMTP id z8-v6mr15045830pge.436.1525241882515; Tue, 01 May 2018 23:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525241882; cv=none; d=google.com; s=arc-20160816; b=jncMzutBnT0G8BodLcklLhIoKYmn5lFBmmkwsMAOW0+v2ueIffSkVZpmDVT8D9FZpz ohk02Wpss96EAjJKOcIdPUNaUS8WZNNiihwzil7NvFMQ3VDRDFtnFPBnvRgZ5vegfPSw 1W9RrbSwYzotcr7Uj1o4sjne8J0yvePXCuW3XJN8t98EJI3xbNrTBJ5gAzqkaMBkLiMm gfXtaSl29nUrwjkmiwmXJF6Jziiqmgx51QivMlMgRm7cdxfdXR55OkMEdCEMjVU5VN1F K+gDO9plQLD31NPc25K8O2y7Khkceb78kBylioxTTZ6lAyot1/q/rj7uuwuXEotApVJZ x+Zg== 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=epRhPIbpL9c6DvnDhBWfPMYpZDjcsCGdoRMST8lHnos=; b=uq9p3E67SoxTcJ7IZs2csYIIloD07cEnjXlHv0oByJLHqSvOCG3PzLoYvRF0hjGqYM HB0n2O5oPg57rHD1lAszei7OvSmRjygsWanhqvNEWdMgBEuUVHg8NiP9tzLKHMPe6E9F FLpNGyomkB+oxPdYqTZz6hXt1RGEwH4j5FO1MFcw10Or+EWAS6474JgJQY9Ztl7HaiJc IuFqh0cS7GBhd4T9MRe74fAmNctBiSqVZR05Ww7M1qCe6h9LTFqk0E8/fYRGdAyV94qK WUuZLThtk8jAZ5XDqsyYsDDzyxlmAB06JZAsBNF6HuWH4C3wOQ5l6TnsviA+hnhYT0IH /x9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ibDmKwaz; 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 x15-v6si11414507pln.479.2018.05.01.23.17.48; Tue, 01 May 2018 23:18:02 -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=ibDmKwaz; 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 S1751181AbeEBGRi (ORCPT + 99 others); Wed, 2 May 2018 02:17:38 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:44850 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751069AbeEBGRg (ORCPT ); Wed, 2 May 2018 02:17:36 -0400 Received: by mail-pf0-f195.google.com with SMTP id q22so10880279pff.11; Tue, 01 May 2018 23:17:36 -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=epRhPIbpL9c6DvnDhBWfPMYpZDjcsCGdoRMST8lHnos=; b=ibDmKwazoz79hxfwvITLZYrCmKu/5PJIzHij5PIpPNVRAdp+JJZLJdNwRENnc6ugt3 rY/x3cvNZ2W8Gg5aaNriLARbmzsSF+sR/j528NN17IeKtCOoEQnPSxyJMPnTou4rR3fl vxE3MnCOmPST8MefyBQ3mPvu8C12r1aLn5gQPmkg2n7fDsC0bfZ9D7Vwj921lGU3xUWB aUHEevP4gs2Qpg+JKA3suGjWE9m0bl5NCSiOfbl2CPJQ7GJh+D8BeeB5fDwWYigGQaxh 3XSBpXW8OjZU44pjDUIjv4nr242FwntbvolqaJ1J/TbvIM0Yi6hzecuPgz2szKChxQen dXSA== 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=epRhPIbpL9c6DvnDhBWfPMYpZDjcsCGdoRMST8lHnos=; b=sBo1cOgZ2oSWI7F9OacKBS2NUi+Qzp10pnSR9IZPf3r/bENC1VSNQeEFIv6mXcbr62 ZjE8M+qw5M99NOO3wfuzVXrfX0uI/2bLQaZrIenwhW18A5Np/YuIddw+cauvqpOgrQqS dFn0zkSetojXmBjZvU+FWb6YVW5+fegRkqPFnPmj1xQJekusWrB5BcyDxY9cFXWF8LpC l5TJdOlRnL8m03iHB37OzUmwc9OPKk1RcfyGyt+oD2pTD4u/FYlu32z5FbVv8mdP74Y2 yeXqW6Sc3frJY58eje9UREMIh4ur9QYbT+hla0OyZcMyMSpQrxa/raWf1ESxIwLOG43u jiKQ== X-Gm-Message-State: ALQs6tCJEed3qZclaDsrGfCUqzh2BKMEOSbkdSaCKkTnZlw/3/FAtW6+ X7lLk7J9AN2700T0jO2eHKEWag== X-Received: by 2002:a17:902:8e8b:: with SMTP id bg11-v6mr15749604plb.95.1525241855890; Tue, 01 May 2018 23:17:35 -0700 (PDT) Received: from linux-l9pv.suse ([134.159.103.118]) by smtp.gmail.com with ESMTPSA id 5sm13982055pfx.140.2018.05.01.23.17.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 May 2018 23:17:34 -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, "Lee, Chun-Yi" , Takashi Iwai , Vivek Goyal , Ingo Molnar Subject: [PATCH] efi: Fix the size not consistent issue when unmapping memory map Date: Wed, 2 May 2018 14:17:24 +0800 Message-Id: <20180502061724.25833-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); Dave Young's a841aa83d patch fixed kexec issue. On UEFI side, 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: Takashi Iwai Cc: Vivek Goyal Cc: Ingo Molnar Tested-by: Randy Wright 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