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 0xe0000 for 128KB
Region 3: type 1 at 0x100000 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 0xbfff0000 for 64KB
Region 16: type 2 at 0xc0000000 for 983040KB
Region 17: type 2 at 0xfec00000 for 4KB
Region 18: type 2 at 0xfed00000 for 1KB
Region 19: type 2 at 0xfee00000 for 1024KB
Region 20: type 1 at 0x100000000 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 0xfee00000: 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 0xfec00000, 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 0xc0000000/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@0xc0000000
Region 0: type 1 at 0x0 for 639KB
Region 1: type 2 at 0x9fc00 for 1KB
Region 2: type 2 at 0xe0000 for 128KB
Region 3: type 1 at 0x100000 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 0xbfff0000 for 64KB
Region 16: type 2 at 0xfec00000 for 4KB
Region 17: type 2 at 0xfed00000 for 1KB
Region 18: type 2 at 0xfee00000 for 1024KB
Region 19: type 1 at 0x100000000 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 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 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Ryzen 7 1700 Eight-Core Processor, 2994.35 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 0xfec00000, version 11, 32 pins
, remapped to apid 4
acpiprt0 at acpi0: bus 0 (PC00)
pvbus0 at mainbus0: bhyve
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 unknown vendor 0x1275 product 0x1275 rev 0x00
ahci0 at pci0 dev 4 function 0 "Intel 82801H AHCI" rev 0x00: apic 4 int 17, 
AHCI 1.3
ahci0: port 0: 6.0Gb/s
scsibus0 at ahci0: 32 targets
sd0 at scsibus0 targ 0 lun 0: <ATA, BHYVE SATA DISK, 001> SCSI3 0/direct fixed 
t10.ATA_BHYVE_SATA_DISK_BHYVE-B660-2D3E-C0F5
sd0: 360MB, 512 bytes/sector, 738240 sectors
virtio0 at pci0 dev 10 function 0 "Qumranet Virtio Network" rev 0x00
vio0 at virtio0: address 58:9c:fc:02:26:16
virtio0: msix shared
"Intel 82371SB ISA" rev 0x00 at pci0 dev 31 function 0 not configured
isa0 at mainbus0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com0: console
com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0 mux 1
softraid0 at root
scsibus1 at softraid0: 256 targets
root on rd0a swap on rd0b dump on rd0b
erase ^?, werase ^W, kill ^U, intr ^C, status ^T

Welcome to the OpenBSD/amd64 6.3 installation program.
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? 
----

is there any better workaround/idea to solve this issue?

--- sys/arch/amd64/stand/libsa/cmd_i386.c
+++ sys/arch/amd64/stand/libsa/cmd_i386.c
@@ -203,8 +203,11 @@ Xmemory(void)
                                return 0;
                        } else {
                                switch (cmd.argv[i][0]) {
+                               case '~':
+                                       mem_delete(addr, addr + size, 1);
+                                       break;
                                case '-':
-                                       mem_delete(addr, addr + size);
+                                       mem_delete(addr, addr + size, 0);
                                        break;
                                case '+':
                                        mem_add(addr, addr + size);
--- sys/arch/amd64/stand/libsa/libsa.h
+++ sys/arch/amd64/stand/libsa/libsa.h
@@ -51,7 +51,7 @@ void apmprobe(void);
 void apmfixmem(void);
 void dump_biosmem(bios_memmap_t *);
 int mem_add(long long, long long);
-int mem_delete(long long, long long);
+int mem_delete(long long, long long, int);
 int mem_limit(long long);
 void mem_pass(void);
 
--- sys/arch/amd64/stand/libsa/memprobe.c
+++ sys/arch/amd64/stand/libsa/memprobe.c
@@ -358,12 +358,12 @@ mem_limit(long long ml)
 }
 
 int
-mem_delete(long long sa, long long ea)
+mem_delete(long long sa, long long ea, int force)
 {
        register bios_memmap_t *p;
 
        for (p = bios_memmap; p->type != BIOS_MAP_END; p++) {
-               if (p->type == BIOS_MAP_FREE) {
+               if (force || p->type == BIOS_MAP_FREE) {
                        register int64_t sp = p->addr, ep = p->addr + p->size;
 
                        /* can we eat it as a whole? */

--
FUKAUMI Naoki

Reply via email to