]> xenbits.xensource.com Git - xen.git/commitdiff
x86/emulate: Remove HAVE_AS_RDRAND and HAVE_AS_RDSEED
authorDenis Mukhin <dmukhin@ford.com>
Sat, 5 Apr 2025 01:25:07 +0000 (01:25 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 7 Apr 2025 11:55:06 +0000 (12:55 +0100)
The new toolchain baseline knows the RDRAND and RDSEED instructions; no need
to carry the workaround in the code.

Fix up arch_get_random() too.

No functional change.

Resolves: https://gitlab.com/xen-project/xen/-/work_items/208
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/arch.mk
xen/arch/x86/include/asm/random.h
xen/arch/x86/x86_emulate/0fc7.c

index 8615533697e78dba97ddb1bdcfbb6d90fc5fd977..7882fb895e1fec4462a8e8cc8bfab3a6fc05d7e8 100644 (file)
@@ -10,8 +10,6 @@ CFLAGS += -msoft-float
 
 $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
 $(call cc-option-add,CFLAGS,CC,-Wnested-externs)
-$(call as-option-add,CFLAGS,CC,"rdrand %eax",-DHAVE_AS_RDRAND)
-$(call as-option-add,CFLAGS,CC,"rdseed %eax",-DHAVE_AS_RDSEED)
 $(call as-option-add,CFLAGS,CC,".equ \"x\"$(comma)1",-DHAVE_AS_QUOTED_SYM)
 $(call as-option-add,CFLAGS,CC,"movdiri %rax$(comma)(%rax)",-DHAVE_AS_MOVDIR)
 $(call as-option-add,CFLAGS,CC,"enqcmd (%rax)$(comma)%rax",-DHAVE_AS_ENQCMD)
index 9e1fe0bc1d01d1ef23aed06faf7537bfc553e774..cd0f650b63bdefe2bb4c0b69d4843e367867446d 100644 (file)
@@ -8,7 +8,7 @@ static inline unsigned int arch_get_random(void)
     unsigned int val = 0;
 
     if ( cpu_has(&current_cpu_data, X86_FEATURE_RDRAND) )
-        asm volatile ( ".byte 0x0f,0xc7,0xf0" : "+a" (val) );
+        asm volatile ( "rdrand %0" : "=r" (val) );
 
     return val;
 }
index 5268d5cafd7b225be9e3a4a69a4954b826a1aa27..58c8f79501debe74280b88564a3c6fbe63e4b33e 100644 (file)
@@ -32,7 +32,6 @@ int x86emul_0fc7(struct x86_emulate_state *s,
             return X86EMUL_UNRECOGNIZED;
 
         case 6: /* rdrand */
-#ifdef HAVE_AS_RDRAND
             generate_exception_if(s->vex.pfx >= vex_f3, X86_EXC_UD);
             host_and_vcpu_must_have(rdrand);
             *dst = s->ea;
@@ -43,12 +42,12 @@ int x86emul_0fc7(struct x86_emulate_state *s,
                       : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) );
                 break;
             default:
-# ifdef __x86_64__
+#ifdef __x86_64__
                 asm ( "rdrand %k0" ASM_FLAG_OUT(, "; setc %1")
                       : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) );
                 break;
             case 8:
-# endif
+#endif
                 asm ( "rdrand %0" ASM_FLAG_OUT(, "; setc %1")
                       : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) );
                 break;
@@ -57,9 +56,6 @@ int x86emul_0fc7(struct x86_emulate_state *s,
             if ( carry )
                 regs->eflags |= X86_EFLAGS_CF;
             break;
-#else
-            return X86EMUL_UNIMPLEMENTED;
-#endif
 
         case 7: /* rdseed / rdpid */
             if ( s->vex.pfx == vex_f3 ) /* rdpid */
@@ -77,7 +73,7 @@ int x86emul_0fc7(struct x86_emulate_state *s,
                 dst->bytes = 4;
                 break;
             }
-#ifdef HAVE_AS_RDSEED
+
             generate_exception_if(s->vex.pfx >= vex_f3, X86_EXC_UD);
             host_and_vcpu_must_have(rdseed);
             *dst = s->ea;
@@ -88,12 +84,12 @@ int x86emul_0fc7(struct x86_emulate_state *s,
                       : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) );
                 break;
             default:
-# ifdef __x86_64__
+#ifdef __x86_64__
                 asm ( "rdseed %k0" ASM_FLAG_OUT(, "; setc %1")
                       : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) );
                 break;
             case 8:
-# endif
+#endif
                 asm ( "rdseed %0" ASM_FLAG_OUT(, "; setc %1")
                       : "=r" (dst->val), ASM_FLAG_OUT("=@ccc", "=qm") (carry) );
                 break;
@@ -102,7 +98,6 @@ int x86emul_0fc7(struct x86_emulate_state *s,
             if ( carry )
                 regs->eflags |= X86_EFLAGS_CF;
             break;
-#endif
         }
     }
     else