Received: by 10.192.165.156 with SMTP id m28csp1581400imm; Tue, 17 Apr 2018 01:37:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ufMqlmHPEkTbWJW/Qm0hAOvtd0XecwEzTQuE/kIAFlC+Vi6V8RHRZv/xix/sCHZXBN3kH X-Received: by 10.99.106.7 with SMTP id f7mr1044528pgc.363.1523954253411; Tue, 17 Apr 2018 01:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523954253; cv=none; d=google.com; s=arc-20160816; b=wXIuNFclYz37ZBh6DS+HcrSgqVTSUXc1mguN5NuFTfDGOpZ8RvuU1GacNhJnwej7wQ /4nMvaEV0xgRicq90Gd/vwjXJJGmOkafb+qOBvjnF8rh68+RdQ32gR9ZDlnE79WY7AdB xjW+9IH41jXhJkCb4amJkaaII7K13bG9bdp/+dVg1fyk4aqfzIZfzUBCPqE0QtOp+yXi G77Rjg1XBH4iC1YBheEPd5VTIBPhtIRgp9oim2XLMm2VJtVi2TDArS3ZzKB9mCfRNZlM mutHlTMI/5fuaznmzs7PLrPX8YYm5tSoy/pChJqMEJK/Y/qKtW8FiDNUwuorYAXmoJFf 7EUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=GiNLwiXYhblvhoP/Zx/R2gkX6AJbtzjbGae2V8lHf2c=; b=F5WreXzNyh7PJcZXjQaKT9Gp7xp3ZfmL9ZHXXoMfz6PangqLC8G/q1WW3pjZ6yTy4Z hf6csKEV8CJNEGVb6bE4JzWz04wzFYTvEU24+bePonjZhtH0bK2/RqQ//QAZxsN9r4jh jFPku3QcMnv2pXGSOwKmMFCVvsqsh+OHxK78bSubR/mC2uDex5KWEFzO+1RdW7x315za 3Lcc5l6kfmvBzqVUt4Oi6CDJgnCcDpy2h4Q9QFJI0A9I1W/x1uM0ahvaiM8Cl20d6pvI Gkb6GS9IKN/4XtG7mKDPQNXFPfZK5HI9GmJyyzntIBdZ5+eEgnhSRJlY56X/EJ2dr7bJ nuSA== 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 m77si12662130pfk.56.2018.04.17.01.37.19; Tue, 17 Apr 2018 01:37:33 -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 S1752144AbeDQIgK (ORCPT + 99 others); Tue, 17 Apr 2018 04:36:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44664 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751147AbeDQIgJ (ORCPT ); Tue, 17 Apr 2018 04:36:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 856E440201A0; Tue, 17 Apr 2018 08:36:08 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-142.pek2.redhat.com [10.72.12.142]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D40CD111DCEB; Tue, 17 Apr 2018 08:36:04 +0000 (UTC) Date: Tue, 17 Apr 2018 16:36:00 +0800 From: Dave Young To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: joeyli , Randy Wright , linux-efi@vger.kernel.org Subject: [PATCH] kexec_file: do not add extra alignment to efi memmap Message-ID: <20180417083600.GA1972@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 17 Apr 2018 08:36:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 17 Apr 2018 08:36:08 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 Chun-Yi reported a kernel warning message below: 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 problem is x86 kexec_file_load adds extra alignment to the efi memmap: in bzImage64_load() efi_map_sz = efi_get_runtime_map_size(); efi_map_sz = ALIGN(efi_map_sz, 16); And __efi_memmap_init maps with the size including the alignment bytes but efi_memmap_unmap use nr_maps * desc_size which does not include the extra bytes. The alignment in kexec code is only needed for the kexec buffer internal use Actually kexec should pass exact size of the efi memmap to 2nd kernel. Signed-off-by: Dave Young Reported-by: joeyli Tested-by: Randy Wright --- arch/x86/kernel/kexec-bzimage64.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- linux.orig/arch/x86/kernel/kexec-bzimage64.c +++ linux/arch/x86/kernel/kexec-bzimage64.c @@ -398,11 +398,10 @@ static void *bzImage64_load(struct kimag * little bit simple */ efi_map_sz = efi_get_runtime_map_size(); - efi_map_sz = ALIGN(efi_map_sz, 16); params_cmdline_sz = sizeof(struct boot_params) + cmdline_len + MAX_ELFCOREHDR_STR_LEN; params_cmdline_sz = ALIGN(params_cmdline_sz, 16); - kbuf.bufsz = params_cmdline_sz + efi_map_sz + + kbuf.bufsz = params_cmdline_sz + ALIGN(efi_map_sz, 16) + sizeof(struct setup_data) + sizeof(struct efi_setup_data); @@ -410,7 +409,7 @@ static void *bzImage64_load(struct kimag if (!params) return ERR_PTR(-ENOMEM); efi_map_offset = params_cmdline_sz; - efi_setup_data_offset = efi_map_offset + efi_map_sz; + efi_setup_data_offset = efi_map_offset + ALIGN(efi_map_sz, 16); /* Copy setup header onto bootparams. Documentation/x86/boot.txt */ setup_header_size = 0x0202 + kernel[0x0201] - setup_hdr_offset;