From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xensource.com, keir.fraser@eu.citrix.com,
Ian.Campbell@citrix.com, Ian.Jackson@eu.citrix.com,
Tim.Deegan@citrix.com
Cc: konrad.wilk@oracle.com
Subject: [PATCH 1 of 4] tools: Add xc_domain_set_memory_map and xc_get_machine_memory_map calls (x86, amd64 only)
Date: Mon, 11 Apr 2011 17:35:31 -0400 [thread overview]
Message-ID: <8190b1eb9a8cfe63ee0a.1302557731@localhost6.localdomain6> (raw)
In-Reply-To: <patchbomb.1302557730@localhost6.localdomain6>
# HG changeset patch
# User Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
# Date 1302557409 14400
# Node ID 8190b1eb9a8cfe63ee0aecc35416c4e8300c45f4
# Parent 4e7016852f35b44af6d5f82737ceb47015ef00a6
tools: Add xc_domain_set_memory_map and xc_get_machine_memory_map calls (x86,amd64 only).
The later retrieves the E820 as seen by the hypervisor (completely
unchanged) and the second call sets the E820 for the specified guest.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
diff -r 4e7016852f35 -r 8190b1eb9a8c tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c Mon Apr 11 17:25:15 2011 -0400
+++ b/tools/libxc/xc_domain.c Mon Apr 11 17:30:09 2011 -0400
@@ -478,37 +478,64 @@ int xc_domain_pin_memory_cacheattr(xc_in
}
#if defined(__i386__) || defined(__x86_64__)
-#include "xc_e820.h"
+int xc_domain_set_memory_map(xc_interface *xch,
+ uint32_t domid,
+ struct e820entry entries[],
+ uint32_t nr_entries)
+{
+ int rc;
+ struct xen_foreign_memory_map fmap = {
+ .domid = domid,
+ .map = { .nr_entries = nr_entries }
+ };
+ DECLARE_HYPERCALL_BOUNCE(entries, nr_entries * sizeof(struct e820entry),
+ XC_HYPERCALL_BUFFER_BOUNCE_IN);
+
+ if ( !entries || xc_hypercall_bounce_pre(xch, entries) )
+ return -1;
+
+ set_xen_guest_handle(fmap.map.buffer, entries);
+
+ rc = do_memory_op(xch, XENMEM_set_memory_map, &fmap, sizeof(fmap));
+
+ xc_hypercall_bounce_post(xch, entries);
+
+ return rc;
+}
+int xc_get_machine_memory_map(xc_interface *xch,
+ struct e820entry entries[],
+ uint32_t max_entries)
+{
+ int rc;
+ struct xen_memory_map memmap = {
+ .nr_entries = max_entries
+ };
+ DECLARE_HYPERCALL_BOUNCE(entries, sizeof(struct e820entry) * max_entries,
+ XC_HYPERCALL_BUFFER_BOUNCE_OUT);
+
+ if ( !entries || xc_hypercall_bounce_pre(xch, entries) || max_entries <= 1)
+ return -1;
+
+
+ set_xen_guest_handle(memmap.buffer, entries);
+
+ rc = do_memory_op(xch, XENMEM_machine_memory_map, &memmap, sizeof(memmap));
+
+ xc_hypercall_bounce_post(xch, entries);
+
+ return rc ? rc : memmap.nr_entries;
+}
int xc_domain_set_memmap_limit(xc_interface *xch,
uint32_t domid,
unsigned long map_limitkb)
{
- int rc;
- struct xen_foreign_memory_map fmap = {
- .domid = domid,
- .map = { .nr_entries = 1 }
- };
- DECLARE_HYPERCALL_BUFFER(struct e820entry, e820);
+ struct e820entry e820;
- e820 = xc_hypercall_buffer_alloc(xch, e820, sizeof(*e820));
+ e820.addr = 0;
+ e820.size = (uint64_t)map_limitkb << 10;
+ e820.type = E820_RAM;
- if ( e820 == NULL )
- {
- PERROR("Could not allocate memory for xc_domain_set_memmap_limit hypercall");
- return -1;
- }
-
- e820->addr = 0;
- e820->size = (uint64_t)map_limitkb << 10;
- e820->type = E820_RAM;
-
- set_xen_guest_handle(fmap.map.buffer, e820);
-
- rc = do_memory_op(xch, XENMEM_set_memory_map, &fmap, sizeof(fmap));
-
- xc_hypercall_buffer_free(xch, e820);
-
- return rc;
+ return xc_domain_set_memory_map(xch, domid, &e820, 1);
}
#else
int xc_domain_set_memmap_limit(xc_interface *xch,
diff -r 4e7016852f35 -r 8190b1eb9a8c tools/libxc/xc_e820.h
--- a/tools/libxc/xc_e820.h Mon Apr 11 17:25:15 2011 -0400
+++ b/tools/libxc/xc_e820.h Mon Apr 11 17:30:09 2011 -0400
@@ -26,6 +26,7 @@
#define E820_RESERVED 2
#define E820_ACPI 3
#define E820_NVS 4
+#define E820_UNUSABLE 5
struct e820entry {
uint64_t addr;
diff -r 4e7016852f35 -r 8190b1eb9a8c tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Mon Apr 11 17:25:15 2011 -0400
+++ b/tools/libxc/xenctrl.h Mon Apr 11 17:30:09 2011 -0400
@@ -966,6 +966,17 @@ int xc_domain_set_memmap_limit(xc_interf
uint32_t domid,
unsigned long map_limitkb);
+#if defined(__i386__) || defined(__x86_64__)
+#include "xc_e820.h"
+int xc_domain_set_memory_map(xc_interface *xch,
+ uint32_t domid,
+ struct e820entry entries[],
+ uint32_t nr_entries);
+
+int xc_get_machine_memory_map(xc_interface *xch,
+ struct e820entry entries[],
+ uint32_t max_entries);
+#endif
int xc_domain_set_time_offset(xc_interface *xch,
uint32_t domid,
int32_t time_offset_seconds);
next prev parent reply other threads:[~2011-04-11 21:35 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-11 21:35 [PATCH 0 of 4] Patches for PCI passthrough with modified E820 (v2) Konrad Rzeszutek Wilk
2011-04-11 21:35 ` Konrad Rzeszutek Wilk [this message]
2011-04-11 21:35 ` [PATCH 2 of 4] x86: make the pv-only e820 array be dynamic Konrad Rzeszutek Wilk
2011-04-12 12:32 ` Keir Fraser
2011-04-12 12:53 ` Konrad Rzeszutek Wilk
2011-04-12 13:06 ` Keir Fraser
2011-04-12 17:21 ` Konrad Rzeszutek Wilk
2011-04-13 7:34 ` Jan Beulich
2011-04-13 13:31 ` Konrad Rzeszutek Wilk
2011-04-13 8:46 ` Keir Fraser
2011-04-13 13:32 ` Konrad Rzeszutek Wilk
2011-04-11 21:35 ` [PATCH 3 of 4] libxl: Add support for passing in the machine's E820 for PCI passthrough in libxl_device_pci_parse_bdf Konrad Rzeszutek Wilk
2011-04-12 12:19 ` Ian Campbell
2011-04-12 17:53 ` Konrad Rzeszutek Wilk
2011-04-12 18:44 ` Ian Campbell
2011-04-12 19:00 ` Konrad Rzeszutek Wilk
2011-04-12 19:29 ` Ian Campbell
2011-04-11 21:35 ` [PATCH 4 of 4] libxl: Convert E820_UNUSABLE and E820_RAM to E820_UNUSABLE as appropriate Konrad Rzeszutek Wilk
-- strict thread matches above, loose matches on Subject: below --
2011-04-12 20:31 [PATCH 0 of 4] Patches for PCI passthrough with modified E820 (v3) Konrad Rzeszutek Wilk
2011-04-12 20:31 ` [PATCH 1 of 4] tools: Add xc_domain_set_memory_map and xc_get_machine_memory_map calls (x86, amd64 only) Konrad Rzeszutek Wilk
2011-05-24 13:14 [PATCH 0 of 4] Patches for PCI passthrough with modified E820 (v3.1) Konrad Rzeszutek Wilk
2011-05-24 13:14 ` [PATCH 1 of 4] tools: Add xc_domain_set_memory_map and xc_get_machine_memory_map calls (x86, amd64 only) Konrad Rzeszutek Wilk
2011-05-24 15:24 [PATCH 0 of 4] Patches for PCI passthrough with modified E820 (v4.1) Konrad Rzeszutek Wilk
2011-05-24 15:24 ` [PATCH 1 of 4] tools: Add xc_domain_set_memory_map and xc_get_machine_memory_map calls (x86, amd64 only) Konrad Rzeszutek Wilk
2011-05-26 14:04 [PATCH 0 of 4] Patches for PCI passthrough with modified E820 (v4.2) Konrad Rzeszutek Wilk
2011-05-26 14:04 ` [PATCH 1 of 4] tools: Add xc_domain_set_memory_map and xc_get_machine_memory_map calls (x86, amd64 only) Konrad Rzeszutek Wilk
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=8190b1eb9a8cfe63ee0a.1302557731@localhost6.localdomain6 \
--to=konrad.wilk@oracle.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=Tim.Deegan@citrix.com \
--cc=keir.fraser@eu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).