All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Andryuk <jason.andryuk@amd.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	<xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v6 3/4] libelf: Store maximum PHDR p_align
Date: Fri, 29 Mar 2024 10:41:50 -0400	[thread overview]
Message-ID: <d6927896-0168-4620-b10a-8d6304b4d6eb@amd.com> (raw)
In-Reply-To: <f2297a46-4d19-4b98-b986-e05ac9f7a2c5@suse.com>

On 2024-03-28 12:47, Jan Beulich wrote:
> On 27.03.2024 22:51, Jason Andryuk wrote:
>> --- a/xen/common/libelf/libelf-loader.c
>> +++ b/xen/common/libelf/libelf-loader.c
>> @@ -468,6 +468,7 @@ void elf_parse_binary(struct elf_binary *elf)
>>   {
>>       ELF_HANDLE_DECL(elf_phdr) phdr;
>>       uint64_t low = -1, high = 0, paddr, memsz;
>> +    uint64_t max_align = 0, palign;
>>       unsigned i, count;
>>   
>>       count = elf_phdr_count(elf);
>> @@ -481,17 +482,23 @@ void elf_parse_binary(struct elf_binary *elf)
>>               continue;
>>           paddr = elf_uval(elf, phdr, p_paddr);
>>           memsz = elf_uval(elf, phdr, p_memsz);
>> -        elf_msg(elf, "ELF: phdr: paddr=%#" PRIx64 " memsz=%#" PRIx64 "\n",
>> -                paddr, memsz);
>> +        palign = elf_uval(elf, phdr, p_align);
>> +        elf_msg(elf,
>> +                "ELF: phdr: paddr=%#" PRIx64 " memsz=%#" PRIx64 " palign=%#" PRIx64 "\n",
>> +                paddr, memsz, palign);
>>           if ( low > paddr )
>>               low = paddr;
>>           if ( high < paddr + memsz )
>>               high = paddr + memsz;
>> +        if ( max_align < palign )
>> +            max_align = palign;
>>       }
>>       elf->pstart = low;
>>       elf->pend = high;
>> -    elf_msg(elf, "ELF: memory: %#" PRIx64 " -> %#" PRIx64 "\n",
>> -            elf->pstart, elf->pend);
>> +    elf->palign = max_align;
>> +    elf_msg(elf,
>> +            "ELF: memory: %#" PRIx64 " -> %#" PRIx64 " align:%#" PRIx64 "\n",
>> +            elf->pstart, elf->pend, elf->palign);
>>   }
> 
> Hmm, it's just this final logging change which I'm a little concerned by:
> Having looked at Linux'es phdr, I noticed that the addresses there aren't
> necessarily matching the corresponding alignment. Therefore I'm a little
> concerned that the output here might raise questions when people see
> seemingly inconsistent values in the log. Could you/we at least make it
> read like e.g. "align (max): ..."?

max_align?

Looking at my test vmlinux, it looks like PHDR 0 (.text) and PHDR 1 
(.data) are aligned.  It's the PHDR 2 (.init) that isn't aligned.  Is 
that what you see?

This line is already printing the min and max across all the PHDRs, so 
it would only look confusing if the start didn't match the align.

I'm not sure how useful it is to print the alignment, and I considered 
not printing it.  It's only used with PVH Dom0 right now, so it's not 
relevant in most cases.

Regards,
Jason


  reply	other threads:[~2024-03-29 14:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 21:50 [PATCH v6 0/4] x86/pvh: Support relocating dom0 kernel Jason Andryuk
2024-03-27 21:50 ` [PATCH v6 1/4] tools/init-xenstore-domain: Replace variable MB() usage Jason Andryuk
2024-04-03 12:41   ` Anthony PERARD
2024-04-03 12:51     ` Jason Andryuk
2024-04-04 10:09   ` Jan Beulich
2024-04-04 13:55     ` Jason Andryuk
2024-03-27 21:51 ` [PATCH v6 2/4] tools: Move MB/GB() to common-macros.h Jason Andryuk
2024-04-03 12:57   ` Anthony PERARD
2024-03-27 21:51 ` [PATCH v6 3/4] libelf: Store maximum PHDR p_align Jason Andryuk
2024-03-28 16:47   ` Jan Beulich
2024-03-29 14:41     ` Jason Andryuk [this message]
2024-04-02  6:44       ` Jan Beulich
2024-04-04 14:00         ` Jason Andryuk
2024-03-27 21:51 ` [PATCH v6 4/4] x86/PVH: Support relocatable dom0 kernels Jason Andryuk
2024-04-02 14:34   ` Jan Beulich
2024-04-04 14:01     ` Jason Andryuk
2024-03-27 21:55 ` [PATCH v6] RFC: x86/pvh: Make Xen PVH entrypoint PIC for x86-64 Jason Andryuk

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=d6927896-0168-4620-b10a-8d6304b4d6eb@amd.com \
    --to=jason.andryuk@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.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.