Skip to content

Commit 863ceaf

Browse files
author
Requiem
committed
chore: minor changes
1 parent affe870 commit 863ceaf

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

src/vmaware.hpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,9 @@ struct VM {
19471947
};
19481948

19491949
std::string model_string;
1950+
#ifdef __VMAWARE_DEBUG__
19501951
const char* debug_tag = "";
1952+
#endif
19511953

19521954
if (type == cpu_type::AMD) {
19531955
if (!cpu::is_amd()) {
@@ -2311,7 +2313,9 @@ struct VM {
23112313
constexpr size_t targetLen = (std::size(targetName) - 1);
23122314

23132315
LIST_ENTRY* head = &ldr->InMemoryOrderModuleList;
2314-
for (LIST_ENTRY* cur = head->Flink; cur != head; cur = cur->Flink) {
2316+
// static analyzers don't know that InMemoryOrderModuleList is a circular list managed by the loader
2317+
// so they conservatively assume head->Flink or some cur->Flink might be nullptr
2318+
for (LIST_ENTRY* cur = head->Flink; cur != nullptr && cur != head; cur = cur->Flink) {
23152319
auto* ent = CONTAINING_RECORD(cur, LDR_DATA_TABLE_ENTRY, InMemoryOrderLinks);
23162320
if (!ent) continue;
23172321

@@ -4652,7 +4656,7 @@ struct VM {
46524656
std::this_thread::sleep_for(std::chrono::milliseconds(1));
46534657
#endif
46544658

4655-
// since we made a sleep, cache is cold (a cache flush might be induced, although is rare, it could happen with sleeps like 500ms)
4659+
// since we made a sleep, cache is cold (a cache flush might be induced, although is rare, it could happen with sleeps of 500ms)
46564660
// so we warm-up to stabilize microarchitectural state (uop cache, predictors, etc)
46574661
for (int w = 0; w < 128; ++w) {
46584662
volatile u64 tmp = cpuid();
@@ -4671,7 +4675,7 @@ struct VM {
46714675
else
46724676
median = (samples[iterations / 2 - 1] + samples[iterations / 2]) / 2;
46734677

4674-
debug("TIMER: Median -> ", median);
4678+
debug("TIMER: VMEXIT latency -> ", median);
46754679

46764680
// we compute the median instead of the average to be immune against DPC/APC (interrupts/kernel noise in general)
46774681
if (median >= cycle_threshold) {
@@ -9720,15 +9724,6 @@ struct VM {
97209724
* @implements VM::EDID
97219725
*/
97229726
[[nodiscard]] static bool edid() {
9723-
// compiles to single mov
9724-
auto read_le16 = [](const BYTE* p) noexcept -> u16 {
9725-
u16 v; memcpy(&v, p, sizeof(v)); return v;
9726-
};
9727-
9728-
auto read_le32 = [](const BYTE* p) noexcept -> u32 {
9729-
u32 v; memcpy(&v, p, sizeof(v)); return v;
9730-
};
9731-
97329727
auto decode_manufacturer = [](const BYTE* edid, char out[4]) noexcept {
97339728
const u16 word = static_cast<u16>((edid[8] << 8) | edid[9]);
97349729

@@ -11181,7 +11176,7 @@ struct VM {
1118111176

1118211177
// remove Hyper-V artifacts if found with other brands
1118311178
if (active_count > 1) {
11184-
int idx = find_index(TMP_HYPERV_ARTIFACT);
11179+
const int idx = find_index(TMP_HYPERV_ARTIFACT);
1118511180
if (idx != -1) {
1118611181
remove_at(idx);
1118711182
}

0 commit comments

Comments
 (0)