Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1792066imm; Wed, 16 May 2018 03:11:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqOQlhIX9eOJA8XOSnUMOmrX0QzvO9LtuEwegAOa4iAqeVwuqP3KfBgz3TF5ETf9VS+Ij+F X-Received: by 2002:a63:618b:: with SMTP id v133-v6mr179477pgb.285.1526465497582; Wed, 16 May 2018 03:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526465497; cv=none; d=google.com; s=arc-20160816; b=OL2zY+GCkIrd63j6AUtf8iFhw+9PhyHTn/qSJaQzexqhVTvhazA0k0J75YU2dFYrNV P4n5GLupXo1qG1IKdRSauWtPLNL9dmUJl48US3P0rh6h/bu8C+FA8bqiZKLWlN334HPe dM+aI2LDWLaa7Z9ZLeaOw/i4CYH17fXxuk6+f0FpK3QB9MIuLjHOEv20uMZP5ieBRouy XlkuwI5XMMV0/bCQMq2VkUz+rNLqXUvv+qg1BXKdRuX2clitSc1naiEdy4sShfdu7uzC IY3o5NtJMKiVlMIaiyN+FdrEJUbwQf9mauTX/7Pgud4y5Naj07HrIV2HcitY9vAwxUE+ Bdhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:arc-authentication-results; bh=yqeIgmigpPV9RsSZwL6G1aIXVx1engxj531uFFz/dQU=; b=YR+U/uK/xxHCmGlBVIdq8TMiEch+XawG173vJPJBIgl3ysQL0Ywnf02Q8tBcmaggSQ Yjg1/t1CMxGLH+7A+RSz2ZJhsT17108x3XVdDDTH2bhrL68TGeOhO8iRqouw88yotccO sRRM+HNuUWuwKTzjwvf8q7os5rd4ICogivCW8+cpzuiCrYJ4/bgxqMv1znvSL4+AuFO0 jeok7ih7fsihI613PdnenkveQxAEg6nwD2sXsuakFFywpDJ0Ky4XJYNzyR0O2NyoQJN0 ZnsUnOCMd913jC8s1VBkd8LIBxzpOsEjGC/Xn+ZN1egkYLYbYKe1HDHl9znZvCsb8qaH yXeQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e39-v6si2222722plg.168.2018.05.16.03.11.23; Wed, 16 May 2018 03:11:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753144AbeEPKJK (ORCPT + 99 others); Wed, 16 May 2018 06:09:10 -0400 Received: from foss.arm.com ([217.140.101.70]:45122 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752832AbeEPKJI (ORCPT ); Wed, 16 May 2018 06:09:08 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 98B9280D; Wed, 16 May 2018 03:09:08 -0700 (PDT) Received: from [10.1.207.55] (melchizedek.cambridge.arm.com [10.1.207.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 947F43F53D; Wed, 16 May 2018 03:09:04 -0700 (PDT) Subject: Re: [PATCH v9 07/11] arm64: kexec_file: add crash dump support From: James Morse To: AKASHI Takahiro 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 References: <20180425062629.29404-1-takahiro.akashi@linaro.org> <20180425062629.29404-8-takahiro.akashi@linaro.org> Message-ID: <512cde7d-d84b-3623-cb09-a2d78acc11dc@arm.com> Date: Wed, 16 May 2018 11:06:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks, James