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

[xen staging] memory: fix build with COVERAGE but !HVM

commit 119c98972c4e737508df827bbbc8453cc93292c7
Author:     Julien Grall <jgrall@xxxxxxxxxx>
AuthorDate: Tue Feb 2 11:35:42 2021 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Feb 2 11:35:42 2021 +0100

    memory: fix build with COVERAGE but !HVM
    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
    ld: ld: prelink.o: in function `xenmem_add_to_physmap_batch':
    /xen/xen/common/memory.c:942: undefined reference to 
    /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 
    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 
    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>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Wei Liu <wl@xxxxxxx>
    Release-Acked-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
 xen/common/memory.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/xen/common/memory.c b/xen/common/memory.c
index 01cab7e493..f23b001fd2 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -904,6 +904,17 @@ static int xenmem_add_to_physmap_batch(struct domain *d,
     union add_to_physmap_extra extra = {};
+    /*
+     * In some configurations, (!HVM, COVERAGE), the 
+     * call doesn't succumb to dead-code-elimination. Duplicate the 
+     * from xatp_permission_check() to try and help the compiler out.
+     */
+    if ( !paging_mode_translate(d) )
+    {
+        return -EACCES;
+    }
     if ( unlikely(xatpb->size < extent) )
         return -EILSEQ;
generated by git-patchbot for /home/xen/git/xen.git#staging



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