From: Diego Ongaro <diego.ongaro@citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH RFC 1/5] Grant table for console, xenstore pages
Date: Fri, 11 Jul 2008 20:14:22 +0100 [thread overview]
Message-ID: <4877B10E.5030306@citrix.com> (raw)
In-Reply-To: <4877B09E.5000909@citrix.com>
This patch claims one grant entry for the console and another for the
xenstore. It modifies the builder to fill in the grant table entries for
the console and the xenstore. At this stage, the grant entries just give
access to domain 0 (addressed in a later patch).
Signed-off-by: Diego Ongaro <diego.ongaro@citrix.com>
---
diff -r b61cab9b4213 tools/libxc/xc_dom.h
--- a/tools/libxc/xc_dom.h Fri Jul 11 19:00:25 2008 +0100
+++ b/tools/libxc/xc_dom.h Fri Jul 11 19:00:41 2008 +0100
@@ -179,6 +179,7 @@
xen_pfn_t count);
int xc_dom_boot_image(struct xc_dom_image *dom);
int xc_dom_compat_check(struct xc_dom_image *dom);
+int xc_dom_gnttab_init(struct xc_dom_image *dom);
/* --- debugging bits ---------------------------------------------- */
diff -r b61cab9b4213 tools/libxc/xc_dom_boot.c
--- a/tools/libxc/xc_dom_boot.c Fri Jul 11 19:00:25 2008 +0100
+++ b/tools/libxc/xc_dom_boot.c Fri Jul 11 19:00:41 2008 +0100
@@ -20,6 +20,7 @@
#include "xg_private.h"
#include "xc_dom.h"
#include <xen/hvm/params.h>
+#include <xen/grant_table.h>
/* ------------------------------------------------------------------------ */
@@ -267,6 +268,88 @@
return rc;
}
+static unsigned long xc_dom_gnttab_mfn(struct xc_dom_image *dom)
+{
+ DECLARE_HYPERCALL;
+ gnttab_setup_table_t setup_table;
+ unsigned long mfn = -1; /* TODO: is this the correct type? */
+
+ setup_table.dom = dom->guest_domid;
+ setup_table.nr_frames = 1;
+ set_xen_guest_handle(setup_table.frame_list, &mfn);
+ setup_table.status = 0;
+
+ hypercall.op = __HYPERVISOR_grant_table_op;
+ hypercall.arg[0] = GNTTABOP_setup_table;
+ hypercall.arg[1] = (unsigned long) &setup_table;
+ hypercall.arg[2] = 1;
+
+ if ( do_xen_hypercall(dom->guest_xc, &hypercall) == -1 ||
+ setup_table.status != GNTST_okay )
+ {
+ xc_dom_panic(XC_INTERNAL_ERROR,
+ "%s: failed to setup domU grant table "
+ "[errno=%d, status=%x]\n",
+ __FUNCTION__, errno, setup_table.status);
+ return -1;
+ }
+
+ return mfn;
+}
+
+/* TODO: don't hard-code these */
+#define CONSOLE_DOMID 0
+#define XENSTORE_DOMID 0
+
+int xc_dom_gnttab_init(struct xc_dom_image *dom)
+{
+ unsigned long grant_table_mfn;
+ grant_entry_t *grant_table;
+
+ grant_table_mfn = xc_dom_gnttab_mfn(dom);
+ if ( grant_table_mfn == -1 )
+ return -1;
+
+ grant_table = xc_map_foreign_range(dom->guest_xc,
+ dom->guest_domid,
+ PAGE_SIZE,
+ PROT_READ | PROT_WRITE,
+ grant_table_mfn);
+ if ( grant_table == NULL )
+ {
+ xc_dom_panic(XC_INTERNAL_ERROR,
+ "%s: failed to map domU grant table "
+ "[errno=%d]\n",
+ __FUNCTION__, errno);
+ return -1;
+ }
+
+ if ( dom->guest_domid != CONSOLE_DOMID )
+ {
+ grant_table[GNTTAB_RESERVED_CONSOLE].flags = GTF_permit_access;
+ grant_table[GNTTAB_RESERVED_CONSOLE].domid = CONSOLE_DOMID;
+ grant_table[GNTTAB_RESERVED_CONSOLE].frame = xc_dom_p2m_host(dom, dom->console_pfn);
+ }
+
+ if ( dom->guest_domid != XENSTORE_DOMID )
+ {
+ grant_table[GNTTAB_RESERVED_XENSTORE].flags = GTF_permit_access;
+ grant_table[GNTTAB_RESERVED_XENSTORE].domid = XENSTORE_DOMID;
+ grant_table[GNTTAB_RESERVED_XENSTORE].frame = xc_dom_p2m_host(dom, dom->xenstore_pfn);
+ }
+
+ if ( munmap(grant_table, PAGE_SIZE) == -1 )
+ {
+ xc_dom_panic(XC_INTERNAL_ERROR,
+ "%s: failed to umap domU grant table "
+ "[errno=%d]\n",
+ __FUNCTION__, errno);
+ return -1;
+ }
+
+ return 0;
+}
+
/*
* Local variables:
* mode: C
diff -r b61cab9b4213 tools/libxc/xc_dom_compat_linux.c
--- a/tools/libxc/xc_dom_compat_linux.c Fri Jul 11 19:00:25 2008 +0100
+++ b/tools/libxc/xc_dom_compat_linux.c Fri Jul 11 19:00:41 2008 +0100
@@ -47,6 +47,8 @@
if ( (rc = xc_dom_build_image(dom)) != 0 )
goto out;
if ( (rc = xc_dom_boot_image(dom)) != 0 )
+ goto out;
+ if ( (rc = xc_dom_gnttab_init(dom)) != 0)
goto out;
*console_mfn = xc_dom_p2m_host(dom, dom->console_pfn);
diff -r b61cab9b4213 xen/include/public/grant_table.h
--- a/xen/include/public/grant_table.h Fri Jul 11 19:00:25 2008 +0100
+++ b/xen/include/public/grant_table.h Fri Jul 11 19:00:41 2008 +0100
@@ -101,6 +101,12 @@
uint32_t frame;
};
typedef struct grant_entry grant_entry_t;
+
+/* External tools reserve first few grant table entries. */
+#define GNTTAB_NR_RESERVED_ENTRIES 8
+#define GNTTAB_RESERVED_CONSOLE 0
+#define GNTTAB_RESERVED_XENSTORE 1
+/* (the next 6 are reserved for future use) */
/*
* Type of grant entry.
next prev parent reply other threads:[~2008-07-11 19:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-11 19:12 [PATCH RFC 0/5] Grant table for console, xenstore pages Diego Ongaro
2008-07-11 19:14 ` Diego Ongaro [this message]
2008-07-11 19:15 ` [PATCH RFC 2/5] " Diego Ongaro
2008-07-11 19:16 ` [PATCH RFC 3/5] " Diego Ongaro
2008-07-11 19:17 ` [PATCH RFC 4/5] " Diego Ongaro
2008-07-11 19:17 ` [PATCH RFC 5/5] " Diego Ongaro
2008-07-12 18:34 ` [PATCH RFC 0/5] " Derek Murray
2008-07-12 18:42 ` Samuel Thibault
2008-07-14 14:37 ` Diego Ongaro
2008-07-14 14:55 ` Derek Murray
2008-07-14 15:42 ` Diego Ongaro
2008-07-14 16:50 ` [PATCH RFC 0/5] Grant table for console, xenstorepages Cihula, Joseph
2008-07-14 17:04 ` Diego Ongaro
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=4877B10E.5030306@citrix.com \
--to=diego.ongaro@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 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.