Received: by 10.192.165.156 with SMTP id m28csp61372imm; Wed, 18 Apr 2018 17:20:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+eEX1GLnp2XEDv8WduDxW1V8fQsdhK2MxeFkZtgBdTFujKhFp+pxjtH8SMqkG7q9q1IMMK X-Received: by 10.98.103.86 with SMTP id b83mr3796493pfc.76.1524097250701; Wed, 18 Apr 2018 17:20:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524097250; cv=none; d=google.com; s=arc-20160816; b=cCW3jUAVjuACg6MvmLUjC9pwIykEqVH2V/TjtpHERbReVZedTYXnIvvrnQPNZm9wOs xaZ+B73+xWyR/Ndka4+urjk5e2sZIZC7pO0TwWFTl7pYZ7Z7AJdLsqkeOJWCkdKRWUXg VcyyKP3gmH36FbdncUWEfo1omL9LAQaPM3+rlnu7n/Dj1QV+3N3SKFUJBeW9KHYgMtud wkTHruMWXQWYVPEOZs3l/PLnSpxzGS8KPuH4uKpZ32I4JFaFuXhO7fcb3rOeC8MzlOPl vRDWNYXvQ6UZXvPcI/s3wCxU0LlYmv4DRuoxecYRCk+ny6ZGsqWVjHtoBRCfSEhho31d cwJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Os8eqohtmdISKiDIKYEdKvYMYuWPCM354kkRAB6A3qk=; b=ozbWiJynSXui9Ko92pHpauYkm1dhbtGvYV9m56K0329a0hX9UxSDWT/CBKqfjbczI9 o4gU7t2C+vZDw8WZcLhD6SEXx3M0SSS/96W/zPrBOEwP+9h9Qv34V53wcyJ7YUNStbUM EIoKIcDJ4m0awyG1BZJSpZjST7StBKi6v4F+xa/s0XMalVVjcxkycIeRURVIyfqmNXcg nVfr1F/C06rBqvo/1vw36y5v+nkflonG3W91wBaci8v/j/Oo3p51YJzN8aL2qeRIaA+G dVuDAw4h2ZL6/k2kpANtjugNbEuG1LSLZx013+5/QI505WNbDJlEYqjlpkHDKXRH99GD +Fdg== 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 s126si1947657pgc.477.2018.04.18.17.20.37; Wed, 18 Apr 2018 17:20:50 -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 S1753256AbeDSATb (ORCPT + 99 others); Wed, 18 Apr 2018 20:19:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45384 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753065AbeDSAT2 (ORCPT ); Wed, 18 Apr 2018 20:19:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFB054022909; Thu, 19 Apr 2018 00:19:26 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EF6A2023238; Thu, 19 Apr 2018 00:19:21 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, robh+dt@kernel.org, dan.j.williams@intel.com, nicolas.pitre@linaro.org, josh@joshtriplett.org Cc: Baoquan He , Eric Biederman , Vivek Goyal , Dave Young , Yinghai Lu , kexec@lists.infradead.org Subject: [PATCH v3 3/3] kexec_file: Load kernel at top of system RAM if required Date: Thu, 19 Apr 2018 08:18:48 +0800 Message-Id: <20180419001848.3041-4-bhe@redhat.com> In-Reply-To: <20180419001848.3041-1-bhe@redhat.com> References: <20180419001848.3041-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 19 Apr 2018 00:19:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 19 Apr 2018 00:19:27 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 For kexec_file loading, if kexec_buf.top_down is 'true', the memory which is used to load kernel/initrd/purgatory is supposed to be allocated from top to down. This is what we have been doing all along in the old kexec loading interface and the kexec loading is still default setting in some distributions. However, the current kexec_file loading interface doesn't do likt this. The function arch_kexec_walk_mem() it calls ignores checking kexec_buf.top_down, but calls walk_system_ram_res() directly to go through all resources of System RAM from bottom to up, to try to find memory region which can contain the specific kexec buffer, then call locate_mem_hole_callback() to allocate memory in that found memory region from top to down. This brings confusion. These two interfaces need be unified on behaviour. Here add checking if kexec_buf.top_down is 'true' in arch_kexec_walk_mem(), if yes, call the newly added walk_system_ram_res_rev() to find memory region from top to down to load kernel. Signed-off-by: Baoquan He Cc: Eric Biederman Cc: Vivek Goyal Cc: Dave Young Cc: Andrew Morton Cc: Yinghai Lu Cc: kexec@lists.infradead.org --- kernel/kexec_file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 75d8e7cf040e..7a66d9d5a534 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -518,6 +518,8 @@ int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY, crashk_res.start, crashk_res.end, kbuf, func); + else if (kbuf->top_down) + return walk_system_ram_res_rev(0, ULONG_MAX, kbuf, func); else return walk_system_ram_res(0, ULONG_MAX, kbuf, func); } -- 2.13.6