Merge pull request #1968 from SChernykh/dev

Added virtual machine detection
This commit is contained in:
xmrig 2020-12-06 23:45:53 +07:00 committed by GitHub
commit 1c9e959cc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 4 deletions

View file

@ -88,12 +88,13 @@ static void print_cpu(Config *)
{ {
const auto info = Cpu::info(); const auto info = Cpu::info();
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s%s (%zu)") " %sx64 %sAES", Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s%s (%zu)") " %sx64 %sAES%s",
"CPU", "CPU",
info->brand(), info->brand(),
info->packages(), info->packages(),
info->isX64() ? GREEN_BOLD_S : RED_BOLD_S "-", info->isX64() ? GREEN_BOLD_S : RED_BOLD_S "-",
info->hasAES() ? GREEN_BOLD_S : RED_BOLD_S "-" info->hasAES() ? GREEN_BOLD_S : RED_BOLD_S "-",
info->isVM() ? RED_BOLD_S " VM" : ""
); );
# if defined(XMRIG_FEATURE_HWLOC) # if defined(XMRIG_FEATURE_HWLOC)
Log::print(WHITE_BOLD(" %-13s") BLACK_BOLD("L2:") WHITE_BOLD("%.1f MB") BLACK_BOLD(" L3:") WHITE_BOLD("%.1f MB") Log::print(WHITE_BOLD(" %-13s") BLACK_BOLD("L2:") WHITE_BOLD("%.1f MB") BLACK_BOLD(" L3:") WHITE_BOLD("%.1f MB")

View file

@ -64,6 +64,7 @@ public:
FLAG_XOP, FLAG_XOP,
FLAG_POPCNT, FLAG_POPCNT,
FLAG_CAT_L3, FLAG_CAT_L3,
FLAG_VM,
FLAG_MAX FLAG_MAX
}; };
@ -83,6 +84,7 @@ public:
virtual bool hasBMI2() const = 0; virtual bool hasBMI2() const = 0;
virtual bool hasOneGbPages() const = 0; virtual bool hasOneGbPages() const = 0;
virtual bool hasCatL3() const = 0; virtual bool hasCatL3() const = 0;
virtual bool isVM() const = 0;
virtual const char *backend() const = 0; virtual const char *backend() const = 0;
virtual const char *brand() const = 0; virtual const char *brand() const = 0;
virtual CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const = 0; virtual CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const = 0;

View file

@ -52,8 +52,8 @@
namespace xmrig { namespace xmrig {
constexpr size_t kCpuFlagsSize = 12; constexpr size_t kCpuFlagsSize = 13;
static const std::array<const char *, kCpuFlagsSize> flagNames = { "aes", "avx2", "avx512f", "bmi2", "osxsave", "pdpe1gb", "sse2", "ssse3", "sse4.1", "xop", "popcnt", "cat_l3" }; static const std::array<const char *, kCpuFlagsSize> flagNames = { "aes", "avx2", "avx512f", "bmi2", "osxsave", "pdpe1gb", "sse2", "ssse3", "sse4.1", "xop", "popcnt", "cat_l3", "vm" };
static_assert(kCpuFlagsSize == ICpuInfo::FLAG_MAX, "kCpuFlagsSize and FLAG_MAX mismatch"); static_assert(kCpuFlagsSize == ICpuInfo::FLAG_MAX, "kCpuFlagsSize and FLAG_MAX mismatch");
@ -148,6 +148,7 @@ static inline bool has_sse41() { return has_feature(PROCESSOR_INFO,
static inline bool has_xop() { return has_feature(0x80000001, ECX_Reg, 1 << 11); } static inline bool has_xop() { return has_feature(0x80000001, ECX_Reg, 1 << 11); }
static inline bool has_popcnt() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 23); } static inline bool has_popcnt() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 23); }
static inline bool has_cat_l3() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 15) && has_feature(0x10, EBX_Reg, 1 << 1); } static inline bool has_cat_l3() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 15) && has_feature(0x10, EBX_Reg, 1 << 1); }
static inline bool is_vm() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 31); }
} // namespace xmrig } // namespace xmrig
@ -185,6 +186,7 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
m_flags.set(FLAG_XOP, has_xop()); m_flags.set(FLAG_XOP, has_xop());
m_flags.set(FLAG_POPCNT, has_popcnt()); m_flags.set(FLAG_POPCNT, has_popcnt());
m_flags.set(FLAG_CAT_L3, has_cat_l3()); m_flags.set(FLAG_CAT_L3, has_cat_l3());
m_flags.set(FLAG_VM, is_vm());
# ifdef XMRIG_FEATURE_ASM # ifdef XMRIG_FEATURE_ASM
if (hasAES()) { if (hasAES()) {

View file

@ -52,6 +52,7 @@ protected:
inline bool hasBMI2() const override { return has(FLAG_BMI2); } inline bool hasBMI2() const override { return has(FLAG_BMI2); }
inline bool hasOneGbPages() const override { return has(FLAG_PDPE1GB); } inline bool hasOneGbPages() const override { return has(FLAG_PDPE1GB); }
inline bool hasCatL3() const override { return has(FLAG_CAT_L3); } inline bool hasCatL3() const override { return has(FLAG_CAT_L3); }
inline bool isVM() const override { return has(FLAG_VM); }
inline const char *brand() const override { return m_brand; } inline const char *brand() const override { return m_brand; }
inline MsrMod msrMod() const override { return m_msrMod; } inline MsrMod msrMod() const override { return m_msrMod; }
inline size_t cores() const override { return 0; } inline size_t cores() const override { return 0; }