Skip to content

Commit 2f9cd11

Browse files
committed
updated VM::PCI_VM_DEVICE_ID and removed VM::PCI_VM
1 parent 3ed9e37 commit 2f9cd11

2 files changed

Lines changed: 25 additions & 68 deletions

File tree

src/cli.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ bool is_disabled(const VM::enum_flags flag) {
331331
case VM::VMWARE_DMESG:
332332
case VM::PORT_CONNECTORS:
333333
case VM::ACPI_TEMPERATURE:
334-
case VM::LSHW_QEMU:
335-
case VM::PCI_VM: return true;
334+
case VM::LSHW_QEMU: return true;
336335
default: return false;
337336
}
338337
}
@@ -395,7 +394,6 @@ bool is_unsupported(VM::enum_flags flag) {
395394
case VM::FILE_ACCESS_HISTORY:
396395
case VM::UNKNOWN_MANUFACTURER:
397396
case VM::NSJAIL_PID:
398-
case VM::PCI_VM:
399397
case VM::PCI_VM_DEVICE_ID:
400398
// ADD LINUX FLAG
401399
return false;
@@ -974,7 +972,6 @@ void general() {
974972
checker(VM::FILE_ACCESS_HISTORY, "low file access count");
975973
checker(VM::UNKNOWN_MANUFACTURER, "unknown manufacturer ids");
976974
checker(VM::NSJAIL_PID, "nsjail PID");
977-
checker(VM::PCI_VM, "PCIe bridge ports");
978975
checker(VM::TPM, "TPM manufacturer");
979976
checker(VM::PCI_VM_DEVICE_ID, "PCI vendor/device ID");
980977
// ADD NEW TECHNIQUE CHECKER HERE

src/vmaware.hpp

Lines changed: 24 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ struct VM {
655655
AUDIO,
656656
UNKNOWN_MANUFACTURER,
657657
NSJAIL_PID,
658-
PCI_VM,
659658
TPM,
660659
PCI_VM_DEVICE_ID,
661660
// ADD NEW TECHNIQUE ENUM NAME HERE
@@ -1254,8 +1253,7 @@ struct VM {
12541253
!cache_keys.test(VMWARE_DMESG) &&
12551254
!cache_keys.test(PORT_CONNECTORS) &&
12561255
!cache_keys.test(ACPI_TEMPERATURE) &&
1257-
!cache_keys.test(LSHW_QEMU) &&
1258-
!cache_keys.test(PCI_VM)
1256+
!cache_keys.test(LSHW_QEMU)
12591257
);
12601258
}
12611259

@@ -9674,52 +9672,6 @@ struct VM {
96749672
}
96759673

96769674

9677-
/**
9678-
* @brief Check for PCIe bridge names for known VM keywords and brands
9679-
* @category Linux
9680-
* @implements VM::PCI_VM
9681-
*/
9682-
[[nodiscard]] static bool lspci() {
9683-
#if (!LINUX)
9684-
return false;
9685-
#else
9686-
if (!(
9687-
(util::exists("/usr/bin/lspci")) ||
9688-
(util::exists("/bin/lspci")) ||
9689-
(util::exists("/usr/sbin/lspci"))
9690-
)) {
9691-
debug("PCI_VM: ", "binary doesn't exist");
9692-
return false;
9693-
}
9694-
9695-
const std::unique_ptr<std::string> result = util::sys_result("lspci 2>&1");
9696-
9697-
if (result == nullptr) {
9698-
debug("PCI_VM: ", "invalid stdout output from lspci");
9699-
return false;
9700-
}
9701-
9702-
const std::string full_command = *result;
9703-
9704-
auto pci_finder = [&](const char* str) -> bool {
9705-
if (util::find(full_command, str)) {
9706-
debug("PCI_VM: found ", str);
9707-
return true;
9708-
} else {
9709-
return false;
9710-
}
9711-
};
9712-
9713-
if (pci_finder("QEMU PCIe Root port")) { return core::add(brands::QEMU); }
9714-
if (pci_finder("QEMU XHCI Host Controller")) { return core::add(brands::QEMU); }
9715-
if (pci_finder("QXL paravirtual graphic card")) { return core::add(brands::QEMU); }
9716-
if (pci_finder("Virtio")) { return true; } // could be used by a lot of brands, who knows
9717-
9718-
return false;
9719-
#endif
9720-
}
9721-
9722-
97239675
/**
97249676
* @brief Check if the system has a physical TPM by matching the TPM manufacturer against known physical TPM chip vendors
97259677
* @category Windows
@@ -9866,6 +9818,16 @@ struct VM {
98669818
);
98679819
}
98689820
#endif
9821+
9822+
auto found = [](const std::string &b) -> bool {
9823+
debug(
9824+
"PCI_VM_DEVICE_ID: found ", b, ", vendor ID = ",
9825+
"0x", std::setw(4), std::setfill('0'), std::hex, dev.vendor_id,
9826+
" device ID = 0x", std::setw(4), std::setfill('0'), std::hex, dev.device_id
9827+
);
9828+
9829+
return true;
9830+
};
98699831

98709832
for (const auto& dev : devices) {
98719833
const u32 id = ((dev.vendor_id << 16) | dev.device_id);
@@ -9891,6 +9853,7 @@ struct VM {
98919853
case 0x1af41053: // Virtio socket
98929854
case 0x1af4105a: // Virtio file system
98939855
case 0x1af41110: // Inter-VM shared memory
9856+
return true;
98949857

98959858
// VMware
98969859
case 0x15ad0405: // SVGA II Adapter
@@ -9922,6 +9885,7 @@ struct VM {
99229885
case 0x0e0f8002: // Root Hub
99239886
case 0x0e0f8003: // Root Hub
99249887
case 0x0e0ff80a: // Smoker FX2
9888+
return found(brands::VMWARE);
99259889

99269890
// Red Hat + QEMU
99279891
case 0x1b360001: // Red Hat, Inc. QEMU PCI-PCI bridge
@@ -9937,34 +9901,33 @@ struct VM {
99379901
case 0x1b360010: // Red Hat, Inc. QEMU NVM Express Controller
99389902
case 0x1b360011: // Red Hat, Inc. QEMU PVPanic device
99399903
case 0x1b360013: // Red Hat, Inc. QEMU UFS Host Controller
9904+
case 0x1b360100: // Red Hat, Inc. QXL paravirtual graphic card
99409905

99419906
// QEMU
9942-
case 0x6270001: // Adomax Technology Co., Ltd QEMU Tablet
9907+
case 0x06270001: // Adomax Technology Co., Ltd QEMU Tablet
99439908
case 0x1d1d1f1f: // CNEX Labs QEMU NVM Express LightNVM Controller
99449909
case 0x80865845: // Intel Corporation QEMU NVM Express Controller
99459910
case 0x1d6b0200: // Linux Foundation Qemu Audio Device
9946-
9911+
return found(brands::QEMU);
9912+
99479913
// vGPUs (mostly NVIDIA)
99489914
case 0x10de0fe7: // GK107GL [GRID K100 vGPU]
99499915
case 0x10de0ff7: // GK107GL [GRID K140Q vGPU]
99509916
case 0x10de118d: // GK104GL [GRID K200 vGPU]
99519917
case 0x10de11b0: // GK104GL [GRID K240Q\K260Q vGPU]
99529918
case 0x1ec6020f: // Vastai Technologies SG100 vGPU
9919+
return true;
99539920

99549921
// VirtualBox
99559922
case 0x80ee0021: // USB Tablet
99569923
case 0x80ee0022: // multitouch tablet
9924+
return found(brands::VBOX);
99579925

9958-
// misc
9959-
case 0x29556e61: // Connectix (VirtualPC) OHCI USB 1.1 controller
9960-
case 0x1ab84000: // Parallels, Inc. Virtual Machine Communication Interface
9961-
debug(
9962-
"PCI_VM_DEVICE_ID: found vendor ID = ",
9963-
"0x", std::setw(4), std::setfill('0'), std::hex, dev.vendor_id,
9964-
" device ID = 0x", std::setw(4), std::setfill('0'), std::hex, dev.device_id
9965-
);
9966-
9967-
return true;
9926+
// Connectix (VirtualPC) OHCI USB 1.1 controller
9927+
case 0x29556e61: return found(brands::VPC);
9928+
9929+
// Parallels, Inc. Virtual Machine Communication Interface
9930+
case 0x1ab84000: return found(brands::PARALLELS);
99689931
}
99699932

99709933
// TODO: EXTRAS TO ADD (64 instead of 32 bits for device_id field)
@@ -10344,7 +10307,6 @@ struct VM {
1034410307
flags.flip(PORT_CONNECTORS);
1034510308
flags.flip(ACPI_TEMPERATURE);
1034610309
flags.flip(LSHW_QEMU);
10347-
flags.flip(PCI_VM);
1034810310

1034910311
// disable all the settings flags
1035010312
flags.flip(NO_MEMO);
@@ -11277,7 +11239,6 @@ struct VM {
1127711239
case AUDIO: return "AUDIO";
1127811240
case UNKNOWN_MANUFACTURER: return "UNKNOWN_MANUFACTURER";
1127911241
case NSJAIL_PID: return "NSJAIL_PID";
11280-
case PCI_VM: return "PCI_VM";
1128111242
case TPM: return "TPM";
1128211243

1128311244
case PCI_VM_DEVICE_ID: return "PCI_VM_DEVICE_ID";
@@ -11846,7 +11807,6 @@ std::pair<VM::enum_flags, VM::core::technique> VM::core::technique_list[] = {
1184611807
std::make_pair(VM::AUDIO, VM::core::technique(25, VM::check_audio)),
1184711808
std::make_pair(VM::UNKNOWN_MANUFACTURER, VM::core::technique(50, VM::unknown_manufacturer)),
1184811809
std::make_pair(VM::NSJAIL_PID, VM::core::technique(75, VM::nsjail_proc_id)),
11849-
std::make_pair(VM::PCI_VM, VM::core::technique(100, VM::lspci)),
1185011810
std::make_pair(VM::TPM, VM::core::technique(50, VM::tpm)),
1185111811
std::make_pair(VM::PCI_VM_DEVICE_ID, VM::core::technique(90, VM::pci_vm_device_id)),
1185211812
// ADD NEW TECHNIQUE STRUCTURE HERE

0 commit comments

Comments
 (0)