Re: [PATCH 05/24] x86/entry: Introduce __entry_text for entry code written in C

From: Lai Jiangshan
Date: Tue Aug 31 2021 - 20:23:13 EST




On 2021/9/1 03:34, Peter Zijlstra wrote:
On Wed, Sep 01, 2021 at 01:50:06AM +0800, Lai Jiangshan wrote:
From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>

Some entry code will be implemented in traps.c. We need __entry_text
to set them in .entry.text section.

Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
---
arch/x86/entry/traps.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/x86/entry/traps.c b/arch/x86/entry/traps.c
index f71db7934f90..ef07ae5fb3a0 100644
--- a/arch/x86/entry/traps.c
+++ b/arch/x86/entry/traps.c
@@ -69,6 +69,11 @@
extern unsigned char native_irq_return_iret[];
extern unsigned char asm_load_gs_index_gs_change[];
+/* Entry code written in C. Must be only used in traps.c */
+#define __entry_text \
+ noinline notrace __attribute((__section__(".entry.text"))) \
+ __no_kcsan __no_sanitize_address __no_profile __no_sanitize_coverage

Urgh, that's bound to get out of sync with noinstr.. How about you make
noinstr something like:

#define __noinstr_section(section) \
noinline notrace __attribute((__section__(section))) \
__no_kcsan __no_sanitize_address __no_profile __no_sanitize_coverage

#define noinstr __noinstr_section(".noinstr.text")

and then write the above like:

#define __entry_text __noinstr_section(".entry.text")

It is a good idea. There was no "__no_profile __no_sanitize_coverage"
when I first made the patch several month ago. I added it after I recheck
the definition of "noinstr" yesterday which means we really need __noinstr_section()
to keep them sync.