@@ -102,7 +102,7 @@ cc-option = $(shell if $(1) $(2:-Wno-%=-
# Usage: $(call cc-option-add CFLAGS,CC,-march=winchip-c6)
cc-option-add = $(eval $(call cc-option-add-closure,$(1),$(2),$(3)))
define cc-option-add-closure
- ifneq ($$(call cc-option,$$($(2)),$(3),n),n)
+ ifneq ($$(call cc-option,$$($(2)),$(firstword $(3)),n),n)
$(1) += $(3)
endif
endef
@@ -415,6 +415,9 @@ AFLAGS += -D__ASSEMBLY__
$(call cc-option-add,AFLAGS,CC,-Wa$$(comma)--noexecstack)
+# Check to see whether the assembler supports the --sectname-subst option.
+$(call cc-option-add,AFLAGS,CC,-Wa$$(comma)--sectname-subst -DHAVE_AS_SECTNAME_SUBST)
+
LDFLAGS-$(call ld-option,--warn-rwx-segments) += --no-warn-rwx-segments
CFLAGS += $(CFLAGS-y)
@@ -28,6 +28,14 @@
#include <asm/arm64/efibind.h>
#endif
+/*
+ * Code here is, at least in part, ordering sensitive. Annotations
+ * from xen/linkage.h therefore may not switch sections (honoring
+ * CONFIG_CC_SPLIT_SECTIONS). Override the respective macro.
+ */
+#undef SYM_PUSH_SECTION
+#define SYM_PUSH_SECTION(name, attr)
+
#define __HEAD_FLAG_PAGE_SIZE ((PAGE_SHIFT - 10) / 2)
#define __HEAD_FLAG_PHYS_BASE 1
@@ -140,6 +140,9 @@ SECTIONS
.init.text : {
_sinittext = .;
*(.init.text)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ *(.init.text.*)
+#endif
_einittext = .;
. = ALIGN(PAGE_SIZE); /* Avoid mapping alt insns executable */
*(.altinstr_replacement)
@@ -103,6 +103,9 @@ SECTIONS
DECL_SECTION(.init.text) {
_sinittext = .;
*(.init.text)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ *(.init.text.*)
+#endif
_einittext = .;
. = ALIGN(PAGE_SIZE); /* Avoid mapping alt insns executable */
} :text
@@ -98,6 +98,9 @@ SECTIONS
.init.text : {
_sinittext = .;
*(.init.text)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ *(.init.text.*)
+#endif
_einittext = .;
. = ALIGN(PAGE_SIZE); /* Avoid mapping alt insns executable */
} :text
@@ -11,6 +11,10 @@
#include <asm/asm_defns.h>
+/* Section placement is done explicitly here; override the respective macro. */
+#undef SYM_PUSH_SECTION
+#define SYM_PUSH_SECTION(name, attr)
+
.macro IND_THUNK_RETPOLINE reg:req
call 1f
int3
@@ -31,6 +31,9 @@ FUNC(entry_int82)
mov %rsp, %rdi
call do_entry_int82
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ jmp compat_test_all_events
+#endif
END(entry_int82)
/* %rbx: struct vcpu */
@@ -771,6 +771,9 @@ END(common_interrupt)
FUNC(entry_PF)
ENDBR64
movb $X86_EXC_PF, EFRAME_entry_vector(%rsp)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ jmp handle_exception
+#endif
END(entry_PF)
/* No special register assumptions. */
FUNC(handle_exception, 0)
@@ -1084,8 +1087,11 @@ FUNC(entry_NMI)
ENDBR64
pushq $0
movb $X86_EXC_NMI, EFRAME_entry_vector(%rsp)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ jmp handle_ist_exception
+#endif
END(entry_NMI)
-
+/* No special register assumptions. */
FUNC(handle_ist_exception)
ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
SAVE_ALL
@@ -85,6 +85,9 @@ SECTIONS
. = ALIGN(PAGE_SIZE);
_stextentry = .;
*(.text.entry)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ *(.text.entry.*)
+#endif
. = ALIGN(PAGE_SIZE);
_etextentry = .;
@@ -204,6 +207,9 @@ SECTIONS
#endif
_sinittext = .;
*(.init.text)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ *(.init.text.*)
+#endif
*(.text.startup)
_einittext = .;
/*
@@ -18,6 +18,14 @@
#define SYM_ALIGN(align...) .balign align
+#if defined(HAVE_AS_SECTNAME_SUBST) && defined(CONFIG_CC_SPLIT_SECTIONS)
+# define SYM_PUSH_SECTION(name, attr) \
+ .pushsection %S.name, attr, %progbits; \
+ .equ .Lsplit_section, 1
+#else
+# define SYM_PUSH_SECTION(name, attr)
+#endif
+
#define SYM_L_GLOBAL(name) .globl name; .hidden name
#define SYM_L_WEAK(name) .weak name
#define SYM_L_LOCAL(name) /* nothing */
@@ -32,7 +40,14 @@
SYM_ALIGN(align); \
name:
-#define END(name) .size name, . - name
+#define END(name) \
+ .size name, . - name; \
+ .ifdef .Lsplit_section; \
+ .if .Lsplit_section; \
+ .popsection; \
+ .equ .Lsplit_section, 0; \
+ .endif; \
+ .endif
/*
* CODE_FILL in particular may need to expand to nothing (e.g. for RISC-V), in
@@ -47,6 +62,7 @@
#endif
#define FUNC(name, align...) \
+ SYM_PUSH_SECTION(name, "ax"); \
SYM(name, FUNC, GLOBAL, DO_CODE_ALIGN(align))
#define LABEL(name, align...) \
SYM(name, NONE, GLOBAL, DO_CODE_ALIGN(align))
@@ -54,6 +70,7 @@
SYM(name, DATA, GLOBAL, LASTARG(DATA_ALIGN, ## align), DATA_FILL)
#define FUNC_LOCAL(name, align...) \
+ SYM_PUSH_SECTION(name, "ax"); \
SYM(name, FUNC, LOCAL, DO_CODE_ALIGN(align))
#define LABEL_LOCAL(name, align...) \
SYM(name, NONE, LOCAL, DO_CODE_ALIGN(align))