cmds: add cpu whitelist for features check
Not all CPUs can be detected with their correct feature set. For example does cpu_features not work well enough when the support does not support AVX (see https://github.com/google/cpu_features/issues/4). To mitigate this we maintain a list of whitelisted CPU models.
This commit is contained in:
parent
24bd4f69a1
commit
e7de965e40
1 changed files with 23 additions and 2 deletions
|
|
@ -21,6 +21,18 @@
|
||||||
#include "cpu_features_macros.h"
|
#include "cpu_features_macros.h"
|
||||||
#include "cpuinfo_x86.h"
|
#include "cpuinfo_x86.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
std::vector<std::string> cpu_whitelist = {
|
||||||
|
// QEMU does not necessarily expose correctly that it supports SSE and friends even
|
||||||
|
// when started with `-cpu qemu64,+ssse3,+sse4.1,+sse4.2,+x2apic`
|
||||||
|
"QEMU",
|
||||||
|
|
||||||
|
// Intel Core i7 M620 does not support AVX which causes cpu_features to not
|
||||||
|
// detect SSE and friends correctly
|
||||||
|
"M 620",
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
anbox::cmds::CheckFeatures::CheckFeatures()
|
anbox::cmds::CheckFeatures::CheckFeatures()
|
||||||
: CommandWithFlagsAndAction{
|
: CommandWithFlagsAndAction{
|
||||||
cli::Name{"check-features"}, cli::Usage{"check-features"},
|
cli::Name{"check-features"}, cli::Usage{"check-features"},
|
||||||
|
|
@ -41,9 +53,18 @@ anbox::cmds::CheckFeatures::CheckFeatures()
|
||||||
|
|
||||||
char brand_string[49];
|
char brand_string[49];
|
||||||
cpu_features::FillX86BrandString(brand_string);
|
cpu_features::FillX86BrandString(brand_string);
|
||||||
const auto is_qemu = utils::string_starts_with(brand_string, "QEMU");
|
std::string brand(brand_string);
|
||||||
|
|
||||||
if (missing_features.size() > 0 && !is_qemu) {
|
// Check if we have a CPU which's features we can't detect correctly
|
||||||
|
auto is_whitelisted = false;
|
||||||
|
for (const auto &entry : cpu_whitelist) {
|
||||||
|
if (brand.find(entry) != std::string::npos) {
|
||||||
|
is_whitelisted = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missing_features.size() > 0 && !is_whitelisted) {
|
||||||
std::cerr << "The CPU of your computer (" << brand_string << ") does not support all" << std::endl
|
std::cerr << "The CPU of your computer (" << brand_string << ") does not support all" << std::endl
|
||||||
<< "features Anbox requires." << std::endl
|
<< "features Anbox requires." << std::endl
|
||||||
<< "It is missing support for the following features: ";
|
<< "It is missing support for the following features: ";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue