[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] memory: fix build with COVERAGE but !HVM


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 1 Feb 2021 18:26:29 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZzeBeog67ofe8nEnuWFZTQD0XYXfMZHV8KiLcfzrO+0=; b=Vyk02z5c4Q3wVDcQyeQUqZiD9Sdl/mLOA9q4+jxy+pB1vhgVij3Ra8v6DYFM2u05XD3hPZ2k2F6e6NyXpNacvmrwnUboFjrhj7nwWZt5/47f28a9yMgMfYBEp0EPMoX8b4ZKPzQMTgEDDjfXeRMLVn4OPdDdA8cmoNlQIzcEhCIkzxafV4ncwFjx4qLN7yqIQFWhaigwbsIQFnaDG9PalMa2jFof9jVK0v/tOXzKeN8HEdT4RqPHUPSoV3nM8Lgs/GfFCnpAvSmQXgIxZTf0FA/yZ80rZXSK2sL5tGoyFObKgbE2xPWF4QQyzh9gGq0II1SJwzAHhncIJrDmOqJgfA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b6jSzKexu37FDwYlsbXZVfKRhx8iElhxfSnsmKiyFhrO/kOr3Lk5NaAaXFyF3jH+NsUGcDZ6Y2FSQ/e30NGjmdsqwIFSjtLFkLwHXaeCODVRa44I5niSJfv7TTVw1EmO/JqBFgCkoSL+m9SwVlF+uQ8Ln56FHuLYYkMt1fEIVqR6DtmvkzspTd74c4CGm4wzMDviDNUJZiRg4rDMoxPkWA5lN2FYGxQueZYlcO6B0N7P69l7BVYgM48iP51jqrrVRkuJlLsJSldCeHBNf++h2cErKnKdJ8cHxduh28U3QOIxfjP9X2dIsIXR7GRPfJmwLhmnbpzK1QQcBWfaJkofpw==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 01 Feb 2021 18:26:52 +0000
  • Ironport-sdr: jRdklUyo6Irdf6VSpNNCBncG3MiX2zf6WwVNnbTD5E5PWUEXLee0ezjsGd7HCgRJ4RRyP+UC9s kByQY1JLrSQSJ3Iwleq3DP1pBVKwoOZ+ehQZwlqQ8jvIMdAc44mfpNsf3IfIX/p2XfXMvEG86X DAiQEn9o4djNXLU8Z3PJjKoEkGm3mn1QwMwWMk3fPQakZTJ0hcf8zPL6KEIpq2KWK1uM2JotfZ qzmuYACkeLracertJormAvejFWs4BWYbF9DeUE1wVvqepbNpKcyeuTz8imLg+WQ1e5OaJgLvb8 rTw=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxx>
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> Release-Acked-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
> ---
> 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@xxxxxxxxxx>, 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. */

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.