vbox5/6: set ia32_tsc_aux for rdtscp usage

Fixes #4314
This commit is contained in:
Alexander Boettcher 2021-11-02 15:40:04 +01:00 committed by Christian Helmuth
parent 533015b93e
commit c774272366
3 changed files with 28 additions and 0 deletions

View File

@ -421,6 +421,11 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<Genode::Thread>,
{ {
PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu); PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu);
::uint64_t tsc_aux = 0;
auto const rc_tsc = CPUMQueryGuestMsr(pVCpu, MSR_K8_TSC_AUX,
&tsc_aux);
Assert(rc_tsc == VINF_SUCCESS);
/* avoid utcb corruption by requesting tpr state early */ /* avoid utcb corruption by requesting tpr state early */
bool interrupt_pending = false; bool interrupt_pending = false;
uint8_t tpr = 0; uint8_t tpr = 0;
@ -430,6 +435,11 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher<Genode::Thread>,
/* don't call function hereafter which may corrupt the utcb ! */ /* don't call function hereafter which may corrupt the utcb ! */
using namespace Nova; using namespace Nova;
if (rc_tsc == VINF_SUCCESS) {
utcb->mtd |= Mtd::TSC_AUX;
utcb->tsc_aux = tsc_aux;
}
utcb->mtd |= Mtd::EIP; utcb->mtd |= Mtd::EIP;
utcb->ip = pCtx->rip; utcb->ip = pCtx->rip;

View File

@ -368,6 +368,15 @@ class Vcpu_handler : public Genode::List<Vcpu_handler>::Element
_state->tpr_threshold.charge(tpr_priority); _state->tpr_threshold.charge(tpr_priority);
} }
{
::uint64_t tsc_aux = 0;
auto const rcStrict = CPUMQueryGuestMsr(pVCpu, MSR_K8_TSC_AUX,
&tsc_aux);
Assert(rcStrict == VINF_SUCCESS);
if (rcStrict == VINF_SUCCESS)
_state->tsc_aux.charge(tsc_aux);
}
return true; return true;
} }

View File

@ -261,6 +261,15 @@ template <typename VIRT> void Sup::Vcpu_impl<VIRT>::_transfer_state_to_vcpu(CPUM
::memcpy(fpu._buffer, ctx.pXStateR3, sizeof(fpu)); ::memcpy(fpu._buffer, ctx.pXStateR3, sizeof(fpu));
}); });
{
::uint64_t tsc_aux = 0;
auto const rcStrict = CPUMQueryGuestMsr(&_vmcpu, MSR_K8_TSC_AUX,
&tsc_aux);
Assert(rcStrict == VINF_SUCCESS);
if (rcStrict == VINF_SUCCESS)
state.tsc_aux.charge(tsc_aux);
}
/* do SVM/VMX-specific transfers */ /* do SVM/VMX-specific transfers */
VIRT::transfer_state_to_vcpu(state, ctx); VIRT::transfer_state_to_vcpu(state, ctx);
} }