Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions VEX/priv/guest_amd64_toIR.c
Original file line number Diff line number Diff line change
Expand Up @@ -22079,12 +22079,8 @@ Long dis_ESC_0F (
if (fAddr == &amd64g_dirtyhelper_CPUID_avx2
|| fAddr == &amd64g_dirtyhelper_CPUID_avx_and_cx16) {
Bool hasF16C = (archinfo->hwcaps & VEX_HWCAPS_AMD64_F16C) != 0;
/* A deterministic RNG still serves RDRAND/RDSEED but hides them. */
Bool advertiseRng = vex_random32 == NULL;
Bool hasRDRAND = advertiseRng
&& (archinfo->hwcaps & VEX_HWCAPS_AMD64_RDRAND) != 0;
Bool hasRDSEED = advertiseRng
&& (archinfo->hwcaps & VEX_HWCAPS_AMD64_RDSEED) != 0;
Bool hasRDRAND = (archinfo->hwcaps & VEX_HWCAPS_AMD64_RDRAND) != 0;
Bool hasRDSEED = (archinfo->hwcaps & VEX_HWCAPS_AMD64_RDSEED) != 0;
args = mkIRExprVec_4(IRExpr_GSPTR(),
mkIRExpr_HWord(hasF16C ? 1 : 0),
mkIRExpr_HWord(hasRDRAND ? 1 : 0),
Expand Down
3 changes: 1 addition & 2 deletions VEX/pub/libvex.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,7 @@ extern void LibVEX_Init (
);

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


Expand Down
9 changes: 4 additions & 5 deletions docs/xml/manual-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -810,11 +810,10 @@ in most cases. We group the available options by rough categories.</para>
<computeroutput>/dev/random</computeroutput> and
<computeroutput>/dev/urandom</computeroutput> (resolved
through <computeroutput>/proc/self/fd</computeroutput>, so
symlinks count). On amd64, CPUID does not report
<computeroutput>RDRAND</computeroutput> and
<computeroutput>RDSEED</computeroutput>. On hosts that support them,
programs that execute them anyway draw from the calling thread's PRNG
stream, which always reports success. On arm64,
symlinks count). On amd64, <computeroutput>RDRAND</computeroutput>
and <computeroutput>RDSEED</computeroutput> draw from the calling
thread's PRNG stream and always report success. CPUID still
reports them only when the host supports them. On arm64,
<computeroutput>RNDR</computeroutput> and
<computeroutput>RNDRRS</computeroutput> draw from the same stream and
always report success, also on hosts without FEAT_RNG.
Expand Down
4 changes: 2 additions & 2 deletions none/tests/amd64/deterministic_rng.stdout.exp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cpuid rdrand: 0
cpuid rdseed: 0
cpuid rdrand: 1
cpuid rdseed: 1
rdrand16: 555555555555d78e
rdrand16: 555555555555b519
rdrand32: 00000000131a7a6b
Expand Down
Loading