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][TOOLS] libxc: mmap fixes for BSD
Date: Tue, 10 Jun 2008 16:09:21 +0200	[thread overview]
Message-ID: <200806101609.21552.Christoph.Egger@amd.com> (raw)

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


Hi!

On BSD, mmap()ing files works on on-disk files but not on
pseudo filesystems like kernfs or procfs.
Therefore, attached patch mmap()s anonymous memory.

Linux equivalents are sysfs and procfs to above BSD's pseudo-filesystems.
On Linux, mmap is implemented for sysfs but it is questionable to me
how write operations work since (most) files in sysfs have
static content. So this patch may fix some problems
with a Linux Dom0, too.

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


-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

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

diff -r 57b8c74c35ef tools/libxc/xc_dom_boot.c
--- a/tools/libxc/xc_dom_boot.c	Tue Jun 10 14:17:20 2008 +0100
+++ b/tools/libxc/xc_dom_boot.c	Tue Jun 10 15:47:37 2008 +0200
@@ -166,7 +166,7 @@ void *xc_dom_boot_domU_map(struct xc_dom
     }
 
     ptr = mmap(NULL, count << page_shift, PROT_READ | PROT_WRITE,
-               MAP_SHARED, dom->guest_xc, 0);
+               MAP_ANON | MAP_SHARED, -1, 0);
     if ( ptr == MAP_FAILED )
     {
         err = errno;
diff -r 57b8c74c35ef tools/libxc/xc_domain_save.c
--- a/tools/libxc/xc_domain_save.c	Tue Jun 10 14:17:20 2008 +0100
+++ b/tools/libxc/xc_domain_save.c	Tue Jun 10 15:47:37 2008 +0200
@@ -589,7 +589,7 @@ static xen_pfn_t *xc_map_m2p(int xc_hand
     }
 
     if ( (m2p = mmap(NULL, m2p_size, prot,
-                     MAP_SHARED, xc_handle, 0)) == MAP_FAILED )
+                     MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED )
     {
         ERROR("failed to mmap m2p");
         return NULL;
diff -r 57b8c74c35ef tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c	Tue Jun 10 14:17:20 2008 +0100
+++ b/tools/libxc/xc_hvm_build.c	Tue Jun 10 15:47:37 2008 +0200
@@ -123,7 +123,7 @@ static int loadelfimage(
     if ( entries == NULL )
         goto err;
     elf->dest = mmap(NULL, pages << PAGE_SHIFT, PROT_READ | PROT_WRITE,
-                     MAP_SHARED, xch, 0);
+                     MAP_ANON | MAP_SHARED, -1, 0);
     if ( elf->dest == MAP_FAILED )
         goto err;
 

[-- 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:[~2008-06-10 14:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10 14:09 Christoph Egger [this message]
2008-06-10 14:21 ` [PATCH][TOOLS] libxc: mmap fixes for BSD Keir Fraser
2008-06-10 14:37   ` Christoph Egger
2008-07-23 15:11   ` Christoph Egger

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=200806101609.21552.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.