Alternatives patching code picks the most suitable NOPs for the
running system, so simply use it to replace the pre-populated ones.

Use an arbitrary, always available feature to key off from.

Signed-off-by: Jan Beulich <jbeul...@suse.com>

--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -185,6 +185,7 @@ ENTRY(compat_restore_all_guest)
         mov   %rax, %cr4
 .Lcr4_alt_end:
         .section .altinstructions, "a"
+        altinstruction_entry .Lcr4_orig, .Lcr4_orig, X86_FEATURE_LM, 12, 0
         altinstruction_entry .Lcr4_orig, .Lcr4_alt, X86_FEATURE_SMEP, 12, \
                              (.Lcr4_alt_end - .Lcr4_alt)
         altinstruction_entry .Lcr4_orig, .Lcr4_alt, X86_FEATURE_SMAP, 12, \
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -204,6 +204,7 @@ void ret_from_intr(void);
         662: __ASM_##op;                                               \
         .popsection;                                                   \
         .pushsection .altinstructions, "a";                            \
+        altinstruction_entry 661b, 661b, X86_FEATURE_LM, 3, 0;         \
         altinstruction_entry 661b, 662b, X86_FEATURE_SMAP, 3, 3;       \
         .popsection
 
@@ -215,6 +216,7 @@ void ret_from_intr(void);
         .pushsection .altinstr_replacement, "ax";                      \
         668: call cr4_smep_smap_restore;                               \
         .section .altinstructions, "a";                                \
+        altinstruction_entry 667b, 667b, X86_FEATURE_LM, 5, 0;         \
         altinstruction_entry 667b, 668b, X86_FEATURE_SMEP, 5, 5;       \
         altinstruction_entry 667b, 668b, X86_FEATURE_SMAP, 5, 5;       \
         .popsection



x86: use optimal NOPs to fill the SMAP/SMEP placeholders

Alternatives patching code picks the most suitable NOPs for the
running system, so simply use it to replace the pre-populated ones.

Use an arbitrary, always available feature to key off from.

Signed-off-by: Jan Beulich <jbeul...@suse.com>

--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -185,6 +185,7 @@ ENTRY(compat_restore_all_guest)
         mov   %rax, %cr4
 .Lcr4_alt_end:
         .section .altinstructions, "a"
+        altinstruction_entry .Lcr4_orig, .Lcr4_orig, X86_FEATURE_LM, 12, 0
         altinstruction_entry .Lcr4_orig, .Lcr4_alt, X86_FEATURE_SMEP, 12, \
                              (.Lcr4_alt_end - .Lcr4_alt)
         altinstruction_entry .Lcr4_orig, .Lcr4_alt, X86_FEATURE_SMAP, 12, \
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -204,6 +204,7 @@ void ret_from_intr(void);
         662: __ASM_##op;                                               \
         .popsection;                                                   \
         .pushsection .altinstructions, "a";                            \
+        altinstruction_entry 661b, 661b, X86_FEATURE_LM, 3, 0;         \
         altinstruction_entry 661b, 662b, X86_FEATURE_SMAP, 3, 3;       \
         .popsection
 
@@ -215,6 +216,7 @@ void ret_from_intr(void);
         .pushsection .altinstr_replacement, "ax";                      \
         668: call cr4_smep_smap_restore;                               \
         .section .altinstructions, "a";                                \
+        altinstruction_entry 667b, 667b, X86_FEATURE_LM, 5, 0;         \
         altinstruction_entry 667b, 668b, X86_FEATURE_SMEP, 5, 5;       \
         altinstruction_entry 667b, 668b, X86_FEATURE_SMAP, 5, 5;       \
         .popsection
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to