All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glauber de Oliveira Costa <gcosta@redhat.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH/RFC] Implement the memory_map hypercall
Date: Fri, 24 Nov 2006 12:08:10 -0200	[thread overview]
Message-ID: <20061124140810.GC7171@redhat.com> (raw)

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

Keir,

Here's a first draft on an implementation on the memory_map 
hypercall. I would like to have comments on this, specially at:

1) I set a new field in the domain structure, and use it whenever it's
set to determine the maximum map. In case it's not, using max_mem will
most probably give us a better bound than tot_pages, as it may allow us
to balloon up later even when using tools that does not call the new
domctl (yet to come) that sets the map limit.

2) However, as it currently breaks dom0, I'm leaving it unimplemented in
this case, and plan to do better than that when you apply the changes
you said you would in dom0 max_mem representation.

I'm currently working on the domctl side of things, but I'd like to have
this sorted out first.

Thank you!

-- 
Glauber de Oliveira Costa
Red Hat Inc.
"Free as in Freedom"

[-- Attachment #2: xen-memory_map.patch --]
[-- Type: text/plain, Size: 1893 bytes --]

# HG changeset patch
# User gcosta@redhat.com
# Date 1164380458 18000
# Node ID da7aa8896ab07932160406c8b19a6ad4a61b3af7
# Parent  47fcd5f768fef50cba2fc6dbadc7b75de55e88a5
[XEN] Implement the memory_map hypercall

It's needed to provide guests with an idea of a physical
mapping that may differ from simply what's needed to fit
tot_pages.

Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>

diff -r 47fcd5f768fe -r da7aa8896ab0 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c	Fri Nov 17 08:30:43 2006 -0500
+++ b/xen/arch/x86/mm.c	Fri Nov 24 10:00:58 2006 -0500
@@ -2976,7 +2976,45 @@ long arch_memory_op(int op, XEN_GUEST_HA
 
     case XENMEM_memory_map:
     {
-        return -ENOSYS;
+        struct xen_memory_map memmap;
+        struct domain *d;
+        XEN_GUEST_HANDLE(e820entry_t) buffer;
+        struct e820entry map;
+    
+        if ( IS_PRIV(current->domain) )
+            return -ENOSYS;
+
+        d = current->domain;
+
+        if ( copy_from_guest(&memmap, arg, 1) )
+            return -EFAULT;
+
+        buffer = guest_handle_cast(memmap.buffer, e820entry_t);
+        if ( unlikely(guest_handle_is_null(buffer)) ) 
+            return -EFAULT;
+
+        memmap.nr_entries = 1;
+
+        /* if we were not supplied with proper information, the best we can 
+         * do is rely on the current max_pages information as a sane bound */ 
+        if (d->memory_map_limit)
+            map.size = d->memory_map_limit;
+        else
+            map.size = d->max_pages << PAGE_SHIFT;
+
+        /* 8MB slack (to balance backend allocations). */
+        map.size += 8 << 20;
+        map.addr = 0ULL;
+        map.type = E820_RAM;
+
+        if ( copy_to_guest(arg, &memmap, 1) )
+            return -EFAULT;
+
+        if ( copy_to_guest(buffer, &map, 1) < 0 )
+            return -EFAULT;
+
+        return 0;
+
     }
 
     case XENMEM_machine_memory_map:

[-- 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:[~2006-11-24 14:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-24 14:08 Glauber de Oliveira Costa [this message]
2006-11-24 14:36 ` [PATCH/RFC] Implement the memory_map hypercall Jun Koi
2006-11-24 14:57   ` Glauber de Oliveira Costa

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=20061124140810.GC7171@redhat.com \
    --to=gcosta@redhat.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.