From: Dave Young <dyoung@redhat.com>
To: AKASHI Takahiro <takahiro.akashi@linaro.org>
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()
Date: Fri, 2 Mar 2018 13:39:45 +0800 [thread overview]
Message-ID: <20180302053945.GD2952@dhcp-128-65.nay.redhat.com> (raw)
In-Reply-To: <20180227044814.24808-7-takahiro.akashi@linaro.org>
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 <takahiro.akashi@linaro.org>
> Cc: Dave Young <dyoung@redhat.com>
> Cc: Vivek Goyal <vgoyal@redhat.com>
> Cc: Baoquan He <bhe@redhat.com>
> ---
> 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);
> 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
next prev parent reply other threads:[~2018-03-02 5:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-27 4:48 [PATCH 0/7] kexec_file: refactoring for other architecutres AKASHI Takahiro
2018-02-27 4:48 ` [PATCH 1/7] kexec_file: make an use of purgatory optional AKASHI Takahiro
2018-03-02 5:58 ` Dave Young
2018-03-02 6:11 ` Dave Young
2018-03-02 7:26 ` AKASHI Takahiro
2018-02-27 4:48 ` [PATCH 2/7] kexec_file,x86,powerpc: factor out kexec_file_ops functions AKASHI Takahiro
2018-03-02 5:04 ` Dave Young
2018-03-02 5:24 ` AKASHI Takahiro
2018-03-02 5:53 ` Dave Young
2018-03-02 6:08 ` Dave Young
2018-03-02 7:16 ` AKASHI Takahiro
2018-03-02 7:56 ` Dave Young
2018-02-27 4:48 ` [PATCH 3/7] x86: kexec_file: purge system-ram walking from prepare_elf64_headers() AKASHI Takahiro
2018-02-27 4:48 ` [PATCH 4/7] x86: kexec_file: remove X86_64 dependency " AKASHI Takahiro
2018-03-02 5:19 ` Dave Young
2018-03-02 5:33 ` AKASHI Takahiro
2018-02-27 4:48 ` [PATCH 5/7] x86: kexec_file: lift CRASH_MAX_RANGES limit on crash_mem buffer AKASHI Takahiro
2018-03-02 5:31 ` Dave Young
2018-03-02 5:36 ` AKASHI Takahiro
2018-02-27 4:48 ` [PATCH 6/7] x86: kexec_file: clean up prepare_elf64_headers() AKASHI Takahiro
2018-03-02 5:39 ` Dave Young [this message]
2018-03-02 5:58 ` AKASHI Takahiro
2018-03-02 6:04 ` Dave Young
2018-02-27 4:48 ` [PATCH 7/7] kexec_file, x86: move re-factored code to generic side AKASHI Takahiro
2018-03-02 5:56 ` [PATCH 0/7] kexec_file: refactoring for other architecutres Dave Young
2018-03-05 2:36 ` Dave Young
2018-03-06 10:28 ` AKASHI Takahiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180302053945.GD2952@dhcp-128-65.nay.redhat.com \
--to=dyoung@redhat.com \
--cc=bauerman@linux.vnet.ibm.com \
--cc=bhe@redhat.com \
--cc=kexec@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mpe@ellerman.id.au \
--cc=prudo@linux.vnet.ibm.com \
--cc=takahiro.akashi@linaro.org \
--cc=vgoyal@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).