Received: by 10.213.65.68 with SMTP id h4csp162760imn; Fri, 23 Mar 2018 01:40:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELsV3BVtHnmKDhxeNjJ+Ky4REsF8gimV1FO2P+bLgm7/1iHVwugHau9P3VhjNOGy/uALXNyb X-Received: by 10.99.147.25 with SMTP id b25mr6089025pge.309.1521794423733; Fri, 23 Mar 2018 01:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521794423; cv=none; d=google.com; s=arc-20160816; b=zji7IBVpUa3lJzO9p9sRQscExlmXSC9jEY1bldHy2WrGmk0ETyR6CoAIKatBbo0pnE Aooovclvr/Ld7TueETzC/Eae8Q4Nz72TGI0FxeVecT2kmB35Sz9lLUpT9LXkjAbzN68F olsP8JH+kjO8jq3PZ1ZvQNQyANKGHsxEICvdXHOMA8Mbh91C8RQRSYHQpzpFtmDy977P d3lXTfPpxRssaafMWsl7XNNNP+ZRSrWvca10TguRFeLF0pGiVwMGP1qFkQ0EfAfBIW1b Hdhy3+enoGmUbIn5OfWPE+hlPsEUJ/cwRKCEDSCI63cloAF2crJxfDnxsm2WfL0lI5vZ l/Pw== 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=UKEckRZbggpU+im/oamsb1VRhWe2VzskpPuyy2GBC6c=; b=uNZVANDtNC5yVeC8tJ1/XJEijpFD8VwQOxw3KKtFt3c1z39t7lO3ECcjZG+RuvMsXW lgGXeAayU/+voX50ZpoxOTcQDzWmVsNjebJSaZnSO7b0tXDcpmDvB7m1pH36wll6T9I1 cKVg8uxEn4SMI2l8p0wnLFnLSrfCO4i2cWVb6+CiTidUW2Py8BX1aTdinIzVEBmCNbh0 YVlv0HveNcju/lrp5lLWULHQxUUED1wOxyHj14dPqMc7da/Z6aFCUjwPFTlwWXHj6/L4 +f2khTsWURA72iNAZ/qRonW5m5VxuDXx/ZeOgRyIfe+4mXeEZWbNzNRPD39iO6lsrO2t 6REw== 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 o191si3314340pfo.56.2018.03.23.01.40.08; Fri, 23 Mar 2018 01:40:23 -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 S1751825AbeCWIjE (ORCPT + 99 others); Fri, 23 Mar 2018 04:39:04 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54032 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751777AbeCWIjD (ORCPT ); Fri, 23 Mar 2018 04:39:03 -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 B1293BD87; Fri, 23 Mar 2018 08:39:02 +0000 (UTC) Received: from localhost (ovpn-8-18.pek2.redhat.com [10.72.8.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD90C2166BAE; Fri, 23 Mar 2018 08:39:01 +0000 (UTC) Date: Fri, 23 Mar 2018 16:38:58 +0800 From: Baoquan He To: vgoyal@redhat.com, hpa@zytor.com, yinghai@kernel.org, Andrew Morton Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, takahiro.akashi@linaro.org, ebiederm@xmission.com, dyoung@redhat.com, prudo@linux.vnet.ibm.com Subject: Re: [PATCH 0/2] Kexec_file: Load kernel at top of system ram Message-ID: <20180323083858.GB25740@localhost.localdomain> References: <20180322033722.9279-1-bhe@redhat.com> <20180322153802.0763bb46978c0c1a3d3f11c0@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180322153802.0763bb46978c0c1a3d3f11c0@linux-foundation.org> 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.1]); Fri, 23 Mar 2018 08:39:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 23 Mar 2018 08:39:02 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bhe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/22/18 at 03:38pm, Andrew Morton wrote: > On Thu, 22 Mar 2018 11:37:20 +0800 Baoquan He wrote: > > > The current kexec_file ignores kexec_buf.top_down value when call > > arch_kexec_walk_mem() to allocate memory for loading kernel/initrd > > stuffs. This is not supposed to be what kexec_buf.top_down is used > > for. > > OK, but why is this a problem? When fixing a bug, please fully > describe the user-visible effects of that bug. That helps others > understand the importance of the fix, whether it should be backported > into various kernels, etc. The problem is the current kexec file loading has different behaviour with the old kexec loading. In kexec loading, user space kexec_tools utility does most of job, it searches in /proc/iomem to try to find a memory region from top to down to load kernel. Therefore with the kexec loading, x86_64 bzImage kernel are all loaded at top of System RAM. However, the kexec file loading just searches for available memory region in iomem resource from bottom to top, then try to allocate from top to down in that region. E.g on my testing system with 2G memory as below, the kexec loading will put kernel near 0x000000013fffffff, while kexec file loading will put kernel near 0x000000003ffddfff. There's no bug reported yet, just we need consider it when take care of the kexec collaboration with other kernel components like kaslr/hotplug etc, and also the consistentency between the different kexec interface. [Mar23 15:13] Linux version 4.16.0-rc3+ (bhe@localhost.localdomain) (gcc version [ +0.000000] Command line: BOOT_IMAGE=/vmlinuz-4.16.0-rc3+ root=UUID=be8f8e3a-9 [ +0.000000] x86/fpu: x87 FPU will use FXSAVE [ +0.000000] e820: BIOS-provided physical RAM map: [ +0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable [ +0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved [ +0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved [ +0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000003ffddfff] usable [ +0.000000] BIOS-e820: [mem 0x000000003ffde000-0x000000003fffffff] reserved [ +0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved [ +0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved [ +0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000013fffffff] usable I searched on internet and found the original patches posted for adding bzImage 64 support into the old kexec loading, which is located in user space kexec_tools utility made by Yinghai, and Vivek and hpa reviewed patches. Still I didn't found out why kernel has to be put at top of system RAM. I guess low memory are reserved for system usage mostly, putting kexec kernel at top is safer and no need to exclude those resereved regions by system or firmware which we may not find out all of them, but not very sure about it. Hi Yinghai, Vivek, hpa, Do you know why we load kexec kernel at top of system RAM when do x86_64 bzImage loading? Thanks Baoquan