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

[Xen-changelog] [xen master] x86emul: correct DECLARE_ALIGNED()



commit da091ea2f194dc5e4c785ff432872f570eb6b531
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Mar 17 09:33:45 2017 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Mar 17 09:33:45 2017 +0100

    x86emul: correct DECLARE_ALIGNED()
    
    Stop creating an excessively large array on the stack, by properly
    taking into account the array element size when establishing its
    element count (and of course also when calculating the pointer to
    be actually used to access the memory).
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c 
b/xen/arch/x86/x86_emulate/x86_emulate.c
index 4872f19..038f558 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -553,10 +553,10 @@ typedef union {
  * the compiler for automatic variables. Use this helper to instantiate a
  * suitably aligned variable, producing a pointer to access it.
  */
-#define DECLARE_ALIGNED(type, var)                                   \
-    long __##var[sizeof(type) + __alignof(type) - __alignof(long)];  \
-    type *const var##p =                                             \
-        (void *)((long)(__##var + __alignof(type) - __alignof(long)) \
+#define DECLARE_ALIGNED(type, var)                                        \
+    long __##var[(sizeof(type) + __alignof(type)) / __alignof(long) - 1]; \
+    type *const var##p =                                                  \
+        (void *)(((long)__##var + __alignof(type) - __alignof(__##var))   \
                  & -__alignof(type))
 
 #ifdef __GCC_ASM_FLAG_OUTPUTS__
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
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®.