xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Jan Beulich <jbeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v3 5/5] x86: remove usage of .skip with non-absolute expressions
Date: Mon, 29 Jan 2018 12:26:43 +0000	[thread overview]
Message-ID: <20180129122643.13008-6-roger.pau@citrix.com> (raw)
In-Reply-To: <20180129122643.13008-1-roger.pau@citrix.com>

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@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-01-29 12:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 12:26 [PATCH v3 0/5] clang fixes Roger Pau Monne
2018-01-29 12:26 ` [PATCH v3 1/5] build: filter out command line assembler arguments Roger Pau Monne
2018-01-29 14:12   ` Ian Jackson
2018-01-29 12:26 ` [PATCH v3 2/5] x86/clang: fix build with indirect thunks Roger Pau Monne
2018-01-29 16:42   ` Jan Beulich
2018-01-29 12:26 ` [PATCH v3 3/5] x86: fix indirect thunk usage of CONFIG_INDIRECT_THUNK Roger Pau Monne
2018-01-29 16:45   ` Jan Beulich
2018-01-29 17:00     ` Roger Pau Monné
2018-01-29 12:26 ` [PATCH v3 4/5] x86: move declaration of the exception_table to C Roger Pau Monne
2018-01-29 16:46   ` Jan Beulich
2018-01-29 12:26 ` Roger Pau Monne [this message]
2018-01-29 12:43   ` [PATCH v3 5/5] x86: remove usage of .skip with non-absolute expressions Wei Liu
2018-01-29 12:53     ` Roger Pau Monné
2018-01-29 13:02     ` Jan Beulich
2018-01-29 13:05       ` Andrew Cooper
2018-01-29 13:39         ` Jan Beulich
2018-01-29 16:50   ` Jan Beulich
2018-01-29 18:22     ` Andrew Cooper
2018-01-30  9:23     ` Roger Pau Monné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180129122643.13008-6-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).