diff --git a/repos/ports/src/virtualbox/main.cc b/repos/ports/src/virtualbox/main.cc index 7896ab501..72bce4603 100644 --- a/repos/ports/src/virtualbox/main.cc +++ b/repos/ports/src/virtualbox/main.cc @@ -21,12 +21,18 @@ /* libc includes */ #include +/* libc memory allocator */ +#include + /* Virtualbox includes of VBoxBFE */ #include #include -void *operator new (Genode::size_t size) { - return Genode::env()->heap()->alloc(size); } +void *operator new (Genode::size_t size) +{ + static Libc::Mem_alloc_impl heap(Genode::env()->rm_session()); + return heap.alloc(size, 0x10); +} void *operator new [] (Genode::size_t size) { return Genode::env()->heap()->alloc(size); } diff --git a/repos/ports/src/virtualbox/nova/vcpu.h b/repos/ports/src/virtualbox/nova/vcpu.h index fd6a84459..25400b295 100644 --- a/repos/ports/src/virtualbox/nova/vcpu.h +++ b/repos/ports/src/virtualbox/nova/vcpu.h @@ -73,6 +73,8 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher { private: + X86FXSTATE _fpu_state __attribute__((aligned(0x10))); + Genode::Cap_connection _cap_connection; Vmm::Vcpu_other_pd _vcpu; @@ -670,9 +672,11 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher */ VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC); - /* write FPU state from pCtx to vCPU */ + /* save current FPU state */ + fpu_save(reinterpret_cast(&_fpu_state)); + /* write FPU state from pCtx to FPU registers */ fpu_load(reinterpret_cast(&pCtx->fpu)); - + /* tell kernel to transfer current fpu registers to vCPU */ utcb->mtd |= Mtd::FPU; _current_vm = pVM; @@ -686,8 +690,10 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher _current_vm = 0; _current_vcpu = 0; - /* write FPU state of vCPU to pCtx */ + /* write FPU state of vCPU (in current FPU registers) to pCtx */ fpu_save(reinterpret_cast(&pCtx->fpu)); + /* load saved FPU state of EMT thread */ + fpu_load(reinterpret_cast(&_fpu_state)); // CPUMSetChangedFlags(pVCpu, CPUM_CHANGED_GLOBAL_TLB_FLUSH);