x86: Avoid using .byte for instructions where safe to do so

The new toolchain baseline knows XGETBV, VPXOR and VPOR.

For the other cases using .byte, annotate the toolchain minima.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
This commit is contained in:
Andrew Cooper committed 2026-04-09 21:04:58 +01:00
1 parent d473af5006
commit 964a4d4281
7 files changed
+27 -23

No files matched your search

+4
View File
@@ -17,7 +17,11 @@ CFLAGS-$(CONFIG_CC_IS_GCC) += -malign-data=abi
$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
$(call cc-option-add,CFLAGS,CC,-Wnested-externs)
$(call as-option-add,CFLAGS,CC,".equ \"x\"$(comma)1",-DHAVE_AS_QUOTED_SYM)
# Binutils >= 2.31, Clang >= 7
$(call as-option-add,CFLAGS,CC,"movdiri %rax$(comma)(%rax)",-DHAVE_AS_MOVDIR)
# Binutils >= 2.33, Clang >= 9
$(call as-option-add,CFLAGS,CC,"enqcmd (%rax)$(comma)%rax",-DHAVE_AS_ENQCMD)
# Check to see whether the assembler supports the .nop directive.
+1
View File
@@ -1,5 +1,6 @@
#include <asm/page-bits.h>
/* binutils >= 2.26 or Clang >= 3.8 */
.macro clzero
.byte 0x0f, 0x01, 0xfc
.endm
+2
View File
@@ -63,6 +63,8 @@ static inline void wrmsrns(uint32_t msr, uint64_t val)
/*
* WRMSR is 2 bytes. WRMSRNS is 3 bytes. Pad WRMSR with a redundant CS
* prefix to avoid a trailing NOP.
*
* Binutils >= 2.40, Clang >= 16
*/
alternative_input(".byte 0x2e; wrmsr",
".byte 0x0f,0x01,0xc6", X86_FEATURE_WRMSRNS,
+2 -2
View File
@@ -19,7 +19,7 @@ static inline uint32_t rdpkru(void)
{
uint32_t pkru;
asm volatile ( ".byte 0x0f,0x01,0xee"
asm volatile ( ".byte 0x0f,0x01,0xee" /* binutils >= 2.26 or Clang >= 3.8 */
: "=a" (pkru) : "c" (0) : "dx" );
return pkru;
@@ -27,7 +27,7 @@ static inline uint32_t rdpkru(void)
static inline void wrpkru(uint32_t pkru)
{
asm volatile ( ".byte 0x0f,0x01,0xef"
asm volatile ( ".byte 0x0f,0x01,0xef" /* binutils >= 2.26 or Clang >= 3.8 */
:: "a" (pkru), "d" (0), "c" (0) );
}
+1 -2
View File
@@ -118,8 +118,7 @@ static inline uint64_t xgetbv(unsigned int index)
uint32_t lo, hi;
ASSERT(index); /* get_xcr0() should be used instead. */
asm volatile ( ".byte 0x0f,0x01,0xd0" /* xgetbv */
: "=a" (lo), "=d" (hi) : "c" (index) );
asm volatile ( "xgetbv" : "=a" (lo), "=d" (hi) : "c" (index) );
return lo | ((uint64_t)hi << 32);
}
+1 -1
View File
@@ -122,7 +122,7 @@ int x86emul_0f01(struct x86_emulate_state *s,
{
case vex_none: /* serialize */
host_and_vcpu_must_have(serialize);
asm volatile ( ".byte 0x0f, 0x01, 0xe8" );
asm volatile ( ".byte 0x0f, 0x01, 0xe8" ); /* Binutils >= 2.34, Clang >= 11 */
break;
case vex_f2: /* xsusldtrk */
vcpu_must_have(tsxldtrk);
+16 -18
View File
@@ -4748,27 +4748,25 @@ x86_emulate(
*/
if ( vex.l )
{
/* vpxor %xmmN, %xmmN, %xmmN */
asm volatile ( ".byte 0xc5,0xf9,0xef,0xc0" );
asm volatile ( ".byte 0xc5,0xf1,0xef,0xc9" );
asm volatile ( ".byte 0xc5,0xe9,0xef,0xd2" );
asm volatile ( ".byte 0xc5,0xe1,0xef,0xdb" );
asm volatile ( ".byte 0xc5,0xd9,0xef,0xe4" );
asm volatile ( ".byte 0xc5,0xd1,0xef,0xed" );
asm volatile ( ".byte 0xc5,0xc9,0xef,0xf6" );
asm volatile ( ".byte 0xc5,0xc1,0xef,0xff" );
asm volatile ( "vpxor %xmm0, %xmm0, %xmm0" );
asm volatile ( "vpxor %xmm1, %xmm1, %xmm1" );
asm volatile ( "vpxor %xmm2, %xmm2, %xmm2" );
asm volatile ( "vpxor %xmm3, %xmm3, %xmm3" );
asm volatile ( "vpxor %xmm4, %xmm4, %xmm4" );
asm volatile ( "vpxor %xmm5, %xmm5, %xmm5" );
asm volatile ( "vpxor %xmm6, %xmm6, %xmm6" );
asm volatile ( "vpxor %xmm7, %xmm7, %xmm7" );
}
else
{
/* vpor %xmmN, %xmmN, %xmmN */
asm volatile ( ".byte 0xc5,0xf9,0xeb,0xc0" );
asm volatile ( ".byte 0xc5,0xf1,0xeb,0xc9" );
asm volatile ( ".byte 0xc5,0xe9,0xeb,0xd2" );
asm volatile ( ".byte 0xc5,0xe1,0xeb,0xdb" );
asm volatile ( ".byte 0xc5,0xd9,0xeb,0xe4" );
asm volatile ( ".byte 0xc5,0xd1,0xeb,0xed" );
asm volatile ( ".byte 0xc5,0xc9,0xeb,0xf6" );
asm volatile ( ".byte 0xc5,0xc1,0xeb,0xff" );
asm volatile ( "vpor %xmm0, %xmm0, %xmm0" );
asm volatile ( "vpor %xmm1, %xmm1, %xmm1" );
asm volatile ( "vpor %xmm2, %xmm2, %xmm2" );
asm volatile ( "vpor %xmm3, %xmm3, %xmm3" );
asm volatile ( "vpor %xmm4, %xmm4, %xmm4" );
asm volatile ( "vpor %xmm5, %xmm5, %xmm5" );
asm volatile ( "vpor %xmm6, %xmm6, %xmm6" );
asm volatile ( "vpor %xmm7, %xmm7, %xmm7" );
}
ASSERT(!state->simd_size);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.