Received: by 10.223.185.116 with SMTP id b49csp8311474wrg; Thu, 1 Mar 2018 22:40:02 -0800 (PST) X-Google-Smtp-Source: AG47ELuu/+z5cbzQRLFKIRhEkXwjCtctbeqk56vXgAoRRZtPnrBZiy4NC6qJhJhudYXW9ZsA3VCl X-Received: by 10.167.129.129 with SMTP id g1mr4641230pfi.224.1519972802671; Thu, 01 Mar 2018 22:40:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519972802; cv=none; d=google.com; s=arc-20160816; b=j7TRzr3eL7cK94olJM8f91f8c5jr4MLU0Q+04B1T6X6vbf5YN4umEhdkUFzjQWgxIk ea3GsDqzUmTaiaKN9VTcPnRyX07aCa6lt0G8X4WSdMAPbLwNOROUMbDiyGPypcZn94O4 flhpL8Mtfc74VBUk2qW85cOaEFcGgymoQU/CQ61NjcxU6rYniSyOiSFXQkrdxGm2Ls2w kZQmng1SaxuHOjCAuSywOqH9dWsum/9LTyl6jCnWFa8xp8HMYx3bCVK1fWEKXXfNWwFD t2d7GGeqKqAKgBOqqGaKyheRC+Pzeo124/fet8EG6urvIFt2SwEfNjegy/YZY4JiwezK hdPA== 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:message-id:subject:to :from:date:arc-authentication-results; bh=eT1zNEUmBXLKtH1q61jd7JpYdgvNNENhFsDwCwtKFXg=; b=Uda++Xz0tS2syY8VvpeEx9ISu1q0BXlM7mmc2yMWi88gevOhcpRQZWRIpRvLNtVWHw HK2wQhvoEet8FGEERlSpbAlIaeu/GKd6gAe2+AeSKHMokxn6mo23fQTLWOaqu60Oy0jN zDsXCLpto90BAI/hejJf76BZaOlFSGP6FfmkcjtVGaWFJUpGwhbxt0VLEdoE0DXUpRXd s9+/Kd8+d0Hd9UAawVB33+dVl45jYH1G8wk75d1yreIFlKmxF1Vwb2YaXH8GxLAsJjow e88OXnHoUjE8WhTPyFreK6MnwxBEuKH+lkLEPzZ2q2WHSWc8cWaIOmG/Rjbo5Q+m8A3n dh/Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2-v6si4323469plk.792.2018.03.01.22.39.46; Thu, 01 Mar 2018 22:40: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935899AbeCBGEg (ORCPT + 99 others); Fri, 2 Mar 2018 01:04:36 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38910 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932310AbeCBGEe (ORCPT ); Fri, 2 Mar 2018 01:04:34 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C14E287ABA; Fri, 2 Mar 2018 06:04:33 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-90.pek2.redhat.com [10.72.12.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0FC2C10AF9F2; Fri, 2 Mar 2018 06:04:28 +0000 (UTC) Date: Fri, 2 Mar 2018 14:04:24 +0800 From: Dave Young To: AKASHI Takahiro , 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: <20180302060424.GC15422@dhcp-128-65.nay.redhat.com> References: <20180227044814.24808-1-takahiro.akashi@linaro.org> <20180227044814.24808-7-takahiro.akashi@linaro.org> <20180302053945.GD2952@dhcp-128-65.nay.redhat.com> <20180302055845.GR6019@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180302055845.GR6019@linaro.org> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 02 Mar 2018 06:04:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 02 Mar 2018 06:04:34 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dyoung@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/02/18 at 02:58pm, AKASHI Takahiro wrote: > 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? Oops, I interpret it as (Elf64_Phdr *)ehdr + 1; Please ignore this comment then. > > -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