Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7817700imu; Fri, 28 Dec 2018 05:32:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN5iszkULMRaCE/xnr8ygKjx1btvP0LGe70ZsCWnI283dV8zptemRemiGLE/m9jrAhKH6iUA X-Received: by 2002:a17:902:680f:: with SMTP id h15mr27210792plk.40.1546003970186; Fri, 28 Dec 2018 05:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546003970; cv=none; d=google.com; s=arc-20160816; b=QIO0mb34oOSJhBySRLnPlQqgufgdig/icoo1TPrFHpw56URU/R2ItsfK9ICZ/iE9oN 6d2xPyDs/OEFb9ykDYhXgmBnRmQhykxR6SoASKWx3DeFr3k+p9K+j5/7UiEA0y09N4kU R2A9RXQpdnR+B10/ZECbaVIDYhZxNKBVtOL1L+5ertLi2de3YaatV7Wp81NXGWF7sJXJ JE7WHOLPsgtWOdz7fm+j9uDEEOwJ9fUigqtAYuF1hlWBIefPrdVWR1sHh2p8McipJHdY wAOkz18dVIP0mIwpCiLHrZqWAntlAjul0l9rKwqRREzjB0Makx+Oc7JnPBxkmMRHw6X6 Fz9w== 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=tMRmVf4CzOhq5hvUnqKTqWxsQADzGxCv9X36H7iB0kU=; b=PWupHLZ1dzR8wp7IYMNk5los+GNZ4U1EjX9FbjiPGW7PciN/36prht1PhZEqHmDp+i Frsw8xFmm8fzm7QJMtUDRj6Bf0GU7dPB+N17lAN4b+Uxwgb+xlrmg/pEoZVO/aZt7Llv iKDAnxFMTfFjwo0Yz0nnJxb7/NUIxDah0PLbNJRPjVfZMyBuASZ5V6/AfIRkEzBmb5oD kE4FxGm8vzItl00OoJglfBb0hP5y/Yfu86fzfD/FX6H2FqmMuk0tQk59yKRYIYpivAmZ oQhTcr6uzvw9IpdkapzMTJgvFXoFarwS1itdvLPIDe7VlyRzce2LT9o89S+8mVqEmBqQ KrxA== 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 d69si38895916pga.184.2018.12.28.05.32.22; Fri, 28 Dec 2018 05:32:50 -0800 (PST) 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 S1730967AbeL1BHG (ORCPT + 99 others); Thu, 27 Dec 2018 20:07:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44850 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727339AbeL1BHE (ORCPT ); Thu, 27 Dec 2018 20:07:04 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 476F63C54; Fri, 28 Dec 2018 01:07:04 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2C955C22B; Fri, 28 Dec 2018 01:06:59 +0000 (UTC) Date: Fri, 28 Dec 2018 09:06:56 +0800 From: Dave Young To: linux-kernel@vger.kernel.org, kexec@lists.infradead.org Cc: AKASHI Takahiro , Andrew Morton , "Eric W. Biederman" , Baoquan He , x86@kernel.org, Ingo Molnar , Borislav Petkov , Thomas Gleixner , Vivek Goyal Subject: Re: [PATCH] x86/kexec: fix a kexec_file_load failure Message-ID: <20181228010656.GA9904@dhcp-128-65.nay.redhat.com> References: <20181227050652.GA2960@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181227050652.GA2960@dhcp-128-65.nay.redhat.com> User-Agent: Mutt/1.9.5 (2018-04-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 28 Dec 2018 01:07:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/27/18 at 01:06pm, Dave Young wrote: > The code cleanup mentioned in Fixes tag changed the behavior of > kexec_locate_mem_hole. The kexec_locate_mem_hole will try to > allocate free memory only when kbuf.mem is initialized as zero. > > But in x86 kexec_file_load implementation there are a few places > the kbuf.mem is reused like below: > /* kbuf initialized, kbuf.mem = 0 */ > ... > kexec_add_buffer() > ... > kexec_add_buffer() > > The second kexec_add_buffer will reuse previous kbuf but not > reinitialize the kbuf.mem. > > Thus kexec_file_load failed because the sanity check failed. > > So explictily reset mem = 0 to fix the issue. > > Fixes: b6664ba42f14 ("s390, kexec_file: drop arch_kexec_mem_walk()") > Signed-off-by: Dave Young > Cc: > --- > arch/x86/kernel/crash.c | 1 + > arch/x86/kernel/kexec-bzimage64.c | 2 ++ > 2 files changed, 3 insertions(+) > > diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c > index f631a3f15587..37147509d2c8 100644 > --- a/arch/x86/kernel/crash.c > +++ b/arch/x86/kernel/crash.c > @@ -469,6 +469,7 @@ int crash_load_segments(struct kimage *image) > > kbuf.memsz = kbuf.bufsz; > kbuf.buf_align = ELF_CORE_HEADER_ALIGN; > + kbuf.mem = 0; Self NAK, will resend with KEXEC_BUF_MEM_UNKNOWN instead of "0" > ret = kexec_add_buffer(&kbuf); > if (ret) { > vfree((void *)image->arch.elf_headers); > diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c > index 278cd07228dd..558204bdf412 100644 > --- a/arch/x86/kernel/kexec-bzimage64.c > +++ b/arch/x86/kernel/kexec-bzimage64.c > @@ -434,6 +434,7 @@ static void *bzImage64_load(struct kimage *image, char *kernel, > kbuf.memsz = PAGE_ALIGN(header->init_size); > kbuf.buf_align = header->kernel_alignment; > kbuf.buf_min = MIN_KERNEL_LOAD_ADDR; > + kbuf.mem = 0; > ret = kexec_add_buffer(&kbuf); > if (ret) > goto out_free_params; > @@ -448,6 +449,7 @@ static void *bzImage64_load(struct kimage *image, char *kernel, > kbuf.bufsz = kbuf.memsz = initrd_len; > kbuf.buf_align = PAGE_SIZE; > kbuf.buf_min = MIN_INITRD_LOAD_ADDR; > + kbuf.mem = 0; > ret = kexec_add_buffer(&kbuf); > if (ret) > goto out_free_params; > -- > 2.17.0 >