mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-18 00:37:46 +00:00
MSR preset for Bulldozer CPUs
Also fixed verbose output for MSR presets with masks.
This commit is contained in:
parent
73722ce186
commit
665e43fecc
6 changed files with 26 additions and 6 deletions
|
@ -47,6 +47,7 @@ public:
|
||||||
MSR_MOD_NONE,
|
MSR_MOD_NONE,
|
||||||
MSR_MOD_RYZEN,
|
MSR_MOD_RYZEN,
|
||||||
MSR_MOD_INTEL,
|
MSR_MOD_INTEL,
|
||||||
|
MSR_MOD_BULLDOZER,
|
||||||
MSR_MOD_CUSTOM,
|
MSR_MOD_CUSTOM,
|
||||||
MSR_MOD_MAX
|
MSR_MOD_MAX
|
||||||
};
|
};
|
||||||
|
|
|
@ -145,6 +145,9 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_assembly = Assembly::BULLDOZER;
|
m_assembly = Assembly::BULLDOZER;
|
||||||
|
if (family == 21) {
|
||||||
|
m_msrMod = MSR_MOD_BULLDOZER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_vendor == VENDOR_INTEL) {
|
else if (m_vendor == VENDOR_INTEL) {
|
||||||
|
|
|
@ -181,6 +181,9 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_assembly = Assembly::BULLDOZER;
|
m_assembly = Assembly::BULLDOZER;
|
||||||
|
if (family == 21) {
|
||||||
|
m_msrMod = MSR_MOD_BULLDOZER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (memcmp(vendor, "GenuineIntel", 12) == 0) {
|
else if (memcmp(vendor, "GenuineIntel", 12) == 0) {
|
||||||
|
|
|
@ -60,16 +60,17 @@ static const std::array<const char *, RxConfig::ModeMax> modeNames = { "auto", "
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_MSR
|
#ifdef XMRIG_FEATURE_MSR
|
||||||
constexpr size_t kMsrArraySize = 4;
|
constexpr size_t kMsrArraySize = 5;
|
||||||
|
|
||||||
static const std::array<MsrItems, kMsrArraySize> msrPresets = {
|
static const std::array<MsrItems, kMsrArraySize> msrPresets = {
|
||||||
MsrItems(),
|
MsrItems(),
|
||||||
MsrItems{{ 0xC0011020, 0x0 }, { 0xC0011021, 0x40, ~0x20ULL }, { 0xC0011022, 0x510000 }, { 0xC001102b, 0x1808cc16 }},
|
MsrItems{{ 0xC0011020, 0x0 }, { 0xC0011021, 0x40, ~0x20ULL }, { 0xC0011022, 0x510000 }, { 0xC001102b, 0x1808cc16 }},
|
||||||
MsrItems{{ 0x1a4, 0xf }},
|
MsrItems{{ 0x1a4, 0xf }},
|
||||||
|
MsrItems{{ 0xc0011022, 0x2010, 0x2010 }, { 0xc001102b, 0x70000, 0x770000 }},
|
||||||
MsrItems()
|
MsrItems()
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::array<const char *, kMsrArraySize> modNames = { "none", "ryzen", "intel", "custom" };
|
static const std::array<const char *, kMsrArraySize> modNames = { "none", "ryzen", "intel", "bulldozer", "custom" };
|
||||||
|
|
||||||
static_assert (kMsrArraySize == ICpuInfo::MSR_MOD_MAX, "kMsrArraySize and MSR_MOD_MAX mismatch");
|
static_assert (kMsrArraySize == ICpuInfo::MSR_MOD_MAX, "kMsrArraySize and MSR_MOD_MAX mismatch");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -91,13 +91,19 @@ static MsrItem rdmsr(uint32_t reg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint64_t get_masked_value(uint64_t old_value, uint64_t new_value, uint64_t mask)
|
||||||
|
{
|
||||||
|
return (new_value & mask) | (old_value & ~mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool wrmsr_on_cpu(uint32_t reg, uint32_t cpu, uint64_t value, uint64_t mask)
|
static bool wrmsr_on_cpu(uint32_t reg, uint32_t cpu, uint64_t value, uint64_t mask)
|
||||||
{
|
{
|
||||||
// If a bit in mask is set to 1, use new value, otherwise use old value
|
// If a bit in mask is set to 1, use new value, otherwise use old value
|
||||||
if (mask != MsrItem::kNoMask) {
|
if (mask != MsrItem::kNoMask) {
|
||||||
uint64_t old_value;
|
uint64_t old_value;
|
||||||
if (rdmsr_on_cpu(reg, cpu, old_value)) {
|
if (rdmsr_on_cpu(reg, cpu, old_value)) {
|
||||||
value = (value & mask) | (old_value & ~mask);
|
value = get_masked_value(old_value, value, mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +168,7 @@ static bool wrmsr(const MsrItems &preset, bool save)
|
||||||
if (save) {
|
if (save) {
|
||||||
for (const auto &i : preset) {
|
for (const auto &i : preset) {
|
||||||
auto item = rdmsr(i.reg());
|
auto item = rdmsr(i.reg());
|
||||||
LOG_VERBOSE(CLEAR "%s" CYAN_BOLD("0x%08" PRIx32) CYAN(":0x%016" PRIx64) CYAN_BOLD(" -> 0x%016" PRIx64), tag, i.reg(), item.value(), i.value());
|
LOG_VERBOSE(CLEAR "%s" CYAN_BOLD("0x%08" PRIx32) CYAN(":0x%016" PRIx64) CYAN_BOLD(" -> 0x%016" PRIx64), tag, i.reg(), item.value(), get_masked_value(item.value(), i.value(), i.mask()));
|
||||||
|
|
||||||
if (item.isValid()) {
|
if (item.isValid()) {
|
||||||
savedState.emplace_back(item);
|
savedState.emplace_back(item);
|
||||||
|
|
|
@ -217,6 +217,12 @@ static MsrItem rdmsr(HANDLE driver, uint32_t reg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint64_t get_masked_value(uint64_t old_value, uint64_t new_value, uint64_t mask)
|
||||||
|
{
|
||||||
|
return (new_value & mask) | (old_value & ~mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool wrmsr(HANDLE driver, uint32_t reg, uint64_t value, uint64_t mask)
|
static bool wrmsr(HANDLE driver, uint32_t reg, uint64_t value, uint64_t mask)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
|
@ -230,7 +236,7 @@ static bool wrmsr(HANDLE driver, uint32_t reg, uint64_t value, uint64_t mask)
|
||||||
if (mask != MsrItem::kNoMask) {
|
if (mask != MsrItem::kNoMask) {
|
||||||
uint64_t old_value;
|
uint64_t old_value;
|
||||||
if (rdmsr(driver, reg, old_value)) {
|
if (rdmsr(driver, reg, old_value)) {
|
||||||
value = (value & mask) | (old_value & ~mask);
|
value = get_masked_value(old_value, value, mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +274,7 @@ static bool wrmsr(const MsrItems &preset, bool save)
|
||||||
if (save) {
|
if (save) {
|
||||||
for (const auto &i : preset) {
|
for (const auto &i : preset) {
|
||||||
auto item = rdmsr(driver, i.reg());
|
auto item = rdmsr(driver, i.reg());
|
||||||
LOG_VERBOSE(CLEAR "%s" CYAN_BOLD("0x%08" PRIx32) CYAN(":0x%016" PRIx64) CYAN_BOLD(" -> 0x%016" PRIx64), tag, i.reg(), item.value(), i.value());
|
LOG_VERBOSE(CLEAR "%s" CYAN_BOLD("0x%08" PRIx32) CYAN(":0x%016" PRIx64) CYAN_BOLD(" -> 0x%016" PRIx64), tag, i.reg(), item.value(), get_masked_value(item.value(), i.value(), i.mask()));
|
||||||
|
|
||||||
if (item.isValid()) {
|
if (item.isValid()) {
|
||||||
savedState.emplace_back(item);
|
savedState.emplace_back(item);
|
||||||
|
|
Loading…
Reference in a new issue