From patchwork Tue Feb 27 04:48:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10244291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C259F602DC for ; Tue, 27 Feb 2018 04:52:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2CE528334 for ; Tue, 27 Feb 2018 04:52:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A64A52871A; Tue, 27 Feb 2018 04:52:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5D91A28334 for ; Tue, 27 Feb 2018 04:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UZUhRIh5cAjHfDg9l27ARPYEfz4zJ5oSuhAp0g+PZHk=; b=l1KRDEFo1HaSA3Zdz5wpdnwYxT dt68kVq5iIDqWlQAFtMhGDNKqQjFdPvNUik1qw3gyYTkxGbi12Tn5dfqGNRkUax25KtqR9ijunJVU oqfNHqVdorBA3horUzhi4jFpDLIxQvFMiPHjcQiGuT3/jzlxv8DRCRzHttful2scL533uQIpL9TUT stZQAz+ZhnlFvMNaXMFLqS6SrxO50SnvMHVy3cPKafGsGrc85zhWWta3nsHRjOp3e84BW/ljVQ3cs Ei0Vt/0dBvV7kHiOatY78FDN2nfbV1E05iZrcPomTu+L78hfIPBm6bvcXcDLNZA7p9XxXO3fniQHK Q4t9rrIA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqXFs-0008Vn-Sx; Tue, 27 Feb 2018 04:52:44 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqXCl-0005ko-9V for linux-arm-kernel@bombadil.infradead.org; Tue, 27 Feb 2018 04:49:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xn902+Uwdq4r1q+SLbai3XhIDKcpWgF42j/eR9GRetQ=; b=kdx1rL/hp5dZxDE1MA8ES0qsl b68ezPH5ustvRmUybepjbWv0FUjSifxbaoUJkXwihRvkD0s7TUYLbbFsGPZ6O8O1dXJLcKRBwhGxB 6a3h5ZceJRmcMpgosihCJnoV5dMvuvKQ1IEqMElKQRnc9EvT6XDD+IkYu61469DHbRh/dxniSTyvb 6lAST9gdtohQOJzDIigcDZi2AoyIofsLwiVfz5kDl5xePdNfmJnu62YwTmaVi5Tb7Tf4i5lbEPpRI XhK6e1I1lPkGjqma8glxgTGJdMo1FavlZw/vNoeyLPGg/9FLZyQhjO51ChoPIP4wCAIGvZle8p9HD aOz1/0RZg==; Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqXCg-000403-Ir for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2018 04:49:29 +0000 Received: by mail-pg0-x242.google.com with SMTP id e11so7093095pgq.12 for ; Mon, 26 Feb 2018 20:49:12 -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=XfJ+d/DdU2v6h0Z+b94BeuwgV9+2T4tgbjerGa+2E+iBTel5L5SrK34bhHAhK6ZS7O LD4VmAzqfCUj6XSPF/xJkjoZjg1qEQfkKTKDed6/DHETxK4pu9EtgShdCXGVoP1G7XJP 2D//XbY7BCrBq8B5X5xLpeUE9bHEz1awnsSeKLLiu2tVueR/JG7rq+WVRpeZ2+7RuyJT 9psZI3d7ZETeV/Hvt2SufDJvWXDIUwexNXz3DKG2LelynPcKIOqLmq+udCOZ9WxA+t6B ppyl4BhmBfL1FB8BXqedzTi4YAFB7wjVOXmbEJkRyLGbfPPme3W0b/h/ZN+iRMQTYeXf pO/Q== X-Gm-Message-State: APf1xPA30vGC7+zN584IfPPM04T+l+PPtBkNwCY8vcnDEk9sehKi6Og0 vb4fzUtgSo+kn2k1ikx4dxh5nQ== X-Google-Smtp-Source: AH8x2258AJxUVmHnSiPAtQq54ea/S9u+yjIm4V3cdVsauFN3Zk3chHdoTx6W7yGjGCBRaaZwW9rewg== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180226_234926_639853_CD49519D X-CRM114-Status: GOOD ( 12.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-s390@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, AKASHI Takahiro MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 */