xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] x86: assorted assembly related cleanup
@ 2018-06-29 12:57 Jan Beulich
  2018-06-29 13:00 ` [PATCH v2 1/3] x86/alternatives: fully leverage automatic NOP filling Jan Beulich
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Jan Beulich @ 2018-06-29 12:57 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

1: alternatives: fully leverage automatic NOP filling
2: move quoting of __ASM_{STAC,CLAC}
3: reduce "visibility" of spec_ctrl_asm.h

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



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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/3] x86/alternatives: fully leverage automatic NOP filling
  2018-06-29 12:57 [PATCH v2 0/3] x86: assorted assembly related cleanup Jan Beulich
@ 2018-06-29 13:00 ` Jan Beulich
  2018-06-29 13:22   ` Andrew Cooper
  2018-06-29 13:01 ` [PATCH v2 2/3] x86: move quoting of __ASM_{STAC,CLAC} Jan Beulich
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Jan Beulich @ 2018-06-29 13:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

As of commit 4008c71d7a ("x86/alt: Support for automatic padding
calculations") there's no point having explict ASM_NOPn instances in
alternatives anymore - drop them. As a result also drop the asm/nops.h
inclusion from alternative.h, adding explicit inclusions in the two
remaining C files needing them.

While touching it also move the CR4_PV32_RESTORE definition out of the
SMAP-specific conditional into a more general one.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Re-base.

--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -24,6 +24,7 @@
 #include <asm/system.h>
 #include <asm/traps.h>
 #include <asm/nmi.h>
+#include <asm/nops.h>
 #include <xen/livepatch.h>
 
 #define MAX_PATCH_LEN (255-1)
--- a/xen/arch/x86/flushtlb.c
+++ b/xen/arch/x86/flushtlb.c
@@ -12,6 +12,7 @@
 #include <xen/softirq.h>
 #include <asm/flushtlb.h>
 #include <asm/invpcid.h>
+#include <asm/nops.h>
 #include <asm/page.h>
 #include <asm/pv/domain.h>
 
@@ -203,7 +204,7 @@ unsigned int flush_area_local(const void
              c->x86_clflush_size && c->x86_cache_size && sz &&
              ((sz >> 10) < c->x86_cache_size) )
         {
-            alternative(ASM_NOP3, "sfence", X86_FEATURE_CLFLUSHOPT);
+            alternative("", "sfence", X86_FEATURE_CLFLUSHOPT);
             for ( i = 0; i < sz; i += c->x86_clflush_size )
                 alternative_input(".byte " __stringify(NOP_DS_PREFIX) ";"
                                   " clflush %0",
--- a/xen/include/asm-x86/alternative.h
+++ b/xen/include/asm-x86/alternative.h
@@ -2,7 +2,6 @@
 #define __X86_ALTERNATIVE_H__
 
 #include <asm/alternative-asm.h>
-#include <asm/nops.h>
 
 #ifndef __ASSEMBLY__
 #include <xen/stringify.h>
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -195,30 +195,19 @@ void ret_from_intr(void);
 #define __ASM_STAC      .byte 0x0f,0x01,0xcb
 
 #ifdef __ASSEMBLY__
-#define ASM_STAC                                        \
-    ALTERNATIVE __stringify(ASM_NOP3),                  \
-        __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP
-
-#define ASM_CLAC                                        \
-    ALTERNATIVE __stringify(ASM_NOP3),                  \
-        __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP
-
-#define CR4_PV32_RESTORE                                \
-    ALTERNATIVE_2 __stringify(ASM_NOP5),                \
-        "call cr4_pv32_restore", X86_FEATURE_XEN_SMEP,  \
-        "call cr4_pv32_restore", X86_FEATURE_XEN_SMAP
-
+#define ASM_STAC ALTERNATIVE "", __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP
+#define ASM_CLAC ALTERNATIVE "", __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP
 #else
 static always_inline void clac(void)
 {
     /* Note: a barrier is implicit in alternative() */
-    alternative(ASM_NOP3, __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP);
+    alternative("", __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP);
 }
 
 static always_inline void stac(void)
 {
     /* Note: a barrier is implicit in alternative() */
-    alternative(ASM_NOP3, __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP);
+    alternative("", __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP);
 }
 #endif
 
@@ -327,6 +316,11 @@ static always_inline void stac(void)
         subq  $-(UREGS_error_code-UREGS_r15+\adj), %rsp
 .endm
 
+#define CR4_PV32_RESTORE                               \
+    ALTERNATIVE_2 "",                                  \
+        "call cr4_pv32_restore", X86_FEATURE_XEN_SMEP, \
+        "call cr4_pv32_restore", X86_FEATURE_XEN_SMAP
+
 #endif
 
 #ifdef CONFIG_PERF_COUNTERS
--- a/xen/include/asm-x86/spec_ctrl.h
+++ b/xen/include/asm-x86/spec_ctrl.h
@@ -60,7 +60,7 @@ static always_inline void spec_ctrl_ente
     barrier();
     info->spec_ctrl_flags |= SCF_use_shadow;
     barrier();
-    asm volatile ( ALTERNATIVE(ASM_NOP3, "wrmsr", X86_FEATURE_SC_MSR_IDLE)
+    asm volatile ( ALTERNATIVE("", "wrmsr", X86_FEATURE_SC_MSR_IDLE)
                    :: "a" (val), "c" (MSR_SPEC_CTRL), "d" (0) : "memory" );
 }
 
@@ -75,7 +75,7 @@ static always_inline void spec_ctrl_exit
      */
     info->spec_ctrl_flags &= ~SCF_use_shadow;
     barrier();
-    asm volatile ( ALTERNATIVE(ASM_NOP3, "wrmsr", X86_FEATURE_SC_MSR_IDLE)
+    asm volatile ( ALTERNATIVE("", "wrmsr", X86_FEATURE_SC_MSR_IDLE)
                    :: "a" (val), "c" (MSR_SPEC_CTRL), "d" (0) : "memory" );
 }
 




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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 2/3] x86: move quoting of __ASM_{STAC,CLAC}
  2018-06-29 12:57 [PATCH v2 0/3] x86: assorted assembly related cleanup Jan Beulich
  2018-06-29 13:00 ` [PATCH v2 1/3] x86/alternatives: fully leverage automatic NOP filling Jan Beulich
@ 2018-06-29 13:01 ` Jan Beulich
  2018-06-29 13:01 ` [PATCH v2 3/3] x86: reduce "visibility" of spec_ctrl_asm.h Jan Beulich
  2018-08-29 13:41 ` [PATCH v3 0/3] x86: assorted assembly related cleanup Jan Beulich
  3 siblings, 0 replies; 11+ messages in thread
From: Jan Beulich @ 2018-06-29 13:01 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

Both consumers want them quoted, so quote them right away instead of
using __stringify() upon use. In the spirit of other recent additions
also make the assembly forms assembler macros, allowing the helper
#define-s to be #undef-ed subsequently.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -191,26 +191,33 @@ void ret_from_intr(void);
 #endif
 
 /* "Raw" instruction opcodes */
-#define __ASM_CLAC      .byte 0x0f,0x01,0xca
-#define __ASM_STAC      .byte 0x0f,0x01,0xcb
+#define __ASM_CLAC      ".byte 0x0f,0x01,0xca"
+#define __ASM_STAC      ".byte 0x0f,0x01,0xcb"
 
 #ifdef __ASSEMBLY__
-#define ASM_STAC ALTERNATIVE "", __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP
-#define ASM_CLAC ALTERNATIVE "", __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP
+.macro ASM_STAC
+    ALTERNATIVE "", __ASM_STAC, X86_FEATURE_XEN_SMAP
+.endm
+.macro ASM_CLAC
+    ALTERNATIVE "", __ASM_CLAC, X86_FEATURE_XEN_SMAP
+.endm
 #else
 static always_inline void clac(void)
 {
     /* Note: a barrier is implicit in alternative() */
-    alternative("", __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP);
+    alternative("", __ASM_CLAC, X86_FEATURE_XEN_SMAP);
 }
 
 static always_inline void stac(void)
 {
     /* Note: a barrier is implicit in alternative() */
-    alternative("", __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP);
+    alternative("", __ASM_STAC, X86_FEATURE_XEN_SMAP);
 }
 #endif
 
+#undef __ASM_STAC
+#undef __ASM_CLAC
+
 #ifdef __ASSEMBLY__
 .macro SAVE_ALL op, compat=0
 .ifeqs "\op", "CLAC"





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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 3/3] x86: reduce "visibility" of spec_ctrl_asm.h
  2018-06-29 12:57 [PATCH v2 0/3] x86: assorted assembly related cleanup Jan Beulich
  2018-06-29 13:00 ` [PATCH v2 1/3] x86/alternatives: fully leverage automatic NOP filling Jan Beulich
  2018-06-29 13:01 ` [PATCH v2 2/3] x86: move quoting of __ASM_{STAC,CLAC} Jan Beulich
@ 2018-06-29 13:01 ` Jan Beulich
  2018-08-29 13:41 ` [PATCH v3 0/3] x86: assorted assembly related cleanup Jan Beulich
  3 siblings, 0 replies; 11+ messages in thread
From: Jan Beulich @ 2018-06-29 13:01 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

Other than indirect_thunk_asm.h, spec_ctrl_asm.h is a header generally
needed by assembly source files only. Avoid having all C sources have a
dependency on that header (the set of assembly sources now gaining a
dependency on the C header is much smaller and hence more acceptable).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -328,6 +328,8 @@ static always_inline void stac(void)
         "call cr4_pv32_restore", X86_FEATURE_XEN_SMEP, \
         "call cr4_pv32_restore", X86_FEATURE_XEN_SMAP
 
+#include <asm/spec_ctrl_asm.h>
+
 #endif
 
 #ifdef CONFIG_PERF_COUNTERS
@@ -370,6 +372,4 @@ static always_inline void stac(void)
 4:  .p2align 2                            ; \
     .popsection
 
-#include <asm/spec_ctrl_asm.h>
-
 #endif /* __X86_ASM_DEFNS_H__ */
--- a/xen/include/asm-x86/spec_ctrl.h
+++ b/xen/include/asm-x86/spec_ctrl.h
@@ -20,6 +20,13 @@
 #ifndef __X86_SPEC_CTRL_H__
 #define __X86_SPEC_CTRL_H__
 
+/* Encoding of cpuinfo.spec_ctrl_flags */
+#define SCF_use_shadow (1 << 0)
+#define SCF_ist_wrmsr  (1 << 1)
+#define SCF_ist_rsb    (1 << 2)
+
+#ifndef __ASSEMBLY__
+
 #include <asm/alternative.h>
 #include <asm/current.h>
 #include <asm/msr-index.h>
@@ -79,6 +86,7 @@ static always_inline void spec_ctrl_exit
                    :: "a" (val), "c" (MSR_SPEC_CTRL), "d" (0) : "memory" );
 }
 
+#endif /* __ASSEMBLY__ */
 #endif /* !__X86_SPEC_CTRL_H__ */
 
 /*
--- a/xen/include/asm-x86/spec_ctrl_asm.h
+++ b/xen/include/asm-x86/spec_ctrl_asm.h
@@ -20,13 +20,9 @@
 #ifndef __X86_SPEC_CTRL_ASM_H__
 #define __X86_SPEC_CTRL_ASM_H__
 
-/* Encoding of cpuinfo.spec_ctrl_flags */
-#define SCF_use_shadow (1 << 0)
-#define SCF_ist_wrmsr  (1 << 1)
-#define SCF_ist_rsb    (1 << 2)
-
 #ifdef __ASSEMBLY__
 #include <asm/msr-index.h>
+#include <asm/spec_ctrl.h>
 
 /*
  * Saving and restoring MSR_SPEC_CTRL state is a little tricky.





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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/3] x86/alternatives: fully leverage automatic NOP filling
  2018-06-29 13:00 ` [PATCH v2 1/3] x86/alternatives: fully leverage automatic NOP filling Jan Beulich
@ 2018-06-29 13:22   ` Andrew Cooper
  2018-06-29 13:43     ` Jan Beulich
  0 siblings, 1 reply; 11+ messages in thread
From: Andrew Cooper @ 2018-06-29 13:22 UTC (permalink / raw)
  To: Jan Beulich, xen-devel

On 29/06/18 14:00, Jan Beulich wrote:
> As of commit 4008c71d7a ("x86/alt: Support for automatic padding
> calculations") there's no point having explict ASM_NOPn instances in
> alternatives anymore - drop them. As a result also drop the asm/nops.h
> inclusion from alternative.h, adding explicit inclusions in the two
> remaining C files needing them.
>
> While touching it also move the CR4_PV32_RESTORE definition out of the
> SMAP-specific conditional into a more general one.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

I'm fine with this in principle, but I'd prefer if it can wait until
after I rebase my toolchain nops patch.  As it stands, this increases
the number of boot time sites we actually modify for nop optimsiation
purposes.

~Andrew

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/3] x86/alternatives: fully leverage automatic NOP filling
  2018-06-29 13:22   ` Andrew Cooper
@ 2018-06-29 13:43     ` Jan Beulich
  0 siblings, 0 replies; 11+ messages in thread
From: Jan Beulich @ 2018-06-29 13:43 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel

>>> On 29.06.18 at 15:22, <andrew.cooper3@citrix.com> wrote:
> On 29/06/18 14:00, Jan Beulich wrote:
>> As of commit 4008c71d7a ("x86/alt: Support for automatic padding
>> calculations") there's no point having explict ASM_NOPn instances in
>> alternatives anymore - drop them. As a result also drop the asm/nops.h
>> inclusion from alternative.h, adding explicit inclusions in the two
>> remaining C files needing them.
>>
>> While touching it also move the CR4_PV32_RESTORE definition out of the
>> SMAP-specific conditional into a more general one.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> I'm fine with this in principle, but I'd prefer if it can wait until
> after I rebase my toolchain nops patch.

Well, I'm fine if this is going to happen in the foreseeable future. But
this series has been pending for over 3 months now, and I'd really
like to get my queue shrunk.

Jan



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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 0/3] x86: assorted assembly related cleanup
  2018-06-29 12:57 [PATCH v2 0/3] x86: assorted assembly related cleanup Jan Beulich
                   ` (2 preceding siblings ...)
  2018-06-29 13:01 ` [PATCH v2 3/3] x86: reduce "visibility" of spec_ctrl_asm.h Jan Beulich
@ 2018-08-29 13:41 ` Jan Beulich
  2018-08-29 13:48   ` [PATCH v3 1/3] x86/alternatives: fully leverage automatic NOP filling Jan Beulich
                     ` (2 more replies)
  3 siblings, 3 replies; 11+ messages in thread
From: Jan Beulich @ 2018-08-29 13:41 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

1: alternatives: fully leverage automatic NOP filling
2: move quoting of __ASM_{STAC,CLAC}
3: reduce "visibility" of spec_ctrl_asm.h

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




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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 1/3] x86/alternatives: fully leverage automatic NOP filling
  2018-08-29 13:41 ` [PATCH v3 0/3] x86: assorted assembly related cleanup Jan Beulich
@ 2018-08-29 13:48   ` Jan Beulich
  2018-08-29 13:57     ` Andrew Cooper
  2018-08-29 13:48   ` [PATCH v3 2/3] x86: move quoting of __ASM_{STAC,CLAC} Jan Beulich
  2018-08-29 13:49   ` [PATCH v3 3/3] x86: reduce "visibility" of spec_ctrl_asm.h Jan Beulich
  2 siblings, 1 reply; 11+ messages in thread
From: Jan Beulich @ 2018-08-29 13:48 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

As of commit 4008c71d7a ("x86/alt: Support for automatic padding
calculations") there's no point having explict ASM_NOPn instances in
alternatives anymore - drop them. As a result also drop the asm/nops.h
inclusion from alternative.h, adding explicit inclusions in the two
remaining C files needing them.

While touching it also move the CR4_PV32_RESTORE definition out of the
SMAP-specific conditional into a more general one.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v3: Re-base.
v2: Re-base.

--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -24,6 +24,7 @@
 #include <asm/system.h>
 #include <asm/traps.h>
 #include <asm/nmi.h>
+#include <asm/nops.h>
 #include <xen/livepatch.h>
 
 #define MAX_PATCH_LEN (255-1)
--- a/xen/arch/x86/flushtlb.c
+++ b/xen/arch/x86/flushtlb.c
@@ -12,6 +12,7 @@
 #include <xen/softirq.h>
 #include <asm/flushtlb.h>
 #include <asm/invpcid.h>
+#include <asm/nops.h>
 #include <asm/page.h>
 #include <asm/pv/domain.h>
 
@@ -207,7 +208,7 @@ unsigned int flush_area_local(const void
              c->x86_clflush_size && c->x86_cache_size && sz &&
              ((sz >> 10) < c->x86_cache_size) )
         {
-            alternative(ASM_NOP3, "sfence", X86_FEATURE_CLFLUSHOPT);
+            alternative("", "sfence", X86_FEATURE_CLFLUSHOPT);
             for ( i = 0; i < sz; i += c->x86_clflush_size )
                 alternative_input(".byte " __stringify(NOP_DS_PREFIX) ";"
                                   " clflush %0",
--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -193,30 +193,19 @@ void ret_from_intr(void);
 #define __ASM_STAC      .byte 0x0f,0x01,0xcb
 
 #ifdef __ASSEMBLY__
-#define ASM_STAC                                        \
-    ALTERNATIVE __stringify(ASM_NOP3),                  \
-        __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP
-
-#define ASM_CLAC                                        \
-    ALTERNATIVE __stringify(ASM_NOP3),                  \
-        __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP
-
-#define CR4_PV32_RESTORE                                \
-    ALTERNATIVE_2 __stringify(ASM_NOP5),                \
-        "call cr4_pv32_restore", X86_FEATURE_XEN_SMEP,  \
-        "call cr4_pv32_restore", X86_FEATURE_XEN_SMAP
-
+#define ASM_STAC ALTERNATIVE "", __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP
+#define ASM_CLAC ALTERNATIVE "", __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP
 #else
 static always_inline void clac(void)
 {
     /* Note: a barrier is implicit in alternative() */
-    alternative(ASM_NOP3, __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP);
+    alternative("", __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP);
 }
 
 static always_inline void stac(void)
 {
     /* Note: a barrier is implicit in alternative() */
-    alternative(ASM_NOP3, __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP);
+    alternative("", __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP);
 }
 #endif
 
@@ -325,6 +314,11 @@ static always_inline void stac(void)
         subq  $-(UREGS_error_code-UREGS_r15+\adj), %rsp
 .endm
 
+#define CR4_PV32_RESTORE                               \
+    ALTERNATIVE_2 "",                                  \
+        "call cr4_pv32_restore", X86_FEATURE_XEN_SMEP, \
+        "call cr4_pv32_restore", X86_FEATURE_XEN_SMAP
+
 #endif
 
 #ifdef CONFIG_PERF_COUNTERS
--- a/xen/include/asm-x86/spec_ctrl.h
+++ b/xen/include/asm-x86/spec_ctrl.h
@@ -72,7 +72,7 @@ static always_inline void spec_ctrl_ente
     barrier();
     info->spec_ctrl_flags |= SCF_use_shadow;
     barrier();
-    asm volatile ( ALTERNATIVE(ASM_NOP3, "wrmsr", X86_FEATURE_SC_MSR_IDLE)
+    asm volatile ( ALTERNATIVE("", "wrmsr", X86_FEATURE_SC_MSR_IDLE)
                    :: "a" (val), "c" (MSR_SPEC_CTRL), "d" (0) : "memory" );
 }
 
@@ -87,7 +87,7 @@ static always_inline void spec_ctrl_exit
      */
     info->spec_ctrl_flags &= ~SCF_use_shadow;
     barrier();
-    asm volatile ( ALTERNATIVE(ASM_NOP3, "wrmsr", X86_FEATURE_SC_MSR_IDLE)
+    asm volatile ( ALTERNATIVE("", "wrmsr", X86_FEATURE_SC_MSR_IDLE)
                    :: "a" (val), "c" (MSR_SPEC_CTRL), "d" (0) : "memory" );
 }
 




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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 2/3] x86: move quoting of __ASM_{STAC,CLAC}
  2018-08-29 13:41 ` [PATCH v3 0/3] x86: assorted assembly related cleanup Jan Beulich
  2018-08-29 13:48   ` [PATCH v3 1/3] x86/alternatives: fully leverage automatic NOP filling Jan Beulich
@ 2018-08-29 13:48   ` Jan Beulich
  2018-08-29 13:49   ` [PATCH v3 3/3] x86: reduce "visibility" of spec_ctrl_asm.h Jan Beulich
  2 siblings, 0 replies; 11+ messages in thread
From: Jan Beulich @ 2018-08-29 13:48 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

Both consumers want them quoted, so quote them right away instead of
using __stringify() upon use. In the spirit of other recent additions
also make the assembly forms assembler macros, allowing the helper
#define-s to be #undef-ed subsequently.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -189,26 +189,33 @@ void ret_from_intr(void);
 #endif
 
 /* "Raw" instruction opcodes */
-#define __ASM_CLAC      .byte 0x0f,0x01,0xca
-#define __ASM_STAC      .byte 0x0f,0x01,0xcb
+#define __ASM_CLAC      ".byte 0x0f,0x01,0xca"
+#define __ASM_STAC      ".byte 0x0f,0x01,0xcb"
 
 #ifdef __ASSEMBLY__
-#define ASM_STAC ALTERNATIVE "", __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP
-#define ASM_CLAC ALTERNATIVE "", __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP
+.macro ASM_STAC
+    ALTERNATIVE "", __ASM_STAC, X86_FEATURE_XEN_SMAP
+.endm
+.macro ASM_CLAC
+    ALTERNATIVE "", __ASM_CLAC, X86_FEATURE_XEN_SMAP
+.endm
 #else
 static always_inline void clac(void)
 {
     /* Note: a barrier is implicit in alternative() */
-    alternative("", __stringify(__ASM_CLAC), X86_FEATURE_XEN_SMAP);
+    alternative("", __ASM_CLAC, X86_FEATURE_XEN_SMAP);
 }
 
 static always_inline void stac(void)
 {
     /* Note: a barrier is implicit in alternative() */
-    alternative("", __stringify(__ASM_STAC), X86_FEATURE_XEN_SMAP);
+    alternative("", __ASM_STAC, X86_FEATURE_XEN_SMAP);
 }
 #endif
 
+#undef __ASM_STAC
+#undef __ASM_CLAC
+
 #ifdef __ASSEMBLY__
 .macro SAVE_ALL op, compat=0
 .ifeqs "\op", "CLAC"





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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 3/3] x86: reduce "visibility" of spec_ctrl_asm.h
  2018-08-29 13:41 ` [PATCH v3 0/3] x86: assorted assembly related cleanup Jan Beulich
  2018-08-29 13:48   ` [PATCH v3 1/3] x86/alternatives: fully leverage automatic NOP filling Jan Beulich
  2018-08-29 13:48   ` [PATCH v3 2/3] x86: move quoting of __ASM_{STAC,CLAC} Jan Beulich
@ 2018-08-29 13:49   ` Jan Beulich
  2 siblings, 0 replies; 11+ messages in thread
From: Jan Beulich @ 2018-08-29 13:49 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper

Other than indirect_thunk_asm.h, spec_ctrl_asm.h is a header generally
needed by assembly source files only. Avoid having all C sources have a
dependency on that header (the set of assembly sources now gaining a
dependency on the C header is much smaller and hence more acceptable).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

--- a/xen/include/asm-x86/asm_defns.h
+++ b/xen/include/asm-x86/asm_defns.h
@@ -326,6 +326,8 @@ static always_inline void stac(void)
         "call cr4_pv32_restore", X86_FEATURE_XEN_SMEP, \
         "call cr4_pv32_restore", X86_FEATURE_XEN_SMAP
 
+#include <asm/spec_ctrl_asm.h>
+
 #endif
 
 #ifdef CONFIG_PERF_COUNTERS
@@ -368,6 +370,4 @@ static always_inline void stac(void)
 4:  .p2align 2                            ; \
     .popsection
 
-#include <asm/spec_ctrl_asm.h>
-
 #endif /* __X86_ASM_DEFNS_H__ */
--- a/xen/include/asm-x86/spec_ctrl.h
+++ b/xen/include/asm-x86/spec_ctrl.h
@@ -20,6 +20,13 @@
 #ifndef __X86_SPEC_CTRL_H__
 #define __X86_SPEC_CTRL_H__
 
+/* Encoding of cpuinfo.spec_ctrl_flags */
+#define SCF_use_shadow (1 << 0)
+#define SCF_ist_wrmsr  (1 << 1)
+#define SCF_ist_rsb    (1 << 2)
+
+#ifndef __ASSEMBLY__
+
 #include <asm/alternative.h>
 #include <asm/current.h>
 #include <asm/msr-index.h>
@@ -91,6 +98,7 @@ static always_inline void spec_ctrl_exit
                    :: "a" (val), "c" (MSR_SPEC_CTRL), "d" (0) : "memory" );
 }
 
+#endif /* __ASSEMBLY__ */
 #endif /* !__X86_SPEC_CTRL_H__ */
 
 /*
--- a/xen/include/asm-x86/spec_ctrl_asm.h
+++ b/xen/include/asm-x86/spec_ctrl_asm.h
@@ -20,13 +20,9 @@
 #ifndef __X86_SPEC_CTRL_ASM_H__
 #define __X86_SPEC_CTRL_ASM_H__
 
-/* Encoding of cpuinfo.spec_ctrl_flags */
-#define SCF_use_shadow (1 << 0)
-#define SCF_ist_wrmsr  (1 << 1)
-#define SCF_ist_rsb    (1 << 2)
-
 #ifdef __ASSEMBLY__
 #include <asm/msr-index.h>
+#include <asm/spec_ctrl.h>
 
 /*
  * Saving and restoring MSR_SPEC_CTRL state is a little tricky.





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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 1/3] x86/alternatives: fully leverage automatic NOP filling
  2018-08-29 13:48   ` [PATCH v3 1/3] x86/alternatives: fully leverage automatic NOP filling Jan Beulich
@ 2018-08-29 13:57     ` Andrew Cooper
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Cooper @ 2018-08-29 13:57 UTC (permalink / raw)
  To: Jan Beulich, xen-devel

On 29/08/18 14:48, Jan Beulich wrote:
> As of commit 4008c71d7a ("x86/alt: Support for automatic padding
> calculations") there's no point having explict ASM_NOPn instances in
> alternatives anymore - drop them. As a result also drop the asm/nops.h
> inclusion from alternative.h, adding explicit inclusions in the two
> remaining C files needing them.
>
> While touching it also move the CR4_PV32_RESTORE definition out of the
> SMAP-specific conditional into a more general one.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-08-29 13:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-29 12:57 [PATCH v2 0/3] x86: assorted assembly related cleanup Jan Beulich
2018-06-29 13:00 ` [PATCH v2 1/3] x86/alternatives: fully leverage automatic NOP filling Jan Beulich
2018-06-29 13:22   ` Andrew Cooper
2018-06-29 13:43     ` Jan Beulich
2018-06-29 13:01 ` [PATCH v2 2/3] x86: move quoting of __ASM_{STAC,CLAC} Jan Beulich
2018-06-29 13:01 ` [PATCH v2 3/3] x86: reduce "visibility" of spec_ctrl_asm.h Jan Beulich
2018-08-29 13:41 ` [PATCH v3 0/3] x86: assorted assembly related cleanup Jan Beulich
2018-08-29 13:48   ` [PATCH v3 1/3] x86/alternatives: fully leverage automatic NOP filling Jan Beulich
2018-08-29 13:57     ` Andrew Cooper
2018-08-29 13:48   ` [PATCH v3 2/3] x86: move quoting of __ASM_{STAC,CLAC} Jan Beulich
2018-08-29 13:49   ` [PATCH v3 3/3] x86: reduce "visibility" of spec_ctrl_asm.h Jan Beulich

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).