linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
To: bsingharora@gmail.com
Cc: kexec@lists.infradead.org,
	Stewart Smith <stewart@linux.vnet.ibm.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Baoquan He <bhe@redhat.com>,
	linuxppc-dev@lists.ozlabs.org, x86@kernel.org,
	"H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	Eric Biederman <ebiederm@xmission.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Thomas Gleixner <tglx@linutronix.de>,
	Dave Young <dyoung@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vivek Goyal <vgoyal@redhat.com>
Subject: Re: [PATCH v5 04/13] powerpc: Factor out relocation code from module_64.c to elf_util_64.c.
Date: Mon, 15 Aug 2016 20:25:51 -0300	[thread overview]
Message-ID: <4126991.2tm6WB17SD@hactar> (raw)
In-Reply-To: <20160815074634.GC21080@balbir.ozlabs.ibm.com>

Am Montag, 15 August 2016, 17:46:34 schrieb Balbir Singh:
> On Thu, Aug 11, 2016 at 08:08:09PM -0300, Thiago Jung Bauermann wrote:
> > +/**
> > + * elf64_apply_relocate_add - apply 64 bit RELA relocations
> > + * @elf_info:		Support information for the ELF binary being 
relocated.
> > + * @strtab:		String table for the associated symbol 
table.
> > + * @symindex:		Section header index for the associated 
symbol table.
> > + * @relsec:		Section header index for the relocations to 
apply.
> > + * @obj_name:		The name of the ELF binary, for information 
messages.
> > + */
> > +int elf64_apply_relocate_add(const struct elf_info *elf_info,
> > +			     const char *strtab, unsigned int symindex,
> > +			     unsigned int relsec, const char *obj_name)
> > +{
> > +	unsigned int i;
> > +	Elf64_Shdr *sechdrs = elf_info->sechdrs;
> > +	Elf64_Rela *rela = (void *)sechdrs[relsec].sh_addr;
> > +	Elf64_Sym *sym;
> > +	unsigned long *location;
> > +	unsigned long value;
> > +
> 
> For the relocatable kernel we expect only
> 
> R_PPC64_RELATIVE
> R_PPC64_NONE
> R_PPC64_ADDR64
> 
> In the future we can use this to check/assert the usage of this
> for the core kernel (vmlinux) when loaded.
> 
> Did we check elf64_apply_relocate_add with zImage and vmlinux?

kexec_file_load doesn't call call elf64_apply_relocate_add on the kernel 
image, it only uses it to relocate the purgatory. So whether it is loading a 
zImage or a vmlinux file, the function will work in the same way since the 
purgatory binary is the same regardless of the kernel image format.

For the same reason, as it currently stands kexec_file_load can't check the 
relocation types used in the kernel image. But it is possible to add such a 
check/assertion in kexec_elf_64.c:build_elf_exec_info if we want.

I tested kexec_file_load on both relocatable and non-relocatable vmlinux and 
it works correctly.

I hadn't tested with zImage yet. I just did, and I had two problems:

1. For some reason, it has an INTERP segment. This patch series doesn't 
support loading program interpreters for ELF binaries, so 
kexec_elf_64.c:build_elf_exec_info refuses to load them.

2. If I disable the check for the INTERP segment, the zImage file loads 
correctly, but then I get an exception during reboot when loading the kexec 
image, right before jumping into the purgatory. I suspect this is because 
the LOAD segment has a virtual address of 0, and the first kernel is not 
coping well with that. But I still have to debug it further.

Is there a reason for the zImage ELF header to request an interpreter and to 
have a virtual address of 0?

-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center

  reply	other threads:[~2016-08-15 23:26 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-11 23:08 [PATCH v5 00/13] kexec_file_load implementation for PowerPC Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 01/13] kexec_file: Allow arch-specific memory walking for kexec_add_buffer Thiago Jung Bauermann
2016-08-13  6:56   ` Balbir Singh
2016-08-11 23:08 ` [PATCH v5 02/13] kexec_file: Change kexec_add_buffer to take kexec_buf as argument Thiago Jung Bauermann
2016-08-15  7:30   ` Balbir Singh
2016-08-15 14:49     ` Thiago Jung Bauermann
2016-08-16  6:15       ` Balbir Singh
2016-08-16 18:49         ` Thiago Jung Bauermann
2016-08-17  2:04           ` Balbir Singh
2016-08-11 23:08 ` [PATCH v5 03/13] kexec_file: Factor out kexec_locate_mem_hole from kexec_add_buffer Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 04/13] powerpc: Factor out relocation code from module_64.c to elf_util_64.c Thiago Jung Bauermann
2016-08-15  7:46   ` Balbir Singh
2016-08-15 23:25     ` Thiago Jung Bauermann [this message]
2016-08-16  6:52       ` Balbir Singh
2016-08-23  3:01         ` Thiago Jung Bauermann
2016-08-23  3:21           ` Balbir Singh
2016-08-24  0:50             ` Oliver O'Halloran
2016-08-24  0:53               ` Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 05/13] powerpc: Generalize elf64_apply_relocate_add Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 06/13] powerpc: Adapt elf64_apply_relocate_add for kexec_file_load Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 07/13] powerpc: Add functions to read ELF files of any endianness Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 08/13] powerpc: Implement kexec_file_load Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 09/13] powerpc: Add code to work with device trees in kexec_file_load Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 10/13] powerpc: Add support for loading ELF kernels with kexec_file_load Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 11/13] powerpc: Allow userspace to set device tree properties in kexec_file_load Thiago Jung Bauermann
2016-08-12  0:45   ` Samuel Mendoza-Jonas
2016-08-12  0:54     ` Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 12/13] powerpc: Add purgatory for kexec_file_load implementation Thiago Jung Bauermann
2016-08-11 23:08 ` [PATCH v5 13/13] powerpc: Enable CONFIG_KEXEC_FILE in powerpc server defconfigs Thiago Jung Bauermann

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=4126991.2tm6WB17SD@hactar \
    --to=bauerman@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=bhe@redhat.com \
    --cc=bsingharora@gmail.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=hpa@zytor.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=stewart@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=vgoyal@redhat.com \
    --cc=x86@kernel.org \
    /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).