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

[Xen-devel] [PATCH v3 5/5] x86: remove usage of .skip with non-absolute expressions



Clang assembler doesn't support using .skip with non-absolute
expressions:

entry.S:109:15: error: expected absolute expression
        .skip .Lcr4_alt_end - .Lcr4_alt, 0x90
              ^

This usage of .skip was to fill code sections with NOPs in order for
them to be patched at run time if required by the alternatives
framework. Instead of using .skip use the appropriate number of NOPs
to match the size of the alternative code.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Tim Deegan <tim@xxxxxxx>
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/Rules.mk                       | 5 -----
 xen/arch/x86/x86_64/compat/entry.S | 9 ++++++++-
 xen/arch/x86/x86_64/entry.S        | 2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/xen/Rules.mk b/xen/Rules.mk
index 205f0aff30..51bcd5804c 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -66,11 +66,6 @@ endif
 
 AFLAGS-y                += -D__ASSEMBLY__
 
-# Clang's built-in assembler doesn't understand .skip or .rept assembler
-# directives without an absolute value:
-# https://bugs.llvm.org/show_bug.cgi?id=27369
-AFLAGS-$(clang)         += -no-integrated-as
-
 ALL_OBJS := $(ALL_OBJS-y)
 
 # Get gcc to generate the dependencies for us.
diff --git a/xen/arch/x86/x86_64/compat/entry.S 
b/xen/arch/x86/x86_64/compat/entry.S
index e668f00c36..d94220b6b6 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -106,7 +106,14 @@ ENTRY(compat_restore_all_guest)
         mov   $~(X86_EFLAGS_IOPL|X86_EFLAGS_NT|X86_EFLAGS_VM),%r11d
         and   UREGS_eflags(%rsp),%r11d
 .Lcr4_orig:
-        .skip .Lcr4_alt_end - .Lcr4_alt, 0x90
+        ASM_NOP8 /* testb $3,UREGS_cs(%rsp) */
+        ASM_NOP2 /* jpe   .Lcr4_alt_end */
+        ASM_NOP8 /* mov   CPUINFO_cr4...(%rsp), %rax */
+        ASM_NOP6 /* and   $..., %rax */
+        ASM_NOP8 /* mov   %rax, CPUINFO_cr4...(%rsp) */
+        ASM_NOP3 /* mov   %rax, %cr4 */
+        ASM_NOP8 /* mov   %rax, CPUINFO_cr4...(%rsp) */
+        ASM_NOP2 /* jne   1b */
 .Lcr4_orig_end:
         .pushsection .altinstr_replacement, "ax"
 .Lcr4_alt:
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index af703f6c06..d9dce0e421 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -529,7 +529,7 @@ handle_exception_saved:
 
 .Lcr4_pv32_orig:
         jmp   .Lcr4_pv32_done
-        .skip (.Lcr4_pv32_alt_end - .Lcr4_pv32_alt) - (. - .Lcr4_pv32_orig), 
0xcc
+        ASM_NOP2 /* jmp is 2 bytes, the alternative mov is 4 bytes. */
         .pushsection .altinstr_replacement, "ax"
 .Lcr4_pv32_alt:
         mov   VCPU_domain(%rbx),%rax
-- 
2.15.1


_______________________________________________
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®.