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-ia64-devel

[Xen-ia64-devel] [PATCH 1/3] xencomm consolidation: xen side

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH 1/3] xencomm consolidation: xen side
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Thu, 16 Aug 2007 12:21:04 +0900
Cc: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Delivery-date: Wed, 15 Aug 2007 20:21:34 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.4.2.1i
# HG changeset patch
# User yamahata@xxxxxxxxxxxxx
# Date 1186975416 -32400
# Node ID abd1440b700a189ac4cd7b71334dfbbeafb1d175
# Parent  b53a87fec6dc7a9f2cc3b3b7df72fa8b2c7fe081
use common xencomm.c and remove ia64 xencomm.c
PATCHNAME: use_common_xencomm_c_and_remove_ia64_xencomm_c

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

diff -r b53a87fec6dc -r abd1440b700a config/ia64.mk
--- a/config/ia64.mk    Tue Aug 14 16:52:49 2007 +0900
+++ b/config/ia64.mk    Mon Aug 13 12:23:36 2007 +0900
@@ -3,5 +3,6 @@ CONFIG_IA64_$(XEN_OS) := y
 
 CONFIG_IOEMU := y
 CONFIG_XCUTILS := y
+CONFIG_XENCOMM := y
 
 LIBDIR := lib
diff -r b53a87fec6dc -r abd1440b700a xen/arch/ia64/xen/Makefile
--- a/xen/arch/ia64/xen/Makefile        Tue Aug 14 16:52:49 2007 +0900
+++ b/xen/arch/ia64/xen/Makefile        Mon Aug 13 12:23:36 2007 +0900
@@ -35,7 +35,6 @@ obj-y += flushd.o
 obj-y += flushd.o
 obj-y += privop_stat.o
 obj-y += xenpatch.o
-obj-y += xencomm.o
 
 obj-$(crash_debug) += gdbstub.o
 obj-$(xen_ia64_tlb_track) += tlb_track.o
diff -r b53a87fec6dc -r abd1440b700a xen/arch/ia64/xen/mm.c
--- a/xen/arch/ia64/xen/mm.c    Tue Aug 14 16:52:49 2007 +0900
+++ b/xen/arch/ia64/xen/mm.c    Mon Aug 13 12:23:36 2007 +0900
@@ -738,7 +738,7 @@ void *domain_mpa_to_imva(struct domain *
 #endif
 
 unsigned long
-xencomm_paddr_to_maddr(unsigned long paddr)
+paddr_to_maddr(unsigned long paddr)
 {
     struct vcpu *v = current;
     struct domain *d = v->domain;
@@ -750,7 +750,7 @@ xencomm_paddr_to_maddr(unsigned long pad
                __func__, paddr, vcpu_regs(v)->cr_iip);
         return 0;
     }
-    return __va_ul((pa & _PFN_MASK) | (paddr & ~PAGE_MASK));
+    return (pa & _PFN_MASK) | (paddr & ~PAGE_MASK);
 }
 
 /* Allocate a new page for domain and map it to the specified metaphysical
diff -r b53a87fec6dc -r abd1440b700a xen/arch/ia64/xen/xencomm.c
--- a/xen/arch/ia64/xen/xencomm.c       Tue Aug 14 16:52:49 2007 +0900
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,387 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Copyright (C) IBM Corp. 2006
- *
- * Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
- *          Tristan Gingold <tristan.gingold@xxxxxxxx>
- */
-
-#include <xen/config.h>
-#include <xen/mm.h>
-#include <xen/sched.h>
-#include <asm/current.h>
-#include <asm/guest_access.h>
-#include <public/xen.h>
-#include <public/xencomm.h>
-#include <xen/errno.h>
-
-#undef DEBUG
-#ifdef DEBUG
-static int xencomm_debug = 1; /* extremely verbose */
-#else
-#define xencomm_debug 0
-#endif
-
-static int
-xencomm_copy_chunk_from(
-    unsigned long to,
-    unsigned long paddr,
-    unsigned int  len)
-{
-    unsigned long maddr;
-    struct page_info *page;
-
-    while (1) {
-       maddr = xencomm_paddr_to_maddr(paddr);
-       if (xencomm_debug > 1)
-           printk("%lx[%d] -> %lx\n", maddr, len, to);
-       if (maddr == 0)
-           return -EFAULT;
-
-       page = virt_to_page(maddr);
-       if (get_page(page, current->domain) == 0) {
-           if (page_get_owner(page) != current->domain) {
-               /* This page might be a page granted by another domain  */
-               panic_domain(NULL, "copy_from_guest from foreign domain\n");
-           }
-           /* Try again.  */
-           continue;
-       }
-       memcpy((void *)to, (void *)maddr, len);
-       put_page(page);
-       return 0;
-    }
-}
-
-/**
- * xencomm_copy_from_guest: Copy a block of data from domain space.
- * @to:   Machine address.
- * @from: Physical address to a xencomm buffer descriptor.
- * @n:    Number of bytes to copy.
- * @skip: Number of bytes from the start to skip.
- *
- * Copy data from domain to hypervisor.
- *
- * Returns number of bytes that could not be copied.
- * On success, this will be zero.
- */
-unsigned long
-xencomm_copy_from_guest(
-    void         *to,
-    const void   *from,
-    unsigned int n,
-    unsigned int skip)
-{
-    struct xencomm_desc *desc;
-    unsigned long desc_addr;
-    unsigned int from_pos = 0;
-    unsigned int to_pos = 0;
-    unsigned int i = 0;
-
-    if (xencomm_debug)
-        printk("xencomm_copy_from_guest: from=%lx+%u n=%u\n",
-               (unsigned long)from, skip, n);
-
-    if (XENCOMM_IS_INLINE(from)) {
-        unsigned long src_paddr = XENCOMM_INLINE_ADDR(from);
-            
-        src_paddr += skip;
-
-        while (n > 0) {
-            unsigned int chunksz;
-            unsigned int bytes;
-           int res;
-            
-            chunksz = PAGE_SIZE - (src_paddr % PAGE_SIZE);
-            
-            bytes = min(chunksz, n);
-
-            res = xencomm_copy_chunk_from((unsigned long)to, src_paddr, bytes);
-           if (res != 0)
-               return -EFAULT;
-            src_paddr += bytes;
-            to += bytes;
-            n -= bytes;
-        }
-        
-        /* Always successful.  */
-        return 0;
-    }
-
-    /* first we need to access the descriptor */
-    desc_addr = xencomm_paddr_to_maddr((unsigned long)from);
-    if (desc_addr == 0)
-        return -EFAULT;
-
-    desc = (struct xencomm_desc *)desc_addr;
-    if (desc->magic != XENCOMM_MAGIC) {
-        printk("%s: error: %p magic was 0x%x\n",
-               __func__, desc, desc->magic);
-        return -EFAULT;
-    }
-
-    /* iterate through the descriptor, copying up to a page at a time */
-    while ((to_pos < n) && (i < desc->nr_addrs)) {
-        unsigned long src_paddr = desc->address[i];
-        unsigned int pgoffset;
-        unsigned int chunksz;
-        unsigned int chunk_skip;
-
-        if (src_paddr == XENCOMM_INVALID) {
-            i++;
-            continue;
-        }
-
-        pgoffset = src_paddr % PAGE_SIZE;
-        chunksz = PAGE_SIZE - pgoffset;
-
-        chunk_skip = min(chunksz, skip);
-        from_pos += chunk_skip;
-        chunksz -= chunk_skip;
-        skip -= chunk_skip;
-
-        if (skip == 0 && chunksz > 0) {
-            unsigned int bytes = min(chunksz, n - to_pos);
-           int res;
-
-            if (xencomm_debug > 1)
-                printk ("src_paddr=%lx i=%d, skip=%d\n",
-                        src_paddr, i, chunk_skip);
-
-            res = xencomm_copy_chunk_from((unsigned long)to + to_pos,
-                                          src_paddr + chunk_skip, bytes);
-            if (res != 0)
-                return -EFAULT;
-
-            from_pos += bytes;
-            to_pos += bytes;
-        }
-
-        i++;
-    }
-
-    return n - to_pos;
-}
-
-static int
-xencomm_copy_chunk_to(
-    unsigned long paddr,
-    unsigned long from,
-    unsigned int  len)
-{
-    unsigned long maddr;
-    struct page_info *page;
-
-    while (1) {
-       maddr = xencomm_paddr_to_maddr(paddr);
-       if (xencomm_debug > 1)
-           printk("%lx[%d] -> %lx\n", from, len, maddr);
-       if (maddr == 0)
-           return -EFAULT;
-
-       page = virt_to_page(maddr);
-       if (get_page(page, current->domain) == 0) {
-           if (page_get_owner(page) != current->domain) {
-               /* This page might be a page granted by another domain  */
-               panic_domain(NULL, "copy_to_guest to foreign domain\n");
-           }
-           /* Try again.  */
-           continue;
-       }
-       memcpy((void *)maddr, (void *)from, len);
-       put_page(page);
-       return 0;
-    }
-}
-
-/**
- * xencomm_copy_to_guest: Copy a block of data to domain space.
- * @to:     Physical address to xencomm buffer descriptor.
- * @from:   Machine address.
- * @n:      Number of bytes to copy.
- * @skip: Number of bytes from the start to skip.
- *
- * Copy data from hypervisor to domain.
- *
- * Returns number of bytes that could not be copied.
- * On success, this will be zero.
- */
-unsigned long
-xencomm_copy_to_guest(
-    void         *to,
-    const void   *from,
-    unsigned int n,
-    unsigned int skip)
-{
-    struct xencomm_desc *desc;
-    unsigned long desc_addr;
-    unsigned int from_pos = 0;
-    unsigned int to_pos = 0;
-    unsigned int i = 0;
-
-    if (xencomm_debug)
-        printk ("xencomm_copy_to_guest: to=%lx+%u n=%u\n",
-                (unsigned long)to, skip, n);
-
-    if (XENCOMM_IS_INLINE(to)) {
-        unsigned long dest_paddr = XENCOMM_INLINE_ADDR(to);
-            
-        dest_paddr += skip;
-
-        while (n > 0) {
-            unsigned int chunksz;
-            unsigned int bytes;
-            int res;
-
-            chunksz = PAGE_SIZE - (dest_paddr % PAGE_SIZE);
-            
-            bytes = min(chunksz, n);
-
-            res = xencomm_copy_chunk_to(dest_paddr, (unsigned long)from, 
bytes);
-            if (res != 0)
-                return res;
-
-            dest_paddr += bytes;
-            from += bytes;
-            n -= bytes;
-        }
-
-        /* Always successful.  */
-        return 0;
-    }
-
-    /* first we need to access the descriptor */
-    desc_addr = xencomm_paddr_to_maddr((unsigned long)to);
-    if (desc_addr == 0)
-        return -EFAULT;
-
-    desc = (struct xencomm_desc *)desc_addr;
-    if (desc->magic != XENCOMM_MAGIC) {
-        printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
-        return -EFAULT;
-    }
-
-    /* iterate through the descriptor, copying up to a page at a time */
-    while ((from_pos < n) && (i < desc->nr_addrs)) {
-        unsigned long dest_paddr = desc->address[i];
-        unsigned int pgoffset;
-        unsigned int chunksz;
-        unsigned int chunk_skip;
-
-        if (dest_paddr == XENCOMM_INVALID) {
-            i++;
-            continue;
-        }
-
-        pgoffset = dest_paddr % PAGE_SIZE;
-        chunksz = PAGE_SIZE - pgoffset;
-
-        chunk_skip = min(chunksz, skip);
-        to_pos += chunk_skip;
-        chunksz -= chunk_skip;
-        skip -= chunk_skip;
-        dest_paddr += chunk_skip;
-
-        if (skip == 0 && chunksz > 0) {
-            unsigned int bytes = min(chunksz, n - from_pos);
-            int res;
-
-            res = xencomm_copy_chunk_to(dest_paddr,
-                                        (unsigned long)from + from_pos, bytes);
-            if (res != 0)
-                return res;
-
-            from_pos += bytes;
-            to_pos += bytes;
-        }
-
-        i++;
-    }
-    return n - from_pos;
-}
-
-/* Offset page addresses in 'handle' to skip 'bytes' bytes. Set completely
- * exhausted pages to XENCOMM_INVALID. */
-void *
-xencomm_add_offset(
-    void         *handle,
-    unsigned int bytes)
-{
-    struct xencomm_desc *desc;
-    unsigned long desc_addr;
-    int i = 0;
-
-    if (XENCOMM_IS_INLINE(handle))
-        return (void *)((unsigned long)handle + bytes);
-
-    /* first we need to access the descriptor */
-    desc_addr = xencomm_paddr_to_maddr((unsigned long)handle);
-    if (desc_addr == 0)
-        return NULL;
-
-    desc = (struct xencomm_desc *)desc_addr;
-    if (desc->magic != XENCOMM_MAGIC) {
-        printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
-        return NULL;
-    }
-
-    /* iterate through the descriptor incrementing addresses */
-    while ((bytes > 0) && (i < desc->nr_addrs)) {
-        unsigned long dest_paddr = desc->address[i];
-        unsigned int pgoffset;
-        unsigned int chunksz;
-        unsigned int chunk_skip;
-
-        if (dest_paddr == XENCOMM_INVALID) {
-            i++;
-            continue;
-        }
-
-        pgoffset = dest_paddr % PAGE_SIZE;
-        chunksz = PAGE_SIZE - pgoffset;
-
-        chunk_skip = min(chunksz, bytes);
-        if (chunk_skip == chunksz) {
-            /* exhausted this page */
-            desc->address[i] = XENCOMM_INVALID;
-        } else {
-            desc->address[i] += chunk_skip;
-        }
-        bytes -= chunk_skip;
-       
-       i++;
-    }
-    return handle;
-}
-
-int
-xencomm_handle_is_null(
-   void *ptr)
-{
-    if (XENCOMM_IS_INLINE(ptr))
-        return XENCOMM_INLINE_ADDR(ptr) == 0;
-    else {
-        struct xencomm_desc *desc;
-        unsigned long desc_addr;
-
-        desc_addr = xencomm_paddr_to_maddr((unsigned long)ptr);
-        if (desc_addr == 0)
-            return 1;
-
-        desc = (struct xencomm_desc *)desc_addr;
-        return (desc->nr_addrs == 0);
-    }
-}
diff -r b53a87fec6dc -r abd1440b700a xen/include/asm-ia64/guest_access.h
--- a/xen/include/asm-ia64/guest_access.h       Tue Aug 14 16:52:49 2007 +0900
+++ b/xen/include/asm-ia64/guest_access.h       Mon Aug 13 12:23:36 2007 +0900
@@ -22,89 +22,9 @@
 #ifndef __ASM_GUEST_ACCESS_H__
 #define __ASM_GUEST_ACCESS_H__
 
-extern unsigned long xencomm_copy_to_guest(void *to, const void *from,
-        unsigned int len, unsigned int skip); 
-extern unsigned long xencomm_copy_from_guest(void *to, const void *from,
-        unsigned int len, unsigned int skip); 
-extern void *xencomm_add_offset(void *handle, unsigned int bytes);
-extern int xencomm_handle_is_null(void *ptr);
-
-
-/* Is the guest handle a NULL reference? */
-#define guest_handle_is_null(hnd)                          \
-    ((hnd).p == NULL || xencomm_handle_is_null((hnd).p))
-
-/* Offset the given guest handle into the array it refers to. */
-#define guest_handle_add_offset(hnd, nr) ({                   \
-    const typeof((hnd).p) _ptr = (hnd).p;                     \
-    (hnd).p = xencomm_add_offset(_ptr, nr * sizeof(*_ptr));   \
-})
-
-/* Cast a guest handle to the specified type of handle. */
-#define guest_handle_cast(hnd, type) ({   \
-    type *_x = (hnd).p;                   \
-    XEN_GUEST_HANDLE(type) _y;            \
-    set_xen_guest_handle(_y, _x);         \
-    _y;                                   \
-})
-
-
-/* Since we run in real mode, we can safely access all addresses. That also
- * means our __routines are identical to our "normal" routines. */
-#define guest_handle_okay(hnd, nr) 1
-
-/*
- * Copy an array of objects to guest context via a guest handle.
- * Optionally specify an offset into the guest array.
- */
-#define copy_to_guest_offset(hnd, idx, ptr, nr) \
-    __copy_to_guest_offset(hnd, idx, ptr, nr)
-
-/* Copy sub-field of a structure to guest context via a guest handle. */
-#define copy_field_to_guest(hnd, ptr, field) \
-    __copy_field_to_guest(hnd, ptr, field)
-
-/*
- * Copy an array of objects from guest context via a guest handle.
- * Optionally specify an offset into the guest array.
- */
-#define copy_from_guest_offset(ptr, hnd, idx, nr) \
-    __copy_from_guest_offset(ptr, hnd, idx, nr)
-
-/* Copy sub-field of a structure from guest context via a guest handle. */
-#define copy_field_from_guest(ptr, hnd, field) \
-    __copy_field_from_guest(ptr, hnd, field)
-
-#define __copy_to_guest_offset(hnd, idx, ptr, nr) ({                    \
-    const typeof(*(ptr)) *_s = (ptr);                                   \
-    void *_d = (hnd).p;                                                 \
-    ((void)((hnd).p == (ptr)));                                         \
-    xencomm_copy_to_guest(_d, _s, sizeof(*_s)*(nr), sizeof(*_s)*(idx)); \
-})
-
-#define __copy_field_to_guest(hnd, ptr, field) ({                   \
-    unsigned int _off = offsetof(typeof(*(hnd).p), field);          \
-    const typeof(&(ptr)->field) _s = &(ptr)->field;                 \
-    void *_d = (hnd).p;                                             \
-    ((void)(&(hnd).p->field == &(ptr)->field));                     \
-    xencomm_copy_to_guest(_d, _s, sizeof(*_s), _off);               \
-})
-
-#define __copy_from_guest_offset(ptr, hnd, idx, nr) ({                    \
-    const typeof(*(ptr)) *_s = (hnd).p;                                   \
-    typeof(*(ptr)) *_d = (ptr);                                           \
-    xencomm_copy_from_guest(_d, _s, sizeof(*_d)*(nr), sizeof(*_d)*(idx)); \
-})
-
-#define __copy_field_from_guest(ptr, hnd, field) ({                 \
-    unsigned int _off = offsetof(typeof(*(hnd).p), field);          \
-    const void *_s = (hnd).p;                                       \
-    typeof(&(ptr)->field) _d = &(ptr)->field;                       \
-    ((void)(&(hnd).p->field == &(ptr)->field));                     \
-    xencomm_copy_from_guest(_d, _s, sizeof(*_d), _off);             \
-})
-
-/* Internal use only: returns 0 in case of bad address.  */
-extern unsigned long xencomm_paddr_to_maddr(unsigned long paddr);
+#include <xen/types.h> /* arch-ia64.h which is included by xen.h 
+                          requires uint64_t */
+#include <public/xen.h>        /* for XENCOMM_INLINE_FLAG */
+#include <xen/xencomm.h>
 
 #endif /* __ASM_GUEST_ACCESS_H__ */
diff -r b53a87fec6dc -r abd1440b700a xen/include/asm-ia64/mm.h
--- a/xen/include/asm-ia64/mm.h Tue Aug 14 16:52:49 2007 +0900
+++ b/xen/include/asm-ia64/mm.h Mon Aug 13 12:23:36 2007 +0900
@@ -499,6 +499,9 @@ extern u64 translate_domain_pte(u64 ptev
     ((get_gpfn_from_mfn((madr) >> PAGE_SHIFT) << PAGE_SHIFT) | \
     ((madr) & ~PAGE_MASK))
 
+/* Internal use only: returns 0 in case of bad address.  */
+extern unsigned long paddr_to_maddr(unsigned long paddr);
+
 /* Arch-specific portion of memory_op hypercall. */
 long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg);
 
diff -r b53a87fec6dc -r abd1440b700a xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h    Tue Aug 14 16:52:49 2007 +0900
+++ b/xen/include/public/arch-ia64.h    Mon Aug 13 12:23:36 2007 +0900
@@ -553,11 +553,6 @@ struct xen_ia64_boot_param {
 #define XENCOMM_INLINE_MASK 0xf800000000000000UL
 #define XENCOMM_INLINE_FLAG 0x8000000000000000UL
 
-#define XENCOMM_IS_INLINE(addr) \
-  (((unsigned long)(addr) & XENCOMM_INLINE_MASK) == XENCOMM_INLINE_FLAG)
-#define XENCOMM_INLINE_ADDR(addr) \
-  ((unsigned long)(addr) & ~XENCOMM_INLINE_MASK)
-
 #ifndef __ASSEMBLY__
 
 /*

Attachment: 15729_abd1440b700a_use_common_xencomm_c_and_remove_ia64_xencomm_c.patch
Description: Text Data

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-ia64-devel] [PATCH 1/3] xencomm consolidation: xen side, Isaku Yamahata <=