From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 1/4] x86: replace __ASM_{CL,ST}AC
Date: Wed, 15 Jul 2020 12:48:14 +0200 [thread overview]
Message-ID: <fc8e042e-fef8-ac38-34d8-16b13e4b0135@suse.com> (raw)
In-Reply-To: <58b9211a-f6dd-85da-d0bd-c927ac537a5d@suse.com>
Introduce proper assembler macros instead, enabled only when the
assembler itself doesn't support the insns. To avoid duplicating the
macros for assembly and C files, have them processed into asm-macros.h.
This in turn requires adding a multiple inclusion guard when generating
that header.
No change to generated code.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -235,7 +235,10 @@ $(BASEDIR)/include/asm-x86/asm-macros.h:
echo '#if 0' >$@.new
echo '.if 0' >>$@.new
echo '#endif' >>$@.new
+ echo '#ifndef __ASM_MACROS_H__' >>$@.new
+ echo '#define __ASM_MACROS_H__' >>$@.new
echo 'asm ( ".include \"$@\"" );' >>$@.new
+ echo '#endif /* __ASM_MACROS_H__ */' >>$@.new
echo '#if 0' >>$@.new
echo '.endif' >>$@.new
cat $< >>$@.new
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -20,6 +20,7 @@ $(call as-option-add,CFLAGS,CC,"rdrand %
$(call as-option-add,CFLAGS,CC,"rdfsbase %rax",-DHAVE_AS_FSGSBASE)
$(call as-option-add,CFLAGS,CC,"xsaveopt (%rax)",-DHAVE_AS_XSAVEOPT)
$(call as-option-add,CFLAGS,CC,"rdseed %eax",-DHAVE_AS_RDSEED)
+$(call as-option-add,CFLAGS,CC,"clac",-DHAVE_AS_CLAC_STAC)
$(call as-option-add,CFLAGS,CC,"clwb (%rax)",-DHAVE_AS_CLWB)
$(call as-option-add,CFLAGS,CC,".equ \"x\"$$(comma)1",-DHAVE_AS_QUOTED_SYM)
$(call as-option-add,CFLAGS,CC,"invpcid (%rax)$$(comma)%rax",-DHAVE_AS_INVPCID)
--- a/xen/arch/x86/asm-macros.c
+++ b/xen/arch/x86/asm-macros.c
@@ -1 +1,2 @@
+#include <asm/asm-defns.h>
#include <asm/alternative-asm.h>
--- /dev/null
+++ b/xen/include/asm-x86/asm-defns.h
@@ -0,0 +1,9 @@
+#ifndef HAVE_AS_CLAC_STAC
+.macro clac
+ .byte 0x0f, 0x01, 0xca
+.endm
+
+.macro stac
+ .byte 0x0f, 0x01, 0xcb
+.endm
+#endif
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -13,10 +13,12 @@
#include <asm/alternative.h>
#ifdef __ASSEMBLY__
+#include <asm/asm-defns.h>
#ifndef CONFIG_INDIRECT_THUNK
.equ CONFIG_INDIRECT_THUNK, 0
#endif
#else
+#include <asm/asm-macros.h>
asm ( "\t.equ CONFIG_INDIRECT_THUNK, "
__stringify(IS_ENABLED(CONFIG_INDIRECT_THUNK)) );
#endif
@@ -200,34 +202,27 @@ register unsigned long current_stack_poi
#endif
-/* "Raw" instruction opcodes */
-#define __ASM_CLAC ".byte 0x0f,0x01,0xca"
-#define __ASM_STAC ".byte 0x0f,0x01,0xcb"
-
#ifdef __ASSEMBLY__
.macro ASM_STAC
- ALTERNATIVE "", __ASM_STAC, X86_FEATURE_XEN_SMAP
+ ALTERNATIVE "", stac, X86_FEATURE_XEN_SMAP
.endm
.macro ASM_CLAC
- ALTERNATIVE "", __ASM_CLAC, X86_FEATURE_XEN_SMAP
+ ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
.endm
#else
static always_inline void clac(void)
{
/* Note: a barrier is implicit in alternative() */
- alternative("", __ASM_CLAC, X86_FEATURE_XEN_SMAP);
+ alternative("", "clac", X86_FEATURE_XEN_SMAP);
}
static always_inline void stac(void)
{
/* Note: a barrier is implicit in alternative() */
- alternative("", __ASM_STAC, X86_FEATURE_XEN_SMAP);
+ alternative("", "stac", X86_FEATURE_XEN_SMAP);
}
#endif
-#undef __ASM_STAC
-#undef __ASM_CLAC
-
#ifdef __ASSEMBLY__
.macro SAVE_ALL op, compat=0
.ifeqs "\op", "CLAC"
next prev parent reply other threads:[~2020-07-15 10:48 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-15 10:47 [PATCH 0/4] x86: some assembler macro rework Jan Beulich
2020-07-15 10:48 ` Jan Beulich [this message]
2020-07-27 14:55 ` [PATCH 1/4] x86: replace __ASM_{CL,ST}AC Roger Pau Monné
2020-07-27 19:47 ` Jan Beulich
2020-07-28 9:06 ` Roger Pau Monné
2020-07-31 8:05 ` Jan Beulich
2020-07-31 8:12 ` Roger Pau Monné
2020-07-28 13:59 ` Andrew Cooper
2020-07-28 19:24 ` Jan Beulich
2020-07-28 13:55 ` Andrew Cooper
2020-07-28 19:18 ` Jan Beulich
2020-07-31 8:00 ` Jan Beulich
2020-07-15 10:48 ` [PATCH 2/4] x86: reduce CET-SS related #ifdef-ary Jan Beulich
2020-07-27 15:00 ` Roger Pau Monné
2020-07-27 19:50 ` Jan Beulich
2020-07-28 8:36 ` Roger Pau Monné
2020-07-28 14:29 ` Andrew Cooper
2020-07-28 19:33 ` Jan Beulich
2020-07-15 10:49 ` [PATCH 3/4] x86: drop ASM_{CL,ST}AC Jan Beulich
2020-07-27 15:10 ` Roger Pau Monné
2020-07-28 14:51 ` Andrew Cooper
2020-07-28 19:41 ` Jan Beulich
2020-07-15 10:49 ` [PATCH 4/4] x86: fold indirect_thunk_asm.h into asm-defns.h Jan Beulich
2020-07-27 15:16 ` 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=fc8e042e-fef8-ac38-34d8-16b13e4b0135@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=roger.pau@citrix.com \
--cc=wl@xen.org \
--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.