All of lore.kernel.org
 help / color / mirror / Atom feed
From: Diego Ongaro <diego.ongaro@citrix.com>
To: xen-devel@lists.xensource.com
Subject: Re: [RFC] grant table map (gntdev) for minios
Date: Thu, 24 Jul 2008 15:42:49 +0100	[thread overview]
Message-ID: <488894E9.8030304@citrix.com> (raw)
In-Reply-To: <48876B00.9050903@citrix.com>

Diego Ongaro wrote:
> I've implemented a grant map for mini-os to support the xc_gnttab_*()
> functions, the equivalent of gntdev in linux.

Bug fixes:
 * Uninitialized dev_bus_addr argument to GNTTABOP_unmap_grant_ref
   results in an angry hypervisor.
 * Set errno in libxc and return -1 on error.
 * op.status is a int16_t, so it should be printed with PRId16.
 * Don't print domids[0] or refs[0] if the ptr is NULL. It's more polite
   to crash later, after the message has been printed.

Signed-off-by: Diego Ongaro <diego.ongaro@citrix.com>
---
diff --git a/extras/mini-os/gntmap.c b/extras/mini-os/gntmap.c
--- a/extras/mini-os/gntmap.c
+++ b/extras/mini-os/gntmap.c
@@ -118,7 +118,7 @@ _gntmap_map_grant_ref(struct gntmap_entr
     rc = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
     if (rc != 0 || op.status != GNTST_okay) {
         printk("GNTTABOP_map_grant_ref failed: "
-               "returned %d, status %d\n",
+               "returned %d, status %" PRId16 "\n",
                rc, op.status);
         return rc != 0 ? rc : op.status;
     }
@@ -135,12 +135,13 @@ _gntmap_unmap_grant_ref(struct gntmap_en
     int rc;
 
     op.host_addr    = (uint64_t) entry->host_addr;
+    op.dev_bus_addr = 0;
     op.handle       = entry->handle;
 
     rc = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
     if (rc != 0 || op.status != GNTST_okay) {
         printk("GNTTABOP_unmap_grant_ref failed: "
-               "returned %d, status %d\n",
+               "returned %d, status %" PRId16 "\n",
                rc, op.status);
         return rc != 0 ? rc : op.status;
     }
@@ -191,8 +192,9 @@ gntmap_map_grant_refs(struct gntmap *map
     printk("gntmap_map_grant_refs(map=%p, count=%" PRIu32 ", "
            "domids=%p [%" PRIu32 "...], domids_stride=%d, "
            "refs=%p [%" PRIu32 "...], writable=%d)\n",
-           map, count, domids, domids[0], domids_stride,
-           refs, refs[0], writable);
+           map, count,
+           domids, domids == NULL ? 0 : domids[0], domids_stride,
+           refs, refs == NULL ? 0 : refs[0], writable);
 #endif
 
     (void) gntmap_set_max_grants(map, DEFAULT_MAX_GRANTS);
diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c
--- a/tools/libxc/xc_minios.c
+++ b/tools/libxc/xc_minios.c
@@ -383,16 +383,28 @@ int xc_gnttab_munmap(int xcg_handle,
                      void *start_address,
                      uint32_t count)
 {
-    return gntmap_munmap(&files[xcg_handle].gntmap,
-                         (unsigned long) start_address,
-                         count);
+    int ret;
+    ret = gntmap_munmap(&files[xcg_handle].gntmap,
+                        (unsigned long) start_address,
+                        count);
+    if (ret < 0) {
+        errno = -ret;
+        return -1;
+    }
+    return ret;
 }
 
 int xc_gnttab_set_max_grants(int xcg_handle,
                              uint32_t count)
 {
-    return gntmap_set_max_grants(&files[xcg_handle].gntmap,
-                                 count);
+    int ret;
+    ret = gntmap_set_max_grants(&files[xcg_handle].gntmap,
+                                count);
+    if (ret < 0) {
+        errno = -ret;
+        return -1;
+    }
+    return ret;
 }
 
 /*

      parent reply	other threads:[~2008-07-24 14:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-23 17:31 [RFC] grant table map (gntdev) for minios Diego Ongaro
2008-07-23 18:11 ` Diego Ongaro
2008-07-24 14:42 ` Diego Ongaro [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=488894E9.8030304@citrix.com \
    --to=diego.ongaro@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.