Re: workaround for buggy bios_memmap?

2018-03-06 Thread Naoki Fukaumi
Hi,

From: Mike Larkin <mlar...@azathoth.net>
Subject: Re: workaround for buggy bios_memmap?
Date: Mon, 5 Mar 2018 23:41:23 -0800

>> is there any better workaround/idea to solve this issue?
>> 
> 
> maybe report it upstream to bhyve if you think this really is a bhyve issue?

well, yes, bhyve issue should be reported to bhyve upstream.
maybe DL20 Gen9 issue should be reported to HPE too.

> why would we want a bootloader hack to fix a bug easily fixed elsewhere?

sorry, I don't think OpenBSD bootloader need to be fixed. my dirty patch
is just a workaround for myself.

and I wanted to know better workaround in OpenBSD because I didn't think
it's easily fixed elsewhere.

Best regards,

--
FUKAUMI Naoki



Re: workaround for buggy bios_memmap?

2018-03-05 Thread Mike Larkin
On Tue, Mar 06, 2018 at 01:46:58PM +0900, Naoki Fukaumi wrote:
> Hi tech@,
> 
> I'm using FreeBSD bhyve to run OpenBSD/amd64 VM for testing biosboot.
> (well, I know efiboot works fine on bhyve, but I want to try biosboot)
> 
> it seems bhyve's BIOS has buggy(?) entry in bios_memmap(E820 table).
> 
> 
> >> OpenBSD/amd64 BOOT 3.34
> boot> m m
> Region 0: type 1 at 0x0 for 639KB
> Region 1: type 2 at 0x9fc00 for 1KB
> Region 2: type 2 at 0xe for 128KB
> Region 3: type 1 at 0x10 for 3078904KB
> Region 4: type 3 at 0xbbfbe000 for 128KB
> Region 5: type 1 at 0xbbfde000 for 38836KB
> Region 6: type 3 at 0xbe5cb000 for 4984KB
> Region 7: type 1 at 0xbeaa9000 for 3556KB
> Region 8: type 3 at 0xbee22000 for 11804KB
> Region 9: type 1 at 0xbf9a9000 for 8KB
> Region 10: type 3 at 0xbf9ab000 for 1864KB
> Region 11: type 2 at 0xbfb7d000 for 16KB
> Region 12: type 3 at 0xbfb81000 for 32KB
> Region 13: type 4 at 0xbfb89000 for 16KB
> Region 14: type 3 at 0xbfb8d000 for 4492KB
> Region 15: type 1 at 0xbfff for 64KB
> Region 16: type 2 at 0xc000 for 983040KB
> Region 17: type 2 at 0xfec0 for 4KB
> Region 18: type 2 at 0xfed0 for 1KB
> Region 19: type 2 at 0xfee0 for 1024KB
> Region 20: type 1 at 0x1 for 5242880KB
> Low ram: 639KB  High ram: 3078904KB
> Total free memory: 8364887KB
> 
> 
> in this case, "Region 16" covers PCI memory-mapped I/O space. (why?)
> 
> in kernel, pci_init_extents() reserves there. then, PCI devices cannot
> use there, it cannot be attached or it cannot work properly.
> 
> 
> boot> boot
> cannot open hd0a:/etc/random.seed: No such file or directory
> booting hd0a:/6.3/amd64/bsd.rd: 3418091+1467392+3899896+0+593920 
> [363308+90+433368+287961]=0x9fd048
> entry point at 0x1000158
> Copyright (c) 1982, 1986, 1989, 1991, 1993
> The Regents of the University of California.  All rights reserved.
> Copyright (c) 1995-2018 OpenBSD. All rights reserved.  https://www.OpenBSD.org
> 
> OpenBSD 6.3-beta (RAMDISK_CD) #26: Sun Mar  4 11:42:12 MST 2018
> dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/RAMDISK_CD
> real mem = 8549187584 (8153MB)
> avail mem = 8286302208 (7902MB)
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 3.0 @ 0xbfb7f000 (14 entries)
> bios0: vendor BHYVE version "1.00" date 03/14/2014
> bios0: bhyve BHYVE
> acpi0 at bios0: rev 2
> acpi0: tables DSDT FACP HPET APIC MCFG SPCR
> acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
> cpu0 at mainbus0: apid 0 (boot processor)
> cpu0: AMD Ryzen 7 1700 Eight-Core Processor, 2994.31 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,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,SKINIT,TCE,DBKP,ITSC,FSGSBASE,BMI1,AVX2,BMI2
> cpu0: 64KB 64b/line 4-way I-cache, 32KB 64b/line 8-way D-cache, 512KB 
> 64b/line 8-way L2 cache, 16MB 64b/line 16-way L3 cache
> cpu0: ITLB 64 4KB entries fully associative, 64 4MB entries fully associative
> cpu0: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
> cpu0: apic clock running at 134MHz
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> ioapic0 at mainbus0: apid 4 pa 0xfec0, version 11, 32 pins
> , remapped to apid 4
> acpiprt0 at acpi0: bus 0 (PC00)
> pvbus0 at mainbus0: bhyve
> pci0 at mainbus0 bus 0
> 0:4:0: mem address conflict 0xc000/0x400
> 0:10:0: mem address conflict 0xc0002000/0x2000
> (bhyve crashes here by calling pci_conf_write(pc, tag, reg, 0) twice ;)
> 
> 
> I can see similar problem on HPE ProLiant DL20 Gen9 with BIOS boot mode.
> (well, I'm sure it works well with UEFI boot mode, but I want to try...)
> 
> I made a dirty patch for boot(8). it adds function to force-delete
> reserved memory region.
> 
> 
> boot> m m ~983040K@0xc000
> Region 0: type 1 at 0x0 for 639KB
> Region 1: type 2 at 0x9fc00 for 1KB
> Region 2: type 2 at 0xe for 128KB
> Region 3: type 1 at 0x10 for 3078904KB
> Region 4: type 3 at 0xbbfbe000 for 128KB
> Region 5: type 1 at 0xbbfde000 for 38836KB
> Region 6: type 3 at 0xbe5cb000 for 4984KB
> Region 7: type 1 at 0xbeaa9000 for 3556KB
> Region 8: type 3 at 0xbee22000 for 11804KB
> Region 9: type 1 at 0xbf9a9000 for 8KB
> Region 10: type 3 at 0xbf9ab000 for 1864KB
> Region 11: type 2 at 0xbfb7d000 for 16KB
> Region 12: type 3 at 0xbfb81000 for 32KB
> Region 13: type 4 at 0xbfb89000 for 16KB
> Region 14: type 3 at 0xbfb8d000 for 4492KB
> Region 15: type 1 at 0xbfff for 64KB
> Region 16: type 2 at 0xfec0 for 4KB
> Region 17: type 2 at 0xfed0 for 1KB
> Region 18: type 2 at 0xfee0 for 1024KB
> Region 19: type 1 at 0x1 for 5242880KB
> Low ram: 639KB  High ram: 3078904KB
> Total free memory: 8364887KB
> boot> boot
> cannot open hd0a:/etc/random.seed: No such file or directory
> booting hd0a:/6.3/amd64/bsd.rd: 

workaround for buggy bios_memmap?

2018-03-05 Thread Naoki Fukaumi
Hi tech@,

I'm using FreeBSD bhyve to run OpenBSD/amd64 VM for testing biosboot.
(well, I know efiboot works fine on bhyve, but I want to try biosboot)

it seems bhyve's BIOS has buggy(?) entry in bios_memmap(E820 table).


>> OpenBSD/amd64 BOOT 3.34
boot> m m
Region 0: type 1 at 0x0 for 639KB
Region 1: type 2 at 0x9fc00 for 1KB
Region 2: type 2 at 0xe for 128KB
Region 3: type 1 at 0x10 for 3078904KB
Region 4: type 3 at 0xbbfbe000 for 128KB
Region 5: type 1 at 0xbbfde000 for 38836KB
Region 6: type 3 at 0xbe5cb000 for 4984KB
Region 7: type 1 at 0xbeaa9000 for 3556KB
Region 8: type 3 at 0xbee22000 for 11804KB
Region 9: type 1 at 0xbf9a9000 for 8KB
Region 10: type 3 at 0xbf9ab000 for 1864KB
Region 11: type 2 at 0xbfb7d000 for 16KB
Region 12: type 3 at 0xbfb81000 for 32KB
Region 13: type 4 at 0xbfb89000 for 16KB
Region 14: type 3 at 0xbfb8d000 for 4492KB
Region 15: type 1 at 0xbfff for 64KB
Region 16: type 2 at 0xc000 for 983040KB
Region 17: type 2 at 0xfec0 for 4KB
Region 18: type 2 at 0xfed0 for 1KB
Region 19: type 2 at 0xfee0 for 1024KB
Region 20: type 1 at 0x1 for 5242880KB
Low ram: 639KB  High ram: 3078904KB
Total free memory: 8364887KB


in this case, "Region 16" covers PCI memory-mapped I/O space. (why?)

in kernel, pci_init_extents() reserves there. then, PCI devices cannot
use there, it cannot be attached or it cannot work properly.


boot> boot
cannot open hd0a:/etc/random.seed: No such file or directory
booting hd0a:/6.3/amd64/bsd.rd: 3418091+1467392+3899896+0+593920 
[363308+90+433368+287961]=0x9fd048
entry point at 0x1000158
Copyright (c) 1982, 1986, 1989, 1991, 1993
  The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2018 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 6.3-beta (RAMDISK_CD) #26: Sun Mar  4 11:42:12 MST 2018
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/RAMDISK_CD
real mem = 8549187584 (8153MB)
avail mem = 8286302208 (7902MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.0 @ 0xbfb7f000 (14 entries)
bios0: vendor BHYVE version "1.00" date 03/14/2014
bios0: bhyve BHYVE
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP HPET APIC MCFG SPCR
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Ryzen 7 1700 Eight-Core Processor, 2994.31 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,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,SKINIT,TCE,DBKP,ITSC,FSGSBASE,BMI1,AVX2,BMI2
cpu0: 64KB 64b/line 4-way I-cache, 32KB 64b/line 8-way D-cache, 512KB 64b/line 
8-way L2 cache, 16MB 64b/line 16-way L3 cache
cpu0: ITLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu0: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu0: apic clock running at 134MHz
cpu at mainbus0: not configured
cpu at mainbus0: not configured
cpu at mainbus0: not configured
ioapic0 at mainbus0: apid 4 pa 0xfec0, version 11, 32 pins
, remapped to apid 4
acpiprt0 at acpi0: bus 0 (PC00)
pvbus0 at mainbus0: bhyve
pci0 at mainbus0 bus 0
0:4:0: mem address conflict 0xc000/0x400
0:10:0: mem address conflict 0xc0002000/0x2000
(bhyve crashes here by calling pci_conf_write(pc, tag, reg, 0) twice ;)


I can see similar problem on HPE ProLiant DL20 Gen9 with BIOS boot mode.
(well, I'm sure it works well with UEFI boot mode, but I want to try...)

I made a dirty patch for boot(8). it adds function to force-delete
reserved memory region.


boot> m m ~983040K@0xc000
Region 0: type 1 at 0x0 for 639KB
Region 1: type 2 at 0x9fc00 for 1KB
Region 2: type 2 at 0xe for 128KB
Region 3: type 1 at 0x10 for 3078904KB
Region 4: type 3 at 0xbbfbe000 for 128KB
Region 5: type 1 at 0xbbfde000 for 38836KB
Region 6: type 3 at 0xbe5cb000 for 4984KB
Region 7: type 1 at 0xbeaa9000 for 3556KB
Region 8: type 3 at 0xbee22000 for 11804KB
Region 9: type 1 at 0xbf9a9000 for 8KB
Region 10: type 3 at 0xbf9ab000 for 1864KB
Region 11: type 2 at 0xbfb7d000 for 16KB
Region 12: type 3 at 0xbfb81000 for 32KB
Region 13: type 4 at 0xbfb89000 for 16KB
Region 14: type 3 at 0xbfb8d000 for 4492KB
Region 15: type 1 at 0xbfff for 64KB
Region 16: type 2 at 0xfec0 for 4KB
Region 17: type 2 at 0xfed0 for 1KB
Region 18: type 2 at 0xfee0 for 1024KB
Region 19: type 1 at 0x1 for 5242880KB
Low ram: 639KB  High ram: 3078904KB
Total free memory: 8364887KB
boot> boot
cannot open hd0a:/etc/random.seed: No such file or directory
booting hd0a:/6.3/amd64/bsd.rd: 3418091+1467392+3899896+0+593920 
[363308+90+433368+287961]=0x9fd048
entry point at 0x1000158
Copyright (c) 1982, 1986, 1989, 1991, 1993
  The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2018 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD