All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Roger Pau Monne <roger.pau@citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: [PATCH v6 2/3] xen: use explicit function alignment if supported by compiler
Date: Wed,  7 Feb 2024 15:55:46 +0100	[thread overview]
Message-ID: <20240207145547.89689-3-roger.pau@citrix.com> (raw)
In-Reply-To: <20240207145547.89689-1-roger.pau@citrix.com>

Introduce a new Kconfig check for whether the compiler supports
-falign-functions and if supported use it to align functions to the per-arch
selected value, just like it's done for assembly ENTRY() and FUNC() symbols.

Note that it's possible for the compiler to end up using a higher function
alignment regardless of the passed value.  Different compilers handle the
option differently, as clang will ignore -falign-functions value if it's
smaller than the one that would be set by the optimization level, while gcc
seems to always honor the function alignment passed in -falign-functions.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v5:
 - New in this version.
---
 xen/Kconfig  | 5 +++++
 xen/Makefile | 1 +
 2 files changed, 6 insertions(+)

diff --git a/xen/Kconfig b/xen/Kconfig
index 1e1b041fd52f..040cba1b4b73 100644
--- a/xen/Kconfig
+++ b/xen/Kconfig
@@ -41,6 +41,11 @@ config CC_SPLIT_SECTIONS
 #
 # Allow setting on a boolean basis, and then convert such selection to an
 # integer for the build system and code to consume more easily.
+#
+# Requires clang >= 7.0.0
+config CC_HAS_FUNCTION_ALIGNMENT
+	def_bool $(cc-option,-falign-functions)
+
 config FUNCTION_ALIGNMENT_4B
 	bool
 config FUNCTION_ALIGNMENT_8B
diff --git a/xen/Makefile b/xen/Makefile
index 21832d640225..7c8249ab3a33 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -390,6 +390,7 @@ CFLAGS += -fomit-frame-pointer
 endif
 
 CFLAGS-$(CONFIG_CC_SPLIT_SECTIONS) += -ffunction-sections -fdata-sections
+CFLAGS-$(CONFIG_CC_HAS_FUNCTION_ALIGNMENT) += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT)
 
 CFLAGS += -nostdinc -fno-builtin -fno-common
 CFLAGS += -Werror -Wredundant-decls -Wwrite-strings -Wno-pointer-arith
-- 
2.43.0



  parent reply	other threads:[~2024-02-07 14:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-07 14:55 [PATCH v6 0/3] xen: introduce Kconfig function alignment option Roger Pau Monne
2024-02-07 14:55 ` [PATCH v6 1/3] " Roger Pau Monne
2024-02-13 15:51   ` Jan Beulich
2024-02-26 11:33     ` Roger Pau Monné
2024-02-26 12:26       ` Jan Beulich
2024-02-14  8:20   ` Michal Orzel
2024-02-26 19:35   ` Shawn Anastasio
2024-02-07 14:55 ` Roger Pau Monne [this message]
2024-03-28  9:44   ` [PATCH v6 2/3] xen: use explicit function alignment if supported by compiler Roger Pau Monné
2024-02-07 14:55 ` [PATCH v6 3/3] xen/livepatch: align functions to ensure minimal distance between entry points Roger Pau Monne
2024-02-13 15:58   ` Jan Beulich
2024-02-26 11:32     ` Roger Pau Monné
2024-02-26 12:36       ` Jan Beulich
2024-02-27  8:15         ` Roger Pau Monné
2024-02-27  8:53           ` Jan Beulich
2024-02-27  9:25             ` 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=20240207145547.89689-3-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --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.