Hi,

due to the previous armv7 non-EFI history, our current efiboot on armv7
still manually modifies a symbol in the kernel before booting it.

Since efiboot for arm64 was copied from armv7, this code is still there
and the mechanism is partially in use.  Why partially?  Well, we pass
the virtual address of esym, which we calculated in efiboot, to the
kernel and the kernel then overwrites the variable again.  So there is
no actual sense in doing that in the bootloader.

Instead, I would prefer to pass the physical address, so that efiboot
does not have to do any virtual address juggling.  Instead, we let the
kernel find out which virtual address the end of symbols is by using
the delta.

Bump the version while there to show the change.

ok?

Patrick


Index: arm64/locore.S
===================================================================
RCS file: /cvs/src/sys/arch/arm64/arm64/locore.S,v
retrieving revision 1.6
diff -u -p -u -r1.6 locore.S
--- arm64/locore.S      23 Jan 2017 13:43:50 -0000      1.6
+++ arm64/locore.S      3 Feb 2017 10:02:12 -0000
@@ -82,6 +82,7 @@ _start:
        adr     x0, .Lesym
        ldr     x0, [x0]
        sub     x0, x0, x29
+       add     x21, x21, x29
        str     x21, [x0]
 
        /*
Index: stand/efiboot/conf.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/stand/efiboot/conf.c,v
retrieving revision 1.1
diff -u -p -u -r1.1 conf.c
--- stand/efiboot/conf.c        17 Dec 2016 23:38:33 -0000      1.1
+++ stand/efiboot/conf.c        3 Feb 2017 10:02:12 -0000
@@ -35,7 +35,7 @@
 #include "efiboot.h"
 #include "efidev.h"
 
-const char version[] = "0.1";
+const char version[] = "0.2";
 int    debug = 0;
 
 struct fs_ops file_system[] = {
Index: stand/efiboot/exec.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/stand/efiboot/exec.c,v
retrieving revision 1.2
diff -u -p -u -r1.2 exec.c
--- stand/efiboot/exec.c        23 Jan 2017 12:02:14 -0000      1.2
+++ stand/efiboot/exec.c        3 Feb 2017 10:02:12 -0000
@@ -35,29 +35,9 @@ typedef void (*startfuncp)(void *, void 
 void
 run_loadfile(u_long *marks, int howto)
 {
-       Elf_Ehdr *elf = (Elf_Ehdr *)marks[MARK_SYM];
-       Elf_Shdr *shp = (Elf_Shdr *)(marks[MARK_SYM] + elf->e_shoff);
-       u_long esym = marks[MARK_END] & 0x000fffffff;
-       u_long offset = 0;
        char args[256];
        char *cp;
        void *fdt;
-       int i;
-
-       /*
-        * Tell locore.S where the symbol table ends by setting
-        * 'esym', which should be the first word in the .data
-        * section.
-        */
-       for (i = 0; i < elf->e_shnum; i++) {
-               /* XXX Assume .data is the first writable segment. */
-               if (shp[i].sh_flags & SHF_WRITE) {
-                       /* XXX We have to store the virtual address. */
-                       esym |= shp[i].sh_addr & 0xffffff8000000000;
-                       *(u_long *)(LOADADDR(shp[i].sh_addr)) = esym;
-                       break;
-               }
-       }
 
        snprintf(args, sizeof(args) - 8, "%s:%s", cmd.bootdev, cmd.image);
        cp = args + strlen(args);
@@ -81,7 +61,7 @@ run_loadfile(u_long *marks, int howto)
 
        efi_cleanup();
 
-       (*(startfuncp)(marks[MARK_ENTRY]))((void *)esym, 0, fdt);
+       (*(startfuncp)(marks[MARK_ENTRY]))((void *)marks[MARK_END], 0, fdt);
 
        /* NOTREACHED */
 }

Reply via email to