From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <george.dunlap@citrix.com>,
Ian Jackson <iwj@xenproject.org>, Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] memory: fix build with COVERAGE but !HVM
Date: Tue, 2 Feb 2021 09:28:36 +0100 [thread overview]
Message-ID: <c26ae312-2e08-6266-ea0d-a7a6c901f866@suse.com> (raw)
In-Reply-To: <a2fff2f5-70d2-19f2-b7d3-01e4db50f709@citrix.com>
On 01.02.2021 19:26, Andrew Cooper wrote:
> On 01/02/2021 16:20, Jan Beulich wrote:
>> Xen is heavily relying on the DCE stage to remove unused code so the
>> linker doesn't throw an error because a function is not implemented
>> yet we defined a prototype for it.
>>
>> On some GCC versions (such as 9.4 provided by Debian sid), the compiler
>> DCE stage will not manage to figure that out for
>> xenmem_add_to_physmap_batch():
>>
>> ld: ld: prelink.o: in function `xenmem_add_to_physmap_batch':
>> /xen/xen/common/memory.c:942: undefined reference to `xenmem_add_to_physmap_one'
>> /xen/xen/common/memory.c:942:(.text+0x22145): relocation truncated
>> to fit: R_X86_64_PLT32 against undefined symbol `xenmem_add_to_physmap_one'
>> prelink-efi.o: in function `xenmem_add_to_physmap_batch':
>> /xen/xen/common/memory.c:942: undefined reference to `xenmem_add_to_physmap_one'
>> make[2]: *** [Makefile:215: /root/xen/xen/xen.efi] Error 1
>> make[2]: *** Waiting for unfinished jobs....
>> ld: /xen/xen/.xen-syms.0: hidden symbol `xenmem_add_to_physmap_one' isn't defined
>> ld: final link failed: bad value
>>
>> It is not entirely clear why the compiler DCE is not detecting the
>> unused code. However, cloning the check introduced by the commit below
>> into xenmem_add_to_physmap_batch() does the trick.
>>
>> No functional change intended.
>>
>> Fixes: d4f699a0df6c ("x86/mm: p2m_add_foreign() is HVM-only")
>> Reported-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>> Signed-off-by: Julien Grall <jgrall@amazon.com>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> Release-Acked-by: Ian Jackson <iwj@xenproject.org>
>> ---
>> Julien, since I reused most of your patch'es description, I've kept your
>> S-o-b. Please let me know if you want me to drop it.
>>
>> --- a/xen/common/memory.c
>> +++ b/xen/common/memory.c
>> @@ -904,6 +904,19 @@ static int xenmem_add_to_physmap_batch(s
>> {
>> union add_to_physmap_extra extra = {};
>>
>> + /*
>> + * While, unlike xenmem_add_to_physmap(), this function is static, there
>> + * still have been cases observed where xatp_permission_check(), invoked
>> + * by our caller, doesn't lead to elimination of this entire function when
>> + * the compile time evaluation of paging_mode_translate(d) is false. Guard
>> + * against this be replicating the same check here.
>> + */
>
> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>,
Thanks.
> but I feel this
> comment can be far more precise/concise.
>
> /* In some configurations, (!HVM, COVERAGE), the
> xenmem_add_to_physmap_one() call doesn't succumb to
> dead-code-elimination. Duplicate the short-circut from
> xatp_permission_check() to try and help the compiler out. */
I'm perfectly fine to take this one. I have to admit though that
I first needed to look up "succumb" ...
Jan
next prev parent reply other threads:[~2021-02-02 8:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 16:20 [PATCH] memory: fix build with COVERAGE but !HVM Jan Beulich
2021-02-01 18:26 ` Andrew Cooper
2021-02-02 8:28 ` Jan Beulich [this message]
2021-02-01 18:26 ` Wei Liu
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=c26ae312-2e08-6266-ea0d-a7a6c901f866@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).