[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 3/7] x86: introduce altinstruction_nop assembler macro



This allows shortening (and making more obvious what they do) some
altinstruction_entry uses.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -135,8 +135,7 @@ ENTRY(compat_restore_all_guest)
         jne   1b
 .Lcr4_alt_end:
         .section .altinstructions, "a"
-        altinstruction_entry .Lcr4_orig, .Lcr4_orig, X86_FEATURE_ALWAYS, \
-                             (.Lcr4_orig_end - .Lcr4_orig), 0
+        altinstruction_nop .Lcr4_orig, .Lcr4_orig_end, X86_FEATURE_ALWAYS
         altinstruction_entry .Lcr4_orig, .Lcr4_alt, X86_FEATURE_XEN_SMEP, \
                              (.Lcr4_orig_end - .Lcr4_orig), \
                              (.Lcr4_alt_end - .Lcr4_alt)
--- a/xen/include/asm-x86/alternative-asm.h
+++ b/xen/include/asm-x86/alternative-asm.h
@@ -17,6 +17,15 @@
     .byte \alt_len
 .endm
 
+/* As above, but to replace the entire range by suitable NOPs. */
+.macro altinstruction_nop start end feature
+    .long \start - .
+    .long \start - .
+    .word \feature
+    .byte \end - \start
+    .byte 0
+.endm
+
 .macro ALTERNATIVE oldinstr, newinstr, feature
 .Lold_start_\@:
     \oldinstr
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -193,24 +193,24 @@ void ret_from_intr(void);
 
 #ifdef __ASSEMBLY__
 #define ASM_AC(op)                                                     \
-        661: ASM_NOP3;                                                 \
+        661: ASM_NOP3; 660:;                                           \
         .pushsection .altinstr_replacement, "ax";                      \
         662: __ASM_##op;                                               \
         .popsection;                                                   \
         .pushsection .altinstructions, "a";                            \
-        altinstruction_entry 661b, 661b, X86_FEATURE_ALWAYS, 3, 0;     \
-        altinstruction_entry 661b, 662b, X86_FEATURE_XEN_SMAP, 3, 3;       \
+        altinstruction_nop 661b, 660b, X86_FEATURE_ALWAYS;             \
+        altinstruction_entry 661b, 662b, X86_FEATURE_XEN_SMAP, 3, 3;   \
         .popsection
 
 #define ASM_STAC ASM_AC(STAC)
 #define ASM_CLAC ASM_AC(CLAC)
 
 #define CR4_PV32_RESTORE                                           \
-        667: ASM_NOP5;                                             \
+        667: ASM_NOP5; 669:;                                       \
         .pushsection .altinstr_replacement, "ax";                  \
         668: call cr4_pv32_restore;                                \
         .section .altinstructions, "a";                            \
-        altinstruction_entry 667b, 667b, X86_FEATURE_ALWAYS, 5, 0; \
+        altinstruction_nop 667b, 669b, X86_FEATURE_ALWAYS;         \
         altinstruction_entry 667b, 668b, X86_FEATURE_XEN_SMEP, 5, 5;   \
         altinstruction_entry 667b, 668b, X86_FEATURE_XEN_SMAP, 5, 5;   \
         .popsection




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.