2010-12-01 18:26:03

by Stefano Stabellini

[permalink] [raw]
Subject: [PATCH 0/2] Xen PV on HVM multiple PV consoles

Hi all,
this small patch series achieves two goals:

- make PV consoles work for PV on HVM guests;

- implement support for multiple PV consoles for PV and PV on HVM guests.

Stefano Stabellini (2):
hvc_xen: support PV on HVM consoles
hvc_xen: implement multiconsole support

drivers/char/hvc_xen.c | 479 ++++++++++++++++++++++++++++++++----
include/xen/interface/hvm/params.h | 6 +-
2 files changed, 441 insertions(+), 44 deletions(-)

A branch with these patches on 2.6.37-rc4 is available here:

git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git 2.6.37-rc4-pvhvm-pvconsole

Cheers,

Stefano


2010-12-01 18:27:48

by Stefano Stabellini

[permalink] [raw]
Subject: [PATCH 1/2] hvc_xen: support PV on HVM consoles

From: Stefano Stabellini <[email protected]>

Signed-off-by: Stefano Stabellini <[email protected]>
---
drivers/char/hvc_xen.c | 79 +++++++++++++++++++++++++++++------
include/xen/interface/hvm/params.h | 6 ++-
2 files changed, 70 insertions(+), 15 deletions(-)

diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c
index 3740e32..dfcd939 100644
--- a/drivers/char/hvc_xen.c
+++ b/drivers/char/hvc_xen.c
@@ -24,9 +24,12 @@
#include <linux/init.h>
#include <linux/types.h>

+#include <asm/io.h>
#include <asm/xen/hypervisor.h>

#include <xen/xen.h>
+#include <xen/interface/xen.h>
+#include <xen/hvm.h>
#include <xen/page.h>
#include <xen/events.h>
#include <xen/interface/io/console.h>
@@ -42,9 +45,13 @@ static int xencons_irq;
/* ------------------------------------------------------------------ */

static unsigned long console_pfn = ~0ul;
+static unsigned int console_evtchn = ~0;
+static struct xencons_interface *xencons_if = NULL;

static inline struct xencons_interface *xencons_interface(void)
{
+ if (xencons_if != NULL)
+ return xencons_if;
if (console_pfn == ~0ul)
return mfn_to_virt(xen_start_info->console.domU.mfn);
else
@@ -54,7 +61,10 @@ static inline struct xencons_interface *xencons_interface(void)
static inline void notify_daemon(void)
{
/* Use evtchn: this is called early, before irq is set up. */
- notify_remote_via_evtchn(xen_start_info->console.domU.evtchn);
+ if (console_evtchn == ~0ul)
+ notify_remote_via_evtchn(xen_start_info->console.domU.evtchn);
+ else
+ notify_remote_via_evtchn(console_evtchn);
}

static int __write_console(const char *data, int len)
@@ -157,26 +167,63 @@ static struct hv_ops dom0_hvc_ops = {
.notifier_hangup = notifier_hangup_irq,
};

+static int xen_hvm_console_init(void)
+{
+ int r;
+ uint64_t v = 0;
+ unsigned long mfn;
+
+ if (!xen_hvm_domain())
+ return -ENODEV;
+
+ if (xencons_if != NULL)
+ return -EBUSY;
+
+ r = hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN, &v);
+ if (r < 0)
+ return -ENODEV;
+ console_evtchn = v;
+ hvm_get_parameter(HVM_PARAM_CONSOLE_PFN, &v);
+ if (r < 0)
+ return -ENODEV;
+ mfn = v;
+ xencons_if = ioremap(mfn << PAGE_SHIFT, PAGE_SIZE);
+ if (xencons_if == NULL)
+ return -ENODEV;
+
+ return 0;
+}
+
static int __init xen_hvc_init(void)
{
struct hvc_struct *hp;
struct hv_ops *ops;
+ int r;

- if (!xen_pv_domain())
+ if (!xen_domain())
+ return -ENODEV;
+
+ if (xen_pv_domain() && !xen_initial_domain() &&
+ !xen_start_info->console.domU.evtchn)
return -ENODEV;

if (xen_initial_domain()) {
ops = &dom0_hvc_ops;
xencons_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
} else {
- if (!xen_start_info->console.domU.evtchn)
- return -ENODEV;
-
ops = &domU_hvc_ops;
- xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn);
+ if (xen_pv_domain()) {
+ console_pfn = mfn_to_pfn(xen_start_info->console.domU.mfn);
+ console_evtchn = xen_start_info->console.domU.evtchn;
+ } else {
+ r = xen_hvm_console_init();
+ if (r < 0)
+ return r;
+ }
+ xencons_irq = bind_evtchn_to_irq(console_evtchn);
+ if (xencons_irq < 0)
+ xencons_irq = 0; /* NO_IRQ */
}
- if (xencons_irq < 0)
- xencons_irq = 0; /* NO_IRQ */

hp = hvc_alloc(HVC_COOKIE, xencons_irq, ops, 256);
if (IS_ERR(hp))
@@ -184,15 +231,13 @@ static int __init xen_hvc_init(void)

hvc = hp;

- console_pfn = mfn_to_pfn(xen_start_info->console.domU.mfn);
-
return 0;
}

void xen_console_resume(void)
{
if (xencons_irq)
- rebind_evtchn_irq(xen_start_info->console.domU.evtchn, xencons_irq);
+ rebind_evtchn_irq(console_evtchn, xencons_irq);
}

static void __exit xen_hvc_fini(void)
@@ -203,16 +248,22 @@ static void __exit xen_hvc_fini(void)

static int xen_cons_init(void)
{
- struct hv_ops *ops;
+ const struct hv_ops *ops;

- if (!xen_pv_domain())
+ if (!xen_domain())
return 0;

if (xen_initial_domain())
ops = &dom0_hvc_ops;
- else
+ else {
ops = &domU_hvc_ops;

+ if (xen_pv_domain())
+ console_evtchn = xen_start_info->console.domU.evtchn;
+ else
+ xen_hvm_console_init();
+ }
+
hvc_instantiate(HVC_COOKIE, 0, ops);
return 0;
}
diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
index 1888d8c..1b4f923 100644
--- a/include/xen/interface/hvm/params.h
+++ b/include/xen/interface/hvm/params.h
@@ -90,6 +90,10 @@
/* Boolean: Enable aligning all periodic vpts to reduce interrupts */
#define HVM_PARAM_VPT_ALIGN 16

-#define HVM_NR_PARAMS 17
+/* Console debug shared memory ring and event channel */
+#define HVM_PARAM_CONSOLE_PFN 17
+#define HVM_PARAM_CONSOLE_EVTCHN 18
+
+#define HVM_NR_PARAMS 19

#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
--
1.5.6.5

2010-12-01 18:27:51

by Stefano Stabellini

[permalink] [raw]
Subject: [PATCH 2/2] hvc_xen: implement multiconsole support

From: Stefano Stabellini <[email protected]>

This patch implements support for multiple consoles:
consoles other than the first one are setup using the traditional xenbus
and grant-table based mechanism.
We use a list to keep track of the allocated consoles, we don't
expect too many of them anyway.

Signed-off-by: Stefano Stabellini <[email protected]>
---
drivers/char/hvc_xen.c | 460 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 401 insertions(+), 59 deletions(-)

diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c
index dfcd939..b51e6de 100644
--- a/drivers/char/hvc_xen.c
+++ b/drivers/char/hvc_xen.c
@@ -2,6 +2,7 @@
* xen console driver interface to hvc_console.c
*
* (c) 2007 Gerd Hoffmann <[email protected]>
+ * (c) 2010 Stefano Stabellini <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +24,7 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/types.h>
+#include <linux/list.h>

#include <asm/io.h>
#include <asm/xen/hypervisor.h>
@@ -30,47 +32,69 @@
#include <xen/xen.h>
#include <xen/interface/xen.h>
#include <xen/hvm.h>
+#include <xen/grant_table.h>
#include <xen/page.h>
#include <xen/events.h>
#include <xen/interface/io/console.h>
#include <xen/hvc-console.h>
+#include <xen/xenbus.h>

#include "hvc_console.h"

#define HVC_COOKIE 0x58656e /* "Xen" in hex */

-static struct hvc_struct *hvc;
-static int xencons_irq;
+struct xencons_info {
+ struct list_head list;
+ struct xenbus_device *xbdev;
+ struct xencons_interface *intf;
+ unsigned int evtchn;
+ struct hvc_struct *hvc;
+ int irq;
+ int vtermno;
+ grant_ref_t gntref;
+};
+
+static LIST_HEAD(xenconsoles);
+static DEFINE_SPINLOCK(xencons_lock);
+static struct xenbus_driver xencons_driver;

/* ------------------------------------------------------------------ */

-static unsigned long console_pfn = ~0ul;
-static unsigned int console_evtchn = ~0;
-static struct xencons_interface *xencons_if = NULL;
+static struct xencons_info *vtermno_to_xencons(int vtermno)
+{
+ struct xencons_info *entry, *ret = NULL;
+
+ if (list_empty(&xenconsoles))
+ return NULL;
+
+ spin_lock(&xencons_lock);
+ list_for_each_entry(entry, &xenconsoles, list) {
+ if (entry->vtermno == vtermno) {
+ ret = entry;
+ break;
+ }
+ }
+ spin_unlock(&xencons_lock);
+
+ return ret;
+}

-static inline struct xencons_interface *xencons_interface(void)
+static inline int xenbus_devid_to_vtermno(int devid)
{
- if (xencons_if != NULL)
- return xencons_if;
- if (console_pfn == ~0ul)
- return mfn_to_virt(xen_start_info->console.domU.mfn);
- else
- return __va(console_pfn << PAGE_SHIFT);
+ return devid + HVC_COOKIE;
}

-static inline void notify_daemon(void)
+static inline void notify_daemon(struct xencons_info *cons)
{
/* Use evtchn: this is called early, before irq is set up. */
- if (console_evtchn == ~0ul)
- notify_remote_via_evtchn(xen_start_info->console.domU.evtchn);
- else
- notify_remote_via_evtchn(console_evtchn);
+ notify_remote_via_evtchn(cons->evtchn);
}

-static int __write_console(const char *data, int len)
+static int __write_console(struct xencons_info *xencons,
+ const char *data, int len)
{
- struct xencons_interface *intf = xencons_interface();
XENCONS_RING_IDX cons, prod;
+ struct xencons_interface *intf = xencons->intf;
int sent = 0;

cons = intf->out_cons;
@@ -85,13 +109,16 @@ static int __write_console(const char *data, int len)
intf->out_prod = prod;

if (sent)
- notify_daemon();
+ notify_daemon(xencons);
return sent;
}

static int domU_write_console(uint32_t vtermno, const char *data, int len)
{
int ret = len;
+ struct xencons_info *cons = vtermno_to_xencons(vtermno);
+ if (cons == NULL)
+ return -EINVAL;

/*
* Make sure the whole buffer is emitted, polling if
@@ -100,7 +127,7 @@ static int domU_write_console(uint32_t vtermno, const char *data, int len)
* kernel is crippled.
*/
while (len) {
- int sent = __write_console(data, len);
+ int sent = __write_console(cons, data, len);

data += sent;
len -= sent;
@@ -114,9 +141,13 @@ static int domU_write_console(uint32_t vtermno, const char *data, int len)

static int domU_read_console(uint32_t vtermno, char *buf, int len)
{
- struct xencons_interface *intf = xencons_interface();
+ struct xencons_interface *intf;
XENCONS_RING_IDX cons, prod;
int recv = 0;
+ struct xencons_info *xencons = vtermno_to_xencons(vtermno);
+ if (xencons == NULL)
+ return -EINVAL;
+ intf = xencons->intf;

cons = intf->in_cons;
prod = intf->in_prod;
@@ -129,7 +160,7 @@ static int domU_read_console(uint32_t vtermno, char *buf, int len)
mb(); /* read ring before consuming */
intf->in_cons = cons;

- notify_daemon();
+ notify_daemon(xencons);
return recv;
}

@@ -172,33 +203,111 @@ static int xen_hvm_console_init(void)
int r;
uint64_t v = 0;
unsigned long mfn;
+ struct xencons_info *info;

if (!xen_hvm_domain())
return -ENODEV;

- if (xencons_if != NULL)
- return -EBUSY;
+ info = vtermno_to_xencons(HVC_COOKIE);
+ if (!info) {
+ info = kmalloc(sizeof(struct xencons_info), GFP_KERNEL | __GFP_ZERO);
+ if (!info)
+ return -ENOMEM;
+ }
+
+ /* already configured */
+ if (info->intf != NULL)
+ return 0;

r = hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN, &v);
- if (r < 0)
+ if (r < 0) {
+ kfree(info);
return -ENODEV;
- console_evtchn = v;
+ }
+ info->evtchn = v;
+ info->irq = bind_evtchn_to_irq(info->evtchn);
hvm_get_parameter(HVM_PARAM_CONSOLE_PFN, &v);
- if (r < 0)
+ if (r < 0) {
+ kfree(info);
return -ENODEV;
+ }
mfn = v;
- xencons_if = ioremap(mfn << PAGE_SHIFT, PAGE_SIZE);
- if (xencons_if == NULL)
+ info->intf = ioremap(mfn << PAGE_SHIFT, PAGE_SIZE);
+ if (info->intf == NULL) {
+ kfree(info);
+ return -ENODEV;
+ }
+ info->vtermno = HVC_COOKIE;
+
+ spin_lock(&xencons_lock);
+ list_add_tail(&info->list, &xenconsoles);
+ spin_unlock(&xencons_lock);
+
+ return 0;
+}
+
+static int xen_pv_console_init(void)
+{
+ struct xencons_info *info;
+
+ if (!xen_pv_domain())
return -ENODEV;

+ if (!xen_start_info->console.domU.evtchn)
+ return -ENODEV;
+
+ info = vtermno_to_xencons(HVC_COOKIE);
+ if (!info) {
+ info = kmalloc(sizeof(struct xencons_info), GFP_KERNEL | __GFP_ZERO);
+ if (!info)
+ return -ENOMEM;
+ }
+
+ /* already configured */
+ if (info->intf != NULL)
+ return 0;
+
+ info->evtchn = xen_start_info->console.domU.evtchn;
+ info->irq = bind_evtchn_to_irq(info->evtchn);
+ info->intf = mfn_to_virt(xen_start_info->console.domU.mfn);
+ info->vtermno = HVC_COOKIE;
+
+ spin_lock(&xencons_lock);
+ list_add_tail(&info->list, &xenconsoles);
+ spin_unlock(&xencons_lock);
+
+ return 0;
+}
+
+static int xen_initial_domain_console_init(void)
+{
+ struct xencons_info *info;
+
+ if (!xen_initial_domain())
+ return -ENODEV;
+
+ info = vtermno_to_xencons(HVC_COOKIE);
+ if (!info) {
+ info = kmalloc(sizeof(struct xencons_info), GFP_KERNEL | __GFP_ZERO);
+ if (!info)
+ return -ENOMEM;
+ }
+
+ info->irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
+ info->vtermno = HVC_COOKIE;
+
+ spin_lock(&xencons_lock);
+ list_add_tail(&info->list, &xenconsoles);
+ spin_unlock(&xencons_lock);
+
return 0;
}

static int __init xen_hvc_init(void)
{
- struct hvc_struct *hp;
- struct hv_ops *ops;
int r;
+ struct xencons_info *info;
+ const struct hv_ops *ops;

if (!xen_domain())
return -ENODEV;
@@ -207,43 +316,251 @@ static int __init xen_hvc_init(void)
!xen_start_info->console.domU.evtchn)
return -ENODEV;

+
if (xen_initial_domain()) {
ops = &dom0_hvc_ops;
- xencons_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
+ r = xen_initial_domain_console_init();
+ if (r < 0)
+ return r;
} else {
ops = &domU_hvc_ops;
- if (xen_pv_domain()) {
- console_pfn = mfn_to_pfn(xen_start_info->console.domU.mfn);
- console_evtchn = xen_start_info->console.domU.evtchn;
- } else {
+ if (xen_hvm_domain())
r = xen_hvm_console_init();
- if (r < 0)
- return r;
- }
- xencons_irq = bind_evtchn_to_irq(console_evtchn);
- if (xencons_irq < 0)
- xencons_irq = 0; /* NO_IRQ */
+ else
+ r = xen_pv_console_init();
+ if (r < 0)
+ return r;
+
+ }
+
+ info = vtermno_to_xencons(HVC_COOKIE);
+ if (info->irq < 0)
+ info->irq = 0; /* NO_IRQ */
+
+ info->hvc = hvc_alloc(HVC_COOKIE, info->irq, ops, 256);
+ if (IS_ERR(info->hvc)) {
+ r = PTR_ERR(info->hvc);
+ spin_lock(&xencons_lock);
+ list_del(&info->list);
+ spin_unlock(&xencons_lock);
+ if (info->irq)
+ unbind_from_irqhandler(info->irq, NULL);
+ kfree(info);
+ return r;
+ }
+
+ return xenbus_register_frontend(&xencons_driver);
+}
+
+void xen_console_resume(void)
+{
+ struct xencons_info *info = vtermno_to_xencons(HVC_COOKIE);
+ if (info != NULL && info->irq)
+ rebind_evtchn_irq(info->evtchn, info->irq);
+}
+
+static void xencons_disconnect_backend(struct xencons_info *info)
+{
+ if (info->irq > 0)
+ unbind_from_irqhandler(info->irq, NULL);
+ info->irq = 0;
+ if (info->evtchn > 0)
+ xenbus_free_evtchn(info->xbdev, info->evtchn);
+ info->evtchn = 0;
+ if (info->gntref > 0)
+ gnttab_free_grant_references(info->gntref);
+ info->gntref = 0;
+ if (info->hvc != NULL)
+ hvc_remove(info->hvc);
+ info->hvc = NULL;
+}
+
+static void xencons_free(struct xencons_info *info)
+{
+ xencons_disconnect_backend(info);
+ free_page((unsigned long)info->intf);
+ info->intf = NULL;
+ info->vtermno = 0;
+ kfree(info);
+}
+
+static int xencons_remove(struct xenbus_device *dev)
+{
+ struct xencons_info *info = dev_get_drvdata(&dev->dev);
+
+ spin_lock(&xencons_lock);
+ list_del(&info->list);
+ spin_unlock(&xencons_lock);
+ xencons_free(info);
+ return 0;
+}
+
+static int xencons_connect_backend(struct xenbus_device *dev,
+ struct xencons_info *info)
+{
+ int ret, evtchn, devid, ref, irq;
+ struct xenbus_transaction xbt;
+ grant_ref_t gref_head;
+ unsigned long mfn;
+
+ ret = xenbus_alloc_evtchn(dev, &evtchn);
+ if (ret)
+ return ret;
+ info->evtchn = evtchn;
+ irq = bind_evtchn_to_irq(evtchn);
+ if (irq < 0)
+ return irq;
+ info->irq = irq;
+ devid = dev->nodename[strlen(dev->nodename) - 1] - '0';
+ info->hvc = hvc_alloc(xenbus_devid_to_vtermno(devid),
+ irq, &domU_hvc_ops, 256);
+ if (IS_ERR(info->hvc))
+ return PTR_ERR(info->hvc);
+ if (xen_pv_domain())
+ mfn = virt_to_mfn(info->intf);
+ else
+ mfn = __pa(info->intf) >> PAGE_SHIFT;
+ ret = gnttab_alloc_grant_references(1, &gref_head);
+ if (ret < 0)
+ return ret;
+ info->gntref = gref_head;
+ ref = gnttab_claim_grant_reference(&gref_head);
+ if (ref < 0)
+ return ref;
+ gnttab_grant_foreign_access_ref(ref, info->xbdev->otherend_id,
+ mfn, 0);
+
+ again:
+ ret = xenbus_transaction_start(&xbt);
+ if (ret) {
+ xenbus_dev_fatal(dev, ret, "starting transaction");
+ return ret;
+ }
+ ret = xenbus_printf(xbt, dev->nodename, "ring-ref", "%d", ref);
+ if (ret)
+ goto error_xenbus;
+ ret = xenbus_printf(xbt, dev->nodename, "port", "%u",
+ evtchn);
+ if (ret)
+ goto error_xenbus;
+ ret = xenbus_printf(xbt, dev->nodename, "type", "ioemu");
+ if (ret)
+ goto error_xenbus;
+ ret = xenbus_transaction_end(xbt, 0);
+ if (ret) {
+ if (ret == -EAGAIN)
+ goto again;
+ xenbus_dev_fatal(dev, ret, "completing transaction");
+ return ret;
}

- hp = hvc_alloc(HVC_COOKIE, xencons_irq, ops, 256);
- if (IS_ERR(hp))
- return PTR_ERR(hp);
+ xenbus_switch_state(dev, XenbusStateInitialised);
+ return 0;
+
+ error_xenbus:
+ xenbus_transaction_end(xbt, 1);
+ xenbus_dev_fatal(dev, ret, "writing xenstore");
+ return ret;
+}
+
+static int __devinit xencons_probe(struct xenbus_device *dev,
+ const struct xenbus_device_id *id)
+{
+ int ret, devid;
+ struct xencons_info *info;
+
+ devid = dev->nodename[strlen(dev->nodename) - 1] - '0';
+ if (devid == 0)
+ return 0;

- hvc = hp;
+ info = kmalloc(sizeof(struct xencons_info), GFP_KERNEL | __GFP_ZERO);
+ if (!info)
+ goto error_nomem;
+ dev_set_drvdata(&dev->dev, info);
+ info->xbdev = dev;
+ info->vtermno = xenbus_devid_to_vtermno(devid);
+ info->intf = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+ if (!info->intf)
+ goto error_nomem;
+
+ ret = xencons_connect_backend(dev, info);
+ if (ret < 0)
+ goto error;
+ spin_lock(&xencons_lock);
+ list_add_tail(&info->list, &xenconsoles);
+ spin_unlock(&xencons_lock);

return 0;
+
+ error_nomem:
+ ret = -ENOMEM;
+ xenbus_dev_fatal(dev, ret, "allocating device memory");
+ error:
+ xencons_free(info);
+ return ret;
}

-void xen_console_resume(void)
+static int xencons_resume(struct xenbus_device *dev)
{
- if (xencons_irq)
- rebind_evtchn_irq(console_evtchn, xencons_irq);
+ struct xencons_info *info = dev_get_drvdata(&dev->dev);
+
+ xencons_disconnect_backend(info);
+ memset(info->intf, 0, PAGE_SIZE);
+ return xencons_connect_backend(dev, info);
}

+static void xencons_backend_changed(struct xenbus_device *dev,
+ enum xenbus_state backend_state)
+{
+ switch (backend_state) {
+ case XenbusStateReconfiguring:
+ case XenbusStateReconfigured:
+ case XenbusStateInitialising:
+ case XenbusStateInitialised:
+ case XenbusStateUnknown:
+ case XenbusStateClosed:
+ break;
+
+ case XenbusStateInitWait:
+ break;
+
+ case XenbusStateConnected:
+ xenbus_switch_state(dev, XenbusStateConnected);
+ break;
+
+ case XenbusStateClosing:
+ xenbus_frontend_closed(dev);
+ break;
+ }
+}
+
+static const struct xenbus_device_id xencons_ids[] = {
+ { "console" },
+ { "" }
+};
+
+
static void __exit xen_hvc_fini(void)
{
- if (hvc)
- hvc_remove(hvc);
+ struct xencons_info *entry, *next;
+
+ if (list_empty(&xenconsoles))
+ return;
+
+ spin_lock(&xencons_lock);
+ list_for_each_entry_safe(entry, next, &xenconsoles, list) {
+ list_del(&entry->list);
+ if (entry->xbdev)
+ xencons_remove(entry->xbdev);
+ else {
+ if (entry->irq > 0)
+ unbind_from_irqhandler(entry->irq, NULL);
+ if (entry->hvc);
+ hvc_remove(entry->hvc);
+ kfree(entry);
+ }
+ }
+ spin_unlock(&xencons_lock);
}

static int xen_cons_init(void)
@@ -256,18 +573,31 @@ static int xen_cons_init(void)
if (xen_initial_domain())
ops = &dom0_hvc_ops;
else {
+ int r;
ops = &domU_hvc_ops;

- if (xen_pv_domain())
- console_evtchn = xen_start_info->console.domU.evtchn;
+ if (xen_hvm_domain())
+ r = xen_hvm_console_init();
else
- xen_hvm_console_init();
+ r = xen_pv_console_init();
+ if (r < 0)
+ return r;
}

hvc_instantiate(HVC_COOKIE, 0, ops);
return 0;
}

+static struct xenbus_driver xencons_driver = {
+ .name = "xenconsole",
+ .owner = THIS_MODULE,
+ .ids = xencons_ids,
+ .probe = xencons_probe,
+ .remove = xencons_remove,
+ .resume = xencons_resume,
+ .otherend_changed = xencons_backend_changed,
+};
+
module_init(xen_hvc_init);
module_exit(xen_hvc_fini);
console_initcall(xen_cons_init);
@@ -284,23 +614,35 @@ static void xenboot_write_console(struct console *console, const char *string,
if (xen_initial_domain())
return;

- domU_write_console(0, "(early) ", 8);
+ domU_write_console(HVC_COOKIE, "(early) ", 8);
while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
linelen = pos-string+off;
if (off + linelen > len)
break;
- domU_write_console(0, string+off, linelen);
- domU_write_console(0, "\r\n", 2);
+ domU_write_console(HVC_COOKIE, string+off, linelen);
+ domU_write_console(HVC_COOKIE, "\r\n", 2);
off += linelen + 1;
}
if (off < len)
- domU_write_console(0, string+off, len-off);
+ domU_write_console(HVC_COOKIE, string+off, len-off);
+}
+
+static int xenboot_console_init(void)
+{
+ if (xen_hvm_domain())
+ return -ENODEV;
+
+ if (!xen_initial_domain())
+ return xen_pv_console_init();
+
+ return 0;
}

struct console xenboot_console = {
.name = "xenboot",
.write = xenboot_write_console,
.flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
+ .early_setup = xenboot_console_init,
};
#endif /* CONFIG_EARLY_PRINTK */

--
1.5.6.5

2010-12-01 20:57:19

by Vasiliy Tolstov

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On Wed, 2010-12-01 at 18:25 +0000, Stefano Stabellini wrote:
> Hi all,
> this small patch series achieves two goals:
>
> - make PV consoles work for PV on HVM guests;
>
> - implement support for multiple PV consoles for PV and PV on HVM guests.
>
> Stefano Stabellini (2):
> hvc_xen: support PV on HVM consoles
> hvc_xen: implement multiconsole support
>
> drivers/char/hvc_xen.c | 479 ++++++++++++++++++++++++++++++++----
> include/xen/interface/hvm/params.h | 6 +-
> 2 files changed, 441 insertions(+), 44 deletions(-)
>
> A branch with these patches on 2.6.37-rc4 is available here:
>
> git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git 2.6.37-rc4-pvhvm-pvconsole
>
> Cheers,

Does it possible to apply only this 2 patches on stable-2.6.32.x and get
working serial consoles?

2010-12-02 17:21:58

by Stefano Stabellini

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On Wed, 1 Dec 2010, Vasiliy G Tolstov wrote:
> On Wed, 2010-12-01 at 18:25 +0000, Stefano Stabellini wrote:
> > Hi all,
> > this small patch series achieves two goals:
> >
> > - make PV consoles work for PV on HVM guests;
> >
> > - implement support for multiple PV consoles for PV and PV on HVM guests.
> >
> > Stefano Stabellini (2):
> > hvc_xen: support PV on HVM consoles
> > hvc_xen: implement multiconsole support
> >
> > drivers/char/hvc_xen.c | 479 ++++++++++++++++++++++++++++++++----
> > include/xen/interface/hvm/params.h | 6 +-
> > 2 files changed, 441 insertions(+), 44 deletions(-)
> >
> > A branch with these patches on 2.6.37-rc4 is available here:
> >
> > git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git 2.6.37-rc4-pvhvm-pvconsole
> >
> > Cheers,
>
> Does it possible to apply only this 2 patches on stable-2.6.32.x and get
> working serial consoles?
>

I backported the two patches to stable-2.6.32 and created a new branch
that is stable-2.6.32.x + support PV on HVM consoles + implement
multiconsole support:

git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git stable-2.6.32-pvconsole

I still haven't tested it with xend though.

2010-12-03 19:35:28

by Vasiliy Tolstov

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On Thu, 2010-12-02 at 17:21 +0000, Stefano Stabellini wrote:
> On Wed, 1 Dec 2010, Vasiliy G Tolstov wrote:
> > On Wed, 2010-12-01 at 18:25 +0000, Stefano Stabellini wrote:
> > > Hi all,
> > > this small patch series achieves two goals:
> > >
> > > - make PV consoles work for PV on HVM guests;
> > >
> > > - implement support for multiple PV consoles for PV and PV on HVM guests.
> > >
> > > Stefano Stabellini (2):
> > > hvc_xen: support PV on HVM consoles
> > > hvc_xen: implement multiconsole support
> > >
> > > drivers/char/hvc_xen.c | 479 ++++++++++++++++++++++++++++++++----
> > > include/xen/interface/hvm/params.h | 6 +-
> > > 2 files changed, 441 insertions(+), 44 deletions(-)
> > >
> > > A branch with these patches on 2.6.37-rc4 is available here:
> > >
> > > git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git 2.6.37-rc4-pvhvm-pvconsole
> > >
> > > Cheers,
> >
> > Does it possible to apply only this 2 patches on stable-2.6.32.x and get
> > working serial consoles?
> >
>
> I backported the two patches to stable-2.6.32 and created a new branch
> that is stable-2.6.32.x + support PV on HVM consoles + implement
> multiconsole support:
>
> git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git stable-2.6.32-pvconsole
>
> I still haven't tested it with xend though.

Kernel crushed =(. Use config file from 64 bit fully worked
configuration, what does it mean? How can i find reason for this crush?

(XEN) d330:v0: unhandled page fault (ec=0000)
(XEN) Pagetable walk from 0000000000000000:
(XEN) L4[0x000] = 0000000000000000 ffffffffffffffff
(XEN) domain_crash_sync called from entry.S
(XEN) Domain 330 (vcpu#0) crashed on cpu#12:
(XEN) ----[ Xen-4.0.0_21091_06-0.2.1 x86_64 debug=n Not tainted ]----
(XEN) CPU: 12
(XEN) RIP: e033:[<ffffffff810bd17e>]
(XEN) RFLAGS: 0000000000000246 EM: 1 CONTEXT: pv guest
(XEN) rax: 0000000000000000 rbx: 0000000000008000 rcx:
fffffffffffffffb
(XEN) rdx: ffffffff819d7000 rsi: 00000000000080d0 rdi:
ffffffff81536be0
(XEN) rbp: ffffffff81533d78 rsp: ffffffff81533cf0 r8:
0000000000000000
(XEN) r9: 0000000000000020 r10: 0000000000000000 r11:
0000000000000000
(XEN) r12: 0000000000000000 r13: ffffffff815d95e1 r14:
ffffffff815d9500
(XEN) r15: ffffffff8130f049 cr0: 000000008005003b cr4:
00000000000026f0
(XEN) cr3: 0000001018ffe000 cr2: 0000000000000000
(XEN) ds: 0000 es: 0000 fs: 0000 gs: 0000 ss: e02b cs: e033
(XEN) Guest stack trace from rsp=ffffffff81533cf0:
(XEN) fffffffffffffffb 0000000000000000 0000000000000000
ffffffff810bd17e
(XEN) 000000010000e030 0000000000010046 ffffffff81533d38
000000000000e02b
(XEN) ffffffff810bd165 ffffffff81533d78 ffffffff81536be0
0000000000000000
(XEN) 0000000000000000 0000000000000000 ffffffff815d95e1
ffffffff815d9500
(XEN) ffffffff815d95d5 ffffffff81533d98 ffffffff8130f049
ffffffff0000000f
(XEN) ffffffff8156a050 ffffffff81533da8 ffffffff8130f121
ffffffff81533de8
(XEN) ffffffff8104443e ffffffff815d95c8 ffffffff815d95e1
0000000000000000
(XEN) ffffffff815d95e1 ffffffff815d95e1 ffffffff815d95d5
ffffffff81533df8
(XEN) ffffffff81026075 ffffffff81533e18 ffffffff815b5ebb
ffffffff816116c0
(XEN) ffffffff815d95d5 ffffffff81533e48 ffffffff815a6738
000000000000000b
(XEN) ffffffff815d95e5 0000000000000000 00000000fffffffe
ffffffff81533ea8
(XEN) ffffffff810549dc 0000000081533d00 0000000000000000
ffffffff814a9d9f
(XEN) ffffffff815a66db ffffffff81533ea8 ffffffff815d8da0
0000000000000000
(XEN) ffffffff81533f70 ffffffffffffffff 0000000000000000
ffffffff81533eb8
(XEN) ffffffff815a67c7 ffffffff81533ec8 ffffffff815a67fa
ffffffff81533f58
(XEN) ffffffff815aa558 0000000000000000 0000000000000000
ffffffffffffffff
(XEN) 0000000000000000 ffffffff81533f58 ffffffff813d9ee2
ffffffff00000010
(XEN) ffffffff81533f68 ffffffff81533f28 ffffffff8105fa4b
ffffffffffffffff
(XEN) ffffffff815d8da0 0000000000000000 0000000000000000
ffffffffffffffff
(XEN) 0000000000000000 ffffffff81533f98 ffffffff815a68a3
ffffffff81533f98
(XEN) cpupool_rm_domain(dom=330,pool=0) n_dom 304
(XEN) mm.c:2562:d0 Unknown domain '330'
(XEN) mm.c:2562:d0 Unknown domain '330'
(XEN) mm.c:2562:d0 Unknown domain '330'
(XEN) mm.c:2562:d0 Unknown domain '330'



2010-12-06 10:36:32

by Stefano Stabellini

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On Fri, 3 Dec 2010, Vasiliy G Tolstov wrote:
> On Thu, 2010-12-02 at 17:21 +0000, Stefano Stabellini wrote:
> > On Wed, 1 Dec 2010, Vasiliy G Tolstov wrote:
> > > On Wed, 2010-12-01 at 18:25 +0000, Stefano Stabellini wrote:
> > > > Hi all,
> > > > this small patch series achieves two goals:
> > > >
> > > > - make PV consoles work for PV on HVM guests;
> > > >
> > > > - implement support for multiple PV consoles for PV and PV on HVM guests.
> > > >
> > > > Stefano Stabellini (2):
> > > > hvc_xen: support PV on HVM consoles
> > > > hvc_xen: implement multiconsole support
> > > >
> > > > drivers/char/hvc_xen.c | 479 ++++++++++++++++++++++++++++++++----
> > > > include/xen/interface/hvm/params.h | 6 +-
> > > > 2 files changed, 441 insertions(+), 44 deletions(-)
> > > >
> > > > A branch with these patches on 2.6.37-rc4 is available here:
> > > >
> > > > git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git 2.6.37-rc4-pvhvm-pvconsole
> > > >
> > > > Cheers,
> > >
> > > Does it possible to apply only this 2 patches on stable-2.6.32.x and get
> > > working serial consoles?
> > >
> >
> > I backported the two patches to stable-2.6.32 and created a new branch
> > that is stable-2.6.32.x + support PV on HVM consoles + implement
> > multiconsole support:
> >
> > git://xenbits.xen.org/people/sstabellini/linux-pvhvm.git stable-2.6.32-pvconsole
> >
> > I still haven't tested it with xend though.
>
> Kernel crushed =(. Use config file from 64 bit fully worked
> configuration, what does it mean? How can i find reason for this crush?


Could you please add CONFIG_DEBUG_INFO=y to your kernel config, so that
we can see the name of the functions in the stack trace?

2010-12-06 13:03:48

by Vasiliy Tolstov

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On Mon, 2010-12-06 at 10:36 +0000, Stefano Stabellini wrote:

>
> Could you please add CONFIG_DEBUG_INFO=y to your kernel config, so that
> we can see the name of the functions in the stack trace?
>

After add debug kernel not crushed. I'm test more expensive it now. Can
You provide ps auxwww | grep qemu-dm after creating domain with two
serial consoles? (sles does not have libxl, i want to write now wrapper
to qemu-dm, after that try to compile rpm from spec to support libxl).



--
Vasiliy G Tolstov <[email protected]>
Selfip.Ru

2010-12-07 10:31:12

by Stefano Stabellini

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On Mon, 6 Dec 2010, Vasiliy G Tolstov wrote:
> On Mon, 2010-12-06 at 10:36 +0000, Stefano Stabellini wrote:
>
> >
> > Could you please add CONFIG_DEBUG_INFO=y to your kernel config, so that
> > we can see the name of the functions in the stack trace?
> >
>
> After add debug kernel not crushed. I'm test more expensive it now. Can
> You provide ps auxwww | grep qemu-dm after creating domain with two
> serial consoles? (sles does not have libxl, i want to write now wrapper
> to qemu-dm, after that try to compile rpm from spec to support libxl).
>

There is no need for any special command line arguments to qemu-dm, it
is going to create as many PV serials as configured on xenstored by
libxl, give a look at tools/libxl/libxl.c:libxl_device_console_add.
The output of the serial is the one specified on the node "output" on
xenstore.

2010-12-09 11:00:21

by Vasiliy Tolstov

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On Tue, 2010-12-07 at 10:30 +0000, Stefano Stabellini wrote:
> On Mon, 6 Dec 2010, Vasiliy G Tolstov wrote:
> > On Mon, 2010-12-06 at 10:36 +0000, Stefano Stabellini wrote:
> >
> > >
> > > Could you please add CONFIG_DEBUG_INFO=y to your kernel config, so that
> > > we can see the name of the functions in the stack trace?
> > >
> >
> > After add debug kernel not crushed. I'm test more expensive it now. Can
> > You provide ps auxwww | grep qemu-dm after creating domain with two
> > serial consoles? (sles does not have libxl, i want to write now wrapper
> > to qemu-dm, after that try to compile rpm from spec to support libxl).
> >
>
> There is no need for any special command line arguments to qemu-dm, it
> is going to create as many PV serials as configured on xenstored by
> libxl, give a look at tools/libxl/libxl.c:libxl_device_console_add.
> The output of the serial is the one specified on the node "output" on
> xenstore.

I reproduce kernel crush:

With attached config file kernel from jeremy stable-2.6.32.x boot ok and
noisy debug info
If i compile with this config from You branch stable-2.6.32-pvconsole
kernel crushed. Nothing displays. Only xm dmesg says:

(XEN) d47:v0: unhandled page fault (ec=0000)
(XEN) Pagetable walk from 0000000000000010:
(XEN) L4[0x000] = 000000083870a027 00000000000013f9
(XEN) L3[0x000] = 0000000000000000 ffffffffffffffff
(XEN) domain_crash_sync called from entry.S
(XEN) Domain 47 (vcpu#0) crashed on cpu#15:
(XEN) ----[ Xen-4.0.0_21091_06-0.2.1 x86_64 debug=n Not tainted ]----
(XEN) CPU: 15
(XEN) RIP: e019:[<00000000c10aaa3f>]
(XEN) RFLAGS: 0000000000000246 EM: 1 CONTEXT: pv guest
(XEN) rax: 0000000000000000 rbx: 00000000c146f5a0 rcx:
00000000c1445298
(XEN) rdx: 0000000000000000 rsi: 0000000000008000 rdi:
0000000000000000
(XEN) rbp: 00000000c13f7e60 rsp: 00000000c13f7e34 r8:
0000000000000000
(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
0000000000000000
(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
0000000000000000
(XEN) r15: 0000000000000000 cr0: 000000008005003b cr4:
00000000000026f0
(XEN) cr3: 000000083fe24000 cr2: 0000000000000010
(XEN) ds: e021 es: e021 fs: 00d8 gs: 0000 ss: e021 cs: e019
(XEN) Guest stack trace from esp=c13f7e34:
(XEN) 00000000 c10aaa3f 0001e019 00010046 c10392d6 c1445298 c11d0e17
00000004
(XEN) c146f5a0 00000000 c14b0cd9 c13f7e70 c11d0e17 c146f5a0 00000000
c13f7e78
(XEN) c11d0ed4 c13f7e98 c103936f c14b0cc8 004b0cc0 00000000 c14b0cd9
00000000
(XEN) c14b0cd9 c13f7ea8 c1495868 c14d215c c14b0ccd c13f7ebc c148541b
c14b0ccd
(XEN) fffffffe 00000000 c13f7ef8 c1048703 c13f7ef8 00000000 c137df19
00000000
(XEN) 0000000f 00000000 00000000 00000000 c14b0cd9 c14b0cdd 00000000
c1480f40
(XEN) c1481900 c13f7f08 c14851fd 00000000 c14853d2 c13f7f10 c14853c6
c13f7f94
(XEN) c148a282 c13f7f20 c13f7fa4 00000000 c104e01e 00000005 00000000
00000000
(XEN) 00000000 00000000 00000098 205b7f4c 30202020 3030302e 5d303030
c1050020
(XEN) c13f7f78 c1bb60d0 c13f7f68 00000024 00000000 c1bb60c0 c1bb5884
c1394221
(XEN) 00000000 c13f7fdc 00000000 c13f7f94 c10392f6 00000000 c13f7fdc
00000000
(XEN) c13f7fac c148562f c137e0bc c12b2020 c14b2c60 00000000 c13f7fb8
c14850a2
(XEN) c21f8000 c13f7ffc c1487d4a 00000000 00000000 00000000 00000000
00000000
(XEN) 00000000 00000000 1f898975 80980201 10100800 000106a5 00000000
00000000
(XEN) c21f8000 00000000 00000000
(XEN) cpupool_rm_domain(dom=47,pool=0) n_dom 1
(XEN) mm.c:2562:d0 Unknown domain '47'
(XEN) mm.c:2562:d0 Unknown domain '47'
(XEN) mm.c:2562:d0 Unknown domain '47'
(XEN) mm.c:2562:d0 Unknown domain '47'



--
Vasiliy G Tolstov <[email protected]>
Selfip.Ru

2010-12-09 12:16:06

by Vasiliy Tolstov

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On Thu, 2010-12-09 at 14:12 +0200, Pasi Kärkkäinen wrote:
> On Thu, Dec 09, 2010 at 02:00:12PM +0300, Vasiliy G Tolstov wrote:
> > On Tue, 2010-12-07 at 10:30 +0000, Stefano Stabellini wrote:
> > > On Mon, 6 Dec 2010, Vasiliy G Tolstov wrote:
> > > > On Mon, 2010-12-06 at 10:36 +0000, Stefano Stabellini wrote:
> > > >
> > > > >
> > > > > Could you please add CONFIG_DEBUG_INFO=y to your kernel config, so that
> > > > > we can see the name of the functions in the stack trace?
> > > > >
> > > >
> > > > After add debug kernel not crushed. I'm test more expensive it now. Can
> > > > You provide ps auxwww | grep qemu-dm after creating domain with two
> > > > serial consoles? (sles does not have libxl, i want to write now wrapper
> > > > to qemu-dm, after that try to compile rpm from spec to support libxl).
> > > >
> > >
> > > There is no need for any special command line arguments to qemu-dm, it
> > > is going to create as many PV serials as configured on xenstored by
> > > libxl, give a look at tools/libxl/libxl.c:libxl_device_console_add.
> > > The output of the serial is the one specified on the node "output" on
> > > xenstore.
> >
> > I reproduce kernel crush:
> >
>
> You need to enable debugging options in your kernel so we can see function
> names in the trace.
>
> -- Pasi

I'm already add this options:
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_SLUB_DEBUG=y
CONFIG_HAVE_DMA_API_DEBUG=y
CONFIG_XEN_DEBUG_FS=y
CONFIG_X86_DEBUGCTLMSR=y
CONFIG_PM_DEBUG=y
CONFIG_DM_DEBUG=y
CONFIG_JBD2_DEBUG=y
CONFIG_DLM_DEBUG=y
CONFIG_DEBUG_FS=y
CONFIG_DEBUG_KERNEL=y
CONFIG_DEBUG_SHIRQ=y
CONFIG_SCHED_DEBUG=y
CONFIG_DEBUG_OBJECTS=y
CONFIG_DEBUG_OBJECTS_FREE=y
CONFIG_DEBUG_OBJECTS_TIMERS=y
CONFIG_DEBUG_OBJECTS_ENABLE_DEFAULT=1
CONFIG_SLUB_DEBUG_ON=y
CONFIG_DEBUG_RT_MUTEXES=y
CONFIG_DEBUG_PI_LIST=y
CONFIG_DEBUG_SPINLOCK=y
CONFIG_DEBUG_MUTEXES=y
CONFIG_DEBUG_LOCK_ALLOC=y
CONFIG_DEBUG_SPINLOCK_SLEEP=y
CONFIG_DEBUG_KOBJECT=y
CONFIG_DEBUG_HIGHMEM=y
CONFIG_DEBUG_BUGVERBOSE=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_VM=y
CONFIG_DEBUG_WRITECOUNT=y
CONFIG_DEBUG_MEMORY_INIT=y
CONFIG_DEBUG_LIST=y
CONFIG_DEBUG_SG=y
CONFIG_DEBUG_NOTIFIERS=y
CONFIG_FAULT_INJECTION_DEBUG_FS=y
CONFIG_DEBUG_PAGEALLOC=y
CONFIG_DMA_API_DEBUG=y
CONFIG_DEBUG_STACKOVERFLOW=y
CONFIG_DEBUG_STACK_USAGE=y
CONFIG_DEBUG_RODATA=y
CONFIG_DEBUG_RODATA_TEST=y
CONFIG_DEBUG_BOOT_PARAMS=y
CONFIG_KEYS_DEBUG_PROC_KEYS=y


see attached file

--
Vasiliy G Tolstov <[email protected]>
Selfip.Ru


Attachments:
DEBUG.config (47.30 kB)

2010-12-09 12:56:29

by Pasi Kärkkäinen

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On Thu, Dec 09, 2010 at 02:00:12PM +0300, Vasiliy G Tolstov wrote:
> On Tue, 2010-12-07 at 10:30 +0000, Stefano Stabellini wrote:
> > On Mon, 6 Dec 2010, Vasiliy G Tolstov wrote:
> > > On Mon, 2010-12-06 at 10:36 +0000, Stefano Stabellini wrote:
> > >
> > > >
> > > > Could you please add CONFIG_DEBUG_INFO=y to your kernel config, so that
> > > > we can see the name of the functions in the stack trace?
> > > >
> > >
> > > After add debug kernel not crushed. I'm test more expensive it now. Can
> > > You provide ps auxwww | grep qemu-dm after creating domain with two
> > > serial consoles? (sles does not have libxl, i want to write now wrapper
> > > to qemu-dm, after that try to compile rpm from spec to support libxl).
> > >
> >
> > There is no need for any special command line arguments to qemu-dm, it
> > is going to create as many PV serials as configured on xenstored by
> > libxl, give a look at tools/libxl/libxl.c:libxl_device_console_add.
> > The output of the serial is the one specified on the node "output" on
> > xenstore.
>
> I reproduce kernel crush:
>

You need to enable debugging options in your kernel so we can see function
names in the trace.

-- Pasi

> With attached config file kernel from jeremy stable-2.6.32.x boot ok and
> noisy debug info
> If i compile with this config from You branch stable-2.6.32-pvconsole
> kernel crushed. Nothing displays. Only xm dmesg says:
>
> (XEN) d47:v0: unhandled page fault (ec=0000)
> (XEN) Pagetable walk from 0000000000000010:
> (XEN) L4[0x000] = 000000083870a027 00000000000013f9
> (XEN) L3[0x000] = 0000000000000000 ffffffffffffffff
> (XEN) domain_crash_sync called from entry.S
> (XEN) Domain 47 (vcpu#0) crashed on cpu#15:
> (XEN) ----[ Xen-4.0.0_21091_06-0.2.1 x86_64 debug=n Not tainted ]----
> (XEN) CPU: 15
> (XEN) RIP: e019:[<00000000c10aaa3f>]
> (XEN) RFLAGS: 0000000000000246 EM: 1 CONTEXT: pv guest
> (XEN) rax: 0000000000000000 rbx: 00000000c146f5a0 rcx:
> 00000000c1445298
> (XEN) rdx: 0000000000000000 rsi: 0000000000008000 rdi:
> 0000000000000000
> (XEN) rbp: 00000000c13f7e60 rsp: 00000000c13f7e34 r8:
> 0000000000000000
> (XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
> 0000000000000000
> (XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
> 0000000000000000
> (XEN) r15: 0000000000000000 cr0: 000000008005003b cr4:
> 00000000000026f0
> (XEN) cr3: 000000083fe24000 cr2: 0000000000000010
> (XEN) ds: e021 es: e021 fs: 00d8 gs: 0000 ss: e021 cs: e019
> (XEN) Guest stack trace from esp=c13f7e34:
> (XEN) 00000000 c10aaa3f 0001e019 00010046 c10392d6 c1445298 c11d0e17
> 00000004
> (XEN) c146f5a0 00000000 c14b0cd9 c13f7e70 c11d0e17 c146f5a0 00000000
> c13f7e78
> (XEN) c11d0ed4 c13f7e98 c103936f c14b0cc8 004b0cc0 00000000 c14b0cd9
> 00000000
> (XEN) c14b0cd9 c13f7ea8 c1495868 c14d215c c14b0ccd c13f7ebc c148541b
> c14b0ccd
> (XEN) fffffffe 00000000 c13f7ef8 c1048703 c13f7ef8 00000000 c137df19
> 00000000
> (XEN) 0000000f 00000000 00000000 00000000 c14b0cd9 c14b0cdd 00000000
> c1480f40
> (XEN) c1481900 c13f7f08 c14851fd 00000000 c14853d2 c13f7f10 c14853c6
> c13f7f94
> (XEN) c148a282 c13f7f20 c13f7fa4 00000000 c104e01e 00000005 00000000
> 00000000
> (XEN) 00000000 00000000 00000098 205b7f4c 30202020 3030302e 5d303030
> c1050020
> (XEN) c13f7f78 c1bb60d0 c13f7f68 00000024 00000000 c1bb60c0 c1bb5884
> c1394221
> (XEN) 00000000 c13f7fdc 00000000 c13f7f94 c10392f6 00000000 c13f7fdc
> 00000000
> (XEN) c13f7fac c148562f c137e0bc c12b2020 c14b2c60 00000000 c13f7fb8
> c14850a2
> (XEN) c21f8000 c13f7ffc c1487d4a 00000000 00000000 00000000 00000000
> 00000000
> (XEN) 00000000 00000000 1f898975 80980201 10100800 000106a5 00000000
> 00000000
> (XEN) c21f8000 00000000 00000000
> (XEN) cpupool_rm_domain(dom=47,pool=0) n_dom 1
> (XEN) mm.c:2562:d0 Unknown domain '47'
> (XEN) mm.c:2562:d0 Unknown domain '47'
> (XEN) mm.c:2562:d0 Unknown domain '47'
> (XEN) mm.c:2562:d0 Unknown domain '47'
>
>
>
> --
> Vasiliy G Tolstov <[email protected]>
> Selfip.Ru
>
>
> _______________________________________________
> Xen-devel mailing list
> [email protected]
> http://lists.xensource.com/xen-devel

2010-12-09 18:07:13

by Jeremy Fitzhardinge

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On 12/09/2010 04:12 AM, Pasi K?rkk?inen wrote:
> On Thu, Dec 09, 2010 at 02:00:12PM +0300, Vasiliy G Tolstov wrote:
>> On Tue, 2010-12-07 at 10:30 +0000, Stefano Stabellini wrote:
>>> On Mon, 6 Dec 2010, Vasiliy G Tolstov wrote:
>>>> On Mon, 2010-12-06 at 10:36 +0000, Stefano Stabellini wrote:
>>>>
>>>>> Could you please add CONFIG_DEBUG_INFO=y to your kernel config, so that
>>>>> we can see the name of the functions in the stack trace?
>>>>>
>>>> After add debug kernel not crushed. I'm test more expensive it now. Can
>>>> You provide ps auxwww | grep qemu-dm after creating domain with two
>>>> serial consoles? (sles does not have libxl, i want to write now wrapper
>>>> to qemu-dm, after that try to compile rpm from spec to support libxl).
>>>>
>>> There is no need for any special command line arguments to qemu-dm, it
>>> is going to create as many PV serials as configured on xenstored by
>>> libxl, give a look at tools/libxl/libxl.c:libxl_device_console_add.
>>> The output of the serial is the one specified on the node "output" on
>>> xenstore.
>> I reproduce kernel crush:
>>
> You need to enable debugging options in your kernel so we can see function
> names in the trace.

That's a Xen-generated dump, so that's the best you're going to get for now.

Vasiliy, you'll need to use System.map or gdb to convert the RIP to a
Linux symbol, and ideally go through the stack dump and see if you can
construct a backtrace.

(Dear lazyweb: there ought to be a program/script which can take a Xen
dump and convert the addresses to symbols like ksymoops used to do.
Somethat that can reformat a Xen dump to a kernel oops for ksymoops
would be a good first step.)

J

> -- Pasi
>
>> With attached config file kernel from jeremy stable-2.6.32.x boot ok and
>> noisy debug info
>> If i compile with this config from You branch stable-2.6.32-pvconsole
>> kernel crushed. Nothing displays. Only xm dmesg says:
>>
>> (XEN) d47:v0: unhandled page fault (ec=0000)
>> (XEN) Pagetable walk from 0000000000000010:
>> (XEN) L4[0x000] = 000000083870a027 00000000000013f9
>> (XEN) L3[0x000] = 0000000000000000 ffffffffffffffff
>> (XEN) domain_crash_sync called from entry.S
>> (XEN) Domain 47 (vcpu#0) crashed on cpu#15:
>> (XEN) ----[ Xen-4.0.0_21091_06-0.2.1 x86_64 debug=n Not tainted ]----
>> (XEN) CPU: 15
>> (XEN) RIP: e019:[<00000000c10aaa3f>]
>> (XEN) RFLAGS: 0000000000000246 EM: 1 CONTEXT: pv guest
>> (XEN) rax: 0000000000000000 rbx: 00000000c146f5a0 rcx:
>> 00000000c1445298
>> (XEN) rdx: 0000000000000000 rsi: 0000000000008000 rdi:
>> 0000000000000000
>> (XEN) rbp: 00000000c13f7e60 rsp: 00000000c13f7e34 r8:
>> 0000000000000000
>> (XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
>> 0000000000000000
>> (XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
>> 0000000000000000
>> (XEN) r15: 0000000000000000 cr0: 000000008005003b cr4:
>> 00000000000026f0
>> (XEN) cr3: 000000083fe24000 cr2: 0000000000000010
>> (XEN) ds: e021 es: e021 fs: 00d8 gs: 0000 ss: e021 cs: e019
>> (XEN) Guest stack trace from esp=c13f7e34:
>> (XEN) 00000000 c10aaa3f 0001e019 00010046 c10392d6 c1445298 c11d0e17
>> 00000004
>> (XEN) c146f5a0 00000000 c14b0cd9 c13f7e70 c11d0e17 c146f5a0 00000000
>> c13f7e78
>> (XEN) c11d0ed4 c13f7e98 c103936f c14b0cc8 004b0cc0 00000000 c14b0cd9
>> 00000000
>> (XEN) c14b0cd9 c13f7ea8 c1495868 c14d215c c14b0ccd c13f7ebc c148541b
>> c14b0ccd
>> (XEN) fffffffe 00000000 c13f7ef8 c1048703 c13f7ef8 00000000 c137df19
>> 00000000
>> (XEN) 0000000f 00000000 00000000 00000000 c14b0cd9 c14b0cdd 00000000
>> c1480f40
>> (XEN) c1481900 c13f7f08 c14851fd 00000000 c14853d2 c13f7f10 c14853c6
>> c13f7f94
>> (XEN) c148a282 c13f7f20 c13f7fa4 00000000 c104e01e 00000005 00000000
>> 00000000
>> (XEN) 00000000 00000000 00000098 205b7f4c 30202020 3030302e 5d303030
>> c1050020
>> (XEN) c13f7f78 c1bb60d0 c13f7f68 00000024 00000000 c1bb60c0 c1bb5884
>> c1394221
>> (XEN) 00000000 c13f7fdc 00000000 c13f7f94 c10392f6 00000000 c13f7fdc
>> 00000000
>> (XEN) c13f7fac c148562f c137e0bc c12b2020 c14b2c60 00000000 c13f7fb8
>> c14850a2
>> (XEN) c21f8000 c13f7ffc c1487d4a 00000000 00000000 00000000 00000000
>> 00000000
>> (XEN) 00000000 00000000 1f898975 80980201 10100800 000106a5 00000000
>> 00000000
>> (XEN) c21f8000 00000000 00000000
>> (XEN) cpupool_rm_domain(dom=47,pool=0) n_dom 1
>> (XEN) mm.c:2562:d0 Unknown domain '47'
>> (XEN) mm.c:2562:d0 Unknown domain '47'
>> (XEN) mm.c:2562:d0 Unknown domain '47'
>> (XEN) mm.c:2562:d0 Unknown domain '47'
>>
>>
>>
>> --
>> Vasiliy G Tolstov <[email protected]>
>> Selfip.Ru
>>
>>
>> _______________________________________________
>> Xen-devel mailing list
>> [email protected]
>> http://lists.xensource.com/xen-devel

2010-12-09 18:17:10

by Pasi Kärkkäinen

[permalink] [raw]
Subject: Re: [Xen-devel] [PATCH 0/2] Xen PV on HVM multiple PV consoles

On Thu, Dec 09, 2010 at 10:07:10AM -0800, Jeremy Fitzhardinge wrote:
> On 12/09/2010 04:12 AM, Pasi K?rkk?inen wrote:
> > On Thu, Dec 09, 2010 at 02:00:12PM +0300, Vasiliy G Tolstov wrote:
> >> On Tue, 2010-12-07 at 10:30 +0000, Stefano Stabellini wrote:
> >>> On Mon, 6 Dec 2010, Vasiliy G Tolstov wrote:
> >>>> On Mon, 2010-12-06 at 10:36 +0000, Stefano Stabellini wrote:
> >>>>
> >>>>> Could you please add CONFIG_DEBUG_INFO=y to your kernel config, so that
> >>>>> we can see the name of the functions in the stack trace?
> >>>>>
> >>>> After add debug kernel not crushed. I'm test more expensive it now. Can
> >>>> You provide ps auxwww | grep qemu-dm after creating domain with two
> >>>> serial consoles? (sles does not have libxl, i want to write now wrapper
> >>>> to qemu-dm, after that try to compile rpm from spec to support libxl).
> >>>>
> >>> There is no need for any special command line arguments to qemu-dm, it
> >>> is going to create as many PV serials as configured on xenstored by
> >>> libxl, give a look at tools/libxl/libxl.c:libxl_device_console_add.
> >>> The output of the serial is the one specified on the node "output" on
> >>> xenstore.
> >> I reproduce kernel crush:
> >>
> > You need to enable debugging options in your kernel so we can see function
> > names in the trace.
>
> That's a Xen-generated dump, so that's the best you're going to get for now.
>

Heh, true. I should have been more careful :)

-- Pasi

> Vasiliy, you'll need to use System.map or gdb to convert the RIP to a
> Linux symbol, and ideally go through the stack dump and see if you can
> construct a backtrace.
>
> (Dear lazyweb: there ought to be a program/script which can take a Xen
> dump and convert the addresses to symbols like ksymoops used to do.
> Somethat that can reformat a Xen dump to a kernel oops for ksymoops
> would be a good first step.)
>
> J
>
> > -- Pasi
> >
> >> With attached config file kernel from jeremy stable-2.6.32.x boot ok and
> >> noisy debug info
> >> If i compile with this config from You branch stable-2.6.32-pvconsole
> >> kernel crushed. Nothing displays. Only xm dmesg says:
> >>
> >> (XEN) d47:v0: unhandled page fault (ec=0000)
> >> (XEN) Pagetable walk from 0000000000000010:
> >> (XEN) L4[0x000] = 000000083870a027 00000000000013f9
> >> (XEN) L3[0x000] = 0000000000000000 ffffffffffffffff
> >> (XEN) domain_crash_sync called from entry.S
> >> (XEN) Domain 47 (vcpu#0) crashed on cpu#15:
> >> (XEN) ----[ Xen-4.0.0_21091_06-0.2.1 x86_64 debug=n Not tainted ]----
> >> (XEN) CPU: 15
> >> (XEN) RIP: e019:[<00000000c10aaa3f>]
> >> (XEN) RFLAGS: 0000000000000246 EM: 1 CONTEXT: pv guest
> >> (XEN) rax: 0000000000000000 rbx: 00000000c146f5a0 rcx:
> >> 00000000c1445298
> >> (XEN) rdx: 0000000000000000 rsi: 0000000000008000 rdi:
> >> 0000000000000000
> >> (XEN) rbp: 00000000c13f7e60 rsp: 00000000c13f7e34 r8:
> >> 0000000000000000
> >> (XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
> >> 0000000000000000
> >> (XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
> >> 0000000000000000
> >> (XEN) r15: 0000000000000000 cr0: 000000008005003b cr4:
> >> 00000000000026f0
> >> (XEN) cr3: 000000083fe24000 cr2: 0000000000000010
> >> (XEN) ds: e021 es: e021 fs: 00d8 gs: 0000 ss: e021 cs: e019
> >> (XEN) Guest stack trace from esp=c13f7e34:
> >> (XEN) 00000000 c10aaa3f 0001e019 00010046 c10392d6 c1445298 c11d0e17
> >> 00000004
> >> (XEN) c146f5a0 00000000 c14b0cd9 c13f7e70 c11d0e17 c146f5a0 00000000
> >> c13f7e78
> >> (XEN) c11d0ed4 c13f7e98 c103936f c14b0cc8 004b0cc0 00000000 c14b0cd9
> >> 00000000
> >> (XEN) c14b0cd9 c13f7ea8 c1495868 c14d215c c14b0ccd c13f7ebc c148541b
> >> c14b0ccd
> >> (XEN) fffffffe 00000000 c13f7ef8 c1048703 c13f7ef8 00000000 c137df19
> >> 00000000
> >> (XEN) 0000000f 00000000 00000000 00000000 c14b0cd9 c14b0cdd 00000000
> >> c1480f40
> >> (XEN) c1481900 c13f7f08 c14851fd 00000000 c14853d2 c13f7f10 c14853c6
> >> c13f7f94
> >> (XEN) c148a282 c13f7f20 c13f7fa4 00000000 c104e01e 00000005 00000000
> >> 00000000
> >> (XEN) 00000000 00000000 00000098 205b7f4c 30202020 3030302e 5d303030
> >> c1050020
> >> (XEN) c13f7f78 c1bb60d0 c13f7f68 00000024 00000000 c1bb60c0 c1bb5884
> >> c1394221
> >> (XEN) 00000000 c13f7fdc 00000000 c13f7f94 c10392f6 00000000 c13f7fdc
> >> 00000000
> >> (XEN) c13f7fac c148562f c137e0bc c12b2020 c14b2c60 00000000 c13f7fb8
> >> c14850a2
> >> (XEN) c21f8000 c13f7ffc c1487d4a 00000000 00000000 00000000 00000000
> >> 00000000
> >> (XEN) 00000000 00000000 1f898975 80980201 10100800 000106a5 00000000
> >> 00000000
> >> (XEN) c21f8000 00000000 00000000
> >> (XEN) cpupool_rm_domain(dom=47,pool=0) n_dom 1
> >> (XEN) mm.c:2562:d0 Unknown domain '47'
> >> (XEN) mm.c:2562:d0 Unknown domain '47'
> >> (XEN) mm.c:2562:d0 Unknown domain '47'
> >> (XEN) mm.c:2562:d0 Unknown domain '47'
> >>
> >>
> >>
> >> --
> >> Vasiliy G Tolstov <[email protected]>
> >> Selfip.Ru
> >>
> >>
> >> _______________________________________________
> >> Xen-devel mailing list
> >> [email protected]
> >> http://lists.xensource.com/xen-devel
>