WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 3/3] linux/x86: avoid casting hypercall arguments to

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 3/3] linux/x86: avoid casting hypercall arguments to long
From: "Jan Beulich" <jbeulich@xxxxxxxxxx>
Date: Tue, 29 Jan 2008 10:47:06 +0000
Delivery-date: Tue, 29 Jan 2008 02:49:21 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
.., providing a little more type correctness checking and producing
better code on 64-bits.

As usual, written and tested on 2.6.24 and made apply to the 2.6.18
tree without further testing.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

Index: head-2008-01-28/include/asm-i386/mach-xen/asm/hypercall.h
===================================================================
--- head-2008-01-28.orig/include/asm-i386/mach-xen/asm/hypercall.h      
2008-01-29 10:09:17.000000000 +0100
+++ head-2008-01-28/include/asm-i386/mach-xen/asm/hypercall.h   2008-01-29 
10:27:28.000000000 +0100
@@ -68,7 +68,7 @@
        asm volatile (                                          \
                HYPERCALL_STR(name)                             \
                : "=a" (__res), "=b" (__ign1)                   \
-               : "1" ((long)(a1))                              \
+               : "1" ((a1)?:0)                                 \
                : "memory" );                                   \
        __res;                                                  \
 })
@@ -80,7 +80,7 @@
        asm volatile (                                          \
                HYPERCALL_STR(name)                             \
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2)    \
-               : "1" ((long)(a1)), "2" ((long)(a2))            \
+               : "1" ((a1)?:0), "2" ((a2)?:0)                  \
                : "memory" );                                   \
        __res;                                                  \
 })
@@ -92,9 +92,8 @@
        asm volatile (                                          \
                HYPERCALL_STR(name)                             \
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
-               "=d" (__ign3)                                   \
-               : "1" ((long)(a1)), "2" ((long)(a2)),           \
-               "3" ((long)(a3))                                \
+                 "=d" (__ign3)                                 \
+               : "1" ((a1)?:0), "2" ((a2)?:0), "3" ((a3)?:0)   \
                : "memory" );                                   \
        __res;                                                  \
 })
@@ -106,9 +105,9 @@
        asm volatile (                                          \
                HYPERCALL_STR(name)                             \
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
-               "=d" (__ign3), "=S" (__ign4)                    \
-               : "1" ((long)(a1)), "2" ((long)(a2)),           \
-               "3" ((long)(a3)), "4" ((long)(a4))              \
+                 "=d" (__ign3), "=S" (__ign4)                  \
+               : "1" ((a1)?:0), "2" ((a2)?:0),                 \
+                 "3" ((a3)?:0), "4" ((a4)?:0)                  \
                : "memory" );                                   \
        __res;                                                  \
 })
@@ -120,10 +119,9 @@
        asm volatile (                                          \
                HYPERCALL_STR(name)                             \
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
-               "=d" (__ign3), "=S" (__ign4), "=D" (__ign5)     \
-               : "1" ((long)(a1)), "2" ((long)(a2)),           \
-               "3" ((long)(a3)), "4" ((long)(a4)),             \
-               "5" ((long)(a5))                                \
+                 "=d" (__ign3), "=S" (__ign4), "=D" (__ign5)   \
+               : "1" ((a1)?:0), "2" ((a2)?:0), "3" ((a3)?:0),  \
+                 "4" ((a4)?:0), "5" ((a5)?:0)                  \
                : "memory" );                                   \
        __res;                                                  \
 })
@@ -231,7 +229,11 @@ static inline int __must_check
 HYPERVISOR_update_descriptor(
        u64 ma, u64 desc)
 {
-       return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
+       unsigned long ma_hi = (unsigned long)(ma>>32);
+       unsigned long ma_lo = (unsigned long)ma;
+       unsigned long desc_hi = (unsigned long)(desc>>32);
+       unsigned long desc_lo = (unsigned long)desc;
+       return _hypercall4(int, update_descriptor, ma_lo, ma_hi, desc_lo, 
desc_hi);
 }
 
 static inline int __must_check
Index: head-2008-01-28/include/asm-x86_64/mach-xen/asm/hypercall.h
===================================================================
--- head-2008-01-28.orig/include/asm-x86_64/mach-xen/asm/hypercall.h    
2008-01-29 10:15:17.000000000 +0100
+++ head-2008-01-28/include/asm-x86_64/mach-xen/asm/hypercall.h 2008-01-29 
10:28:59.000000000 +0100
@@ -72,7 +72,7 @@
        asm volatile (                                          \
                HYPERCALL_STR(name)                             \
                : "=a" (__res), "=D" (__ign1)                   \
-               : "1" ((long)(a1))                              \
+               : "1" ((a1)?:0)                                 \
                : "memory" );                                   \
        __res;                                                  \
 })
@@ -84,7 +84,7 @@
        asm volatile (                                          \
                HYPERCALL_STR(name)                             \
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2)    \
-               : "1" ((long)(a1)), "2" ((long)(a2))            \
+               : "1" ((a1)?:0), "2" ((a2)?:0)                  \
                : "memory" );                                   \
        __res;                                                  \
 })
@@ -96,9 +96,8 @@
        asm volatile (                                          \
                HYPERCALL_STR(name)                             \
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
-               "=d" (__ign3)                                   \
-               : "1" ((long)(a1)), "2" ((long)(a2)),           \
-               "3" ((long)(a3))                                \
+                 "=d" (__ign3)                                 \
+               : "1" ((a1)?:0), "2" ((a2)?:0), "3" ((a3)?:0)   \
                : "memory" );                                   \
        __res;                                                  \
 })
@@ -107,13 +106,12 @@
 ({                                                             \
        type __res;                                             \
        long __ign1, __ign2, __ign3;                            \
-       register long __arg4 asm("r10") = (long)(a4);           \
+       register typeof((a4)?:0) __arg4 asm("r10") = (a4);      \
        asm volatile (                                          \
                HYPERCALL_STR(name)                             \
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
                  "=d" (__ign3), "+r" (__arg4)                  \
-               : "1" ((long)(a1)), "2" ((long)(a2)),           \
-                 "3" ((long)(a3))                              \
+               : "1" ((a1)?:0), "2" ((a2)?:0), "3" ((a3)?:0)   \
                : "memory" );                                   \
        __res;                                                  \
 })
@@ -122,14 +120,13 @@
 ({                                                             \
        type __res;                                             \
        long __ign1, __ign2, __ign3;                            \
-       register long __arg4 asm("r10") = (long)(a4);           \
-       register long __arg5 asm("r8") = (long)(a5);            \
+       register typeof((a4)?:0) __arg4 asm("r10") = (a4);      \
+       register typeof((a5)?:0) __arg5 asm("r8") = (a5);       \
        asm volatile (                                          \
                HYPERCALL_STR(name)                             \
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
                  "=d" (__ign3), "+r" (__arg4), "+r" (__arg5)   \
-               : "1" ((long)(a1)), "2" ((long)(a2)),           \
-                 "3" ((long)(a3))                              \
+               : "1" ((a1)?:0), "2" ((a2)?:0), "3" ((a3)?:0)   \
                : "memory" );                                   \
        __res;                                                  \
 })



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>