aboutsummaryrefslogtreecommitdiff
path: root/src/randomenv.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2019-11-19 14:55:02 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2019-11-19 14:56:23 -0800
commitba2c5fe1477cec80d7e02f824daba21a1021758e (patch)
treef201d39c33957f9719189928acda780d6d872879 /src/randomenv.cpp
parentb4a1da9ef8e4b673c290d5b882527e627ae1b43a (diff)
downloadbitcoin-ba2c5fe1477cec80d7e02f824daba21a1021758e.tar.xz
Fix CPUID subleaf iteration
Diffstat (limited to 'src/randomenv.cpp')
-rw-r--r--src/randomenv.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/randomenv.cpp b/src/randomenv.cpp
index ec42ddabc3..79f7bc93b1 100644
--- a/src/randomenv.cpp
+++ b/src/randomenv.cpp
@@ -198,12 +198,23 @@ void AddAllCPUID(CSHA512& hasher)
AddCPUID(hasher, 0, 0, ax, bx, cx, dx); // Returns max leaf in ax
uint32_t max = ax;
for (uint32_t leaf = 1; leaf <= max; ++leaf) {
+ uint32_t maxsub = 0;
for (uint32_t subleaf = 0;; ++subleaf) {
AddCPUID(hasher, leaf, subleaf, ax, bx, cx, dx);
- // Iterate over subleaves for leaf 4, 11, 13
- if (leaf != 4 && leaf != 11 && leaf != 13) break;
- if ((leaf == 4 || leaf == 13) && ax == 0) break;
- if (leaf == 11 && (cx & 0xFF00) == 0) break;
+ // Iterate subleafs for leaf values 4, 7, 11, 13
+ if (leaf == 4) {
+ if ((ax & 0x1f) == 0) break;
+ } else if (leaf == 7) {
+ if (subleaf == 0) maxsub = ax;
+ if (subleaf == maxsub) break;
+ } else if (leaf == 11) {
+ if ((cx & 0xff00) == 0) break;
+ } else if (leaf == 13) {
+ if (ax == 0 && bx == 0 && cx == 0 && dx == 0) break;
+ } else {
+ // For any other leaf, stop after subleaf 0.
+ break;
+ }
}
}
// Iterate over all extended leaves