From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>,
Volodymyr Babchuk <volodymyr_babchuk@epam.com>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Bobby Eshleman <bobbyeshleman@gmail.com>,
Alistair Francis <alistair.francis@wdc.com>,
Connor Davis <connojdavis@gmail.com>
Subject: Re: [PATCH v2 1/2] x86: annotate entry points with type and size
Date: Tue, 30 May 2023 15:21:01 +0200 [thread overview]
Message-ID: <ZHX4PR56MQZQCVUX@Air-de-Roger> (raw)
In-Reply-To: <bba057a2-0a68-bf05-9a92-59546b52c73c@suse.com>
On Tue, May 30, 2023 at 10:06:27AM +0200, Jan Beulich wrote:
> On 29.05.2023 15:34, Roger Pau Monné wrote:
> > On Tue, May 23, 2023 at 01:30:51PM +0200, Jan Beulich wrote:
> >> Note that the FB-label in autogen_stubs() cannot be converted just yet:
> >> Such labels cannot be used with .type. We could further diverge from
> >> Linux'es model and avoid setting STT_NOTYPE explicitly (that's the type
> >> labels get by default anyway).
> >>
> >> Note that we can't use ALIGN() (in place of SYM_ALIGN()) as long as we
> >> still have ALIGN.
> >
> > FWIW, as I'm looking into using the newly added macros in order to add
> > annotations suitable for live-patching, I would need to switch some of
> > the LABEL usages into it's own functions, as it's not possible to
> > livepatch a function that has labels jumped into from code paths
> > outside of the function.
>
> Hmm, I'm not sure what the best way is to overcome that restriction. I'm
> not convinced we want to arbitrarily name things "functions".
Any external entry point in the middle of a function-like block will
prevent it from being live patched.
If you want I can try to do a pass on top of your patch and see how
that would end up looking. I'm attempting to think about other
solutions, but every other solution seems quite horrible.
> >> --- a/xen/arch/x86/include/asm/asm_defns.h
> >> +++ b/xen/arch/x86/include/asm/asm_defns.h
> >> @@ -81,6 +81,45 @@ register unsigned long current_stack_poi
> >>
> >> #ifdef __ASSEMBLY__
> >>
> >> +#define SYM_ALIGN(algn...) .balign algn
> >> +
> >> +#define SYM_L_GLOBAL(name) .globl name
> >> +#define SYM_L_WEAK(name) .weak name
> >
> > Won't this better be added when required? I can't spot any weak
> > symbols in assembly ATM, and you don't introduce any _WEAK macro
> > variants below.
>
> Well, Andrew specifically mentioned to desire to also have Linux'es
> support for weak symbols. Hence I decided to add it here despite
> (for now) being unused). I can certainly drop that again, but in
> particular if we wanted to use the scheme globally, I think we may
> want to make it "complete".
OK, as long as we know it's unused.
> >> +#define SYM_L_LOCAL(name) /* nothing */
> >> +
> >> +#define SYM_T_FUNC STT_FUNC
> >> +#define SYM_T_DATA STT_OBJECT
> >> +#define SYM_T_NONE STT_NOTYPE
> >> +
> >> +#define SYM(name, typ, linkage, algn...) \
> >> + .type name, SYM_T_ ## typ; \
> >> + SYM_L_ ## linkage(name); \
> >> + SYM_ALIGN(algn); \
> >> + name:
> >> +
> >> +#define END(name) .size name, . - name
> >> +
> >> +#define ARG1_(x, y...) (x)
> >> +#define ARG2_(x, y...) ARG1_(y)
> >> +
> >> +#define LAST__(nr) ARG ## nr ## _
> >> +#define LAST_(nr) LAST__(nr)
> >> +#define LAST(x, y...) LAST_(count_args(x, ## y))(x, ## y)
> >
> > I find LAST not very descriptive, won't it better be named OPTIONAL()
> > or similar? (and maybe placed in lib.h?)
>
> I don't think OPTIONAL describes the purpose. I truly mean "last" here.
> As to placing in lib.h - perhaps, but then we may want to have forms
> with more than 2 arguments right away (and it would be a little unclear
> how far up to go).
Hm, I would be fine with adding that version with just 2 arguments, as
it's better to have the helper in a generic place IMO.
> >> +
> >> +#define FUNC(name, algn...) \
> >> + SYM(name, FUNC, GLOBAL, LAST(16, ## algn), 0x90)
> >
> > A rant, should the alignment of functions use a different padding?
> > (ie: ret or ud2?) In order to prevent stray jumps falling in the
> > padding and fall trough into the next function. That would also
> > prevent the implicit fall trough used in some places.
>
> Yes, but that's a separate topic (for which iirc patches are pending
> as well, just of course not integrated with the work here. There's
> the slight risk of overlooking some "fall-through" case ...
Oh, OK, wasn't aware patches are floating for this already, just came
across it while reviewing.
> >> --- a/xen/arch/x86/x86_64/compat/entry.S
> >> +++ b/xen/arch/x86/x86_64/compat/entry.S
> >> @@ -8,10 +8,11 @@
> >> #include <asm/page.h>
> >> #include <asm/processor.h>
> >> #include <asm/desc.h>
> >> +#include <xen/lib.h>
> >
> > Shouldn't the inclusion of lib.h be in asm_defs.h, as that's where the
> > usage of count_args() resides? (I assume that's why lib.h is added
> > here).
>
> When the uses are in macros I'm always largely undecided, and I slightly
> tend towards the (in general, perhaps not overly relevant here) "less
> dependencies" solution. As in: Source files not using the macros which
> use count_args() also don't need libs.h then.
I tend to prefer headers to be self contained, as it overall leads to
a clearer set of includes in source files. It's not obvious why
entry.S needs lib.h unless the asm_macros.h usage is taken into
account.
> >> sti
> >> call do_softirq
> >> jmp compat_test_all_events
> >>
> >> - ALIGN
> >> /* %rbx: struct vcpu, %rdx: struct trap_bounce */
> >> -.Lcompat_process_trapbounce:
> >> +LABEL_LOCAL(.Lcompat_process_trapbounce)
> >
> > It's my understanding that here the '.L' prefix is pointless, since
> > LABEL_LOCAL() will forcefully create a symbol for the label due to the
> > usage of .type?
>
> I don't think .type has this effect. There's certainly no such label in
> the symbol table of the object file I have as a result.
I was expecting .type to force the creation of a symbol, so the '.L'
prefix does prevent the symbol from being created even if .type is
specified.
Shouldn't the assembler complain that we are attempting to set a type
for a not present symbol?
Thanks, Roger.
next prev parent reply other threads:[~2023-05-30 13:21 UTC|newest]
Thread overview: 150+ 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é [this message]
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 ` [PATCH v6 1/7] common: honor CONFIG_CC_SPLIT_SECTIONS also for assembly functions Jan Beulich
2024-02-07 13:37 ` [PATCH v6 2/7] SVM: convert entry point annotations 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
2024-10-01 15:11 ` [PATCH v7 00/11] (mostly) x86+Arm32: add/convert entry point annotations Jan Beulich
2024-10-01 15:13 ` [PATCH v7 01/11] common: honor CONFIG_CC_SPLIT_SECTIONS also for assembly functions Jan Beulich
2024-10-01 15:13 ` [PATCH v7 02/11] VMX: convert entry point annotations Jan Beulich
2024-10-01 17:03 ` Andrew Cooper
2024-10-01 15:14 ` [PATCH v7 03/11] x86/ACPI: annotate assembly function/data with type and size Jan Beulich
2024-10-01 16:51 ` Andrew Cooper
2024-10-02 5:56 ` Jan Beulich
2024-10-01 15:15 ` [PATCH v7 04/11] x86/kexec: convert entry point annotations Jan Beulich
2024-10-01 17:19 ` Andrew Cooper
2024-10-01 15:15 ` [PATCH v7 05/11] x86: convert dom_crash_sync_extable() annotation Jan Beulich
2024-10-01 17:05 ` Andrew Cooper
2024-10-01 15:15 ` [PATCH v7 06/11] x86: move ENTRY(), GLOBAL(), and ALIGN Jan Beulich
2024-10-01 15:16 ` [PATCH v7 07/11] Arm32: use new-style entry annotations for library code Jan Beulich
2024-11-25 20:15 ` Julien Grall
2024-11-26 8:41 ` Jan Beulich
2024-11-27 10:57 ` Julien Grall
2024-10-01 15:16 ` [PATCH v7 08/11] Arm32: use new-style entry annotations for MMU code Jan Beulich
2024-10-01 15:19 ` Jan Beulich
2024-10-01 15:17 ` [PATCH v7 09/11] Arm32: use new-style entry annotations for entry code Jan Beulich
2024-11-25 20:25 ` Julien Grall
2024-11-26 8:53 ` Jan Beulich
2024-10-01 15:17 ` [PATCH v7 10/11] Arm32: use new-style entry annotations in head.S Jan Beulich
2024-11-25 20:28 ` Julien Grall
2024-11-26 9:02 ` Jan Beulich
2024-10-01 15:18 ` [PATCH v7 11/11] Arm: purge ENTRY(), ENDPROC(), and ALIGN Jan Beulich
2024-11-25 20:29 ` Julien Grall
2024-11-04 9:45 ` Ping: [PATCH v7 00/11] (mostly) x86+Arm32: add/convert entry point annotations Jan Beulich
2025-02-26 15:58 ` [PATCH v8 0/6] (mostly) Arm32: " Jan Beulich
2025-02-26 16:00 ` [PATCH v8 1/6] Arm32: use new-style entry annotations for library code Jan Beulich
2025-02-26 16:00 ` [PATCH v8 2/6] Arm32: use new-style entry annotations for MMU code Jan Beulich
2025-02-26 16:01 ` [PATCH v8 3/6] Arm32: use new-style entry annotations for entry code Jan Beulich
2025-02-26 16:01 ` [PATCH v8 4/6] Arm32: use new-style entry annotations in head.S Jan Beulich
2025-02-26 16:01 ` [PATCH v8 5/6] Arm: purge ENTRY(), ENDPROC(), and ALIGN Jan Beulich
2025-02-26 16:02 ` [PATCH v8 6/6] common: honor CONFIG_CC_SPLIT_SECTIONS also for assembly functions Jan Beulich
2025-03-04 10:34 ` [PATCH v8 0/6] (mostly) Arm32: add/convert entry point annotations Luca Fancellu
2025-03-13 8:04 ` [PATCH v8 RESEND " Jan Beulich
2025-03-13 8:06 ` [PATCH v8 RESEND 1/6] Arm32: use new-style entry annotations for library code Jan Beulich
2025-03-28 18:33 ` Julien Grall
2025-03-13 8:07 ` [PATCH v8 RESEND 2/6] Arm32: use new-style entry annotations for MMU code Jan Beulich
2025-03-28 18:39 ` Julien Grall
2025-03-31 6:50 ` Jan Beulich
2025-03-13 8:07 ` [PATCH v8 RESEND 3/6] Arm32: use new-style entry annotations for entry code Jan Beulich
2025-03-28 18:46 ` Julien Grall
2025-03-31 6:52 ` Jan Beulich
2025-03-13 8:08 ` [PATCH v8 RESEND 4/6] Arm32: use new-style entry annotations in head.S Jan Beulich
2025-03-28 18:48 ` Julien Grall
2025-03-28 18:48 ` Julien Grall
2025-03-13 8:08 ` [PATCH v8 RESEND 5/6] Arm: purge ENTRY(), ENDPROC(), and ALIGN Jan Beulich
2025-03-13 8:10 ` [PATCH v8 RESEND 6/6] common: honor CONFIG_CC_SPLIT_SECTIONS also for assembly functions Jan Beulich
2025-03-28 18:53 ` Julien Grall
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=ZHX4PR56MQZQCVUX@Air-de-Roger \
--to=roger.pau@citrix.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=jbeulich@suse.com \
--cc=julien@xen.org \
--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.