|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/3] x86/alternatives: fully leverage automatic NOP filling
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@xxxxxxxx>
--- 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
@@ -10,6 +10,7 @@
#include <xen/sched.h>
#include <xen/softirq.h>
#include <asm/flushtlb.h>
+#include <asm/nops.h>
#include <asm/page.h>
/* Debug builds: Wrap frequently to stress-test the wrap logic. */
@@ -143,7 +144,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
@@ -50,7 +50,7 @@ static always_inline void spec_ctrl_ente
barrier();
info->use_shadow_spec_ctrl = true;
barrier();
- asm volatile ( ALTERNATIVE(ASM_NOP3, "wrmsr", X86_FEATURE_XEN_IBRS_SET)
+ asm volatile ( ALTERNATIVE("", "wrmsr", X86_FEATURE_XEN_IBRS_SET)
:: "a" (val), "c" (MSR_SPEC_CTRL), "d" (0) : "memory" );
}
@@ -65,7 +65,7 @@ static always_inline void spec_ctrl_exit
*/
info->use_shadow_spec_ctrl = false;
barrier();
- asm volatile ( ALTERNATIVE(ASM_NOP3, "wrmsr", X86_FEATURE_XEN_IBRS_SET)
+ asm volatile ( ALTERNATIVE("", "wrmsr", X86_FEATURE_XEN_IBRS_SET)
:: "a" (val), "c" (MSR_SPEC_CTRL), "d" (0) : "memory" );
}
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |