Compare commits

..

1 commit
main ... alt

Author SHA1 Message Date
43f8cfdd83 Got OVMF on bochs running, kinda 2025-12-20 17:12:36 +01:00
3 changed files with 46 additions and 53 deletions

77
bochsrc
View file

@ -1,37 +1,40 @@
# configuration file generated by Bochs cpu: model=corei5_lynnfield_750, count=1, reset_on_triple_fault=1
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1 #cpuid: x86_64=1, mmx=1, sep=1, simd=sse4_2, apic=xapic, aes=1, movbe=1, xsave=1
memory: host=64, guest=64 #cpuid: family=6, model=0x1a, stepping=5
romimage: file="/usr/share/OVMF/x64/MICROVM.fd", address=0x0, options=none
vgaromimage: file="/usr/share/bochs/VGABIOS-lgpl-latest-cirrus" memory: guest=1024, host=1024
boot: floppy
floppy_bootsig_check: disabled=0 #romimage: file=$BXSHARE/BIOS-bochs-latest, options=fastboot
# no floppya #romimage: file=DEBUGX64_OVMF.fd, address=0x0, options=none
# no floppyb #romimage: file=OVMF-pure-efi.fd, address=0x0, options=none
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 romimage: file=/usr/share/OVMF/x64/OVMF.fd, address=0x0, options=none
ata0-master: type=none
ata0-slave: type=none #vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest-cirrus.bin
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15 vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest.bin
ata1-master: type=none vga: extension=cirrus
ata1-slave: type=none
pci: enabled=1, chipset=i440fx, slot1=cirrus mouse: enabled=0
vga: extension=cirrus, update_freq=5, realtime=1
cpu: count=1, ips=4000000, model=bx_generic, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0 pci: enabled=1, chipset=i440fx, slot1=cirrus
cpuid: level=6, stepping=3, model=3, family=6, vendor_string="GenuineIntel", brand_string=" Intel(R) Pentium(R) 4 CPU "
cpuid: mmx=1, apic=xapic, simd=sse2, sse4a=0, misaligned_sse=0, sep=1, movbe=0, adx=0 ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
cpuid: aes=0, sha=0, xsave=0, xsaveopt=0, x86_64=1, 1g_pages=0, pcid=0, fsgsbase=0 ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
#cpuid: smep=0, smap=0, mwait=1, vmx=1 ata2: enabled=0, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=11
print_timestamps: enabled=0 ata3: enabled=0, ioaddr1=0x168, ioaddr2=0x360, irq=9
port_e9_hack: enabled=0
private_colormap: enabled=0 ata0-master: type=disk, mode=flat, path="disk.img", cylinders=1024, heads=1, spt=16
clock: sync=none, time0=local, rtc_sync=0 boot: disk
# no cmosimage
# no loader #ata0-master: type=cdrom, path=UefiShell.iso, status=inserted, model="UefiShell.iso"
log: - #boot: cdrom
logprefix: %t%e%d
debug: action=ignore panic: action=ask
info: action=report error: action=report
error: action=report info: action=report
panic: action=ask #debug: action=ignore, apic0=report, pic=report, ioapic=report
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none debug: action=ignore, keyboard=report
mouse: type=ps2, enabled=0, toggle=ctrl+mbutton
com1: enabled=1, mode=null #com1: enabled=1, mode=socket-server, dev=localhost:1111
port_e9_hack: enabled=1
log: log.txt

View file

@ -20,12 +20,6 @@
#define HOST_GS_SELECTOR 0x0C0A #define HOST_GS_SELECTOR 0x0C0A
#define HOST_TR_SELECTOR 0x0C0C #define HOST_TR_SELECTOR 0x0C0C
#define IO_BITMAP_ADDRESS_A 0x2000
#define IO_BITMAP_ADDRESS_B 0x2002
#define MSR_BITMAP_ADDRESS 0x2004
#define VM_EXIT_MSR_STORE_ADDRESS 0x2006
#define VM_EXIT_MSR_LOAD_ADDRESS 0x2008
#define VMCS_LINK_POINTER 0x2800 #define VMCS_LINK_POINTER 0x2800
#define GUEST_IA32_DEBUGCTL 0x2802 #define GUEST_IA32_DEBUGCTL 0x2802
#define GUEST_IA32_PAT 0x2804 #define GUEST_IA32_PAT 0x2804

View file

@ -39,6 +39,12 @@ vintel_has_support(char *err, size_t errmax)
return false; return false;
} }
/* Bochs does not enable VMX, relying on the BIOS instead.
* OVMF, the UEFI BIOS, only enables VMX if told so through a fw_cfg device,
* which is not emulated by Bochs. As a workaround, we try to enable VMX
* ourselves ... */
writemsr64(IA32_FEATURE_CONTROL, readmsr64(IA32_FEATURE_CONTROL) | 0x5);
if (!vintel_has_bios_support()) { if (!vintel_has_bios_support()) {
strlcpy(err, "VT-x support is not enabled in BIOS.", errmax); strlcpy(err, "VT-x support is not enabled in BIOS.", errmax);
return false; return false;
@ -207,12 +213,8 @@ vintel_init_host(void)
// Set GDT and IDT // Set GDT and IDT
checked_vmwrite(HOST_GDTR_BASE, (uintptr_t)pv->host_gdtr.base); checked_vmwrite(HOST_GDTR_BASE, (uintptr_t)pv->host_gdtr.base);
checked_vmwrite(HOST_IDTR_BASE, (uintptr_t)pv->host_idtr.base); checked_vmwrite(HOST_IDTR_BASE, (uintptr_t)pv->host_idtr.base);
checked_vmwrite(HOST_FS_BASE, 0);
checked_vmwrite(HOST_GS_BASE, 0);
checked_vmwrite(HOST_TR_BASE, 0); // TODO proper value
// Dummy sysenter & sysexit values // Dummy sysenter & sysexit values
checked_vmwrite(HOST_SYSENTER_CS, 0x08);
checked_vmwrite(HOST_SYSENTER_ESP, 0x4000); checked_vmwrite(HOST_SYSENTER_ESP, 0x4000);
checked_vmwrite(HOST_SYSENTER_EIP, 0x4000); checked_vmwrite(HOST_SYSENTER_EIP, 0x4000);
} }
@ -279,12 +281,6 @@ vintel_enable(void)
checked_vmwrite(VM_EXIT_CONTROLS, exitControls); checked_vmwrite(VM_EXIT_CONTROLS, exitControls);
AsciiPrint("VM_EXIT_CONTROLS: %lx\n", exitControls); AsciiPrint("VM_EXIT_CONTROLS: %lx\n", exitControls);
checked_vmwrite(IO_BITMAP_ADDRESS_A, 0);
checked_vmwrite(IO_BITMAP_ADDRESS_B, 0);
checked_vmwrite(MSR_BITMAP_ADDRESS, 0);
checked_vmwrite(VM_EXIT_MSR_STORE_ADDRESS, 0);
checked_vmwrite(VM_EXIT_MSR_LOAD_ADDRESS, 0);
checked_vmwrite(VM_ENTRY_MSR_LOAD_COUNT, 0); checked_vmwrite(VM_ENTRY_MSR_LOAD_COUNT, 0);
checked_vmwrite(VM_ENTRY_INTR_INFO_FIELD, 0); checked_vmwrite(VM_ENTRY_INTR_INFO_FIELD, 0);
checked_vmwrite(VM_EXIT_MSR_STORE_COUNT, 0); checked_vmwrite(VM_EXIT_MSR_STORE_COUNT, 0);