Skip to content

Commit b293afb

Browse files
committed
Revert "feat(vex): hide RDRAND and RDSEED from CPUID with --deterministic-rng"
This reverts commit 81d7365.
1 parent bca1dda commit b293afb

4 files changed

Lines changed: 9 additions & 15 deletions

File tree

‎VEX/priv/guest_amd64_toIR.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22079,12 +22079,8 @@ Long dis_ESC_0F (
2207922079
if (fAddr == &amd64g_dirtyhelper_CPUID_avx2
2208022080
|| fAddr == &amd64g_dirtyhelper_CPUID_avx_and_cx16) {
2208122081
Bool hasF16C = (archinfo->hwcaps & VEX_HWCAPS_AMD64_F16C) != 0;
22082-
/* A deterministic RNG still serves RDRAND/RDSEED but hides them. */
22083-
Bool advertiseRng = vex_random32 == NULL;
22084-
Bool hasRDRAND = advertiseRng
22085-
&& (archinfo->hwcaps & VEX_HWCAPS_AMD64_RDRAND) != 0;
22086-
Bool hasRDSEED = advertiseRng
22087-
&& (archinfo->hwcaps & VEX_HWCAPS_AMD64_RDSEED) != 0;
22082+
Bool hasRDRAND = (archinfo->hwcaps & VEX_HWCAPS_AMD64_RDRAND) != 0;
22083+
Bool hasRDSEED = (archinfo->hwcaps & VEX_HWCAPS_AMD64_RDSEED) != 0;
2208822084
args = mkIRExprVec_4(IRExpr_GSPTR(),
2208922085
mkIRExpr_HWord(hasF16C ? 1 : 0),
2209022086
mkIRExpr_HWord(hasRDRAND ? 1 : 0),

‎VEX/pub/libvex.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,7 @@ extern void LibVEX_Init (
689689
);
690690

691691
/* Install before guest execution. NULL preserves host RDRAND/RDSEED.
692-
Otherwise CPUID hides them, and they return bits from this callback,
693-
which runs on the executing guest thread. */
692+
The callback runs on the executing guest thread and returns 32 random bits. */
694693
extern void LibVEX_SetRandom32 ( UInt (*random32)(void) );
695694

696695

‎docs/xml/manual-core.xml‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,11 +810,10 @@ in most cases. We group the available options by rough categories.</para>
810810
<computeroutput>/dev/random</computeroutput> and
811811
<computeroutput>/dev/urandom</computeroutput> (resolved
812812
through <computeroutput>/proc/self/fd</computeroutput>, so
813-
symlinks count). On amd64, CPUID does not report
814-
<computeroutput>RDRAND</computeroutput> and
815-
<computeroutput>RDSEED</computeroutput>. On hosts that support them,
816-
programs that execute them anyway draw from the calling thread's PRNG
817-
stream, which always reports success. On arm64,
813+
symlinks count). On amd64, <computeroutput>RDRAND</computeroutput>
814+
and <computeroutput>RDSEED</computeroutput> draw from the calling
815+
thread's PRNG stream and always report success. CPUID still
816+
reports them only when the host supports them. On arm64,
818817
<computeroutput>RNDR</computeroutput> and
819818
<computeroutput>RNDRRS</computeroutput> draw from the same stream and
820819
always report success, also on hosts without FEAT_RNG.

‎none/tests/amd64/deterministic_rng.stdout.exp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
cpuid rdrand: 0
2-
cpuid rdseed: 0
1+
cpuid rdrand: 1
2+
cpuid rdseed: 1
33
rdrand16: 555555555555d78e
44
rdrand16: 555555555555b519
55
rdrand32: 00000000131a7a6b

0 commit comments

Comments
 (0)