Received: by 10.223.185.116 with SMTP id b49csp4546380wrg; Mon, 26 Feb 2018 21:10:02 -0800 (PST) X-Google-Smtp-Source: AH8x226XK9Bf+9iKbZ+YQIqtq0Qc5D1MucZBUMMq8veuiHklJ1nV86+o9Gi6JIoCQBAYDxn8zaQo X-Received: by 2002:a17:902:42a3:: with SMTP id h32-v6mr13315144pld.231.1519708202427; Mon, 26 Feb 2018 21:10:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519708202; cv=none; d=google.com; s=arc-20160816; b=gcn7xhFcyhIbLTVelbbxSPcz3dQRz6x7EkbgPlbSyWE2zwamBrDp5GZfPeC7lPqmhB 9ZOhcS0mlToBbHjXoul/Q1HTTBZcGwPd/OTxSuwVt20gRcMmH3LevDr1w6WYkxgReJeB piLn0xP5kJDSoDfEnMIXHkhdkB+pnN7nmkrRxxFTwVAng54eoVhhnheCul6E63BXTJDT PjgQ9PfWb/UFffp1H2Yrb5j15tTt7v/K4MmiiM2FQ2I/Ait3hQjNwB3KHq7NGbaH/J5J MhO+IKsNoMUqmbVqunCBfmEGNMsOfjFl2n12SVdyXNRaVJ6Uke8VKh7LH6nbYFcQWE9G glXw== 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=xn902+Uwdq4r1q+SLbai3XhIDKcpWgF42j/eR9GRetQ=; b=RGMESTE0BDhdwnVHszzLeOJ5h302Y6T6LONQ8ZtYGMFXYxou5BBPIBC2cOebcecosv QEaWk/xMUojQBSB8QZgOcldgPDRTU38cc7jsLvtlAkB+PFU5Y7tyzOx3DQpNWzj9i/hJ DiRiV57hw7LCUoLFIpGqiNChRG248D/bHoLHlyrVL8OP/DLFGxqQyRJfhOex+oUXgsoX WrcWyro8ctkq5+liQztpyUjd7K7hPuYQY9hMaU8D+D/B7/PbA2vEXbnB0mqOQiIVYcmO jnTiSyZaRQTH+okrRGcI5fulMFlemkZ/wTNxk6dZ1P8SplomPKGA+eUCK92YcKqhKI1d vU4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Th7R5DWF; 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 t64si6512406pgb.294.2018.02.26.21.09.46; Mon, 26 Feb 2018 21:10:02 -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=Th7R5DWF; 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 S1752134AbeB0EtO (ORCPT + 99 others); Mon, 26 Feb 2018 23:49:14 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:42799 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751961AbeB0EtK (ORCPT ); Mon, 26 Feb 2018 23:49:10 -0500 Received: by mail-pg0-f67.google.com with SMTP id y8so7097468pgr.9 for ; Mon, 26 Feb 2018 20:49:10 -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=xn902+Uwdq4r1q+SLbai3XhIDKcpWgF42j/eR9GRetQ=; b=Th7R5DWFFSc0Sz9ylMr0i8bbc6QkY8N1lfR+Tp7WKugaQM+TsqzInTNv6drRlATY9E ANMmFOGlyUPSibGXOYbtfpvIuP66KXj+1zSiAPJ+pO6ChG+62Zm/Izpq+hZktwLwIU2x dBUj1KwwibsChmfnYlon8nHPtRUDPLYaSjGrE= 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=xn902+Uwdq4r1q+SLbai3XhIDKcpWgF42j/eR9GRetQ=; b=MCa0rovdDTCuu+0o6cuEY9nb587D/PaOwlF/V2uFWnhCr2yhE7WlVmm2Ddl0yEcf3t Kl5ThWF4Eu1/8W9sg7YqYd2aZDRYvnQyctB6x4taUHdTtNvLEkAbW+adizPBOmf2OUzC tXrqfOtBgYfWchvtFEqBoTd4Znc7FzegiFQ0/leiEprVqN2PnFYkIqKXWAu4RWt4sRCN rChwZy9KB1RqiTkNBM1Z7kljI/JesCllyIMjv0bsVLK3EiNYBU3y2nfN92UDewXGw5+W kgrLTWWwVczjtjAj1kMtJbzizYzU1qoqIp5FkAovzu+bfFIc9CueEmuqZhYs8GOvOUWD 0zHg== X-Gm-Message-State: APf1xPDpJ+3stlM5VwYyk250RmWRUfxesExCbfJ1WdnLmBFFMDL0zhqI olKMuUIL5KZViJ7+rZkUVrplIA== X-Received: by 10.98.137.90 with SMTP id v87mr12879685pfd.80.1519706949883; Mon, 26 Feb 2018 20:49:09 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id h75sm21246815pfh.28.2018.02.26.20.49.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2018 20:49:09 -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 6/7] x86: kexec_file: clean up prepare_elf64_headers() Date: Tue, 27 Feb 2018 13:48:13 +0900 Message-Id: <20180227044814.24808-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180227044814.24808-1-takahiro.akashi@linaro.org> References: <20180227044814.24808-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 bfc37ad20d4a..a842fd847684 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -334,7 +334,7 @@ static int prepare_elf64_headers(struct crash_mem *cmem, int 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; @@ -359,9 +359,8 @@ static int prepare_elf64_headers(struct crash_mem *cmem, int 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; @@ -377,33 +376,30 @@ static int prepare_elf64_headers(struct crash_mem *cmem, int 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