From owner-freebsd-current@FreeBSD.ORG Tue Dec 24 11:25:29 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id F32342D1; Tue, 24 Dec 2013 11:25:28 +0000 (UTC) Received: from SMTP02.CITRIX.COM (smtp02.citrix.com [66.165.176.63]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 663DA16EF; Tue, 24 Dec 2013 11:25:27 +0000 (UTC) X-IronPort-AV: E=Sophos;i="4.95,542,1384300800"; d="scan'208";a="85273155" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 24 Dec 2013 11:25:21 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.2.342.4; Tue, 24 Dec 2013 06:25:20 -0500 Received: from gateway-cbg.eng.citrite.net ([10.80.16.17] helo=localhost.localdomain) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1VvQ4H-0007qS-8T; Tue, 24 Dec 2013 11:22:33 +0000 From: Roger Pau Monne To: , , , , , , Subject: [PATCH RFC 13/13] xenstore: changes needed to boot in Dom0 mode Date: Tue, 24 Dec 2013 12:21:02 +0100 Message-ID: <1387884062-41154-14-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 1.7.7.5 (Apple Git-26) In-Reply-To: <1387884062-41154-1-git-send-email-roger.pau@citrix.com> References: <1387884062-41154-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain X-DLP: MIA2 Cc: Roger Pau Monne X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Dec 2013 11:25:29 -0000 This patch includes changes to xenstore in order to boot as Dom0. This is different from booting as a guest, since when booted as Dom0 xenstore is not available. This patch sets up a memory page, an event channel for xenstore and disables xenbus device probing at boot. It contains a workaround for xs_watch, that should be fixed when we are able to start xenstored from Dom0. --- sys/xen/xenbus/xenbusb.c | 6 ++++-- sys/xen/xenstore/xenstore.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/sys/xen/xenbus/xenbusb.c b/sys/xen/xenbus/xenbusb.c index 1f84795..11be0f5 100644 --- a/sys/xen/xenbus/xenbusb.c +++ b/sys/xen/xenbus/xenbusb.c @@ -760,8 +760,10 @@ xenbusb_attach(device_t dev, char *bus_node, u_int id_components) * bus when they are dynamically attached to us * by a Xen management action. */ - (void)xenbusb_enumerate_bus(xbs); - xenbusb_probe_children(dev); + if (!xen_initial_domain()) { + (void)xenbusb_enumerate_bus(xbs); + xenbusb_probe_children(dev); + } xbs->xbs_device_watch.node = bus_node; xbs->xbs_device_watch.callback = xenbusb_devices_changed; diff --git a/sys/xen/xenstore/xenstore.c b/sys/xen/xenstore/xenstore.c index 2893c84..bde3f5d 100644 --- a/sys/xen/xenstore/xenstore.c +++ b/sys/xen/xenstore/xenstore.c @@ -1144,6 +1144,24 @@ xs_attach(device_t dev) xs.gpfn = hvm_get_parameter(HVM_PARAM_STORE_PFN); xen_store = pmap_mapdev(xs.gpfn * PAGE_SIZE, PAGE_SIZE); } else if (xen_pv_domain()) { + if (!HYPERVISOR_start_info->store_evtchn) { + struct evtchn_alloc_unbound alloc_unbound; + + /* Allocate a local event channel for xenstore */ + alloc_unbound.dom = DOMID_SELF; + alloc_unbound.remote_dom = DOMID_SELF; + error = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, + &alloc_unbound); + if (error) + panic("unable to alloc event channel for Dom0: %d", + error); + + HYPERVISOR_start_info->store_evtchn = alloc_unbound.port; + + /* Allocate memory for the xs shared ring */ + xen_store = malloc(PAGE_SIZE, M_XENSTORE, + M_WAITOK | M_ZERO); + } xs.evtchn = HYPERVISOR_start_info->store_evtchn; } else { panic("Unknown domain type, cannot initialize xenstore\n"); @@ -1579,6 +1597,10 @@ xs_register_watch(struct xs_watch *watch) char token[sizeof(watch) * 2 + 1]; int error; + /* XXX: this is a hack until we get xenstored working */ + if (xen_initial_domain()) + return (0); + sprintf(token, "%lX", (long)watch); sx_slock(&xs.suspend_mutex); -- 1.7.7.5 (Apple Git-26)