[U-Boot] [PATCH v4 00/21] sandbox: efi_loader support

Alexander Graf agraf at suse.de
Mon Jun 18 15:53:52 UTC 2018


On 06/18/2018 05:22 PM, Alexander Graf wrote:
> This patch set augments Simon's patch set for efi_loader support
> in sandbox[1], but cuts off the memory allocation scheme at a different
> point.
>
> According to the UEFI spec, efi_allocate_pages() takes a uint64_t *
> argument. Via this argument, we get a physical address as input, but
> emit a pointer as output.
>
> With this patch set in place, I can successfully run the selftest suite
> as well as an aarch64 grub.efi binary. X86_64 grub.efi doesn't work
> because that one requires inl instructions to work.

I've assembled a quick grub.efi that does work in sandbox as it no 
longer accesses I/O ports directly. Patch for it is below.

   http://csgraf.de/tmp2/grub.efi

When building your own, make sure to exclude coreboot (cb*) modules - 
they seem to do something dirty and segfault for me. The other modules 
seem to work fine for me so far.


Alex


diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
index f266eb131..99fc9f7fb 100644
--- a/grub-core/kern/i386/tsc.c
+++ b/grub-core/kern/i386/tsc.c
@@ -68,7 +68,7 @@ grub_tsc_init (void)
  #ifdef GRUB_MACHINE_XEN
    (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
  #elif defined (GRUB_MACHINE_EFI)
-  (void) (grub_tsc_calibrate_from_pmtimer () || 
grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_efi() || 
calibrate_tsc_hardcode());
+  (void) (grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode());
  #elif defined (GRUB_MACHINE_COREBOOT)
    (void) (grub_tsc_calibrate_from_pmtimer () || 
grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
  #else
diff --git a/include/grub/i386/io.h b/include/grub/i386/io.h
index ae12a3e3d..9fbeef916 100644
--- a/include/grub/i386/io.h
+++ b/include/grub/i386/io.h
@@ -26,47 +26,40 @@ typedef unsigned short int grub_port_t;
  static __inline unsigned char
  grub_inb (unsigned short int port)
  {
-  unsigned char _v;
+  unsigned char _v = 0;

-  __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port));
    return _v;
  }

  static __inline unsigned short int
  grub_inw (unsigned short int port)
  {
-  unsigned short _v;
+  unsigned short _v = 0;

-  __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port));
    return _v;
  }

  static __inline unsigned int
  grub_inl (unsigned short int port)
  {
-  unsigned int _v;
+  unsigned int _v = 0;

-  __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port));
    return _v;
  }

  static __inline void
  grub_outb (unsigned char value, unsigned short int port)
  {
-  __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port));
  }

  static __inline void
  grub_outw (unsigned short int value, unsigned short int port)
  {
-  __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port));
-
  }

  static __inline void
  grub_outl (unsigned int value, unsigned short int port)
  {
-  __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port));
  }

  #endif /* _SYS_IO_H */



More information about the U-Boot mailing list