Skip to contentSkip to conversation

x86/alternatives: Remove double patching in ALTERNATIVE_TERNARY

PATCH New Brian Gerst 1 participant 1 message Oct 8, 2022 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/alternatives: Remove double patching in ALTERNATIVE_TERNARY

Use ALT_NOT(feature) instead of X86_FEATURE_ALWAYS to avoid patching the code twice when the feature is present.

---
 arch/x86/include/asm/alternative.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/alternative.h +2 -2
index 9542c582d546..f4efce972277 100644
@@ -181,7 +181,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
 
 /* If @feature is set, patch in @newinstr_yes, otherwise @newinstr_no. */
 #define ALTERNATIVE_TERNARY(oldinstr, feature, newinstr_yes, newinstr_no) \
-	ALTERNATIVE_2(oldinstr, newinstr_no, X86_FEATURE_ALWAYS,	\
+	ALTERNATIVE_2(oldinstr, newinstr_no, ALT_NOT(feature),		\
 		      newinstr_yes, feature)
 
 #define ALTERNATIVE_3(oldinsn, newinsn1, feat1, newinsn2, feat2, newinsn3, feat3) \
@@ -386,7 +386,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
 
 /* If @feature is set, patch in @newinstr_yes, otherwise @newinstr_no. */
 #define ALTERNATIVE_TERNARY(oldinstr, feature, newinstr_yes, newinstr_no) \
-	ALTERNATIVE_2 oldinstr, newinstr_no, X86_FEATURE_ALWAYS,	\
+	ALTERNATIVE_2 oldinstr, newinstr_no, ALT_NOT(feature),		\
 	newinstr_yes, feature
 
 #endif /* __ASSEMBLY__ */
Signature · 1 line
2.37.3