Received: by 10.223.185.116 with SMTP id b49csp8284189wrg; Thu, 1 Mar 2018 22:00:55 -0800 (PST) X-Google-Smtp-Source: AG47ELt60+Wco9adkCBdU8WyQouZOci33pfXkE+jgHhLinHZwlBqMgR4LTTnCOjNs6+QhEJqFgZu X-Received: by 10.98.8.219 with SMTP id 88mr4588315pfi.4.1519970454957; Thu, 01 Mar 2018 22:00:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519970454; cv=none; d=google.com; s=arc-20160816; b=nnLHDYtauJj7zLiGL1fH7Swg5xnXh6H0T5PC+va2ey6iQowA/x1jL27UBFt+x/6jY8 XSVJp3kAuO4n4WbY9JR/y7oFBYFAE7lCGEXicgqvK+Dprsq86MvqiXAYMpE5GyV9OFhG 2OJogAHHETMaA1h6dwHznXRTkcCcN5J76toamNoYmC/qmeWGVZpsgTUmwp6JYYI7u6mg NW+dFixkSo8N12QN4mgP7erPJJbG8UgPGZxpncg0ziZgZBF1Fc2gFtz+D0qpoo0h87hG 4zFrOWB2FMgohhJPAZL2BOE6w9EPPPuG/Q5hKmtky642UCWhCHFfGrWnG8EwNmhA8lT4 Omow== 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=FnHXo2hMzA7NzOQzSKHPpGZ5ETkcHDp5jU08ysbBLsY=; b=xybScHSUOVrecnTmA3v+uK+nQgLIC2SaKDVEOVShzEwAmTYItPQjDluUI7vnEz8RRS wwISaDypRZmXnhlblp6T5/dewR1NE2CiF3ldy6pTjBhxjO6vZhoxbxTDHialCV12cETr 5kAxzq4X9fAPG1DqnvNOPBGuQUgxd9mhAPNa2B6tt+8l9SIhxbPUROv+MBLRjwNty/+M F0s4JZ17IrNi+udaIQK3VxiTaDGEhC+HZRI2naNOmZ+gycT6+3OWHpTm/ojOmYwaW8j6 REYG8YdBmAaGgwjHj82Uj2yW83SHI25UC+7AAL0G/zojW4aIjovunTgmg3JNUcg+r1T0 z/JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=czoYj/5l; 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 q4-v6si4262409plb.29.2018.03.01.22.00.40; Thu, 01 Mar 2018 22:00:54 -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=czoYj/5l; 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 S935790AbeCBF6j (ORCPT + 99 others); Fri, 2 Mar 2018 00:58:39 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:34795 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932309AbeCBF6g (ORCPT ); Fri, 2 Mar 2018 00:58:36 -0500 Received: by mail-pl0-f65.google.com with SMTP id u13-v6so5104687plq.1 for ; Thu, 01 Mar 2018 21:58:36 -0800 (PST) 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=FnHXo2hMzA7NzOQzSKHPpGZ5ETkcHDp5jU08ysbBLsY=; b=czoYj/5l77nKOEdlmXaLfMl8KWIcLJgGO3dJPobSgJWsN/w+XGiyed8cWJvuVGHPBe 5QlA1yWOrilo5n5QGEtNsgF9kjsZzbOnQmy02vzS8Gkqu/GJ6DTR8GzQBJsDDwOH0893 VGg385f5ZolLJEQx+jrRVasuK8boIO+NtjhAs= 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=FnHXo2hMzA7NzOQzSKHPpGZ5ETkcHDp5jU08ysbBLsY=; b=UjwjGygtOX5omQIPM+SvlHfcMX1+izEklj15OvOVmCIkqINHIcmh8D8unphS7faQj3 RvuNBUgP8v9lXC0a+qiNZbXZvTwtUzi/gEKAppHxQJHgNPRtXyEmiRiJeWEUcXie8x67 irfHzh5x1vc06EaIg2i7mMeL5Nobu54vDC8wifqyyfy7ihLot31A6Jl45gf+jq9pwtY1 DMm9Q/QhLmlfwFJo2AF5IxBweF10dkFxdG9ykpIA37qv7oFuvaAmJrS1XDsDKSmjmjjp 82v/+mRuKv25NW8TqJCp2xEC/G9bfG6Sq9rwMFkh056dVjxDXzb/FErWY72fMyWQWCWx vFfA== X-Gm-Message-State: APf1xPDPxoylP6QLHnxylw8JyU4/b8yQBb3OjzavBuySoaAPeFWi9G5B POFZpGYKIIPfoccB4pIWyaS8COu3RfM= X-Received: by 2002:a17:902:4581:: with SMTP id n1-v6mr4391037pld.135.1519970315928; Thu, 01 Mar 2018 21:58:35 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id p9sm9824087pgs.89.2018.03.01.21.58.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 21:58:35 -0800 (PST) Date: Fri, 2 Mar 2018 14:58:48 +0900 From: AKASHI Takahiro To: Dave Young Cc: vgoyal@redhat.com, bhe@redhat.com, mpe@ellerman.id.au, bauerman@linux.vnet.ibm.com, prudo@linux.vnet.ibm.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: Re: [PATCH 6/7] x86: kexec_file: clean up prepare_elf64_headers() Message-ID: <20180302055845.GR6019@linaro.org> Mail-Followup-To: AKASHI Takahiro , Dave Young , vgoyal@redhat.com, bhe@redhat.com, mpe@ellerman.id.au, bauerman@linux.vnet.ibm.com, prudo@linux.vnet.ibm.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org References: <20180227044814.24808-1-takahiro.akashi@linaro.org> <20180227044814.24808-7-takahiro.akashi@linaro.org> <20180302053945.GD2952@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180302053945.GD2952@dhcp-128-65.nay.redhat.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 Fri, Mar 02, 2018 at 01:39:45PM +0800, Dave Young wrote: > On 02/27/18 at 01:48pm, AKASHI Takahiro wrote: > > 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); > > phdr should start with ehdr + sizeof(Elf64_Ehdr); Well, it's a matter of rhetoric :) The values from both expressions are the same. Or do you mean my expression is confusing? -Takahiro AKASHI > > 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 > > > > Thanks > Dave