Skip to content

Commit 9957676

Browse files
author
Requiem
committed
remove: msr range checks for hv brands
1 parent efaec3c commit 9957676

File tree

1 file changed

+0
-29
lines changed

1 file changed

+0
-29
lines changed

src/vmaware.hpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11282,15 +11282,6 @@ struct VM {
1128211282
#endif
1128311283
constexpr u32 random_msr = 0xDEADBEEFu;
1128411284

11285-
struct range {
11286-
u32 start;
11287-
u32 end;
11288-
};
11289-
static constexpr range ranges[] = {
11290-
{ 0x40000000u, 0x400000FFu },
11291-
{ 0x4B564D00u, 0x4B564DFFu }
11292-
};
11293-
1129411285
auto try_read = [](u32 msr_index) -> bool {
1129511286
#if (MSVC)
1129611287
unsigned __int64 value = 0;
@@ -11338,26 +11329,6 @@ struct VM {
1133811329
debug("MSR: Detected hypervisor not correctly handling #GP");
1133911330
return true;
1134011331
}
11341-
for (size_t r = 0; r < (sizeof(ranges) / sizeof(ranges[0])); ++r) {
11342-
const u32 s = ranges[r].start;
11343-
const u32 e = ranges[r].end;
11344-
for (u32 i = s; i != e + 1u; ++i) {
11345-
if (try_read(i)) {
11346-
if (s == 0x40000000u && e == 0x400000FFu) {
11347-
debug("MSR: Detected Hyper-V VM");
11348-
return core::add(brands::HYPERV);
11349-
}
11350-
else if (s == 0x4B564D00u && e == 0x4B564DFFu) {
11351-
debug("MSR: Detected KVM");
11352-
return core::add(brands::KVM);
11353-
}
11354-
else {
11355-
debug("MSR: Detected readable MSR index: 0x", std::hex, i, std::dec, '\n');
11356-
return true;
11357-
}
11358-
}
11359-
}
11360-
}
1136111332

1136211333
return false;
1136311334
}

0 commit comments

Comments
 (0)