Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
target/i386: do not accept RDSEED if CPUID bit absent
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Jun 26, 2023
1 parent 691925e commit f9e0dba
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions target/i386/tcg/translate.c
Expand Up @@ -3925,12 +3925,20 @@ static bool disas_insn(DisasContext *s, CPUState *cpu)
break;

case 7: /* RDSEED */
if (mod != 3 ||
(s->prefix & (PREFIX_LOCK | PREFIX_REPZ | PREFIX_REPNZ)) ||
!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_RDSEED)) {
goto illegal_op;
}
goto do_rdrand;

case 6: /* RDRAND */
if (mod != 3 ||
(s->prefix & (PREFIX_LOCK | PREFIX_REPZ | PREFIX_REPNZ)) ||
!(s->cpuid_ext_features & CPUID_EXT_RDRAND)) {
goto illegal_op;
}
do_rdrand:
translator_io_start(&s->base);
gen_helper_rdrand(s->T0, cpu_env);
rm = (modrm & 7) | REX_B(s);
Expand Down

0 comments on commit f9e0dba

Please sign in to comment.