(Re-adding misc@ for the thrilling conclusion.)

Success! It boots to installer without issue. EFI-enabled dmesg follows.

Thanks again for your work.

Brian

OpenBSD 5.8-current (RAMDISK_CD) #1254: Tue Sep 22 19:46:40 MDT 2015
    [email protected]:/usr/src/sys/arch/amd64/compile/RAMDISK_CD
real mem = 7979794432 (7610MB)
avail mem = 7736233984 (7377MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xebe50 (48 entries)
bios0: vendor American Megatrends Inc. version "V10.2" date 12/24/2014
bios0: MSI MS-7865
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP APIC FPDT MCFG HPET SSDT SSDT CRAT SSDT
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Athlon(tm) 5350 APU with Radeon(tm) R3, 2046.44 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TOPEXT,ITSC,BMI1
cpu0: 32KB 64b/line 2-way I-cache, 32KB 64b/line 8-way D-cache, 2MB
64b/line 16-way L2 cache
cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: DTLB 40 4KB entries fully associative, 8 4MB entries fully associative
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, IBE
cpu at mainbus0: not configured
cpu at mainbus0: not configured
cpu at mainbus0: not configured
ioapic0 at mainbus0: apid 5 pa 0xfec00000, version 21, 24 pins
ioapic1 at mainbus0: apid 6 pa 0xfec01000, version 21, 32 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (GPP0)
acpiprt2 at acpi0: bus -1 (GPP3)
acpiprt3 at acpi0: bus 1 (BR11)
acpiprt4 at acpi0: bus -1 (GPP2)
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "AMD AMD64 16h Host" rev 0x00
vendor "ATI", unknown product 0x9830 (class display subclass VGA, rev
0x00) at pci0 dev 1 function 0 not configured
vendor "ATI", unknown product 0x9840 (class multimedia subclass
hdaudio, rev 0x00) at pci0 dev 1 function 1 not configured
pchb1 at pci0 dev 2 function 0 vendor "AMD", unknown product 0x1538 rev 0x00
ppb0 at pci0 dev 2 function 1 "AMD AMD64 16h PCIE" rev 0x00: msi
pci1 at ppb0 bus 1
em0 at pci1 dev 0 function 0 "Intel 82574L" rev 0x00: msi, address
68:05:ca:24:f3:3e
xhci0 at pci0 dev 16 function 0 vendor "AMD", unknown product 0x7814
rev 0x01: msi
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 "AMD xHCI root hub" rev 3.00/1.00 addr 1
ahci0 at pci0 dev 17 function 0 "AMD Hudson-2 SATA" rev 0x40: msi, AHCI 1.3
ahci0: port 0: 3.0Gb/s
ahci0: port 1: 3.0Gb/s
scsibus0 at ahci0: 32 targets
sd0 at scsibus0 targ 0 lun 0: <ATA, Hitachi HDS72202, JKAO> SCSI3
0/direct fixed naa.5000cca221f7a107
sd0: 1907729MB, 512 bytes/sector, 3907029168 sectors
sd1 at scsibus0 targ 1 lun 0: <ATA, Hitachi HDS72202, JKAO> SCSI3
0/direct fixed naa.5000cca221f2c7aa
sd1: 1907729MB, 512 bytes/sector, 3907029168 sectors
ohci0 at pci0 dev 18 function 0 "AMD Hudson-2 USB" rev 0x39: apic 5
int 18, version 1.0, legacy support
ehci0 at pci0 dev 18 function 2 "AMD Hudson-2 USB2" rev 0x39: apic 5 int 17
usb1 at ehci0: USB revision 2.0
uhub1 at usb1 "AMD EHCI root hub" rev 2.00/1.00 addr 1
ohci1 at pci0 dev 19 function 0 "AMD Hudson-2 USB" rev 0x39: apic 5
int 18, version 1.0, legacy support
ehci1 at pci0 dev 19 function 2 "AMD Hudson-2 USB2" rev 0x39: apic 5 int 17
usb2 at ehci1: USB revision 2.0
uhub2 at usb2 "AMD EHCI root hub" rev 2.00/1.00 addr 1
"AMD Hudson-2 SMBus" rev 0x3a at pci0 dev 20 function 0 not configured
"AMD Hudson-2 LPC" rev 0x11 at pci0 dev 20 function 3 not configured
pchb2 at pci0 dev 24 function 0 "AMD AMD64 16h Link Cfg" rev 0x00
pchb3 at pci0 dev 24 function 1 "AMD AMD64 16h Address Map" rev 0x00
pchb4 at pci0 dev 24 function 2 "AMD AMD64 16h DRAM Cfg" rev 0x00
pchb5 at pci0 dev 24 function 3 "AMD AMD64 16h Misc Cfg" rev 0x00
pchb6 at pci0 dev 24 function 4 "AMD AMD64 16h CPU Power" rev 0x00
pchb7 at pci0 dev 24 function 5 vendor "AMD", unknown product 0x1535 rev 0x00
usb3 at ohci0: USB revision 1.0
uhub3 at usb3 "AMD OHCI root hub" rev 1.00/1.00 addr 1
usb4 at ohci1: USB revision 1.0
uhub4 at usb4 "AMD OHCI root hub" rev 1.00/1.00 addr 1
isa0 at mainbus0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com0: probed fifo depth: 15 bytes
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard
efifb0 at mainbus0
wsdisplay0 at efifb0 mux 1: console (std, vt100 emulation), using wskbd0
uhidev0 at uhub0 port 4 configuration 1 interface 0 "Microsoft Comfort
Curve Keyboard 3000" rev 2.00/1.70 addr 2
uhidev0: iclass 3/1
ukbd0 at uhidev0
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0
uhidev1 at uhub0 port 4 configuration 1 interface 1 "Microsoft Comfort
Curve Keyboard 3000" rev 2.00/1.70 addr 2
uhidev1: iclass 3/0, 1 report id
uhid at uhidev1 reportid 1 not configured
umass0 at uhub2 port 2 configuration 1 interface 0 " Patriot Memory"
rev 2.00/1.00 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd2 at scsibus1 targ 1 lun 0: <, Patriot Memory, PMAP> SCSI2 0/direct
removable serial.13fe3e002446EDB2A631
sd2: 30544MB, 512 bytes/sector, 62554112 sectors
softraid0 at root
scsibus2 at softraid0: 256 targets
sd3 at scsibus2 targ 1 lun 0: <OPENBSD, SR RAID 1, 005> SCSI2 0/direct fixed
sd3: 1907724MB, 512 bytes/sector, 3907020272 sectors
root on rd0a swap on rd0b dump on rd0b

On Sun, Oct 4, 2015 at 11:45 PM, YASUOKA Masahiko <[email protected]> wrote:
> It seems I could fix the problem.
>
>   http://yasuoka.net/~yasuoka/BOOTX64.EFI
>   (updated)
>
> This diff avoids conflicting address space kernel and UEFI OS loader.
>
> I'll commit this to OpenBSD repository soon, but please try if you
> can.
>
> Index: sys//arch/amd64/include/loadfile_machdep.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/include/loadfile_machdep.h,v
> retrieving revision 1.5
> diff -u -p -r1.5 loadfile_machdep.h
> --- sys//arch/amd64/include/loadfile_machdep.h  17 Jul 2015 20:44:38 -0000    
>   1.5
> +++ sys//arch/amd64/include/loadfile_machdep.h  5 Oct 2015 04:42:04 -0000
> @@ -41,7 +41,13 @@
>  #define LOAD_KERNEL            LOAD_ALL
>  #define COUNT_KERNEL           COUNT_ALL
>
> +#ifdef EFIBOOT
> +extern u_long                  efi_loadaddr;
> +#define LOADADDR(a)            (((((u_long)(a)) + offset)&0xfffffff) + \
> +                                   efi_loadaddr)
> +#else
>  #define LOADADDR(a)            ((((u_long)(a)) + offset)&0xfffffff)
> +#endif
>  #define ALIGNENTRY(a)          ((u_long)(a))
>  #define READ(f, b, c)          read((f), (void *)LOADADDR(b), (c))
>  #define BCOPY(s, d, c)         memcpy((void *)LOADADDR(d), (void *)(s), (c))
> Index: sys//arch/amd64/stand/efiboot/efiboot.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/stand/efiboot/efiboot.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 efiboot.c
> --- sys//arch/amd64/stand/efiboot/efiboot.c     23 Sep 2015 03:29:26 -0000    
>   1.5
> +++ sys//arch/amd64/stand/efiboot/efiboot.c     5 Oct 2015 04:42:04 -0000
> @@ -36,6 +36,8 @@
>  #include "eficall.h"
>  #include "run_i386.h"
>
> +#define        KERN_LOADSPACE_SIZE     (32 * 1024 * 1024)
> +
>  EFI_SYSTEM_TABLE       *ST;
>  EFI_BOOT_SERVICES      *BS;
>  EFI_RUNTIME_SERVICES   *RS;
> @@ -46,6 +48,7 @@ UINTN                  heapsiz = 1 * 1024 * 1024;
>  UINTN                   mmap_key;
>  static EFI_GUID                 imgdp_guid = { 0xbc62157e, 0x3e33, 0x4fec,
>                             { 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf 
> }};
> +u_long                  efi_loadaddr;
>
>  static void     efi_heap_init(void);
>  static void     efi_memprobe_internal(void);
> @@ -61,9 +64,10 @@ extern int bios_bootdev;
>  EFI_STATUS
>  efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
>  {
> -       extern char     *progname;
> -       EFI_DEVICE_PATH *dp0 = NULL, *dp;
> -       EFI_STATUS       status;
> +       extern char             *progname;
> +       EFI_DEVICE_PATH         *dp0 = NULL, *dp;
> +       EFI_STATUS               status;
> +       EFI_PHYSICAL_ADDRESS     stack;
>
>         ST = systab;
>         BS = ST->BootServices;
> @@ -101,8 +105,27 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
>
>         progname = "EFIBOOT";
>
> -       boot(bios_bootdev);
> +       /*
> +        * Move the stack before calling boot().  UEFI on some machines
> +        * locate the stack on our kernel load address.
> +        */
> +       status = EFI_CALL(BS->AllocatePages, AllocateMaxAddress, 
> EfiLoaderData,
> +           EFI_SIZE_TO_PAGES(128 * 1024), &stack);
> +       if (status != EFI_SUCCESS)
> +               panic("BS->AllocatePages()");
>
> +#if defined(__amd64__)
> +       asm("movq       %0, %%rsp;"
> +           "mov        %1, %%edi;"
> +           "call       boot@PLT;"
> +           :: "r"(stack + 128 * 1024 - 32), "r"(bios_bootdev));
> +#else
> +       asm("movl       %0, %%esp;"
> +           "movl       %1, (%%esp);"
> +           "call       boot@PLT;"
> +           :: "r"(stack + 128 * 1024 - 32), "r"(bios_bootdev));
> +#endif
> +       /* must not reach here */
>         return (EFI_SUCCESS);
>  }
>
> @@ -212,6 +235,15 @@ efi_memprobe(void)
>  {
>         u_int            n = 0;
>         bios_memmap_t   *bm;
> +       EFI_STATUS       status;
> +       EFI_PHYSICAL_ADDRESS
> +                        addr = 0x10000000ULL;  /* Below 256MB */
> +
> +       status = EFI_CALL(BS->AllocatePages, AllocateMaxAddress, 
> EfiLoaderData,
> +           EFI_SIZE_TO_PAGES(KERN_LOADSPACE_SIZE), &addr);
> +       if (status != EFI_SUCCESS)
> +               panic("BS->AllocatePages()");
> +       efi_loadaddr = addr;
>
>         printf(" mem[");
>         efi_memprobe_internal();
> @@ -236,7 +268,7 @@ efi_memprobe_internal(void)
>         UINT32                   mmver;
>         EFI_MEMORY_DESCRIPTOR   *mm0, *mm;
>         int                      i, n;
> -       bios_memmap_t            *bm, bm0;
> +       bios_memmap_t           *bm, bm0;
>
>         cnvmem = extmem = 0;
>         bios_memmap[0].type = BIOS_MAP_END;
> Index: sys//arch/amd64/stand/libsa/exec_i386.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/stand/libsa/exec_i386.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 exec_i386.c
> --- sys//arch/amd64/stand/libsa/exec_i386.c     2 Sep 2015 04:09:24 -0000     
>   1.14
> +++ sys//arch/amd64/stand/libsa/exec_i386.c     5 Oct 2015 04:42:04 -0000
> @@ -37,6 +37,7 @@
>
>  #include "disk.h"
>  #include "libsa.h"
> +#include "cmd.h"
>
>  #ifdef SOFTRAID
>  #include <dev/softraidvar.h>
> @@ -72,8 +73,11 @@ run_loadfile(u_long *marks, int howto)
>         bios_bootsr_t bootsr;
>         struct sr_boot_volume *bv;
>  #endif
> +#if defined(EFIBOOT)
> +       int i;
> +       u_long delta;
> +       extern u_long efi_loadaddr;
>
> -#ifdef EFIBOOT
>         if ((av = alloc(ac)) == NULL)
>                 panic("alloc for bootarg");
>         efi_makebootargs();
> @@ -131,17 +135,29 @@ run_loadfile(u_long *marks, int howto)
>         printf("entry point at 0x%lx [%x, %x, %x, %x]\n", entry,
>             ((int *)entry)[0], ((int *)entry)[1],
>             ((int *)entry)[2], ((int *)entry)[3]);
> -
> -#if defined(EFIBOOT)
> +#ifndef EFIBOOT
> +       /* stack and the gung is ok at this point, so, no need for asm setup 
> */
> +       (*(startfuncp)entry)(howto, bootdev, BOOTARG_APIVER, marks[MARK_END],
> +           extmem, cnvmem, ac, (int)av);
> +#else
> +       /*
> +        * Move the loaded kernel image to the usual place after calling
> +        * ExitBootServervice()
> +        */
> +       delta = DEFAULT_KERNEL_ADDRESS - efi_loadaddr;
>         efi_cleanup();
> -#endif
> -#if defined(EFIBOOT) && defined(__amd64__)
> +       memcpy((void *)marks[MARK_START] + delta, (void *)marks[MARK_START],
> +           marks[MARK_END] - marks[MARK_START]);
> +       for (i = 0; i < MARK_MAX; i++)
> +               marks[i] += delta;
> +       entry += delta;
> +#ifdef __amd64__
>         (*run_i386)((u_long)run_i386, entry, howto, bootdev, BOOTARG_APIVER,
>             marks[MARK_END], extmem, cnvmem, ac, (intptr_t)av);
>  #else
> -       /* stack and the gung is ok at this point, so, no need for asm setup 
> */
>         (*(startfuncp)entry)(howto, bootdev, BOOTARG_APIVER, marks[MARK_END],
>             extmem, cnvmem, ac, (int)av);
> -       /* not reached */
>  #endif
> +#endif
> +       /* not reached */
>  }
>
>
> On Wed, 30 Sep 2015 21:24:09 -0500
> Brian Conway <[email protected]> wrote:
>> Fantastic!
>>
>> Brian Conway
>> Software Engineer, Owner
>> RCE Software, LLC
>>
>> On Sep 30, 2015 9:11 PM, "YASUOKA Masahiko" <[email protected]> wrote:
>>
>>> I got a AM1l and I could repeat the problem.  I'll try to fix the
>>> problem on this weekend.
>>>
>>> On Sun, 27 Sep 2015 19:55:07 -0500
>>> Brian Conway <[email protected]> wrote:
>>> > Thanks for all your hard work. Let me know if there's any additional
>>> > testing I can provide.
>>> >
>>> > Brian Conway
>>> > Software Engineer, Owner
>>> > RCE Software, LLC
>>> >
>>> >
>>> > On Sun, Sep 27, 2015 at 6:23 PM, YASUOKA Masahiko <[email protected]>
>>> wrote:
>>> >> Thank you for your report.
>>> >>
>>> >> On Sun, 27 Sep 2015 14:08:49 -0500
>>> >> Brian Conway <[email protected]> wrote:
>>> >>> Great, we're getting closer! The kernel finishes loading, there's a
>>> >>> quick screen flash with a resolution change and I see "entry point at
>>> >>> ..." for a split second, and then the system reboots and the bios
>>> >>> loading screen comes up.
>>> >>>
>>> >>> Thanks again.
>>> >>>
>>> >>> Brian Conway

Reply via email to