Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1235032ybm; Wed, 22 May 2019 20:24:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzaCuvP1DTq6tb0SBragjfDeNwI862QGEQ4RuQXZ4Qc8PCf7IBHUcWaWJDR3o3grpPhLXH X-Received: by 2002:a17:902:6ac6:: with SMTP id i6mr94652865plt.336.1558581891998; Wed, 22 May 2019 20:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558581891; cv=none; d=google.com; s=arc-20160816; b=z9OkMe63hhpvGkKxfXtRKs+dodKU0ZVrtujbqTGAbxSQx+f3ElD2J8Ej8M//3f3c1p 4R8apNrlmYQ8QTmGizeCoFXgl6ZCOgwZiLyGe+ji99zWv0/loFnFQFaxFi8Ym7zXrpkN WfsIcHvMuTMoKInFOqgMrW0j2LXE8vrlI2+l8qoLHkmLdQdZUARCM66FaFxGgJL03D0Q wFO1s19GNkGMEU92gV6NAo8ZRkJc6rMOjWvaGJzI5mdRwNQhMzhuliDGVvu1ejanGg9D iFIFFn/g1QKMQksyudtlbYJxJS5daI8iQgGchAty2pBO7+YfQ6+i97t+4TGHsFEB2I2v yNRQ== 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; bh=uJSbybSlzOBB11bAiuTBsrwMpvA9oGV26MJHBNsClcE=; b=JsME7SLNiEBr2DjlwowUhxe/xcNUKz38YTSgshIGk0C0HogFooKng6WowFBT+Kgg0I pARHuEn1nqbtwwRzXp8+HiVOfXJ/jeOf2zkCm7FEAjG4m4GbtbUaIHVqydrv6ZH7icf5 IrTigawA+NZtQMyHe+o8oB0olgBaaFuOQSWBfXr4UKxZmXTXLlSvgBjTlaSc/B0163WW a8ptA27PxbU1+rIPlr3nzjewXBEnkSI6daZeIW3AXJhd8BtH0RjA9rjFf+Ma8wwpD19v L11mah/AOUmvmEfSvfrzEFQlaOisx0cGoxKsZV42uCN4hZtmGKSgHIyVnqUu48FSML22 2b4Q== 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 w16si17244779pgf.138.2019.05.22.20.24.36; Wed, 22 May 2019 20:24:51 -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 S1729797AbfEWDXK (ORCPT + 99 others); Wed, 22 May 2019 23:23:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58732 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728237AbfEWDXK (ORCPT ); Wed, 22 May 2019 23:23:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 017E5C057F2F; Thu, 23 May 2019 03:23:10 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-185.pek2.redhat.com [10.72.12.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9AED218687; Thu, 23 May 2019 03:23:06 +0000 (UTC) Date: Thu, 23 May 2019 11:23:02 +0800 From: Dave Young To: Thiago Jung Bauermann Cc: linuxppc-dev@lists.ozlabs.org, Michael Ellerman , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Mimi Zohar , AKASHI Takahiro Subject: Re: [PATCH] powerpc: Fix loading of kernel + initramfs with kexec_file_load() Message-ID: <20190523032302.GD8174@dhcp-128-65.nay.redhat.com> References: <20190522220158.18479-1-bauerman@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190522220158.18479-1-bauerman@linux.ibm.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 23 May 2019 03:23:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/22/19 at 07:01pm, Thiago Jung Bauermann wrote: > Commit b6664ba42f14 ("s390, kexec_file: drop arch_kexec_mem_walk()") > changed kexec_add_buffer() to skip searching for a memory location if > kexec_buf.mem is already set, and use the address that is there. > > In powerpc code we reuse a kexec_buf variable for loading both the kernel > and the initramfs by resetting some of the fields between those uses, but > not mem. This causes kexec_add_buffer() to try to load the kernel at the > same address where initramfs will be loaded, which is naturally rejected: > > # kexec -s -l --initrd initramfs vmlinuz > kexec_file_load failed: Invalid argument > > Setting the mem field before every call to kexec_add_buffer() fixes this > regression. > > Fixes: b6664ba42f14 ("s390, kexec_file: drop arch_kexec_mem_walk()") > Signed-off-by: Thiago Jung Bauermann > --- > arch/powerpc/kernel/kexec_elf_64.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/kernel/kexec_elf_64.c b/arch/powerpc/kernel/kexec_elf_64.c > index ba4f18a43ee8..52a29fc73730 100644 > --- a/arch/powerpc/kernel/kexec_elf_64.c > +++ b/arch/powerpc/kernel/kexec_elf_64.c > @@ -547,6 +547,7 @@ static int elf_exec_load(struct kimage *image, struct elfhdr *ehdr, > kbuf.memsz = phdr->p_memsz; > kbuf.buf_align = phdr->p_align; > kbuf.buf_min = phdr->p_paddr + base; > + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; > ret = kexec_add_buffer(&kbuf); > if (ret) > goto out; > @@ -581,7 +582,8 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, > struct kexec_buf kbuf = { .image = image, .buf_min = 0, > .buf_max = ppc64_rma_size }; > struct kexec_buf pbuf = { .image = image, .buf_min = 0, > - .buf_max = ppc64_rma_size, .top_down = true }; > + .buf_max = ppc64_rma_size, .top_down = true, > + .mem = KEXEC_BUF_MEM_UNKNOWN }; > > ret = build_elf_exec_info(kernel_buf, kernel_len, &ehdr, &elf_info); > if (ret) > @@ -606,6 +608,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, > kbuf.bufsz = kbuf.memsz = initrd_len; > kbuf.buf_align = PAGE_SIZE; > kbuf.top_down = false; > + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; > ret = kexec_add_buffer(&kbuf); > if (ret) > goto out; > @@ -638,6 +641,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, > kbuf.bufsz = kbuf.memsz = fdt_size; > kbuf.buf_align = PAGE_SIZE; > kbuf.top_down = true; > + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; > ret = kexec_add_buffer(&kbuf); > if (ret) > goto out; > > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec Reviewed-by: Dave Young Thanks Dave