Message ID | 873e73a998c198de69f6f01f92176be2b613c500.1408736066.git.geoff@infradead.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Aug 22, 2014 at 08:49:15PM +0100, Geoff Levand wrote: > The recent addition of EFI support has changed the way the arm64 kernel > image is entered based on whether or not CONFIG_EFI is defined. To support > this conditional entry point add a new global symbol start to head.S that > marks the entry, and change the the linker script ENTRY() command to define > start as the kernel entry. I don't yet understand what the problem is. The _text symbol is currently defined in vmlinux.lds.S to be the beginning of the .head.text section. Whether we have CONFIG_EFI or not, the entry point is the same.
On 26 August 2014 17:55, Catalin Marinas <catalin.marinas@arm.com> wrote: > On Fri, Aug 22, 2014 at 08:49:15PM +0100, Geoff Levand wrote: >> The recent addition of EFI support has changed the way the arm64 kernel >> image is entered based on whether or not CONFIG_EFI is defined. To support >> this conditional entry point add a new global symbol start to head.S that >> marks the entry, and change the the linker script ENTRY() command to define >> start as the kernel entry. > > I don't yet understand what the problem is. The _text symbol is > currently defined in vmlinux.lds.S to be the beginning of the .head.text > section. Whether we have CONFIG_EFI or not, the entry point is the same. > First of all, the 'add x13, x18, #0x16' was carefully chosen to be both a "MZ" prefix and an executable instruction without any harmful side effects. So currently, the EFI stub jumps to that add instruction, and not to the 'b stext' that comes after. There is an issue with that, which I have already proposed a patch for (arm64/efi: efistub: jump to 'stext' directly, not through the header), but this is related to the guarantees the UEFI spec gives about where the header gets loaded (if at all). However, going back to your patch, setting ENTRY() only affects the vmlinux ELF image, and this information gets stripped when creating the binary. Do you need the entry point to be set so you can load vmlinux using the debugger, perhaps? In that case, did you have any problems branching to the add instruction? If so, I would like to know about it.
Hi, On Tue, 2014-08-26 at 18:19 +0200, Ard Biesheuvel wrote: > First of all, the 'add x13, x18, #0x16' was carefully chosen to be > both a "MZ" prefix and an executable instruction without any harmful > side effects. OK, I didn't look so closely to realize this was an instruction with out side effects. > So currently, the EFI stub jumps to that add > instruction, and not to the 'b stext' that comes after. There is an > issue with that, which I have already proposed a patch for (arm64/efi: > efistub: jump to 'stext' directly, not through the header), but this > is related to the guarantees the UEFI spec gives about where the > header gets loaded (if at all). > > However, going back to your patch, setting ENTRY() only affects the > vmlinux ELF image, and this information gets stripped when creating > the binary. Do you need the entry point to be set so you can load > vmlinux using the debugger, perhaps? In that case, did you have any > problems branching to the add instruction? If so, I would like to know > about it. kexec-tools [1] can load vmlinux elf files, and uses ehdr.e_entry as the kernel entry point. I tested without this patch (branching to _text), and it works OK, so we can drop this patch. -Geoff [1] https://git.linaro.org/people/geoff.levand/kexec-tools.git -Geoff
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 144f105..4019b85 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -100,6 +100,8 @@ */ __HEAD +.globl start + /* * DO NOT MODIFY. Image header expected by Linux boot-loaders. */ @@ -110,8 +112,10 @@ efi_head: * its opcode forms the magic "MZ" signature required by UEFI. */ add x13, x18, #0x16 +start: b stext #else +start: b stext // branch to kernel start, magic .long 0 // reserved #endif diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 97f0c04..fbb1af7 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -15,7 +15,7 @@ #define ARM_EXIT_DISCARD(x) x OUTPUT_ARCH(aarch64) -ENTRY(_text) +ENTRY(start) jiffies = jiffies_64;
The recent addition of EFI support has changed the way the arm64 kernel image is entered based on whether or not CONFIG_EFI is defined. To support this conditional entry point add a new global symbol start to head.S that marks the entry, and change the the linker script ENTRY() command to define start as the kernel entry. Signed-off-by: Geoff Levand <geoff@infradead.org> --- arch/arm64/kernel/head.S | 4 ++++ arch/arm64/kernel/vmlinux.lds.S | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)