2022-11-19 10:40:32 -05:00
|
|
|
static int
|
|
|
|
|
opRDTSC(uint32_t fetchdat)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2022-11-19 10:40:32 -05:00
|
|
|
if (!cpu_has_feature(CPU_FEATURE_RDTSC)) {
|
|
|
|
|
cpu_state.pc = cpu_state.oldpc;
|
|
|
|
|
x86illegal();
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if ((cr4 & CR4_TSD) && CPL) {
|
|
|
|
|
x86gpf("RDTSC when TSD set and CPL != 0", 0);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
EAX = tsc & 0xffffffff;
|
|
|
|
|
EDX = tsc >> 32;
|
|
|
|
|
CLOCK_CYCLES(1);
|
2020-06-13 12:32:09 +02:00
|
|
|
#ifdef USE_DYNAREC
|
2022-11-13 16:38:48 -05:00
|
|
|
if (cpu_use_dynarec)
|
|
|
|
|
update_tsc();
|
2020-06-13 12:32:09 +02:00
|
|
|
#endif
|
2022-11-19 10:40:32 -05:00
|
|
|
return 0;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-19 10:40:32 -05:00
|
|
|
static int
|
|
|
|
|
opRDPMC(uint32_t fetchdat)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2022-11-19 10:40:32 -05:00
|
|
|
if (ECX > 1 || (!(cr4 & CR4_PCE) && (cr0 & 1) && CPL)) {
|
|
|
|
|
x86gpf("RDPMC not allowed", 0);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
EAX = EDX = 0;
|
|
|
|
|
CLOCK_CYCLES(1);
|
|
|
|
|
return 0;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|