From: Sheng Yang <sheng@linux.intel.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Jun Nakajima <jun.nakajima@intel.com>,
Eddie Dong <eddie.dong@intel.com>,
linux-kernel@vger.kernel.org,
xen-devel <xen-devel@lists.xensource.com>,
Sheng Yang <sheng@linux.intel.com>
Subject: [RFC][PATCH 10/10] xen/hybrid: Enable grant table and xenbus
Date: Wed, 16 Sep 2009 16:42:31 +0800 [thread overview]
Message-ID: <1253090551-7969-11-git-send-email-sheng@linux.intel.com> (raw)
In-Reply-To: <1253090551-7969-1-git-send-email-sheng@linux.intel.com>
Now vnif and vbd drivers can work.
Notice one memory region(0xfbfe0000ul - 0xfc000000ul) would be reserved in the
bios E820 table. This memory region would be used as grant table.
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
arch/x86/include/asm/xen/hypervisor.h | 3 +
arch/x86/xen/enlighten.c | 1 +
drivers/block/xen-blkfront.c | 3 +
drivers/input/xen-kbdfront.c | 4 ++
drivers/net/xen-netfront.c | 3 +
drivers/video/xen-fbfront.c | 4 ++
drivers/xen/grant-table.c | 67 ++++++++++++++++++++++++++++++++-
drivers/xen/xenbus/xenbus_probe.c | 23 ++++++++++-
8 files changed, 103 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
index 7eee836..267fa43 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -41,6 +41,7 @@ enum xen_domain_type {
XEN_NATIVE, /* running on bare hardware */
XEN_PV_DOMAIN, /* running in a PV domain */
XEN_HVM_DOMAIN, /* running in a Xen hvm domain */
+ XEN_HYBRID_DOMAIN,
};
#ifdef CONFIG_XEN
@@ -55,6 +56,8 @@ extern void xen_start_hybrid(void);
xen_domain_type == XEN_PV_DOMAIN)
#define xen_hvm_domain() (xen_domain() && \
xen_domain_type == XEN_HVM_DOMAIN)
+#define xen_hybrid_domain() (xen_domain() && \
+ xen_domain_type == XEN_HYBRID_DOMAIN)
#define XEN_HYBRID_ENABLED (1u << 0)
#define XEN_HYBRID_TIMER_ENABLED (1u << 1)
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index f515584..6c4f0c1 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1129,6 +1129,7 @@ static int init_hybrid_info(void)
pv_info = xen_info;
pv_info.kernel_rpl = 0;
+ xen_domain_type = XEN_HYBRID_DOMAIN;
return 0;
}
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index a6cbf7b..14188ed 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -1072,6 +1072,9 @@ static int __init xlblk_init(void)
if (!xen_domain())
return -ENODEV;
+ if (xen_hybrid_domain() && !xen_hybrid_evtchn_enabled())
+ return -ENODEV;
+
if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) {
printk(KERN_WARNING "xen_blk: can't get major %d with name %s\n",
XENVBD_MAJOR, DEV_NAME);
diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c
index 928d2ed..a82b6aa 100644
--- a/drivers/input/xen-kbdfront.c
+++ b/drivers/input/xen-kbdfront.c
@@ -338,6 +338,10 @@ static int __init xenkbd_init(void)
if (!xen_domain())
return -ENODEV;
+ /* Xen Hybrid domain don't need vkbd */
+ if (xen_hybrid_domain())
+ return -ENODEV;
+
/* Nothing to do if running in dom0. */
if (xen_initial_domain())
return -ENODEV;
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index f673253..3ad2c45 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1806,6 +1806,9 @@ static int __init netif_init(void)
if (!xen_domain())
return -ENODEV;
+ if (xen_hybrid_domain() && !xen_hybrid_evtchn_enabled())
+ return -ENODEV;
+
if (xen_initial_domain())
return 0;
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 2493f05..b423248 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -683,6 +683,10 @@ static int __init xenfb_init(void)
if (!xen_domain())
return -ENODEV;
+ /* Don't enable vfb in Xen hybrid domain */
+ if (xen_hybrid_domain())
+ return -ENODEV;
+
/* Nothing to do if running in dom0. */
if (xen_initial_domain())
return -ENODEV;
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 7d8f531..3e4ac4a 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -45,6 +45,9 @@
#include <asm/pgtable.h>
#include <asm/sync_bitops.h>
+#include <xen/interface/memory.h>
+#include <linux/io.h>
+#include <asm/e820.h>
/* External tools reserve first few grant table entries. */
#define NR_RESERVED_ENTRIES 8
@@ -440,12 +443,33 @@ static inline unsigned int max_nr_grant_frames(void)
return xen_max;
}
+static unsigned long hybrid_resume_frames;
+
static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
{
struct gnttab_setup_table setup;
unsigned long *frames;
unsigned int nr_gframes = end_idx + 1;
int rc;
+ struct xen_add_to_physmap xatp;
+ unsigned int i = end_idx;
+
+ if (xen_hybrid_domain() && xen_hybrid_evtchn_enabled()) {
+ /*
+ * Loop backwards, so that the first hypercall has the largest
+ * index, ensuring that the table will grow only once.
+ */
+ do {
+ xatp.domid = DOMID_SELF;
+ xatp.idx = i;
+ xatp.space = XENMAPSPACE_grant_table;
+ xatp.gpfn = (hybrid_resume_frames >> PAGE_SHIFT) + i;
+ if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
+ BUG();
+ } while (i-- > start_idx);
+
+ return 0;
+ }
frames = kmalloc(nr_gframes * sizeof(unsigned long), GFP_ATOMIC);
if (!frames)
@@ -472,11 +496,47 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
return 0;
}
+#define GNTTAB_START 0xfbfe0000ul
+#define GNTTAB_SIZE 0x20000ul
+
int gnttab_resume(void)
{
- if (max_nr_grant_frames() < nr_grant_frames)
+ unsigned int max_nr_gframes;
+
+ max_nr_gframes = max_nr_grant_frames();
+ if (max_nr_gframes < nr_grant_frames)
return -ENOSYS;
- return gnttab_map(0, nr_grant_frames - 1);
+
+ if (!(xen_hybrid_domain() && xen_hybrid_evtchn_enabled()))
+ return gnttab_map(0, nr_grant_frames - 1);
+
+ if (!hybrid_resume_frames) {
+ /* Check if e820 reserved the related region */
+ if (!e820_all_mapped(GNTTAB_START,
+ GNTTAB_START + GNTTAB_SIZE, 2)) {
+ printk(KERN_WARNING
+ "Fail to found grant table region in e820!\n");
+ return -ENODEV;
+ }
+ if (PAGE_SIZE * max_nr_gframes > GNTTAB_SIZE) {
+ printk(KERN_WARNING
+ "Grant table size exceed the limit!\n");
+ return -EINVAL;
+ }
+
+ hybrid_resume_frames = GNTTAB_START;
+ shared = ioremap(hybrid_resume_frames,
+ PAGE_SIZE * max_nr_gframes);
+ if (shared == NULL) {
+ printk(KERN_WARNING
+ "Fail to ioremap gnttab share frames\n");
+ return -ENOMEM;
+ }
+ }
+
+ gnttab_map(0, nr_grant_frames - 1);
+
+ return 0;
}
int gnttab_suspend(void)
@@ -512,6 +572,9 @@ static int __devinit gnttab_init(void)
if (!xen_domain())
return -ENODEV;
+ if (xen_hybrid_domain() && !xen_hybrid_evtchn_enabled())
+ return -ENODEV;
+
nr_grant_frames = 1;
boot_max_nr_grant_frames = __max_nr_grant_frames();
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 773d1cf..4b87605 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -53,6 +53,8 @@
#include <xen/events.h>
#include <xen/page.h>
+#include <xen/hvm.h>
+
#include "xenbus_comms.h"
#include "xenbus_probe.h"
@@ -828,6 +830,9 @@ static int __init xenbus_probe_init(void)
if (!xen_domain())
goto out_error;
+ if (xen_hybrid_domain() && !xen_hybrid_evtchn_enabled())
+ goto out_error;
+
/* Register ourselves with the kernel bus subsystem */
err = bus_register(&xenbus_frontend.bus);
if (err)
@@ -844,10 +849,19 @@ static int __init xenbus_probe_init(void)
/* dom0 not yet supported */
} else {
xenstored_ready = 1;
- xen_store_evtchn = xen_start_info->store_evtchn;
- xen_store_mfn = xen_start_info->store_mfn;
+ if (xen_hybrid_domain()) {
+ xen_store_evtchn =
+ hvm_get_parameter(HVM_PARAM_STORE_EVTCHN);
+ xen_store_mfn =
+ hvm_get_parameter(HVM_PARAM_STORE_PFN);
+ xen_store_interface =
+ ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
+ } else {
+ xen_store_evtchn = xen_start_info->store_evtchn;
+ xen_store_mfn = xen_start_info->store_mfn;
+ xen_store_interface = mfn_to_virt(xen_store_mfn);
+ }
}
- xen_store_interface = mfn_to_virt(xen_store_mfn);
/* Initialize the interface to xenstore. */
err = xs_init();
@@ -959,6 +973,9 @@ static void wait_for_devices(struct xenbus_driver *xendrv)
if (!ready_to_wait_for_devices || !xen_domain())
return;
+ if (xen_hybrid_domain() && !xen_hybrid_evtchn_enabled())
+ return;
+
while (exists_disconnected_device(drv)) {
if (time_after(jiffies, timeout))
break;
--
1.5.4.5
next prev parent reply other threads:[~2009-09-16 8:44 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-16 8:42 [RFC][PATCH 0/10] Xen Hybrid extension support Sheng Yang
2009-09-16 8:42 ` [RFC][PATCH 01/10] xen/pvhvm: add support for hvm_op Sheng Yang
2009-09-16 8:42 ` [RFC][PATCH 02/10] xen/hybrid: Import cpuid.h from Xen Sheng Yang
2009-09-16 8:42 ` [RFC][PATCH 03/10] xen/hybrid: Xen Hybrid Extension initialization Sheng Yang
2009-09-16 20:24 ` [Xen-devel] " Jeremy Fitzhardinge
2009-09-17 6:22 ` Keir Fraser
2009-09-17 16:46 ` Jeremy Fitzhardinge
2009-09-16 8:42 ` [RFC][PATCH 04/10] xen/hybrid: Modify pv_init_ops and xen_info Sheng Yang
2009-09-16 8:42 ` [RFC][PATCH 05/10] xen/hybrid: Add PV halt support Sheng Yang
2009-09-16 8:42 ` [RFC][PATCH 06/10] xen/hybrid: Add shared_info page for xen Sheng Yang
2009-09-16 8:42 ` [RFC][PATCH 07/10] xen/hybrid: Add PV timer support Sheng Yang
2009-09-16 20:25 ` [Xen-devel] " Jeremy Fitzhardinge
2009-09-17 5:54 ` Sheng Yang
2009-09-16 8:42 ` [RFC][PATCH 08/10] x86: Don't ack_APIC_irq() if lapic is disabled in GENERIC_INTERRUPT_VECTOR handler Sheng Yang
2009-09-16 8:58 ` Cyrill Gorcunov
2009-09-16 9:03 ` Cyrill Gorcunov
2009-09-16 9:37 ` Cyrill Gorcunov
2009-09-17 3:54 ` Sheng Yang
2009-09-16 8:42 ` [RFC][PATCH 09/10] xen/hybrid: Make event channel work with QEmu emulated devices Sheng Yang
2009-09-16 20:35 ` [Xen-devel] " Jeremy Fitzhardinge
2009-09-17 5:58 ` Sheng Yang
2009-09-16 8:42 ` Sheng Yang [this message]
2009-09-16 13:31 ` [Xen-devel] [RFC][PATCH 0/10] Xen Hybrid extension support Konrad Rzeszutek Wilk
2009-09-17 8:59 ` Sheng Yang
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=1253090551-7969-11-git-send-email-sheng@linux.intel.com \
--to=sheng@linux.intel.com \
--cc=eddie.dong@intel.com \
--cc=jeremy.fitzhardinge@citrix.com \
--cc=jun.nakajima@intel.com \
--cc=keir.fraser@eu.citrix.com \
--cc=linux-kernel@vger.kernel.org \
--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.