All of lore.kernel.org
 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 1/2] x86/clang: fix build with indirect thunks
Date: Wed, 24 Jan 2018 15:48:48 +0000	[thread overview]
Message-ID: <20180124154849.84889-2-roger.pau@citrix.com> (raw)
In-Reply-To: <20180124154849.84889-1-roger.pau@citrix.com>

The build with clang is currently broken because clang requires asm
macros to be declared inside the same inline asm declaration where
they are used.

In order to fix this always include indirect_thunk_asm.h in the same
asm declaration where it's being used.

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                           | 6 ++++--
 xen/arch/x86/extable.c                 | 3 ++-
 xen/arch/x86/x86_emulate/x86_emulate.c | 3 ++-
 xen/common/wait.c                      | 1 +
 xen/include/asm-x86/asm_defns.h        | 7 ++++---
 5 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/xen/Rules.mk b/xen/Rules.mk
index 3cf40754a6..1bd3fa1773 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -66,8 +66,10 @@ endif
 
 AFLAGS-y                += -D__ASSEMBLY__
 
-# Clang's built-in assembler can't handle embedded .include's
-CFLAGS-$(clang)         += -no-integrated-as
+# Clang's built-in assembler doesn't understand 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)
 
diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 72f30d9060..30893c3770 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -158,7 +158,8 @@ static int __init stub_selftest(void)
         memcpy(ptr, tests[i].opc, ARRAY_SIZE(tests[i].opc));
         unmap_domain_page(ptr);
 
-        asm volatile ( "INDIRECT_CALL %[stb]\n"
+        asm volatile ( INCLUDE_INDIRECT_THUNK
+                       "INDIRECT_CALL %[stb]\n"
                        ".Lret%=:\n\t"
                        ".pushsection .fixup,\"ax\"\n"
                        ".Lfix%=:\n\t"
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index ff0a003902..e525e6bb0d 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -867,7 +867,8 @@ static inline int mkec(uint8_t e, int32_t ec, ...)
 #ifdef __XEN__
 # define invoke_stub(pre, post, constraints...) do {                    \
     union stub_exception_token res_ = { .raw = ~0 };                    \
-    asm volatile ( pre "\n\tINDIRECT_CALL %[stub]\n\t" post "\n"        \
+    asm volatile ( INCLUDE_INDIRECT_THUNK                               \
+                   pre "\n\tINDIRECT_CALL %[stub]\n\t" post "\n"        \
                    ".Lret%=:\n\t"                                       \
                    ".pushsection .fixup,\"ax\"\n"                       \
                    ".Lfix%=:\n\t"                                       \
diff --git a/xen/common/wait.c b/xen/common/wait.c
index a57bc10d61..91dcd46342 100644
--- a/xen/common/wait.c
+++ b/xen/common/wait.c
@@ -207,6 +207,7 @@ void check_wakeup_from_wait(void)
      * restored from the stack, so are available for use here.
      */
     asm volatile (
+        INCLUDE_INDIRECT_THUNK
         "mov %1,%%"__OP"sp; INDIRECT_JMP %[ip]"
         : : "S" (wqv->stack), "D" (wqv->esp),
           "c" ((char *)get_cpu_info() - (char *)wqv->esp),
diff --git a/xen/include/asm-x86/asm_defns.h b/xen/include/asm-x86/asm_defns.h
index d2d91ca1fa..627a544326 100644
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -16,9 +16,10 @@
 #ifdef __ASSEMBLY__
 # include <asm/indirect_thunk_asm.h>
 #else
-asm ( "\t.equ CONFIG_INDIRECT_THUNK, "
-      __stringify(IS_ENABLED(CONFIG_INDIRECT_THUNK)) );
-asm ( "\t.include \"asm/indirect_thunk_asm.h\"" );
+#define INCLUDE_INDIRECT_THUNK                                  \
+    "\t.equ CONFIG_INDIRECT_THUNK, "                            \
+    __stringify(IS_ENABLED(CONFIG_INDIRECT_THUNK)) "\n"         \
+    "\t.include \"asm/indirect_thunk_asm.h\"\n"
 #endif
 
 #ifndef __ASSEMBLY__
-- 
2.15.1


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

  reply	other threads:[~2018-01-24 15:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24 15:48 [PATCH 0/2] clang: fixes for the indirect thunk Roger Pau Monne
2018-01-24 15:48 ` Roger Pau Monne [this message]
2018-01-24 16:40   ` [PATCH 1/2] x86/clang: fix build with indirect thunks Jan Beulich
2018-01-24 17:06     ` Roger Pau Monné
2018-01-25  9:39       ` Jan Beulich
2018-01-25  9:50         ` Roger Pau Monné
2018-01-24 15:48 ` [PATCH 2/2] x86: fix indirect thunk usage of CONFIG_INDIRECT_THUNK Roger Pau Monne
2018-01-24 16:23   ` Jan Beulich
2018-01-24 16:52     ` Roger Pau Monné
2018-01-25 10:13       ` Jan Beulich
2018-01-25 10:15       ` 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=20180124154849.84889-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.