All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Frediano Ziglio <frediano.ziglio@cloud.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Alejandro Vallejo" <alejandro.vallejo@cloud.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH] Avoid additional relocations in trampoline code
Date: Tue, 27 Aug 2024 17:50:29 +0200	[thread overview]
Message-ID: <527b3a0f-3e86-47aa-9092-e67df329b7e9@suse.com> (raw)
In-Reply-To: <CACHz=ZgbU3-HBgoDC9ws=cCK10B2D4K2JxjLN3_0YGoksVep8w@mail.gmail.com>

On 27.08.2024 15:56, Frediano Ziglio wrote:
> On Mon, Aug 26, 2024 at 9:21 AM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> On 22.08.2024 17:29, Frediano Ziglio wrote:
>>> The trampoline could have "manual" relocation entries (created
>>> by assembly macros and some code to use them) and (in case of PE)
>>> normal executable relocations.
>>> Remove all normal executable ones. In this way we don't have to
>>> worry about applying both correctly (they need proper order
>>> which is hard to spot looking at the code).
>>>
>>> Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
>>
>> I think this wants splitting into one patch replacing sym_offs() and a
>> 2nd one introducing the hand-crafted __XEN_VIRT_START additions (which
>> may want macro-izing). Plus the justification for the change wants
>> extending, to actually explain what the problem is - after all there's
>> no issue anywhere right now.
> 
> Should I explain the time dependency issue with source code?

Time dependency? I guess I don't understand ...

> I suppose I can describe where currently is and why it would be better
> to have it removed (honestly I though I did but reading the commit
> message I didn't).
> Maybe for search reasons it would be better to define 2 macros like
> the following?
> 
> #define phys_addr(sym) sym ## _pa
> #define virt_addr(sym) sym ## _va
> 
> This way, for instance, searching for the "__high_start" word (like
> "grep -rw __high_start") would produce a result.

I assume it's best to keep everything there together, so see below.

>> With the sym_offs() uses gone, I think it would be best if the macro was
>> #undef-ed ahead of the inclusion of trampoline.S. Since x86_64.S uses the
>> macro, that'll require careful re-arrangement of #include order.
>>
> 
> I think you mean including the trampoline after including x86_64.S in
> head.S.

Yes.

>>> --- a/xen/arch/x86/xen.lds.S
>>> +++ b/xen/arch/x86/xen.lds.S
>>> @@ -71,7 +71,12 @@ SECTIONS
>>>    __2M_text_start = .;         /* Start of 2M superpages, mapped RX. */
>>>  #endif
>>>
>>> -  start_pa = ABSOLUTE(start - __XEN_VIRT_START);
>>> +#define DEFINE_PA_ADDRESS(sym) sym ## _pa = ABSOLUTE(sym - __XEN_VIRT_START)
>>> +  DEFINE_PA_ADDRESS(start);
>>> +  DEFINE_PA_ADDRESS(saved_magic);
>>> +  DEFINE_PA_ADDRESS(idle_pg_table);
>>> +  DEFINE_PA_ADDRESS(__high_start);
>>> +  DEFINE_PA_ADDRESS(s3_resume);
>>>
>>>    . = __XEN_VIRT_START + XEN_IMG_OFFSET;
>>>    _start = .;
>>
>> For the cases where in assembly code you add __XEN_VIRT_START this is pretty
>> odd: You subtract the value here just to add it back there. Did you consider
>> a more straightforward approach, like introducing absolute xxx_va symbols?
> 
> I didn't consider. Would something like
> 
> #define DEFINE_ABS_ADDRESSES(sym) \
>    sym ## _pa = ABSOLUTE(sym - __XEN_VIRT_START); \
>    sym ## _va = ABSOLUTE(sym)
> 
> make sense? Maybe the _pa and _va suffixes are too similar? Maybe
> _physaddr and _virtaddr? Or use capical letters and macros (as above)
> to avoid possible clashes?

I'd like to ask that we don't introduce symbols we don't actually use. Hence
a single macro defining both is probably not going to be overly helpful. As
to capital letters: I'm struggling with the "(as above)" - I don't see any
use of capital letters in symbol names being generated. But yes, I was going
to suggest to consider _VA and _PA tags, precisely to reduce the risk of
clashes.

Jan


  reply	other threads:[~2024-08-27 15:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22 15:29 [PATCH] Avoid additional relocations in trampoline code Frediano Ziglio
2024-08-26  8:21 ` Jan Beulich
2024-08-27 13:56   ` Frediano Ziglio
2024-08-27 15:50     ` Jan Beulich [this message]
2024-08-28  7:51       ` Frediano Ziglio

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=527b3a0f-3e86-47aa-9092-e67df329b7e9@suse.com \
    --to=jbeulich@suse.com \
    --cc=alejandro.vallejo@cloud.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=frediano.ziglio@cloud.com \
    --cc=roger.pau@citrix.com \
    --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.