[PATCH] x86/alternatives: Remove double patching in ALTERNATIVE_TERNARY

From: Brian Gerst
Date: Sat Oct 08 2022 - 16:14:53 EST


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

Signed-off-by: Brian Gerst <brgerst@xxxxxxxxx>
---
arch/x86/include/asm/alternative.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index 9542c582d546..f4efce972277 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -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__ */
--
2.37.3