Received: by 10.223.185.116 with SMTP id b49csp3637650wrg; Tue, 6 Mar 2018 02:25:17 -0800 (PST) X-Google-Smtp-Source: AG47ELvYkjj52FNrux9sGTYMbdDJMgPBnsrSv4/FJG63UpXisEBwRIQSHDyMrEzOg12R/C9CWXuZ X-Received: by 10.98.194.219 with SMTP id w88mr18529465pfk.26.1520331917670; Tue, 06 Mar 2018 02:25:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520331917; cv=none; d=google.com; s=arc-20160816; b=lurVek95GdZIu7GrvLXr7BoCiKyn0rCmm/K7jaQ7A1r9cGVsYLZktECPZhHyUwk26j mYPeUwqkvAtwSbAWZ4jCzHLmSMtcmSMZzu1ouGmnM9mjVGbM1P4i8L0uKNMYRa0992Mg gx2yR2pzn2FDQxQCYQF8WodmzABSJEKamyIJgHW90tmD2K8LCBixehHLwA+PcvsMQX5N MeOnYVYQIz+jcBerC1Hy0Wcwj7C/S40qekl75pw3ZfddvyCLaplbh/+KMCMaHmvyBy8/ P566hGJLxDEskvQk4oZjNINfmFZpi7Voqa8QscLOYA+M0Q2y9PAwwgJ8CKyHZH9vU41R h8mQ== 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:dkim-signature:arc-authentication-results; bh=cvruR1fK+YTngn6oDfuQqc3wPWykq+0V2AulaM5gBOY=; b=avhMwji5MKYCPLqhsgXIIsqFkD0X9LEmF8iR2Rq2PF+sEN2mMfxhxakHosniTWU9Vp tdPnBDKjKr2cP7H12sg2XTrxwSDAQzL5USai6FZeQ/yq8OJ8EPemALufy4xDdp2kOWMp q75rNone/T6VEDXYQmoaH15tdxzsxC+0h5qTodYOahchpzJo3F2QUwnNSgzyPNCNvE67 +ocp4CYo5bW1mwjxBgChrNCTC59M44H43J726FJG/+CgGrFUw9WQqLM5ITBhgQL6tpax s1eOJXVJUYI+S0YylABko1A+dw0hJoTynWEAvUhLY+UQ5HS0jJLpjWzbLAgZZLZT/Jjs MzHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E83ezOS7; 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 w10si9599280pgv.486.2018.03.06.02.25.03; Tue, 06 Mar 2018 02:25:17 -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; dkim=pass header.i=@linaro.org header.s=google header.b=E83ezOS7; 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 S1753529AbeCFKXo (ORCPT + 99 others); Tue, 6 Mar 2018 05:23:44 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:46671 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753305AbeCFKXj (ORCPT ); Tue, 6 Mar 2018 05:23:39 -0500 Received: by mail-io0-f193.google.com with SMTP id p78so21481568iod.13 for ; Tue, 06 Mar 2018 02:23:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cvruR1fK+YTngn6oDfuQqc3wPWykq+0V2AulaM5gBOY=; b=E83ezOS7joLwYiR1oFoCW9mbVBxVMzbx8Th2Qkzg6g4NOhrAs4MTwj9e+zBnI3HUV3 lrNH6SL1PzC6JemSGWg5ugv9fao45TQxWyyW9nl5mLoztkF0Cqx85/2upNW2M3UobIO4 dYKIjPKjsMKM0xFaEGu28uGpyTSfiJm2N+w/E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cvruR1fK+YTngn6oDfuQqc3wPWykq+0V2AulaM5gBOY=; b=q+/zS3290oHg2tsAvJnKasKRAWhM8JJMss+6pZav/9yn+nRGC/9SxONUWkGOlrQsSn O3NuHPIZ+zXHvhNcaCwPpAk19sLkkFMaFSdLDe/F5XH81jZzm3NQjJqgVD9DYrl9nMxs vrufYY0nwVwyhekm63RECDPy/EYQBAdUXLteMXra91HwdXub54rlBsy/kwGihGKzLpwj lCzA/B7+F1Al6d+GdGdHi2INQRmOTXprTQ8t9XJogM9Tbw8sMsDV+YWmfuqgEI95ou1o Ci7NQMo+GFRLQneBe81BVZIVZOy4SC8xi4pfTDkAzG0D6yI4Q1dtC8Xt8ps5wcSvv5tu naxA== X-Gm-Message-State: APf1xPBafVN3FzeehfAfZpZHmMhBDmmg/CVWwWIqrNuolVqcBNyNM7kn VXPCXGc1xdB2ZkpzHaKObQmKhw== X-Received: by 10.107.175.151 with SMTP id p23mr20299484ioo.215.1520331818831; Tue, 06 Mar 2018 02:23:38 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id i197sm9909999ioe.54.2018.03.06.02.23.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 02:23:38 -0800 (PST) From: AKASHI Takahiro To: dyoung@redhat.com, vgoyal@redhat.com, bhe@redhat.com, mpe@ellerman.id.au, bauerman@linux.vnet.ibm.com, prudo@linux.vnet.ibm.com Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v2 6/7] x86: kexec_file: clean up prepare_elf64_headers() Date: Tue, 6 Mar 2018 19:23:02 +0900 Message-Id: <20180306102303.9063-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180306102303.9063-1-takahiro.akashi@linaro.org> References: <20180306102303.9063-1-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org removing bufp variable in prepare_elf64_headers() makes the code simpler and more understandable. Signed-off-by: AKASHI Takahiro Cc: Dave Young Cc: Vivek Goyal Cc: Baoquan He --- arch/x86/kernel/crash.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 0f20a6330bd6..24de3f13f40c 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -336,7 +336,7 @@ static int prepare_elf64_headers(struct crash_mem *cmem, bool kernel_map, Elf64_Ehdr *ehdr; Elf64_Phdr *phdr; unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; - unsigned char *buf, *bufp; + unsigned char *buf; unsigned int cpu, i; unsigned long long notes_addr; unsigned long mstart, mend; @@ -361,9 +361,8 @@ static int prepare_elf64_headers(struct crash_mem *cmem, bool kernel_map, if (!buf) return -ENOMEM; - bufp = buf; - ehdr = (Elf64_Ehdr *)bufp; - bufp += sizeof(Elf64_Ehdr); + ehdr = (Elf64_Ehdr *)buf; + phdr = (Elf64_Phdr *)(ehdr + 1); memcpy(ehdr->e_ident, ELFMAG, SELFMAG); ehdr->e_ident[EI_CLASS] = ELFCLASS64; ehdr->e_ident[EI_DATA] = ELFDATA2LSB; @@ -379,33 +378,30 @@ static int prepare_elf64_headers(struct crash_mem *cmem, bool kernel_map, /* Prepare one phdr of type PT_NOTE for each present cpu */ for_each_present_cpu(cpu) { - phdr = (Elf64_Phdr *)bufp; - bufp += sizeof(Elf64_Phdr); phdr->p_type = PT_NOTE; notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); phdr->p_offset = phdr->p_paddr = notes_addr; phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); (ehdr->e_phnum)++; + phdr++; } /* Prepare one PT_NOTE header for vmcoreinfo */ - phdr = (Elf64_Phdr *)bufp; - bufp += sizeof(Elf64_Phdr); phdr->p_type = PT_NOTE; phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; (ehdr->e_phnum)++; + phdr++; /* Prepare PT_LOAD type program header for kernel text region */ if (kernel_map) { - phdr = (Elf64_Phdr *)bufp; - bufp += sizeof(Elf64_Phdr); phdr->p_type = PT_LOAD; phdr->p_flags = PF_R|PF_W|PF_X; phdr->p_vaddr = (Elf64_Addr)_text; phdr->p_filesz = phdr->p_memsz = _end - _text; phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); - (ehdr->e_phnum)++; + ehdr->e_phnum++; + phdr++; } /* Go through all the ranges in cmem->ranges[] and prepare phdr */ -- 2.16.2