mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-30 16:14:13 +00:00
parent
6bf4fd3340
commit
2c558de891
@ -50,6 +50,8 @@ class Vmm::Vcpu_dispatcher : public T
|
|||||||
Genode::Thread_base *myself = Genode::Thread_base::myself();
|
Genode::Thread_base *myself = Genode::Thread_base::myself();
|
||||||
DISPATCHER *vd = static_cast<DISPATCHER *>(myself);
|
DISPATCHER *vd = static_cast<DISPATCHER *>(myself);
|
||||||
|
|
||||||
|
vd->exit_reason = EV;
|
||||||
|
|
||||||
/* call event-specific handler function */
|
/* call event-specific handler function */
|
||||||
(vd->*FUNC)();
|
(vd->*FUNC)();
|
||||||
|
|
||||||
@ -59,6 +61,8 @@ class Vmm::Vcpu_dispatcher : public T
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
unsigned int exit_reason = 0;
|
||||||
|
|
||||||
Vcpu_dispatcher(size_t stack_size, Cap_connection &cap,
|
Vcpu_dispatcher(size_t stack_size, Cap_connection &cap,
|
||||||
Cpu_session * cpu_session,
|
Cpu_session * cpu_session,
|
||||||
Genode::Affinity::Location location)
|
Genode::Affinity::Location location)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
VBOX_MACH := $(filter $(SPECS), x86_32 x86_64)
|
VBOX_MACH := $(filter $(SPECS), x86_32 x86_64)
|
||||||
|
|
||||||
VBOX_MACH_CC_OPT_x86_32 = -DRT_ARCH_X86 -D__X86__ -DHC_ARCH_BITS=32
|
VBOX_MACH_CC_OPT_x86_32 = -DRT_ARCH_X86 -D__X86__
|
||||||
VBOX_MACH_ASM_OPT_x86_32 = -f elf32
|
VBOX_MACH_ASM_OPT_x86_32 = -f elf32
|
||||||
VBOX_MACH_CC_OPT_x86_64 = -DRT_ARCH_AMD64 -D__AMD64__ -DHC_ARCH_BITS=64
|
VBOX_MACH_CC_OPT_x86_64 = -DRT_ARCH_AMD64 -D__AMD64__
|
||||||
VBOX_MACH_ASM_OPT_x86_64 = -f elf64
|
VBOX_MACH_ASM_OPT_x86_64 = -f elf64
|
||||||
|
|
||||||
ifeq ($(shell which yasm),)
|
ifeq ($(shell which yasm),)
|
||||||
@ -16,13 +16,12 @@ VIRTUALBOX_SDK_DIR = $(call select_from_ports,virtualbox)/src/app/virtualbox_sdk
|
|||||||
VBOX_DIR = $(VIRTUALBOX_DIR)/src/VBox
|
VBOX_DIR = $(VIRTUALBOX_DIR)/src/VBox
|
||||||
|
|
||||||
VBOX_CC_OPT += -DIN_RING3 -DVBOX -DVBOX_OSE \
|
VBOX_CC_OPT += -DIN_RING3 -DVBOX -DVBOX_OSE \
|
||||||
-DGC_ARCH_BITS=64 \
|
|
||||||
-D_FILE_OFFSET_BITS=64 -DLOG_ENABLED
|
-D_FILE_OFFSET_BITS=64 -DLOG_ENABLED
|
||||||
|
|
||||||
VBOX_CC_OPT += $(VBOX_MACH_CC_OPT_$(VBOX_MACH))
|
VBOX_CC_OPT += $(VBOX_MACH_CC_OPT_$(VBOX_MACH))
|
||||||
|
|
||||||
# Required if on a 32bit host 64bit VMs should be executed
|
VBOX_CC_OPT += -DVBOX_WITH_64_BITS_GUESTS
|
||||||
# VBOX_CC_OPT += -DVBOX_WITH_64_BITS_GUESTS
|
VBOX_CC_OPT += -DVBOX_WITH_NEW_MSR_CODE
|
||||||
|
|
||||||
VBOX_CC_OPT += -DIN_SUP_R3 -DIN_VMM_R3
|
VBOX_CC_OPT += -DIN_SUP_R3 -DIN_VMM_R3
|
||||||
|
|
||||||
|
@ -61,6 +61,9 @@ CC_OPT += -DVBOX_WITH_WDDM -DVBOX_WITH_WDDM_W8 -DVBOXWDDM_WITH_VBVA
|
|||||||
CC_OPT += -DVBOX_WITH_VDMA
|
CC_OPT += -DVBOX_WITH_VDMA
|
||||||
CC_OPT += -DVBOX_WITH_VMSVGA
|
CC_OPT += -DVBOX_WITH_VMSVGA
|
||||||
|
|
||||||
|
# found in src/VBox/Devices/Makefile.kmk
|
||||||
|
CC_OPT += -DVBOX_HGCM_HOST_CODE
|
||||||
|
|
||||||
Devices/Graphics/DevVGA.o: vbetables.h
|
Devices/Graphics/DevVGA.o: vbetables.h
|
||||||
|
|
||||||
vbetables.h: vbetables-gen
|
vbetables.h: vbetables-gen
|
||||||
|
15
repos/ports/run/vbox_auto_win81_64.run
Normal file
15
repos/ports/run/vbox_auto_win81_64.run
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#
|
||||||
|
# Windows 8.1 (64 bit) in VirtualBox
|
||||||
|
#
|
||||||
|
|
||||||
|
assert_spec 64bit
|
||||||
|
|
||||||
|
set flavor "win81_64"
|
||||||
|
|
||||||
|
# Write overlay back to harddisk if set to 0
|
||||||
|
set use_ram_fs 0
|
||||||
|
|
||||||
|
set use_usb 1
|
||||||
|
set use_ps2 [have_spec ps2]
|
||||||
|
|
||||||
|
source ${genode_dir}/repos/ports/run/vbox_win.inc
|
106
repos/ports/run/vm_win81_64.vbox
Normal file
106
repos/ports/run/vm_win81_64.vbox
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
** DO NOT EDIT THIS FILE.
|
||||||
|
** If you make changes to this file while any VirtualBox related application
|
||||||
|
** is running, your changes will be overwritten later, without taking effect.
|
||||||
|
** Use VBoxManage or the VirtualBox Manager GUI to make changes.
|
||||||
|
-->
|
||||||
|
<VirtualBox xmlns="http://www.innotek.de/VirtualBox-settings" version="1.14-linux">
|
||||||
|
<Machine uuid="{179f623e-40a1-4827-995d-251537a53129}" name="Win81_64" OSType="Windows81_64" snapshotFolder="Snapshots" lastStateChange="2015-01-08T11:27:52Z">
|
||||||
|
<MediaRegistry>
|
||||||
|
<HardDisks>
|
||||||
|
<HardDisk uuid="{4def7eeb-7836-4f3e-9b6c-a850b307ef10}" location="/win81_64.vdi" format="VDI" type="Immutable">
|
||||||
|
<HardDisk uuid="{9d5f52e5-81ef-45ef-8334-5c644f5a4ef0}" location="/ram/overlay_win81_64.vdi" format="VDI" autoReset="true"/>
|
||||||
|
</HardDisk>
|
||||||
|
</HardDisks>
|
||||||
|
<DVDImages/>
|
||||||
|
<FloppyImages/>
|
||||||
|
</MediaRegistry>
|
||||||
|
<ExtraData>
|
||||||
|
<ExtraDataItem name="GUI/LastGuestSizeHint" value="1024,768"/>
|
||||||
|
<ExtraDataItem name="GUI/LastNormalWindowPosition" value="0,12,1439,863"/>
|
||||||
|
</ExtraData>
|
||||||
|
<Hardware version="2">
|
||||||
|
<CPU count="1" hotplug="false">
|
||||||
|
<HardwareVirtEx enabled="true"/>
|
||||||
|
<HardwareVirtExNestedPaging enabled="true"/>
|
||||||
|
<HardwareVirtExVPID enabled="true"/>
|
||||||
|
<HardwareVirtExUX enabled="true"/>
|
||||||
|
<PAE enabled="true"/>
|
||||||
|
<LongMode enabled="true"/>
|
||||||
|
<HardwareVirtExLargePages enabled="false"/>
|
||||||
|
<HardwareVirtForce enabled="false"/>
|
||||||
|
</CPU>
|
||||||
|
<Memory RAMSize="1024" PageFusion="false"/>
|
||||||
|
<HID Pointing="PS2Mouse" Keyboard="PS2Keyboard"/>
|
||||||
|
<HPET enabled="false"/>
|
||||||
|
<Chipset type="PIIX3"/>
|
||||||
|
<Boot>
|
||||||
|
<Order position="1" device="Floppy"/>
|
||||||
|
<Order position="2" device="DVD"/>
|
||||||
|
<Order position="3" device="HardDisk"/>
|
||||||
|
<Order position="4" device="None"/>
|
||||||
|
</Boot>
|
||||||
|
<Display VRAMSize="128" monitorCount="1" accelerate3D="false" accelerate2DVideo="false"/>
|
||||||
|
<VideoCapture enabled="false" screens="18446744073709551615" horzRes="1024" vertRes="768" rate="512" fps="25"/>
|
||||||
|
<RemoteDisplay enabled="false" authType="Null"/>
|
||||||
|
<BIOS>
|
||||||
|
<ACPI enabled="true"/>
|
||||||
|
<IOAPIC enabled="true"/>
|
||||||
|
<Logo fadeIn="true" fadeOut="true" displayTime="0"/>
|
||||||
|
<BootMenu mode="MessageAndMenu"/>
|
||||||
|
<TimeOffset value="0"/>
|
||||||
|
<PXEDebug enabled="false"/>
|
||||||
|
</BIOS>
|
||||||
|
<USB>
|
||||||
|
<Controllers>
|
||||||
|
<Controller name="OHCI" type="OHCI"/>
|
||||||
|
</Controllers>
|
||||||
|
<DeviceFilters/>
|
||||||
|
</USB>
|
||||||
|
<Network>
|
||||||
|
<Adapter slot="0" enabled="false" MACAddress="080027235455" cable="true" speed="0" type="82540EM">
|
||||||
|
<HostInterface/>
|
||||||
|
<DisabledModes/>
|
||||||
|
</Adapter>
|
||||||
|
</Network>
|
||||||
|
<UART>
|
||||||
|
<Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
|
||||||
|
<Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3" hostMode="Disconnected"/>
|
||||||
|
</UART>
|
||||||
|
<LPT>
|
||||||
|
<Port slot="0" enabled="false" IOBase="0x378" IRQ="7"/>
|
||||||
|
<Port slot="1" enabled="false" IOBase="0x378" IRQ="7"/>
|
||||||
|
</LPT>
|
||||||
|
<AudioAdapter controller="HDA" driver="Pulse" enabled="true"/>
|
||||||
|
<RTC localOrUTC="UTC"/>
|
||||||
|
<SharedFolders/>
|
||||||
|
<Clipboard mode="Disabled"/>
|
||||||
|
<DragAndDrop mode="Disabled"/>
|
||||||
|
<IO>
|
||||||
|
<IoCache enabled="true" size="5"/>
|
||||||
|
<BandwidthGroups/>
|
||||||
|
</IO>
|
||||||
|
<HostPci>
|
||||||
|
<Devices/>
|
||||||
|
</HostPci>
|
||||||
|
<EmulatedUSB>
|
||||||
|
<CardReader enabled="false"/>
|
||||||
|
</EmulatedUSB>
|
||||||
|
<Guest memoryBalloonSize="0"/>
|
||||||
|
<GuestProperties>
|
||||||
|
<GuestProperty name="/VirtualBox/HostInfo/GUI/LanguageID" value="en_US" timestamp="1420716068888210000" flags=""/>
|
||||||
|
</GuestProperties>
|
||||||
|
</Hardware>
|
||||||
|
<StorageControllers>
|
||||||
|
<StorageController name="IDE" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
|
||||||
|
<AttachedDevice type="HardDisk" port="0" device="0">
|
||||||
|
<Image uuid="{9d5f52e5-81ef-45ef-8334-5c644f5a4ef0}"/>
|
||||||
|
</AttachedDevice>
|
||||||
|
<AttachedDevice passthrough="false" type="DVD" port="1" device="0"/>
|
||||||
|
</StorageController>
|
||||||
|
<!--<StorageController name="SATA" type="AHCI" PortCount="1" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
|
||||||
|
</StorageController>-->
|
||||||
|
</StorageControllers>
|
||||||
|
</Machine>
|
||||||
|
</VirtualBox>
|
@ -122,7 +122,7 @@ HRESULT Host::GetProcessorFeature(ProcessorFeature_T feature, BOOL *supported)
|
|||||||
*supported = true;
|
*supported = true;
|
||||||
break;
|
break;
|
||||||
case ProcessorFeature_LongMode:
|
case ProcessorFeature_LongMode:
|
||||||
*supported = false;
|
*supported = (sizeof(void *) > 4);
|
||||||
break;
|
break;
|
||||||
case ProcessorFeature_NestedPaging:
|
case ProcessorFeature_NestedPaging:
|
||||||
*supported = true;
|
*supported = true;
|
||||||
|
@ -348,7 +348,7 @@ class Guest_memory
|
|||||||
if (vmm_local)
|
if (vmm_local)
|
||||||
return vmm_local;
|
return vmm_local;
|
||||||
|
|
||||||
it = Genode::Flexpage_iterator((addr_t)r->pv_at_offset(GCPhys - r->GCPhys()), size, GCPhys, size, GCPhys - r->GCPhys());
|
it = Genode::Flexpage_iterator((addr_t)r->pv_at_offset(GCPhys - r->GCPhys()), size, GCPhys, size, GCPhys);
|
||||||
|
|
||||||
return r->pv_at_offset(GCPhys - r->GCPhys());
|
return r->pv_at_offset(GCPhys - r->GCPhys());
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
static bool enabled_hm = true;
|
static bool enabled_hm = true;
|
||||||
static bool enable_pae_nx = false;
|
static bool enable_pae_nx = false;
|
||||||
|
static bool enable_64bit = false;
|
||||||
|
|
||||||
VMMR3DECL(int) HMR3Init(PVM pVM)
|
VMMR3DECL(int) HMR3Init(PVM pVM)
|
||||||
{
|
{
|
||||||
@ -40,6 +41,10 @@ VMMR3DECL(int) HMR3Init(PVM pVM)
|
|||||||
false);
|
false);
|
||||||
AssertRCReturn(rc, rc);
|
AssertRCReturn(rc, rc);
|
||||||
|
|
||||||
|
/* check whether to enable long-mode bit - in 64bit host mode */
|
||||||
|
rc = CFGMR3QueryBoolDef(pCfgHM, "64bitEnabled", &enable_64bit, false);
|
||||||
|
AssertRCReturn(rc, rc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We always set the fHMEnabled flag. Otherwise, the EM won't
|
* We always set the fHMEnabled flag. Otherwise, the EM won't
|
||||||
* consult us for taking scheduling decisions. The actual switch to
|
* consult us for taking scheduling decisions. The actual switch to
|
||||||
@ -80,6 +85,11 @@ VMMR3_INT_DECL(int) HMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat)
|
|||||||
CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
|
CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
|
||||||
CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
|
CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
|
||||||
}
|
}
|
||||||
|
if (sizeof(void *) > 4 && enable_64bit) {
|
||||||
|
CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);
|
||||||
|
CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);
|
||||||
|
CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -51,7 +51,7 @@ static bool debug_map_memory = false;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* VirtualBox stores segment attributes in Intel format using a 32-bit
|
* VirtualBox stores segment attributes in Intel format using a 32-bit
|
||||||
* value. NOVA represents the attributes in packet format using a 16-bit
|
* value. NOVA represents the attributes in packed format using a 16-bit
|
||||||
* value.
|
* value.
|
||||||
*/
|
*/
|
||||||
static inline Genode::uint16_t sel_ar_conv_to_nova(Genode::uint32_t v)
|
static inline Genode::uint16_t sel_ar_conv_to_nova(Genode::uint32_t v)
|
||||||
@ -140,8 +140,6 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
|
|||||||
void * _stack_reply;
|
void * _stack_reply;
|
||||||
jmp_buf _env;
|
jmp_buf _env;
|
||||||
|
|
||||||
bool _last_exit_was_recall;
|
|
||||||
|
|
||||||
void switch_to_hw()
|
void switch_to_hw()
|
||||||
{
|
{
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
@ -159,7 +157,7 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
|
|||||||
Assert(utcb->actv_state == ACTIVITY_STATE_ACTIVE);
|
Assert(utcb->actv_state == ACTIVITY_STATE_ACTIVE);
|
||||||
Assert(!(utcb->inj_info & IRQ_INJ_VALID_MASK));
|
Assert(!(utcb->inj_info & IRQ_INJ_VALID_MASK));
|
||||||
|
|
||||||
/* go back to re-compiler */
|
/* go back to VirtualBox */
|
||||||
_fpu_save_and_longjmp();
|
_fpu_save_and_longjmp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +187,6 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
|
|||||||
|
|
||||||
/* are we forced to go back to emulation mode ? */
|
/* are we forced to go back to emulation mode ? */
|
||||||
if (!continue_hw_accelerated(utcb)) {
|
if (!continue_hw_accelerated(utcb)) {
|
||||||
_last_exit_was_recall = true;
|
|
||||||
/* go back to emulation mode */
|
/* go back to emulation mode */
|
||||||
_fpu_save_and_longjmp();
|
_fpu_save_and_longjmp();
|
||||||
}
|
}
|
||||||
@ -334,6 +331,16 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
|
|||||||
utcb->si = pCtx->rsi;
|
utcb->si = pCtx->rsi;
|
||||||
utcb->di = pCtx->rdi;
|
utcb->di = pCtx->rdi;
|
||||||
|
|
||||||
|
utcb->mtd |= Mtd::R8_R15;
|
||||||
|
utcb->write_r8(pCtx->r8);
|
||||||
|
utcb->write_r9(pCtx->r9);
|
||||||
|
utcb->write_r10(pCtx->r10);
|
||||||
|
utcb->write_r11(pCtx->r11);
|
||||||
|
utcb->write_r12(pCtx->r12);
|
||||||
|
utcb->write_r13(pCtx->r13);
|
||||||
|
utcb->write_r14(pCtx->r14);
|
||||||
|
utcb->write_r15(pCtx->r15);
|
||||||
|
|
||||||
utcb->mtd |= Mtd::EFL;
|
utcb->mtd |= Mtd::EFL;
|
||||||
utcb->flags = pCtx->rflags.u;
|
utcb->flags = pCtx->rflags.u;
|
||||||
|
|
||||||
@ -394,6 +401,29 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
|
|||||||
utcb->pdpte[3] = pdpte[3];
|
utcb->pdpte[3] = pdpte[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utcb->mtd |= Mtd::SYSCALL_SWAPGS;
|
||||||
|
utcb->write_star(pCtx->msrSTAR);
|
||||||
|
utcb->write_lstar(pCtx->msrLSTAR);
|
||||||
|
utcb->write_fmask(pCtx->msrSFMASK);
|
||||||
|
utcb->write_kernel_gs_base(pCtx->msrKERNELGSBASE);
|
||||||
|
|
||||||
|
/* from HMVMXR0.cpp */
|
||||||
|
bool interrupt_pending = false;
|
||||||
|
uint8_t tpr = 0;
|
||||||
|
uint8_t pending_interrupt = 0;
|
||||||
|
PDMApicGetTPR(pVCpu, &tpr, &interrupt_pending, &pending_interrupt);
|
||||||
|
utcb->mtd |= Mtd::TPR;
|
||||||
|
utcb->write_tpr(tpr);
|
||||||
|
utcb->write_tpr_threshold(0);
|
||||||
|
if (interrupt_pending) {
|
||||||
|
const uint8_t pending_priority = (pending_interrupt >> 4) & 0xf;
|
||||||
|
const uint8_t tpr_priority = (tpr >> 4) & 0xf;
|
||||||
|
if (pending_priority <= tpr_priority)
|
||||||
|
utcb->write_tpr_threshold(pending_priority);
|
||||||
|
else
|
||||||
|
utcb->write_tpr_threshold(tpr_priority);
|
||||||
|
}
|
||||||
|
|
||||||
Assert(!(VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)));
|
Assert(!(VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -417,6 +447,15 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
|
|||||||
pCtx->rdi = utcb->di;
|
pCtx->rdi = utcb->di;
|
||||||
pCtx->rflags.u = utcb->flags;
|
pCtx->rflags.u = utcb->flags;
|
||||||
|
|
||||||
|
pCtx->r8 = utcb->read_r8();
|
||||||
|
pCtx->r9 = utcb->read_r9();
|
||||||
|
pCtx->r10 = utcb->read_r10();
|
||||||
|
pCtx->r11 = utcb->read_r11();
|
||||||
|
pCtx->r12 = utcb->read_r12();
|
||||||
|
pCtx->r13 = utcb->read_r13();
|
||||||
|
pCtx->r14 = utcb->read_r14();
|
||||||
|
pCtx->r15 = utcb->read_r15();
|
||||||
|
|
||||||
pCtx->dr[7] = utcb->dr7;
|
pCtx->dr[7] = utcb->dr7;
|
||||||
|
|
||||||
if (pCtx->SysEnter.cs != utcb->sysenter_cs)
|
if (pCtx->SysEnter.cs != utcb->sysenter_cs)
|
||||||
@ -450,6 +489,20 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
|
|||||||
if (pCtx->cr4 != utcb->cr4)
|
if (pCtx->cr4 != utcb->cr4)
|
||||||
CPUMSetGuestCR4(pVCpu, utcb->cr4);
|
CPUMSetGuestCR4(pVCpu, utcb->cr4);
|
||||||
|
|
||||||
|
if (pCtx->msrSTAR != utcb->read_star())
|
||||||
|
CPUMSetGuestMsr(pVCpu, MSR_K6_STAR, utcb->read_star());
|
||||||
|
|
||||||
|
if (pCtx->msrLSTAR != utcb->read_lstar())
|
||||||
|
CPUMSetGuestMsr(pVCpu, MSR_K8_LSTAR, utcb->read_lstar());
|
||||||
|
|
||||||
|
if (pCtx->msrSFMASK != utcb->read_fmask())
|
||||||
|
CPUMSetGuestMsr(pVCpu, MSR_K8_SF_MASK, utcb->read_fmask());
|
||||||
|
|
||||||
|
if (pCtx->msrKERNELGSBASE != utcb->read_kernel_gs_base())
|
||||||
|
CPUMSetGuestMsr(pVCpu, MSR_K8_KERNEL_GS_BASE, utcb->read_kernel_gs_base());
|
||||||
|
|
||||||
|
PDMApicSetTPR(pVCpu, utcb->read_tpr());
|
||||||
|
|
||||||
VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_TO_R3);
|
VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_TO_R3);
|
||||||
|
|
||||||
/* tell rem compiler that FPU register changed XXX optimizations ? */
|
/* tell rem compiler that FPU register changed XXX optimizations ? */
|
||||||
@ -623,6 +676,7 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
|
|||||||
|
|
||||||
virtual bool hw_load_state(Nova::Utcb *, VM *, PVMCPU) = 0;
|
virtual bool hw_load_state(Nova::Utcb *, VM *, PVMCPU) = 0;
|
||||||
virtual bool hw_save_state(Nova::Utcb *, VM *, PVMCPU) = 0;
|
virtual bool hw_save_state(Nova::Utcb *, VM *, PVMCPU) = 0;
|
||||||
|
virtual bool vm_exit_requires_instruction_emulation() = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -812,8 +866,6 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
|
|||||||
_current_vm = pVM;
|
_current_vm = pVM;
|
||||||
_current_vcpu = pVCpu;
|
_current_vcpu = pVCpu;
|
||||||
|
|
||||||
_last_exit_was_recall = false;
|
|
||||||
|
|
||||||
/* switch to hardware accelerated mode */
|
/* switch to hardware accelerated mode */
|
||||||
switch_to_hw();
|
switch_to_hw();
|
||||||
|
|
||||||
@ -859,7 +911,8 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<pthread>,
|
|||||||
REMFlushTBs(pVM);
|
REMFlushTBs(pVM);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return _last_exit_was_recall ? VINF_SUCCESS : VINF_EM_RAW_EMULATE_INSTR;
|
return vm_exit_requires_instruction_emulation() ? VINF_EM_RAW_EMULATE_INSTR
|
||||||
|
: VINF_SUCCESS;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,6 +128,14 @@ class Vcpu_handler_svm : public Vcpu_handler
|
|||||||
bool hw_load_state(Nova::Utcb * utcb, VM * pVM, PVMCPU pVCpu) {
|
bool hw_load_state(Nova::Utcb * utcb, VM * pVM, PVMCPU pVCpu) {
|
||||||
return svm_load_state(utcb, pVM, pVCpu);
|
return svm_load_state(utcb, pVM, pVCpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool vm_exit_requires_instruction_emulation()
|
||||||
|
{
|
||||||
|
if (exit_reason == RECALL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _VIRTUALBOX__SPEC__NOVA__VCPU_SVM_H_ */
|
#endif /* _VIRTUALBOX__SPEC__NOVA__VCPU_SVM_H_ */
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
#ifndef _VIRTUALBOX__SPEC__NOVA__VCPU_VMX_H_
|
#ifndef _VIRTUALBOX__SPEC__NOVA__VCPU_VMX_H_
|
||||||
#define _VIRTUALBOX__SPEC__NOVA__VCPU_VMX_H_
|
#define _VIRTUALBOX__SPEC__NOVA__VCPU_VMX_H_
|
||||||
|
|
||||||
|
/* libc includes */
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* VirtualBox includes */
|
/* VirtualBox includes */
|
||||||
#include <VBox/vmm/hm_vmx.h>
|
#include <VBox/vmm/hm_vmx.h>
|
||||||
|
|
||||||
@ -61,8 +64,9 @@ class Vcpu_handler_vmx : public Vcpu_handler
|
|||||||
VMX_VMCS_CTRL_PROC_EXEC_MONITOR_EXIT |
|
VMX_VMCS_CTRL_PROC_EXEC_MONITOR_EXIT |
|
||||||
VMX_VMCS_CTRL_PROC_EXEC_MWAIT_EXIT |
|
VMX_VMCS_CTRL_PROC_EXEC_MWAIT_EXIT |
|
||||||
*/
|
*/
|
||||||
VMX_VMCS_CTRL_PROC_EXEC_CR8_LOAD_EXIT |
|
/* VMX_VMCS_CTRL_PROC_EXEC_CR8_LOAD_EXIT |
|
||||||
VMX_VMCS_CTRL_PROC_EXEC_CR8_STORE_EXIT |
|
VMX_VMCS_CTRL_PROC_EXEC_CR8_STORE_EXIT |*/
|
||||||
|
VMX_VMCS_CTRL_PROC_EXEC_USE_TPR_SHADOW |
|
||||||
VMX_VMCS_CTRL_PROC_EXEC_RDPMC_EXIT;
|
VMX_VMCS_CTRL_PROC_EXEC_RDPMC_EXIT;
|
||||||
/* VMX_VMCS_CTRL_PROC_EXEC_PAUSE_EXIT | */
|
/* VMX_VMCS_CTRL_PROC_EXEC_PAUSE_EXIT | */
|
||||||
/*
|
/*
|
||||||
@ -87,12 +91,8 @@ class Vcpu_handler_vmx : public Vcpu_handler
|
|||||||
|
|
||||||
__attribute__((noreturn)) void _vmx_triple()
|
__attribute__((noreturn)) void _vmx_triple()
|
||||||
{
|
{
|
||||||
Genode::Thread_base *myself = Genode::Thread_base::myself();
|
|
||||||
using namespace Nova;
|
|
||||||
|
|
||||||
Vmm::printf("triple fault - dead\n");
|
Vmm::printf("triple fault - dead\n");
|
||||||
|
exit(-1);
|
||||||
_default_handler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((noreturn)) void _vmx_irqwin() { _irq_window(); }
|
__attribute__((noreturn)) void _vmx_irqwin() { _irq_window(); }
|
||||||
@ -115,7 +115,8 @@ class Vcpu_handler_vmx : public Vcpu_handler
|
|||||||
utcb->inj_info, utcb->inj_error,
|
utcb->inj_info, utcb->inj_error,
|
||||||
utcb->intr_state, utcb->actv_state);
|
utcb->intr_state, utcb->actv_state);
|
||||||
|
|
||||||
Vcpu_handler::_default_handler();
|
Vmm::printf("invalid guest state - dead\n");
|
||||||
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -134,6 +135,11 @@ class Vcpu_handler_vmx : public Vcpu_handler
|
|||||||
Genode::Thread_base *myself = Genode::Thread_base::myself();
|
Genode::Thread_base *myself = Genode::Thread_base::myself();
|
||||||
Nova::Utcb *utcb = reinterpret_cast<Nova::Utcb *>(myself->utcb());
|
Nova::Utcb *utcb = reinterpret_cast<Nova::Utcb *>(myself->utcb());
|
||||||
|
|
||||||
|
unsigned int cr = utcb->qual[0] & 0xf;
|
||||||
|
|
||||||
|
if (cr == 8)
|
||||||
|
_default_handler();
|
||||||
|
|
||||||
Genode::uint64_t *pdpte = (Genode::uint64_t*)
|
Genode::uint64_t *pdpte = (Genode::uint64_t*)
|
||||||
guest_memory()->lookup(utcb->cr3, sizeof(utcb->pdpte));
|
guest_memory()->lookup(utcb->cr3, sizeof(utcb->pdpte));
|
||||||
|
|
||||||
@ -201,6 +207,8 @@ class Vcpu_handler_vmx : public Vcpu_handler
|
|||||||
&This::_vmx_mov_crx> (exc_base, Mtd::ALL | Mtd::FPU);
|
&This::_vmx_mov_crx> (exc_base, Mtd::ALL | Mtd::FPU);
|
||||||
register_handler<VMX_EXIT_MOV_DRX, This,
|
register_handler<VMX_EXIT_MOV_DRX, This,
|
||||||
&This::_vmx_default> (exc_base, Mtd::ALL | Mtd::FPU);
|
&This::_vmx_default> (exc_base, Mtd::ALL | Mtd::FPU);
|
||||||
|
register_handler<VMX_EXIT_TPR_BELOW_THRESHOLD, This,
|
||||||
|
&This::_vmx_default> (exc_base, Mtd::ALL | Mtd::FPU);
|
||||||
register_handler<VMX_EXIT_EPT_VIOLATION, This,
|
register_handler<VMX_EXIT_EPT_VIOLATION, This,
|
||||||
&This::_vmx_ept<VMX_EXIT_EPT_VIOLATION>> (exc_base, Mtd::ALL | Mtd::FPU);
|
&This::_vmx_ept<VMX_EXIT_EPT_VIOLATION>> (exc_base, Mtd::ALL | Mtd::FPU);
|
||||||
register_handler<VCPU_STARTUP, This,
|
register_handler<VCPU_STARTUP, This,
|
||||||
@ -218,6 +226,19 @@ class Vcpu_handler_vmx : public Vcpu_handler
|
|||||||
bool hw_load_state(Nova::Utcb * utcb, VM * pVM, PVMCPU pVCpu) {
|
bool hw_load_state(Nova::Utcb * utcb, VM * pVM, PVMCPU pVCpu) {
|
||||||
return vmx_load_state(utcb, pVM, pVCpu);
|
return vmx_load_state(utcb, pVM, pVCpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool vm_exit_requires_instruction_emulation()
|
||||||
|
{
|
||||||
|
if (exit_reason == VMX_EXIT_TPR_BELOW_THRESHOLD) {
|
||||||
|
/* the instruction causing the exit has already been executed */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exit_reason == RECALL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _VIRTUALBOX__SPEC__NOVA__VCPU_VMX_H_ */
|
#endif /* _VIRTUALBOX__SPEC__NOVA__VCPU_VMX_H_ */
|
||||||
|
@ -65,17 +65,7 @@ enum { VMCS_SEG_UNUSABLE = 0x10000 };
|
|||||||
utcb->REG.sel = pCtx->REG.Sel; \
|
utcb->REG.sel = pCtx->REG.Sel; \
|
||||||
utcb->REG.limit = pCtx->REG.u32Limit; \
|
utcb->REG.limit = pCtx->REG.u32Limit; \
|
||||||
utcb->REG.base = pCtx->REG.u64Base; \
|
utcb->REG.base = pCtx->REG.u64Base; \
|
||||||
\
|
utcb->REG.ar = sel_ar_conv_to_nova(pCtx->REG.Attr.u ? : VMCS_SEG_UNUSABLE);
|
||||||
/* attribute fixup according to 'VMX_WRITE_SELREG' in 'HWVMXR0.h' */ \
|
|
||||||
if (( pCtx->REG.Sel \
|
|
||||||
|| !CPUMIsGuestInPagedProtectedModeEx(pCtx) \
|
|
||||||
|| (!pCtx->cs.Attr.n.u1DefBig && !CPUMIsGuestIn64BitCodeEx(pCtx))) \
|
|
||||||
&& pCtx->REG.Attr.n.u1Present == 1) \
|
|
||||||
{ \
|
|
||||||
utcb->REG.ar = sel_ar_conv_to_nova(pCtx->REG.Attr.u | X86_SEL_TYPE_ACCESSED); \
|
|
||||||
} else { \
|
|
||||||
utcb->REG.ar = sel_ar_conv_to_nova(VMCS_SEG_UNUSABLE); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool vmx_load_state(Nova::Utcb * utcb, VM * pVM, PVMCPU pVCpu)
|
static inline bool vmx_load_state(Nova::Utcb * utcb, VM * pVM, PVMCPU pVCpu)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@ pthread
|
|||||||
vbox_auto_win7
|
vbox_auto_win7
|
||||||
vbox_auto_win7_share
|
vbox_auto_win7_share
|
||||||
vbox_auto_win8
|
vbox_auto_win8
|
||||||
|
vbox_auto_win81_64
|
||||||
tz_vmm
|
tz_vmm
|
||||||
vmm
|
vmm
|
||||||
bomb
|
bomb
|
||||||
|
Loading…
x
Reference in New Issue
Block a user