Message ID | 20180618152315.34233-1-agraf@suse.de |
---|---|
Headers | show |
Series | sandbox: efi_loader support | expand |
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 */
Hi Alex, On 18 June 2018 at 09:53, Alexander Graf <agraf@suse.de> wrote: > 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. OK thanks for that. The binary says this for me: efi_load_pe: Invalid DOS signature I'm running on x86_64. I tried the patch below but it still crashes, presumably because of the coreboot modules. How do I actually exclude them? I cannot see anything in ./configure --help Regards, Simon
On 06/21/2018 04:44 AM, Simon Glass wrote: > Hi Alex, > > On 18 June 2018 at 09:53, Alexander Graf <agraf@suse.de> wrote: >> 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. > OK thanks for that. The binary says this for me: > > efi_load_pe: Invalid DOS signature > > I'm running on x86_64. Are you using my patch set or yours? In mine this should be fixed. > I tried the patch below but it still crashes, presumably because of > the coreboot modules. How do I actually exclude them? I cannot see > anything in ./configure --help When you call grub-mkimage you explicitly pass a list of modules to include. In that list, just omit any module that starts with cb :) Alex
Hi Alex, On 21 June 2018 at 03:47, Alexander Graf <agraf@suse.de> wrote: > On 06/21/2018 04:44 AM, Simon Glass wrote: >> >> Hi Alex, >> >> On 18 June 2018 at 09:53, Alexander Graf <agraf@suse.de> wrote: >>> >>> 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. >> >> OK thanks for that. The binary says this for me: >> >> efi_load_pe: Invalid DOS signature >> >> I'm running on x86_64. > > > Are you using my patch set or yours? In mine this should be fixed. I'm using the series at u-boot-dm/efi-working - am I missing something else? > >> I tried the patch below but it still crashes, presumably because of >> the coreboot modules. How do I actually exclude them? I cannot see >> anything in ./configure --help > > > When you call grub-mkimage you explicitly pass a list of modules to include. > In that list, just omit any module that starts with cb :) In my case I am not specifying a list. I'll see if I can do that. I'm worried there are a lot of modules to find and specify. I cannot find documentation on what they are. Regards, Simon
On 06/21/2018 09:45 PM, Simon Glass wrote: > Hi Alex, > > On 21 June 2018 at 03:47, Alexander Graf <agraf@suse.de> wrote: >> On 06/21/2018 04:44 AM, Simon Glass wrote: >>> Hi Alex, >>> >>> On 18 June 2018 at 09:53, Alexander Graf <agraf@suse.de> wrote: >>>> 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. >>> OK thanks for that. The binary says this for me: >>> >>> efi_load_pe: Invalid DOS signature >>> >>> I'm running on x86_64. >> >> Are you using my patch set or yours? In mine this should be fixed. > I'm using the series at u-boot-dm/efi-working - am I missing something else? > >>> I tried the patch below but it still crashes, presumably because of >>> the coreboot modules. How do I actually exclude them? I cannot see >>> anything in ./configure --help >> >> When you call grub-mkimage you explicitly pass a list of modules to include. >> In that list, just omit any module that starts with cb :) > In my case I am not specifying a list. I'll see if I can do that. I'm > worried there are a lot of modules to find and specify. I cannot find > documentation on what they are. ./grub-mkimage -O x86_64-efi -o grub.efi $(cd grub-core; ls *mod | cut -d . -f 1) is what I usually do to get all modules. In this case you have to | egrep -v '^cb' as well. Alex