Skip to content

Commit 82b545b

Browse files
author
Requiem
committed
2 parents dcf6ad4 + 239ab88 commit 82b545b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/vmaware.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4612,7 +4612,7 @@ struct VM {
46124612
cpu::cpuid(regs, 0x80000001);
46134613
const bool have_rdtscp = (regs[3] & (1u << 27)) != 0;
46144614
if (!have_rdtscp) {
4615-
debug("TIMER: RDTSCP instruction not supported"); // __rdtscp should be supported nowadays
4615+
debug("TIMER: (1/7) RDTSCP instruction not supported"); // __rdtscp should be supported nowadays
46164616
return true;
46174617
}
46184618

@@ -5011,15 +5011,18 @@ struct VM {
50115011
debug("TIMER: vmexit latency: ", cpuid_latency);
50125012

50135013
if (cpuid_latency >= cycle_threshold) {
5014+
debug("TIMER: (2/7) CPUID latency is above cycle threshold");
50145015
return true;
50155016
}
50165017
else if (cpuid_latency <= 25) {
50175018
// cpuid is fully serializing, no CPU have this low average cycles in real-world scenarios
50185019
// however, in patches, zero or even negative deltas can be seen oftenly
5020+
debug("TIMER: (3/7) CPUID latency is far too low in practice");
50195021
return true;
50205022
}
50215023

50225024
if (t1_delta == 0 || calib_delta == 0) {
5025+
debug("TIMER: (4/7) calibration and thread deltas are both null");
50235026
return true;
50245027
}
50255028

@@ -5028,10 +5031,12 @@ struct VM {
50285031

50295032
// if thread 1 was faster than thread 2, hypervisor downscaled TSC per-vCPU in either cpuid or rdtsc
50305033
if (ratio < 0.95 || ratio > 1.05) {
5034+
debug("TIMER: (5/7) thread 1 was faster than thread 2, hypervisor is downscaling TSC");
50315035
return true;
50325036
}
50335037
// if calibration was much faster than thread 1, hypervisor downscaled TSC globally while thread 2 was spamming
50345038
if (calibration_ratio < 0.95) {
5039+
debug("TIMER: (6/7) hypervisor is globally downscaling TSC");
50355040
return true;
50365041
}
50375042

@@ -5086,7 +5091,7 @@ struct VM {
50865091
_freea(raw);
50875092

50885093
if (speed < 800) {
5089-
debug("TIMER: VMAware detected an hypervisor offsetting TSC: ", speed);
5094+
debug("TIMER: (7/7) VMAware detected a hypervisor offsetting TSC: ", speed);
50905095
return true;
50915096
}
50925097
#endif
@@ -13005,4 +13010,4 @@ std::array<VM::core::technique, VM::enum_size + 1> VM::core::technique_table = [
1300513010
return table;
1300613011
}();
1300713012

13008-
#endif // include guard end
13013+
#endif // include guard end

0 commit comments

Comments
 (0)