diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2019-11-19 14:55:02 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2019-11-19 14:56:23 -0800 |
commit | ba2c5fe1477cec80d7e02f824daba21a1021758e (patch) | |
tree | f201d39c33957f9719189928acda780d6d872879 /src/randomenv.cpp | |
parent | b4a1da9ef8e4b673c290d5b882527e627ae1b43a (diff) |
Fix CPUID subleaf iteration
Diffstat (limited to 'src/randomenv.cpp')
-rw-r--r-- | src/randomenv.cpp | 19 |
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 |