All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Egger <Christoph.Egger@amd.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] libxc: make unlock_page return error
Date: Wed, 18 Aug 2010 16:42:10 +0200	[thread overview]
Message-ID: <201008181642.10467.Christoph.Egger@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 440 bytes --]


Hi!

As a result of debugging 'xend segfaults when starting',
the attached patch makes unlock_pages return an error.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>

-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

[-- Attachment #2: xen_tools_libxc.diff --]
[-- Type: text/x-diff, Size: 2244 bytes --]

diff -r 36bd4630ad99 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c	Wed Aug 18 10:22:48 2010 +0200
+++ b/tools/libxc/xc_private.c	Wed Aug 18 16:39:11 2010 +0200
@@ -175,7 +175,7 @@ void xc_report_progress_step(xc_interfac
 #ifdef __sun__
 
 int lock_pages(void *addr, size_t len) { return 0; }
-void unlock_pages(void *addr, size_t len) { }
+int unlock_pages(void *addr, size_t len) { return 0; }
 
 int hcall_buf_prep(void **addr, size_t len) { return 0; }
 void hcall_buf_release(void **addr, size_t len) { }
@@ -184,20 +184,21 @@ void hcall_buf_release(void **addr, size
 
 int lock_pages(void *addr, size_t len)
 {
-      int e;
+      int e = 0;
       void *laddr = (void *)((unsigned long)addr & PAGE_MASK);
       size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) +
                      PAGE_SIZE - 1) & PAGE_MASK;
-      e = mlock(laddr, llen);
+      if (mlock(laddr, llen) == -1)
+          e = errno;
       return e;
 }
 
-void unlock_pages(void *addr, size_t len)
+int unlock_pages(void *addr, size_t len)
 {
     void *laddr = (void *)((unsigned long)addr & PAGE_MASK);
     size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) +
                    PAGE_SIZE - 1) & PAGE_MASK;
-    safe_munlock(laddr, llen);
+    return safe_munlock(laddr, llen);
 }
 
 static pthread_key_t hcall_buf_pkey;
diff -r 36bd4630ad99 tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h	Wed Aug 18 10:22:48 2010 +0200
+++ b/tools/libxc/xc_private.h	Wed Aug 18 16:39:11 2010 +0200
@@ -86,16 +86,19 @@ void xc_report_progress_step(xc_interfac
 void *xc_memalign(size_t alignment, size_t size);
 
 int lock_pages(void *addr, size_t len);
-void unlock_pages(void *addr, size_t len);
+int unlock_pages(void *addr, size_t len);
 
 int hcall_buf_prep(void **addr, size_t len);
 void hcall_buf_release(void **addr, size_t len);
 
-static inline void safe_munlock(const void *addr, size_t len)
+static inline int safe_munlock(const void *addr, size_t len)
 {
+    int err = 0;
     int saved_errno = errno;
-    (void)munlock(addr, len);
+    if (munlock(addr, len) == -1)
+        err = errno;
     errno = saved_errno;
+    return err;
 }
 
 int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

             reply	other threads:[~2010-08-18 14:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-18 14:42 Christoph Egger [this message]
2010-08-18 16:05 ` [PATCH] libxc: make unlock_page return error Ian Jackson
2010-08-19  8:44   ` Christoph Egger
2010-08-19 14:43     ` Ian Jackson
2010-08-19 14:46 ` Ian Jackson
2010-08-19 14:57   ` Ian Campbell
2010-08-19 15:39     ` Christoph Egger
2010-08-19 16:01       ` Ian Campbell
2010-08-19 16:35         ` Tim Deegan

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=201008181642.10467.Christoph.Egger@amd.com \
    --to=christoph.egger@amd.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.