Skip to contentSkip to conversation

x86: use alternative_input() in cache_flush()

PATCH In review Jan Beulich 2 participants 4 messages Sep 30, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: use alternative_input() in cache_flush()

There's no point using alternative_io() when there are no outputs.

No functional change.

xen/arch/x86/flushtlb.c +4 -5
@@ -286,11 +286,10 @@ void cache_flush(const void *addr, unsig
          * + prefix than a clflush + nop, and hence the prefix is added instead
          * of letting the alternative framework fill the gap by appending nops.
          */
-        alternative_io("ds; clflush %[p]",
-                       "data16 clflush %[p]", /* clflushopt */
-                       X86_FEATURE_CLFLUSHOPT,
-                       /* no outputs */,
-                       [p] "m" (*(const char *)(addr)));
+        alternative_input("ds; clflush %[p]",
+                          "data16 clflush %[p]", /* clflushopt */
+                           X86_FEATURE_CLFLUSHOPT,
+                           [p] "m" (*(const char *)(addr)));
     }
 
     alternative_2("",
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jan Beulich

There's no point using alternative_io() when there are no outputs.

No functional change.

xen/arch/x86/flushtlb.c void cache_flush(const void *addr, unsig · line 289

Quoted 9 lines
xen/arch/x86/flushtlb.c +1 -5
@@ -286,11 +286,10 @@ void cache_flush(const void *addr, unsig
          * + prefix than a clflush + nop, and hence the prefix is added instead
          * of letting the alternative framework fill the gap by appending nops.
          */
-        alternative_io("ds; clflush %[p]",
-                       "data16 clflush %[p]", /* clflushopt */
-                       X86_FEATURE_CLFLUSHOPT,
-                       /* no outputs */,
-                       [p] "m" (*(const char *)(addr)));
+        alternative_input("ds; clflush %[p]",

Drop the ; as you're altering the line anyway?

However, switching to ds ds will avoid a trailing nop, so will be marginally better.

Quoted 6 lines
xen/arch/x86/flushtlb.c +3 -0
+                          "data16 clflush %[p]", /* clflushopt */
+                           X86_FEATURE_CLFLUSHOPT,
+                           [p] "m" (*(const char *)(addr)));
     }
 
     alternative_2("",
#2 lore raw
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Jan Beulich

There's no point using alternative_io() when there are no outputs.

No functional change.

Quoted 14 lines

xen/arch/x86/flushtlb.c void cache_flush(const void *addr, unsig · line 289

Quoted 12 lines
xen/arch/x86/flushtlb.c +1 -5
@@ -286,11 +286,10 @@ void cache_flush(const void *addr, unsig
          * + prefix than a clflush + nop, and hence the prefix is added instead
          * of letting the alternative framework fill the gap by appending nops.
          */
-        alternative_io("ds; clflush %[p]",
-                       "data16 clflush %[p]", /* clflushopt */
-                       X86_FEATURE_CLFLUSHOPT,
-                       /* no outputs */,
-                       [p] "m" (*(const char *)(addr)));
+        alternative_input("ds; clflush %[p]",

Drop the ; as you're altering the line anyway?

Oh, sure.

Quoted 1 line

Thanks.

Quoted 2 lines

However, switching to ds ds will avoid a trailing nop, so will be marginally better.

I don't think I understand, which may or may not be due to me not being sure whether "ds ds" is a typo. What trailing NOP are you seeing? The "ds" that's there already covers for the sole trailing NOP that would otherwise result due to the "data16" prefix.

Jan

#3 lore raw
Quoted 24 lines · Jan Beulich
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Jan Beulich

There's no point using alternative_io() when there are no outputs.

No functional change.

Quoted 13 lines

xen/arch/x86/flushtlb.c void cache_flush(const void *addr, unsig · line 289

Quoted 12 lines
xen/arch/x86/flushtlb.c +1 -5
@@ -286,11 +286,10 @@ void cache_flush(const void *addr, unsig
          * + prefix than a clflush + nop, and hence the prefix is added instead
          * of letting the alternative framework fill the gap by appending nops.
          */
-        alternative_io("ds; clflush %[p]",
-                       "data16 clflush %[p]", /* clflushopt */
-                       X86_FEATURE_CLFLUSHOPT,
-                       /* no outputs */,
-                       [p] "m" (*(const char *)(addr)));
+        alternative_input("ds; clflush %[p]",

Drop the ; as you're altering the line anyway?

Oh, sure.

Quoted 1 line
Quoted 8 lines

Thanks.

Quoted 2 lines

However, switching to ds ds will avoid a trailing nop, so will be marginally better.

I don't think I understand, which may or may not be due to me not being sure whether "ds ds" is a typo. What trailing NOP are you seeing? The "ds" that's there already covers for the sole trailing NOP that would otherwise result due to the "data16" prefix.

Oh of course.  I can't count.  Sorry for the noise.

~Andrew