All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Julien Grall" <julien@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Volodymyr Babchuk" <volodymyr_babchuk@epam.com>,
	"Bertrand Marquis" <bertrand.marquis@arm.com>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Shawn Anastasio" <sanastasio@raptorengineering.com>,
	"Bobby Eshleman" <bobbyeshleman@gmail.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Connor Davis" <connojdavis@gmail.com>
Subject: [PATCH v6 1/7] common: honor CONFIG_CC_SPLIT_SECTIONS also for assembly functions
Date: Wed, 7 Feb 2024 14:36:41 +0100	[thread overview]
Message-ID: <782b911e-c40e-4e9c-b259-af287d968b3b@suse.com> (raw)
In-Reply-To: <3ba82c3a-ff95-43d0-8672-a63b23bc2cdc@suse.com>

Leverage the new infrastructure in xen/linkage.h to also switch to per-
function sections (when configured), deriving the specific name from the
"base" section in use at the time FUNC() is invoked.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
TBD: Since we use .subsection in UNLIKELY_START(), a perhaps not really
     wanted side effect of this change is that respective out-of-line
     code now moves much closer to its original (invoking) code.

TBD: Of course something with the same overall effect, but less
     impactful might do in Config.mk. E.g. $(filter-out -D%,$(3))
     instead of $(firstword (3)). In fact Roger wants the detection to
     be in Kconfig, for LIVEPATCH to depend on it. Yet the whole
     underlying discussion there imo would first need settling (and
     therefore reviving).

TBD: On top of Roger's respective patch (for livepatch), also respect
     CONFIG_FUNCTION_ALIGNMENT.

Note that we'd need to split DATA() in order to separate r/w and r/o
contributions. Further splitting might be needed to also support more
advanced attributes (e.g. merge), hence why this isn't done right here.
Sadly while a new section's name can be derived from the presently in
use, its attributes cannot be. Perhaps the only thing we can do is give
DATA() a 2nd mandatory parameter. Then again I guess most data
definitions could be moved to C anyway.
---
v6: Deal with x86'es entry_PF() and entry_int82() falling through to the
    next "function". Re-base.
v5: Re-base over changes earlier in the series.
v4: Re-base.
v2: Make detection properly fail on old gas (by adjusting
    cc-option-add-closure).

--- a/Config.mk
+++ b/Config.mk
@@ -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
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -409,6 +409,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)
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -157,6 +157,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)
--- a/xen/arch/ppc/xen.lds.S
+++ b/xen/arch/ppc/xen.lds.S
@@ -104,6 +104,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
--- a/xen/arch/riscv/xen.lds.S
+++ b/xen/arch/riscv/xen.lds.S
@@ -104,6 +104,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
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -29,6 +29,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 */
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -723,6 +723,9 @@ END(common_interrupt)
 FUNC(entry_PF)
         ENDBR64
         movl  $X86_EXC_PF, 4(%rsp)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+        jmp   handle_exception
+#endif
 END(entry_PF)
 /* No special register assumptions. */
 FUNC(handle_exception, 0)
@@ -1023,8 +1026,11 @@ FUNC(entry_NMI)
         ENDBR64
         pushq $0
         movl  $X86_EXC_NMI, 4(%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
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -86,6 +86,9 @@ SECTIONS
        . = ALIGN(PAGE_SIZE);
        _stextentry = .;
        *(.text.entry)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+       *(.text.entry.*)
+#endif
        . = ALIGN(PAGE_SIZE);
        _etextentry = .;
 
@@ -214,6 +217,9 @@ SECTIONS
 #endif
        _sinittext = .;
        *(.init.text)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+       *(.init.text.*)
+#endif
        *(.text.startup)
        _einittext = .;
        /*
--- a/xen/include/xen/linkage.h
+++ b/xen/include/xen/linkage.h
@@ -19,6 +19,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 */
@@ -33,7 +41,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))



  parent reply	other threads:[~2024-02-07 13:36 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 10:25 [PATCH 0/2] x86: aid debug info generation in assembly files Jan Beulich
2022-04-12 10:27 ` [PATCH 1/2] x86: improve .debug_line contents for assembly sources Jan Beulich
2022-04-14 12:40   ` Roger Pau Monné
2022-04-14 12:52     ` Jan Beulich
2022-04-14 13:31       ` Roger Pau Monné
2022-04-14 13:36         ` Roger Pau Monné
2022-04-14 14:15         ` Jan Beulich
2022-04-14 16:02           ` Roger Pau Monné
2022-04-14 16:34             ` Jan Beulich
2022-04-26  9:26             ` Jan Beulich
2022-04-12 10:28 ` [PATCH 2/2] x86: annotate entry points with type and size Jan Beulich
2022-04-14 12:49   ` Andrew Cooper
2022-04-14 12:59     ` Jan Beulich
2022-06-23 11:47       ` Jan Beulich
2023-05-23 11:30 ` [PATCH v2 0/2] " Jan Beulich
2023-05-23 11:30   ` [PATCH v2 1/2] " Jan Beulich
2023-05-29 13:34     ` Roger Pau Monné
2023-05-30  8:06       ` Jan Beulich
2023-05-30 13:21         ` Roger Pau Monné
2023-05-30 14:23           ` Jan Beulich
2023-05-30 15:15             ` Roger Pau Monné
2023-05-23 11:31   ` [PATCH v2 2/2] x86: also mark assembler globals hidden Jan Beulich
2023-05-29 13:38     ` Roger Pau Monné
2023-07-10  8:50 ` [PATCH v3 0/8] annotate entry points with type and size Jan Beulich
2023-07-10  8:51   ` [PATCH v3 1/8] common: move a few macros out of xen/lib.h Jan Beulich
2023-07-18 15:40     ` Oleksii
2023-07-18 19:49     ` Shawn Anastasio
2023-07-19  6:28       ` Jan Beulich
2023-07-10  8:52   ` [PATCH v3 2/8] common: assembly entry point type/size annotations Jan Beulich
2023-07-10  9:28     ` Jan Beulich
2023-07-10  8:53   ` [PATCH v3 3/8] x86: annotate entry points with type and size Jan Beulich
2023-07-10  8:54   ` [PATCH v3 4/8] x86: also mark assembler globals hidden Jan Beulich
2023-07-10  8:55   ` [PATCH v3 5/8] Arm: annotate entry points with type and size Jan Beulich
2023-07-10  8:56   ` [PATCH v3 6/8] RISC-V: " Jan Beulich
2023-07-10  8:58     ` Jan Beulich
2023-07-26 15:28       ` Oleksii
2023-07-26 15:43         ` Jan Beulich
2023-07-26 16:55           ` Oleksii
2023-07-10  8:56   ` [PATCH v3 7/8] PPC: switch entry point annotations to common model Jan Beulich
2023-07-10  8:57   ` [PATCH v3 8/8] tools/binfile: switch to common annotations model Jan Beulich
2023-07-17 14:18   ` [PATCH v3 9/8] common: honor CONFIG_CC_SPLIT_SECTIONS also for assembly functions Jan Beulich
2023-07-18 12:28     ` Jan Beulich
2023-08-04  6:24 ` [PATCH v4 0/8] annotate entry points with type and size Jan Beulich
2023-08-04  6:26   ` [PATCH v4 1/8] common: assembly entry point type/size annotations Jan Beulich
2023-09-14 21:06     ` Julien Grall
2023-09-18 10:24       ` Jan Beulich
2023-09-18 10:34         ` Julien Grall
2023-09-18 10:51           ` Jan Beulich
2023-08-04  6:26   ` [PATCH v4 2/8] x86: annotate entry points with type and size Jan Beulich
2023-08-04  6:27   ` [PATCH v4 3/8] x86: also mark assembler globals hidden Jan Beulich
2023-08-04  6:28   ` [PATCH v4 4/8] Arm: annotate entry points with type and size Jan Beulich
2023-09-14 21:25     ` Julien Grall
2023-09-15  7:00       ` Jan Beulich
2023-08-04  6:29   ` [PATCH v4 5/8] RISC-V: " Jan Beulich
2023-08-04  6:30   ` [PATCH v4 5/8] PPC: switch entry point annotations to common model Jan Beulich
2023-08-04  6:30   ` [PATCH v4 6/8] tools/binfile: switch to common annotations model Jan Beulich
2023-09-14 21:30     ` Julien Grall
2023-08-04  6:31   ` [PATCH v4 8/8] common: honor CONFIG_CC_SPLIT_SECTIONS also for assembly functions Jan Beulich
2023-08-04  6:32   ` [PATCH v4 0/8] annotate entry points with type and size Jan Beulich
2024-01-15 14:30 ` [PATCH v5 " Jan Beulich
2024-01-15 14:34   ` [PATCH v5 1/8] common: assembly entry point type/size annotations Jan Beulich
2024-01-17 17:02     ` Roger Pau Monné
2024-01-18 15:48       ` Jan Beulich
2024-01-18 14:52     ` Roger Pau Monné
2024-01-18 16:00       ` Jan Beulich
2024-01-15 14:34   ` [PATCH v5 2/8] x86: annotate entry points with type and size Jan Beulich
2024-01-18 17:45     ` Roger Pau Monné
2024-01-19  8:06       ` Jan Beulich
2024-01-19  9:48     ` Roger Pau Monné
2024-01-15 14:35   ` [PATCH v5 3/8] x86: also mark assembler globals hidden Jan Beulich
2024-01-15 14:36   ` [PATCH v5 4/8] Arm: annotate entry points with type and size Jan Beulich
2024-01-22 13:22     ` Jan Beulich
2024-03-15 19:09       ` Julien Grall
2024-01-15 14:37   ` [PATCH v5 5/8] RISC-V: " Jan Beulich
2024-01-16 12:15     ` Oleksii
2024-01-15 14:38   ` [PATCH v5 6/8] PPC: switch entry point annotations to common model Jan Beulich
2024-01-22 13:20     ` Ping: " Jan Beulich
2024-01-23  3:00       ` Shawn Anastasio
2024-01-15 14:39   ` [PATCH v5 7/8] tools/binfile: switch to common annotations model Jan Beulich
2024-01-15 14:40   ` [PATCH v5 8/8] common: honor CONFIG_CC_SPLIT_SECTIONS also for assembly functions Jan Beulich
2024-01-19 10:36     ` Roger Pau Monné
2024-01-22 10:50       ` Jan Beulich
2024-01-22 17:40         ` Roger Pau Monné
2024-02-07 13:34 ` [PATCH v6 7/7] (mostly) x86: add/convert entry point annotations Jan Beulich
2024-02-07 13:35   ` [PATCH v6 0/7] " Jan Beulich
2024-02-07 13:36   ` Jan Beulich [this message]
2024-02-07 13:37   ` [PATCH v6 2/7] SVM: convert " Jan Beulich
2024-02-07 13:48     ` Andrew Cooper
2024-02-07 13:37   ` [PATCH v6 3/7] VMX: " Jan Beulich
2024-02-07 13:55     ` Andrew Cooper
2024-02-07 14:25       ` Jan Beulich
2024-02-08 16:20         ` Jan Beulich
2024-02-07 13:37   ` [PATCH v6 4/7] x86/ACPI: annotate assembly functions with type and size Jan Beulich
2024-02-07 14:00     ` Andrew Cooper
2024-02-07 13:38   ` [PATCH v6 5/7] x86/kexec: convert entry point annotations Jan Beulich
2024-02-07 14:05     ` Andrew Cooper
2024-02-07 13:38   ` [PATCH v6 6/7] x86: convert misc assembly function annotations Jan Beulich
2024-02-07 14:11     ` Andrew Cooper
2024-02-07 13:39   ` [PATCH v6 7/7] x86: move ENTRY(), GLOBAL(), and ALIGN Jan Beulich
2024-02-07 14:27     ` Andrew Cooper

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=782b911e-c40e-4e9c-b259-af287d968b3b@suse.com \
    --to=jbeulich@suse.com \
    --cc=alistair.francis@wdc.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bertrand.marquis@arm.com \
    --cc=bobbyeshleman@gmail.com \
    --cc=connojdavis@gmail.com \
    --cc=george.dunlap@citrix.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sanastasio@raptorengineering.com \
    --cc=sstabellini@kernel.org \
    --cc=volodymyr_babchuk@epam.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.