mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-25 14:41:02 +00:00
Revert earlier rdtsc changes, implement fixes
This commit is contained in:
@@ -328,7 +328,7 @@ windows_emulator::windows_emulator(std::unique_ptr<x86_64_emulator> emu, const e
|
||||
this->map_port(mapping.first, mapping.second);
|
||||
}
|
||||
|
||||
this->setup_hooks();
|
||||
this->setup_hooks();
|
||||
}
|
||||
|
||||
windows_emulator::~windows_emulator() = default;
|
||||
@@ -434,9 +434,6 @@ void windows_emulator::on_instruction_execution(const uint64_t address)
|
||||
|
||||
void windows_emulator::setup_hooks()
|
||||
{
|
||||
uint64_t tsc_base = splitmix64(0xCAFEBABEDEADBEEFull);
|
||||
constexpr uint64_t tick_scale = 50;
|
||||
|
||||
this->emu().hook_instruction(x86_hookable_instructions::syscall, [&] {
|
||||
this->dispatcher.dispatch(*this);
|
||||
return instruction_hook_continuation::skip_instruction;
|
||||
@@ -445,8 +442,7 @@ void windows_emulator::setup_hooks()
|
||||
this->emu().hook_instruction(x86_hookable_instructions::rdtscp, [&] {
|
||||
this->callbacks.on_rdtscp();
|
||||
|
||||
const uint64_t retired = this->executed_instructions_;
|
||||
const uint64_t ticks = tsc_base + (retired * tick_scale);
|
||||
const auto ticks = this->clock_->timestamp_counter();
|
||||
this->emu().reg(x86_register::rax, static_cast<uint32_t>(ticks));
|
||||
this->emu().reg(x86_register::rdx, static_cast<uint32_t>(ticks >> 32));
|
||||
|
||||
@@ -460,8 +456,7 @@ void windows_emulator::setup_hooks()
|
||||
this->emu().hook_instruction(x86_hookable_instructions::rdtsc, [&] {
|
||||
this->callbacks.on_rdtsc();
|
||||
|
||||
const uint64_t retired = this->executed_instructions_;
|
||||
const uint64_t ticks = tsc_base + (retired * tick_scale);
|
||||
const auto ticks = this->clock_->timestamp_counter();
|
||||
this->emu().reg(x86_register::rax, static_cast<uint32_t>(ticks));
|
||||
this->emu().reg(x86_register::rdx, static_cast<uint32_t>(ticks >> 32));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user