All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Julien Grall <julien@xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	George Dunlap <george.dunlap@citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v4 1/8] common: assembly entry point type/size annotations
Date: Mon, 18 Sep 2023 12:51:27 +0200	[thread overview]
Message-ID: <adcffca2-e8c2-6c31-2f88-72bb2648abc5@suse.com> (raw)
In-Reply-To: <6acaf6f5-7c55-4165-91f6-a912c058746e@xen.org>

On 18.09.2023 12:34, Julien Grall wrote:
> Hi,
> 
> On 18/09/2023 11:24, Jan Beulich wrote:
>> On 14.09.2023 23:06, Julien Grall wrote:
>>> On 04/08/2023 07:26, Jan Beulich wrote:
>>>> TBD: What to set CODE_ALIGN to by default? Or should we requires arch-es
>>>>        to define that in all cases?
>>>
>>> The code alignment is very specific to an architecture. So I think it
>>> would be better if there are no default.
>>>
>>> Otherwise, it will be more difficult for a developper to figure out that
>>> CODE_ALIGN may need an update.
>>
>> Okay, I've dropped the fallback then.
>>
>>>> --- /dev/null
>>>> +++ b/xen/include/xen/linkage.h
>>>> @@ -0,0 +1,56 @@
>>>> +#ifndef __LINKAGE_H__
>>>> +#define __LINKAGE_H__
>>>> +
>>>> +#ifdef __ASSEMBLY__
>>>> +
>>>> +#include <xen/macros.h>
>>>> +
>>>> +#ifndef CODE_ALIGN
>>>> +# define CODE_ALIGN ??
>>>> +#endif
>>>> +#ifndef CODE_FILL
>>>> +# define CODE_FILL ~0
>>>> +#endif
>>>
>>> What's the value to allow the architecture to override CODE_FILL and ...
>>
>> What is put between functions may be relevant to control. Without fall-
>> through to a subsequent label, I think the intention is to use "int3" (0xcc)
>> filler bytes, for example. (With fall-through to the subsequent label, NOPs
>> would need using in any event.)
> 
> I guess for x86 it makes sense. For Arm, the filler is unlikely to be 
> used as the instruction size is always fixed.
> 
>>
>>>> +
>>>> +#ifndef DATA_ALIGN
>>>> +# define DATA_ALIGN 0
>>>> +#endif
>>>> +#ifndef DATA_FILL
>>>> +# define DATA_FILL ~0
>>>> +#endif
>>>
>>> ... DATA_FILL?
>>
>> For data the need is probably less strict; still I could see one arch to
>> prefer zero filling while another might better like all-ones-filling.
> 
> It is unclear to me why an architecture would prefer one over the other. 
> Can you provide a bit more details?
> 
>>
>>>> +
>>>> +#define SYM_ALIGN(algn...) .balign algn
>>>
>>> I find the name 'algn' confusing (not even referring to the missing
>>> 'i'). Why not naming it 'args'?
>>
>> I can name it "args", sure. It's just that "algn" is in line with the
>> naming further down (where "args" isn't reasonable to use as substitution).
> 
> If you want to be consistent then, I think it would be best to use 
> 'align'. I think it should be fine as we don't seem to use '.align'.

I think I had a conflict from this somewhere, but that may have been very
early when I hadn't switched to .balign yet. I'll see if renaming works
out.

>>>> +#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 FUNC(name, algn...) \
>>>> +        SYM(name, FUNC, GLOBAL, LASTARG(CODE_ALIGN, ## algn), CODE_FILL)
>>>> +#define LABEL(name, algn...) \
>>>> +        SYM(name, NONE, GLOBAL, LASTARG(CODE_ALIGN, ## algn), CODE_FILL)
>>>> +#define DATA(name, algn...) \
>>>> +        SYM(name, DATA, GLOBAL, LASTARG(DATA_ALIGN, ## algn), DATA_FILL)
>>>
>>> I think the alignment should be explicit for DATA. Otherwise, at least
>>> on Arm, we would default to 0 which could lead to unaligned access if
>>> not careful.
>>
>> I disagree. Even for byte-granular data (like strings) it may be desirable
>> to have some default alignment, without every use site needing to repeat
>> that specific value. 
> 
> I understand that some cases may want to use a default alignment. But my 
> concern is the developer may not realize that alignment is necessary. So 
> by making it mandatory, it would at least prompt the developper to think 
> whether this is needed.

Forcing people to use a specific value every time, even when none would
be needed. Anyway, if others think your way, then I can certainly change.
But then I need to know whether others perhaps think alignment on functions
(and maybe even labels) should also be explicit in all cases.

> For the string case, we could introduce a different macro.

Hmm, yet one more special thing then (for people to remember to use under
certain circumstances).

Jan


  reply	other threads:[~2023-09-18 10:52 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 [this message]
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

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=adcffca2-e8c2-6c31-2f88-72bb2648abc5@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.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.