All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Elena Ufimtseva <elena.ufimtseva@oracle.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH RFC v1 12/13] xen: allow 64bit HVM guests to use XENMEM_memory_map
Date: Mon, 22 Jun 2015 18:11:26 +0200	[thread overview]
Message-ID: <1434989487-74940-13-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1434989487-74940-1-git-send-email-roger.pau@citrix.com>

Enable this hypercall for 64bit HVM guests in order to fetch the e820 memory
map in the absence of an emulated BIOS. The memory map is populated and
notified to Xen in arch_setup_meminit_hvm.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Elena Ufimtseva <elena.ufimtseva@oracle.com>
---
I see no reason to not enable it for 32bit HVM guests, but let's leave that
for later.
---
 tools/libxc/xc_dom_x86.c | 29 ++++++++++++++++++++++++++++-
 xen/arch/x86/hvm/hvm.c   |  1 -
 xen/arch/x86/mm.c        |  6 ------
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index 0d9ec42..3a57ded 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -1154,6 +1154,7 @@ static int check_mmio_hole(uint64_t start, uint64_t memsize,
         return 1;
 }
 
+#define MAX_E820_ENTRIES    128
 static int arch_setup_meminit_hvm(struct xc_dom_image *dom)
 {
     unsigned long i, vmemid, nr_pages = dom->total_pages;
@@ -1174,6 +1175,8 @@ static int arch_setup_meminit_hvm(struct xc_dom_image *dom)
     unsigned int nr_vmemranges, nr_vnodes;
     xc_interface *xch = dom->xch;
     uint32_t domid = dom->guest_domid;
+    struct e820entry entries[MAX_E820_ENTRIES];
+    int e820_index = 0;
 
     if ( nr_pages > target_pages )
         memflags |= XENMEMF_populate_on_demand;
@@ -1224,6 +1227,13 @@ static int arch_setup_meminit_hvm(struct xc_dom_image *dom)
         vnode_to_pnode = dom->vnode_to_pnode;
     }
 
+    /* Add one additional memeory range to account for the VGA hole */
+    if ( (nr_vmemranges + (dom->vga_hole ? 1 : 0)) > MAX_E820_ENTRIES )
+    {
+        DOMPRINTF("Too many memory ranges");
+        goto error_out;
+    }
+
     total_pages = 0;
     p2m_size = 0;
     for ( i = 0; i < nr_vmemranges; i++ )
@@ -1313,9 +1323,13 @@ static int arch_setup_meminit_hvm(struct xc_dom_image *dom)
      * Under 2MB mode, we allocate pages in batches of no more than 8MB to 
      * ensure that we can be preempted and hence dom0 remains responsive.
      */
-    if ( dom->vga_hole )
+    if ( dom->vga_hole ) {
         rc = xc_domain_populate_physmap_exact(
             xch, domid, 0xa0, 0, memflags, &dom->p2m_host[0x00]);
+        entries[e820_index].addr = 0;
+        entries[e820_index].size = 0xa0 << PAGE_SHIFT;
+        entries[e820_index++].type = E820_RAM;
+    }
 
     stat_normal_pages = 0;
     for ( vmemid = 0; vmemid < nr_vmemranges; vmemid++ )
@@ -1342,6 +1356,12 @@ static int arch_setup_meminit_hvm(struct xc_dom_image *dom)
         else
             cur_pages = vmemranges[vmemid].start >> PAGE_SHIFT;
 
+                /* Build an e820 map. */
+        entries[e820_index].addr = cur_pages << PAGE_SHIFT;
+        entries[e820_index].size = vmemranges[vmemid].end -
+                                   entries[e820_index].addr;
+        entries[e820_index++].type = E820_RAM;
+
         while ( (rc == 0) && (end_pages > cur_pages) )
         {
             /* Clip count to maximum 1GB extent. */
@@ -1459,6 +1479,13 @@ static int arch_setup_meminit_hvm(struct xc_dom_image *dom)
     DPRINTF("  2MB PAGES: 0x%016lx\n", stat_2mb_pages);
     DPRINTF("  1GB PAGES: 0x%016lx\n", stat_1gb_pages);
 
+    rc = xc_domain_set_memory_map(xch, domid, entries, e820_index);
+    if ( rc != 0 )
+    {
+        DOMPRINTF("unable to set memory map.");
+        goto error_out;
+    }
+
     rc = 0;
     goto out;
  error_out:
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 7694c9e..98109e2 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4749,7 +4749,6 @@ static long hvm_memory_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 
     switch ( cmd & MEMOP_CMD_MASK )
     {
-    case XENMEM_memory_map:
     case XENMEM_machine_memory_map:
     case XENMEM_machphys_mapping:
         return -ENOSYS;
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 9e08c9b..fcb8682 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4717,12 +4717,6 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
             return rc;
         }
 
-        if ( is_hvm_domain(d) )
-        {
-            rcu_unlock_domain(d);
-            return -EPERM;
-        }
-
         e820 = xmalloc_array(e820entry_t, fmap.map.nr_entries);
         if ( e820 == NULL )
         {
-- 
1.9.5 (Apple Git-50.3)


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

  parent reply	other threads:[~2015-06-22 16:15 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-22 16:11 [PATCH RFC v1 00/13] Introduce HMV without dm and new boot ABI Roger Pau Monne
2015-06-22 16:11 ` [PATCH RFC v1 01/13] libxc: split x86 HVM setup_guest into smaller logical functions Roger Pau Monne
2015-06-22 16:11 ` [PATCH RFC v1 02/13] libxc: unify xc_dom_p2m_{host/guest} Roger Pau Monne
2015-06-22 16:11 ` [PATCH RFC v1 03/13] libxc: introduce the notion of a container type Roger Pau Monne
2015-06-22 16:11 ` [PATCH RFC v1 04/13] libxc: allow arch_setup_meminit to populate HVM domain memory Roger Pau Monne
2015-06-25 10:29   ` Wei Liu
2015-06-25 10:33     ` Wei Liu
2015-06-22 16:11 ` [PATCH RFC v1 05/13] libxc: introduce a domain loader for HVM guest firmware Roger Pau Monne
2015-06-23  9:29   ` Jan Beulich
2015-06-23  9:36     ` Roger Pau Monné
2015-07-10 19:09   ` Konrad Rzeszutek Wilk
2015-06-22 16:11 ` [PATCH RFC v1 06/13] libxc: introduce a xc_dom_arch for hvm-3.0-x86_32 guests Roger Pau Monne
2015-06-22 16:11 ` [PATCH RFC v1 07/13] libxl: switch HVM domain building to use xc_dom_* helpers Roger Pau Monne
2015-06-22 16:11 ` [PATCH RFC v1 08/13] libxc: remove dead x86 HVM code Roger Pau Monne
2015-06-22 16:11 ` [PATCH RFC v1 09/13] elfnotes: intorduce a new PHYS_ENTRY elfnote Roger Pau Monne
2015-06-23  9:35   ` Jan Beulich
2015-06-23  9:40     ` Roger Pau Monné
2015-06-23 10:01       ` Jan Beulich
2015-06-22 16:11 ` [PATCH RFC v1 10/13] lib{xc/xl}: allow the creation of HVM domains with a kernel Roger Pau Monne
2015-06-25 10:39   ` Wei Liu
2015-06-22 16:11 ` [PATCH RFC v1 11/13] xen/libxl: allow creating HVM guests without a device model Roger Pau Monne
2015-06-23  9:41   ` Jan Beulich
2015-06-22 16:11 ` Roger Pau Monne [this message]
2015-06-23  9:43   ` [PATCH RFC v1 12/13] xen: allow 64bit HVM guests to use XENMEM_memory_map Jan Beulich
2015-06-22 16:11 ` [PATCH RFC v1 13/13] xenconsole: try to attach to PV console if HVM fails Roger Pau Monne
2015-06-22 17:55 ` [PATCH RFC v1 00/13] Introduce HMV without dm and new boot ABI Stefano Stabellini
2015-06-22 18:05   ` Konrad Rzeszutek Wilk
2015-06-23  8:14     ` Roger Pau Monné
2015-06-23 10:55     ` Stefano Stabellini
2015-06-23 12:50       ` Ian Campbell
2015-06-23 13:12         ` Stefano Stabellini
2015-06-24  2:45           ` Boris Ostrovsky
2015-06-24  9:47       ` Roger Pau Monné
2015-06-24 10:05         ` Jan Beulich
2015-06-24 10:14           ` Roger Pau Monné
2015-06-24 11:52             ` Boris Ostrovsky
2015-06-24 12:04               ` Roger Pau Monné
2015-06-24 13:36                 ` Konrad Rzeszutek Wilk
2015-07-03 16:22               ` Tim Deegan
2015-06-24 13:26         ` Stefano Stabellini
2015-06-24 16:30           ` Boris Ostrovsky
2015-06-24 17:54             ` Stefano Stabellini
2015-06-23  7:14   ` Roger Pau Monné

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=1434989487-74940-13-git-send-email-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=elena.ufimtseva@oracle.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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.