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

[Xen-changelog] [xen staging] xen/arm: fix get_cpu_info() when built with clang



commit a943d6ccffff7bba9988c1c8968b37b031724cd2
Author:     Julien Grall <julien.grall@xxxxxxx>
AuthorDate: Tue Mar 26 21:52:20 2019 +0000
Commit:     Julien Grall <julien.grall@xxxxxxx>
CommitDate: Thu Oct 3 11:38:14 2019 +0100

    xen/arm: fix get_cpu_info() when built with clang
    
    Clang understands the GCCism in use here, but still complains that sp is
    unitialised. In such cases, resort to the older versions of this code,
    which directly read sp into the temporary variable.
    
    Note that GCCism is still kept in default because other compilers (e.g.
    clang) may also define __GNUC__, so AFAIK there are no proper way to
    detect properly GCC.
    
    This means that in the event Xen is ported to a new compiler, the code
    will need to be updated. But that likely not going to be the only place
    where Xen will need to be adapted...
    
    This is based on the x86 counterpart.
    
    Signed-off-by: Julien Grall <julien.grall@xxxxxxx>
    Release-acked-by: Juergen Gross <jgross@xxxxxxxx>
    Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
 xen/include/asm-arm/current.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/xen/include/asm-arm/current.h b/xen/include/asm-arm/current.h
index 1653e89d30..80503578cf 100644
--- a/xen/include/asm-arm/current.h
+++ b/xen/include/asm-arm/current.h
@@ -28,8 +28,16 @@ struct cpu_info {
 
 static inline struct cpu_info *get_cpu_info(void)
 {
+#ifdef __clang__
+    unsigned long sp;
+
+    asm ("mov %0, sp" : "=r" (sp));
+#else
     register unsigned long sp asm ("sp");
-    return (struct cpu_info *)((sp & ~(STACK_SIZE - 1)) + STACK_SIZE - 
sizeof(struct cpu_info));
+#endif
+
+    return (struct cpu_info *)((sp & ~(STACK_SIZE - 1)) +
+                               STACK_SIZE - sizeof(struct cpu_info));
 }
 
 #define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs)
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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