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

[XenPPC] [xenppc-unstable] [POWERPC][XEN] Use INVALID_MFN and fail prope

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: [XenPPC] [xenppc-unstable] [POWERPC][XEN] Use INVALID_MFN and fail properly rather than panic
From: Xen patchbot-xenppc-unstable <patchbot-xenppc-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 31 Aug 2006 12:40:36 +0000
Delivery-date: Thu, 31 Aug 2006 06:10:38 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
# Node ID 2bf7c6cb46e32eed10ffbe573381aa23400f84ea
# Parent  e12aa1195f5842a9bb1cc141e6f515f5bd446352
[POWERPC][XEN] Use INVALID_MFN and fail properly rather than panic

Better pfn2mfn() failure reporting, adn push it all the way up.

Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
---
 xen/arch/powerpc/iommu.c               |    2 -
 xen/arch/powerpc/mm.c                  |    7 +++--
 xen/arch/powerpc/papr/xlate.c          |    4 ++
 xen/arch/powerpc/usercopy.c            |   46 ++++++++++++++++++++++++++-------
 xen/include/asm-powerpc/guest_access.h |    2 -
 xen/include/asm-powerpc/mm.h           |    2 +
 6 files changed, 50 insertions(+), 13 deletions(-)

diff -r e12aa1195f58 -r 2bf7c6cb46e3 xen/arch/powerpc/iommu.c
--- a/xen/arch/powerpc/iommu.c  Wed Aug 30 18:35:20 2006 -0400
+++ b/xen/arch/powerpc/iommu.c  Thu Aug 31 08:32:55 2006 -0400
@@ -52,7 +52,7 @@ int iommu_put(u32 buid, ulong ioba, unio
 
         pfn = tce.tce_bits.tce_rpn;
         mfn = pfn2mfn(d, pfn, &mtype);
-        if (mfn > 0) {
+        if (mfn != INVALID_MFN) {
 #ifdef DEBUG
             printk("%s: ioba=0x%lx pfn=0x%lx mfn=0x%lx\n", __func__,
                    ioba, pfn, mfn);
diff -r e12aa1195f58 -r 2bf7c6cb46e3 xen/arch/powerpc/mm.c
--- a/xen/arch/powerpc/mm.c     Wed Aug 30 18:35:20 2006 -0400
+++ b/xen/arch/powerpc/mm.c     Thu Aug 31 08:32:55 2006 -0400
@@ -345,6 +345,10 @@ ulong pfn2mfn(struct domain *d, long pfn
     ulong rma_size_mfn = 1UL << d->arch.rma_order;
     struct page_extents *pe;
 
+    if (type)
+        *type = PFN_TYPE_NONE;
+
+    /* quick tests first */
     if (pfn < rma_size_mfn) {
         if (type)
             *type = PFN_TYPE_RMA;
@@ -358,7 +362,6 @@ ulong pfn2mfn(struct domain *d, long pfn
         return pfn;
     }
 
-    /* quick tests first */
     list_for_each_entry (pe, &d->arch.extent_list, pe_list) {
         uint end_pfn = pe->pfn + (1 << pe->order);
 
@@ -378,7 +381,7 @@ ulong pfn2mfn(struct domain *d, long pfn
     }
 
     BUG();
-    return 0;
+    return INVALID_MFN;
 }
 
 void guest_physmap_add_page(
diff -r e12aa1195f58 -r 2bf7c6cb46e3 xen/arch/powerpc/papr/xlate.c
--- a/xen/arch/powerpc/papr/xlate.c     Wed Aug 30 18:35:20 2006 -0400
+++ b/xen/arch/powerpc/papr/xlate.c     Thu Aug 31 08:32:55 2006 -0400
@@ -164,6 +164,10 @@ static void h_enter(struct cpu_user_regs
     lpn = pte.bits.rpn & lpn;
 
     rpn = pfn2mfn(d, lpn, &mtype);
+    if (rpn == INVALID_MFN) {
+        regs->gprs[3] =  H_Parameter;
+        return;
+    }
 
     if (mtype == PFN_TYPE_IO) {
         /* only a privilaged dom can access outside IO space */
diff -r e12aa1195f58 -r 2bf7c6cb46e3 xen/arch/powerpc/usercopy.c
--- a/xen/arch/powerpc/usercopy.c       Wed Aug 30 18:35:20 2006 -0400
+++ b/xen/arch/powerpc/usercopy.c       Thu Aug 31 08:32:55 2006 -0400
@@ -47,14 +47,23 @@ static unsigned long paddr_to_maddr(unsi
     pfn = pa >> PAGE_SHIFT;
 
     pa = pfn2mfn(d, pfn, &mtype);
+    if (pa == INVALID_MFN) {
+        printk("%s: Dom:%d bad paddr: 0x%lx\n",
+               __func__, d->domain_id, paddr);
+        return 0;
+    }
     switch (mtype) {
-        case PFN_TYPE_RMA:
-        case PFN_TYPE_LOGICAL:
-            break;
-        default:
-            panic("%s: called with bad memory address type: 0x%lx\n",
-                    __func__, paddr);
-            break;
+    case PFN_TYPE_RMA:
+    case PFN_TYPE_LOGICAL:
+        break;
+    case PFN_TYPE_REMOTE:
+        printk("%s: Dom:%d paddr: 0x%lx type: REMOTE\n",
+               __func__, d->domain_id, paddr);
+        break;
+    default:
+        panic("%s: Dom:%d paddr: 0x%lx bad type:0x%x\n",
+               __func__, d->domain_id, paddr, mtype);
+        break;
     }
     pa <<= PAGE_SHIFT;
     pa |= offset;
@@ -85,6 +94,9 @@ xencomm_copy_from_guest(void *to, const 
 
     /* first we need to access the descriptor */
     desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)from);
+    if (desc == NULL)
+        return n;
+
     if (desc->magic != XENCOMM_MAGIC) {
         printk("%s: error: %p magic was 0x%x\n",
                __func__, desc, desc->magic);
@@ -117,6 +129,9 @@ xencomm_copy_from_guest(void *to, const 
             unsigned int bytes = min(chunksz, n - to_pos);
 
             src_maddr = paddr_to_maddr(src_paddr + chunk_skip);
+            if (src_maddr == 0)
+                return n - to_pos;
+
             if (xencomm_debug)
                 printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest);
             memcpy((void *)dest, (void *)src_maddr, bytes);
@@ -153,6 +168,9 @@ xencomm_copy_to_guest(void *to, const vo
 
     /* first we need to access the descriptor */
     desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)to);
+    if (desc == NULL)
+        return n;
+
     if (desc->magic != XENCOMM_MAGIC) {
         printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
         return n;
@@ -184,6 +202,9 @@ xencomm_copy_to_guest(void *to, const vo
             unsigned int bytes = min(chunksz, n - from_pos);
 
             dest_maddr = paddr_to_maddr(dest_paddr + chunk_skip);
+            if (dest_maddr == 0)
+                return -1;
+
             if (xencomm_debug)
                 printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr);
             memcpy((void *)dest_maddr, (void *)source, bytes);
@@ -199,16 +220,19 @@ xencomm_copy_to_guest(void *to, const vo
 
 /* 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)
+int xencomm_add_offset(void *handle, unsigned int bytes)
 {
     struct xencomm_desc *desc;
     int i = 0;
 
     /* first we need to access the descriptor */
     desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)handle);
+    if (desc == NULL)
+        return -1;
+
     if (desc->magic != XENCOMM_MAGIC) {
         printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
-        return;
+        return -1;
     }
 
     /* iterate through the descriptor incrementing addresses */
@@ -230,6 +254,7 @@ void xencomm_add_offset(void *handle, un
         }
         bytes -= chunk_skip;
     }
+    return 0;
 }
 
 int xencomm_handle_is_null(void *ptr)
@@ -237,6 +262,9 @@ int xencomm_handle_is_null(void *ptr)
     struct xencomm_desc *desc;
 
     desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)ptr);
+    if (desc == NULL)
+        return 1;
 
     return (desc->nr_addrs == 0);
 }
+
diff -r e12aa1195f58 -r 2bf7c6cb46e3 xen/include/asm-powerpc/guest_access.h
--- a/xen/include/asm-powerpc/guest_access.h    Wed Aug 30 18:35:20 2006 -0400
+++ b/xen/include/asm-powerpc/guest_access.h    Thu Aug 31 08:32:55 2006 -0400
@@ -25,7 +25,7 @@ extern unsigned long xencomm_copy_to_gue
         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_add_offset(void *handle, unsigned int bytes);
 extern int xencomm_handle_is_null(void *ptr);
 
 
diff -r e12aa1195f58 -r 2bf7c6cb46e3 xen/include/asm-powerpc/mm.h
--- a/xen/include/asm-powerpc/mm.h      Wed Aug 30 18:35:20 2006 -0400
+++ b/xen/include/asm-powerpc/mm.h      Thu Aug 31 08:32:55 2006 -0400
@@ -234,6 +234,8 @@ extern int update_grant_va_mapping(unsig
                                    struct domain *,
                                    struct vcpu *);
 
+#define INVALID_MFN (~0UL)
+#define PFN_TYPE_NONE 0
 #define PFN_TYPE_RMA 1
 #define PFN_TYPE_LOGICAL 2
 #define PFN_TYPE_IO 3

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

<Prev in Thread] Current Thread [Next in Thread>
  • [XenPPC] [xenppc-unstable] [POWERPC][XEN] Use INVALID_MFN and fail properly rather than panic, Xen patchbot-xenppc-unstable <=