Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4302416imm; Fri, 18 May 2018 02:52:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqwxAAdTW7SxCU+GVHeKky0FejoP6b9Rd62jNFiM6k9tzgfeOzbN34zDQCJjnK15dzNq4Kg X-Received: by 2002:a17:902:2702:: with SMTP id c2-v6mr8646627plb.297.1526637138312; Fri, 18 May 2018 02:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526637138; cv=none; d=google.com; s=arc-20160816; b=EdkjI0ub2f0R9nidCpEC30oakzMQMvaYHYYDuSTzIL5hZCuwdXaltXbkfCPtIEhNav brcwUoWu89t9+2/Bxp8BN86XZeoXCoq9GKN1I8nPkwLckHTMkfWbXSw0pJCr2zyZYq3g B9ycYeLSiLSHVEWO4BVTZEG0c6Ua7b0OtGPZD8F5l8kvAcSluOcol/BXsNSeH8nzIQsZ SwiimPk9L9ESMXJfsOaBct/awNYfuV0C2KXrDzB9mW/iAG+m2Tv0isV57g4whLv/+RMM 2tgSDwuAtJho0npODJxAiFnSmZQPHkfXE94418p7EyA2qRtaFbydLLTRowBvr5KxmrF9 B+HQ== 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:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=VEjRXmTJA36ukyoNmw+kDO14pWMxtpXROePbcyaIfYE=; b=iP52hxlR4ioPntXvmFWNm+2rGqhczwtTeRlKDGpwEBkMqQIZ/WXaJfzwOL84UIl+2A +YVeKqAA7/IDg1iFx5bXcoLW1Oqxp1kBn3vwL5Hn8SoHxzV+zwkZMaYLDPCIbgdZEl+M bwEszbqbNDaPJIxYVmdSTEKH5LQyrXlw3cegN+2xrXtnSZe7u0xvezuNg5V/CU9jYUv5 dWgG4dFO5LJyst7XwrQat7FsvuCY5uAx8hAGsfW3nvaUJsXnE31N0tQgnkMSRmuMN/Bv zR/maM06oBPeZiMpLc60wb3VuIsQ3i8slUuIKN+3VJCYIb+x0YBWPSYDu1cTfCDwMxoc os9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PhtmSw2J; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o4-v6si6921849plk.321.2018.05.18.02.52.04; Fri, 18 May 2018 02:52:18 -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; dkim=pass header.i=@linaro.org header.s=google header.b=PhtmSw2J; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753281AbeERJvG (ORCPT + 99 others); Fri, 18 May 2018 05:51:06 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:36774 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753259AbeERJvC (ORCPT ); Fri, 18 May 2018 05:51:02 -0400 Received: by mail-pl0-f67.google.com with SMTP id v24-v6so4298278plo.3 for ; Fri, 18 May 2018 02:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VEjRXmTJA36ukyoNmw+kDO14pWMxtpXROePbcyaIfYE=; b=PhtmSw2JwRZ8Z1AFxb40xhMVXCkWPIqP7c2CRG5+iv1/eOldH2z1nT79pMDD+RqMWA ZGvIygxfy1hbaVBP8jcCeh5qjI/9jY/dcTXdilNkc4jQf9IpVnKGwKzDxxDhRZqyVMNw Wf6IkZzkVo5yZwHKtiDR7xYhsS5C74UqvJH0E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=VEjRXmTJA36ukyoNmw+kDO14pWMxtpXROePbcyaIfYE=; b=Xie5jKpEdQuBrnyAskQQKkEn3RHlngIXt6hPGE5zMA8AU7kO/1BeJqw+FVGrMHS6XL FY5xz620qPHhl+Pta+FQDr9ZiuBH/XP2ettOba3y9Hn2ckLni7ADp4SNYAtLK6sRFe+2 eXHxMMr/J08qIc9O7C6wFPCHOsCp8sfEseehqZjwQ2z2gZROdx77D7+SNeGFjkUL2kA1 vN9nz1W02HI8C2Gd417jmYR8MjWe2/JQZCL0ZxLal1ijXGopPU3kc08wXDjpJ54MVKoH 0ei1nqVQSY5QSEvCqcqYIp8ma97JT3Kyjks/Lk9tfOn9soqXMjoLwQiTfXwcercng3e+ VN/Q== X-Gm-Message-State: ALKqPwfosPYed/Px4AGpc/vOunO2zBwB83Kpl+R0M6xsJPNFpksMt7HC ipWRPaB6vIiYV/UDTi0jUq7QGA== X-Received: by 2002:a17:902:683:: with SMTP id 3-v6mr8858678plh.291.1526637062162; Fri, 18 May 2018 02:51:02 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id e87-v6sm16775238pfl.65.2018.05.18.02.50.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 02:51:01 -0700 (PDT) Date: Fri, 18 May 2018 18:50:59 +0900 From: AKASHI Takahiro To: James Morse Cc: catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, ard.biesheuvel@linaro.org, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 07/11] arm64: kexec_file: add crash dump support Message-ID: <20180518095057.GN2737@linaro.org> Mail-Followup-To: AKASHI Takahiro , James Morse , catalin.marinas@arm.com, will.deacon@arm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, ard.biesheuvel@linaro.org, bhsharma@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20180425062629.29404-1-takahiro.akashi@linaro.org> <20180425062629.29404-8-takahiro.akashi@linaro.org> <512cde7d-d84b-3623-cb09-a2d78acc11dc@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <512cde7d-d84b-3623-cb09-a2d78acc11dc@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 16, 2018 at 11:06:02AM +0100, James Morse wrote: > Hi Akashi, > > On 15/05/18 18:11, James Morse wrote: > > On 25/04/18 07:26, AKASHI Takahiro wrote: > >> Enabling crash dump (kdump) includes > >> * prepare contents of ELF header of a core dump file, /proc/vmcore, > >> using crash_prepare_elf64_headers(), and > >> * add two device tree properties, "linux,usable-memory-range" and > >> "linux,elfcorehdr", which represent repsectively a memory range > >> to be used by crash dump kernel and the header's location > > >> diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c > >> index 37c0a9dc2e47..ec674f4d267c 100644 > >> --- a/arch/arm64/kernel/machine_kexec_file.c > >> +++ b/arch/arm64/kernel/machine_kexec_file.c > > >> +static struct crash_mem *get_crash_memory_ranges(void) > >> +{ > >> + unsigned int nr_ranges; > >> + struct crash_mem *cmem; > >> + > >> + nr_ranges = 1; /* for exclusion of crashkernel region */ > >> + walk_system_ram_res(0, -1, &nr_ranges, get_nr_ranges_callback); > >> + > >> + cmem = vmalloc(sizeof(struct crash_mem) + > >> + sizeof(struct crash_mem_range) * nr_ranges); > >> + if (!cmem) > >> + return NULL; > >> + > >> + cmem->max_nr_ranges = nr_ranges; > >> + cmem->nr_ranges = 0; > >> + walk_system_ram_res(0, -1, cmem, add_mem_range_callback); > >> + > >> + /* Exclude crashkernel region */ > >> + if (crash_exclude_mem_range(cmem, crashk_res.start, crashk_res.end)) { > >> + vfree(cmem); > >> + return NULL; > >> + } > >> + > >> + return cmem; > >> +} > > > > Could this function be included in prepare_elf_headers() so that the alloc() and > > free() occur together. > > > > > >> +static int prepare_elf_headers(void **addr, unsigned long *sz) > >> +{ > >> + struct crash_mem *cmem; > >> + int ret = 0; > >> + > >> + cmem = get_crash_memory_ranges(); > >> + if (!cmem) > >> + return -ENOMEM; > >> + > >> + ret = crash_prepare_elf64_headers(cmem, true, addr, sz); > >> + > >> + vfree(cmem); > > > >> + return ret; > >> +} > > > > All this is moving memory-range information from core-code's > > walk_system_ram_res() into core-code's struct crash_mem, and excluding > > crashk_res, which again is accessible to the core code. > > > > It looks like this is duplicated in arch/x86 and arch/arm64 because arm64 > > doesn't have a second 'crashk_low_res' region, and always wants elf64, instead > > of when IS_ENABLED(CONFIG_X86_64). > > Thinking about it some more: don't we want to walk memblock here, not > walk_system_ram_res()? What we want is a list of not-nomap regions that the > kernel may have been using, to form part of vmcore. > walk_system_ram_res() is becoming a murkier list of maybe-nomap, maybe-reserved. > > I think we should walk the same list here as we do in patch 4. For consistency, yes. I missed that. -Takahiro AKASHI > > > Thanks, > > James