]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
target/i386: do not accept RDSEED if CPUID bit absent
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 20 Jun 2023 22:43:22 +0000 (00:43 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 26 Jun 2023 08:23:02 +0000 (10:23 +0200)
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/tcg/translate.c

index 0de068d4b7913dc60a8b057c88f6bde3749529ad..4ef45bbd71e5fe1d9577642722ba0caa4b4c57cb 100644 (file)
@@ -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);