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 5/7] xencomm take 3: linux side various fixes and pre

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 5/7] xencomm take 3: linux side various fixes and preparation for consolidation
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Tue, 14 Aug 2007 18:50:23 +0900
Cc: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>, xen-ia64-devel@xxxxxxxxxxxxxxxxxxx, xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 14 Aug 2007 02:55:40 -0700
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
User-agent: Mutt/1.4.2.1i
# HG changeset patch
# User yamahata@xxxxxxxxxxxxx
# Date 1186975024 -32400
# Node ID 06791935b2cb9d69e94ca89ca8febcda627017b2
# Parent  d2f9b7e3623114e6a45c916f21b348fda122fa8e
[linux, xencomm]Various fixes common xencomm.c for ia64 xencomm consolidation
  - move xen_guest_handle() macro into include/xen/xencomm.h
    ia64 also uses it.
  - is_kern_addr() is powerpc specific. and other arch doesn't implement it.
    It will be defined in linux/include/asm-ia64/xen/xencomm.h
  - fix error recovery path of xencomm_create()
    xencomm_free() requires pseudo physical address, not virtual address.
  - add one BUG_ON() to xencomm_create_mini() for alignment requirement
  - use xencomm_pa() instead of __pa() in xencomm_map() and
    xencomm_map_no_alloc().
    They should work for statically allocated area. On ia64 it isn't in
    straight mapping area so that xencomm_pa() is necessary.
  - add gcc bug work around. gcc 4.1.2 doesn't handle properly
    variables on stack with align attribute.
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660

PATCHNAME: fix_xencomm_create_in_common_code

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>)

diff -r d2f9b7e36231 -r 06791935b2cb arch/powerpc/platforms/xen/setup.h
--- a/arch/powerpc/platforms/xen/setup.h        Thu Aug 09 16:16:28 2007 +0100
+++ b/arch/powerpc/platforms/xen/setup.h        Mon Aug 13 12:17:04 2007 +0900
@@ -40,8 +40,6 @@ static inline u64 jiffies_to_ns(unsigned
        return j * (1000000000UL / HZ);
 }
 
-#define xen_guest_handle(hnd)  ((hnd).p)
-
 extern struct page *alloc_foreign_page(void);
 extern void free_foreign_page(struct page *page);
 
diff -r d2f9b7e36231 -r 06791935b2cb drivers/xen/core/xencomm.c
--- a/drivers/xen/core/xencomm.c        Thu Aug 09 16:16:28 2007 +0100
+++ b/drivers/xen/core/xencomm.c        Mon Aug 13 12:17:04 2007 +0900
@@ -23,6 +23,9 @@
 #include <asm/page.h>
 #include <xen/xencomm.h>
 #include <xen/interface/xen.h>
+#ifdef __ia64__
+#include <asm/xen/xencomm.h>   /* for is_kern_addr() */
+#endif
 
 static int xencomm_init(struct xencomm_desc *desc,
                        void *buffer, unsigned long bytes)
@@ -111,7 +114,7 @@ static int xencomm_create(void *buffer, 
        rc = xencomm_init(desc, buffer, bytes);
        if (rc) {
                printk("%s failure: %d\n", "xencomm_init", rc);
-               xencomm_free(desc);
+               xencomm_free((void *)__pa(desc));
                return rc;
        }
 
@@ -146,6 +149,7 @@ static int xencomm_create_mini(void *buf
 {
        int rc = 0;
        struct xencomm_desc *desc;
+       BUG_ON(((unsigned long)xc_desc) % sizeof(*xc_desc) != 0);
 
        desc = (void *)xc_desc; 
 
@@ -170,7 +174,7 @@ void *xencomm_map(void *ptr, unsigned lo
        if (rc || desc == NULL)
                return NULL;
 
-       return (void *)__pa(desc);
+       return xencomm_pa(desc);
 }
 
 void *__xencomm_map_no_alloc(void *ptr, unsigned long bytes, 
@@ -188,5 +192,5 @@ void *__xencomm_map_no_alloc(void *ptr, 
        if (rc)
                return NULL;
  
-       return (void *)__pa(desc);
+       return xencomm_pa(desc);
 }
diff -r d2f9b7e36231 -r 06791935b2cb include/xen/xencomm.h
--- a/include/xen/xencomm.h     Thu Aug 09 16:16:28 2007 +0100
+++ b/include/xen/xencomm.h     Mon Aug 13 12:17:04 2007 +0900
@@ -35,10 +35,30 @@ extern void *__xencomm_map_no_alloc(void
 extern void *__xencomm_map_no_alloc(void *ptr, unsigned long bytes, 
                                struct xencomm_mini *xc_area);
 
-#define xencomm_map_no_alloc(ptr, bytes) \
-       ({struct xencomm_mini xc_desc\
-               __attribute__((__aligned__(sizeof(struct xencomm_mini))));\
-               __xencomm_map_no_alloc(ptr, bytes, &xc_desc);})
+#if 0
+#define XENCOMM_MINI_ALIGNED(xc_desc, n)                               \
+       struct xencomm_mini xc_desc ## _base[(n)]                       \
+       __attribute__((__aligned__(sizeof(struct xencomm_mini))));      \
+       struct xencomm_mini* xc_desc = &xc_desc ## _base[0];
+#else
+/*
+ * gcc bug workaround:
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660
+ * gcc doesn't handle properly stack variable with
+ * __attribute__((__align__(sizeof(struct xencomm_mini))))
+ */
+#define XENCOMM_MINI_ALIGNED(xc_desc, n)                               \
+       unsigned char xc_desc ## _base[((n) + 1 ) *                     \
+                                      sizeof(struct xencomm_mini)];    \
+       struct xencomm_mini *xc_desc = (struct xencomm_mini*)           \
+               ((unsigned long)xc_desc ## _base +                      \
+                (sizeof(struct xencomm_mini) -                         \
+                 ((unsigned long)xc_desc ## _base) %                   \
+                 sizeof(struct xencomm_mini)));
+#endif
+#define xencomm_map_no_alloc(ptr, bytes)                       \
+       ({XENCOMM_MINI_ALIGNED(xc_desc, 1);                     \
+               __xencomm_map_no_alloc(ptr, bytes, xc_desc);})
 
 /* provided by architecture code: */
 extern unsigned long xencomm_vtop(unsigned long vaddr);
@@ -48,4 +68,6 @@ static inline void *xencomm_pa(void *ptr
        return (void *)xencomm_vtop((unsigned long)ptr);
 }
 
+#define xen_guest_handle(hnd)  ((hnd).p)
+
 #endif /* _LINUX_XENCOMM_H_ */

Attachment: 157_06791935b2cb_fix_xencomm_create_in_common_code.patch
Description: Text Data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 5/7] xencomm take 3: linux side various fixes and preparation for consolidation, Isaku Yamahata <=