From: Daniel De Graaf <dgdegra@tycho.nsa.gov>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: xen-devel@lists.xensource.com, linaro-dev@lists.linaro.org,
Ian.Campbell@citrix.com, arnd@arndb.de,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
catalin.marinas@arm.com, tim@xen.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 10/23] xen/arm: compile and run xenbus
Date: Tue, 07 Aug 2012 14:44:56 -0400 [thread overview]
Message-ID: <50216228.7010407@tycho.nsa.gov> (raw)
In-Reply-To: <20120807182157.GN15053@phenom.dumpdata.com>
On 08/07/2012 02:21 PM, Konrad Rzeszutek Wilk wrote:
> On Mon, Aug 06, 2012 at 03:27:13PM +0100, Stefano Stabellini wrote:
>> bind_evtchn_to_irqhandler can legitimately return 0 (irq 0): it is not
>> an error.
>>
>> If Linux is running as an HVM domain and is running as Dom0, use
>> xenstored_local_init to initialize the xenstore page and event channel.
>>
>> Changes in v2:
>>
>> - refactor xenbus_init.
>
> Thank you. Lets also CC our friend at NSA who has been doing some work
> in that area. Daniel are you OK with this change - will it still make
> PV initial domain with with the MiniOS XenBus driver?
>
> Thanks.
That case will work, but what this will break is launching the initial domain
with a Xenstore stub domain already running (see below).
>>
>> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>> ---
>> drivers/xen/xenbus/xenbus_comms.c | 2 +-
>> drivers/xen/xenbus/xenbus_probe.c | 62 +++++++++++++++++++++++++-----------
>> drivers/xen/xenbus/xenbus_xs.c | 1 +
>> 3 files changed, 45 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/xen/xenbus/xenbus_comms.c b/drivers/xen/xenbus/xenbus_comms.c
>> index 52fe7ad..c5aa55c 100644
>> --- a/drivers/xen/xenbus/xenbus_comms.c
>> +++ b/drivers/xen/xenbus/xenbus_comms.c
>> @@ -224,7 +224,7 @@ int xb_init_comms(void)
>> int err;
>> err = bind_evtchn_to_irqhandler(xen_store_evtchn, wake_waiting,
>> 0, "xenbus", &xb_waitq);
>> - if (err <= 0) {
>> + if (err < 0) {
>> printk(KERN_ERR "XENBUS request irq failed %i\n", err);
>> return err;
>> }
>
>> diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
>> index b793723..a67ccc0 100644
>> --- a/drivers/xen/xenbus/xenbus_probe.c
>> +++ b/drivers/xen/xenbus/xenbus_probe.c
>> @@ -719,37 +719,61 @@ static int __init xenstored_local_init(void)
>> return err;
>> }
>>
>> +enum xenstore_init {
>> + UNKNOWN,
>> + PV,
>> + HVM,
>> + LOCAL,
>> +};
>> static int __init xenbus_init(void)
>> {
>> int err = 0;
>> + enum xenstore_init usage = UNKNOWN;
>> + uint64_t v = 0;
>>
>> if (!xen_domain())
>> return -ENODEV;
>>
>> xenbus_ring_ops_init();
>>
>> - if (xen_hvm_domain()) {
>> - uint64_t v = 0;
>> - err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
>> - if (err)
>> - goto out_error;
>> - xen_store_evtchn = (int)v;
>> - err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
>> - if (err)
>> - goto out_error;
>> - xen_store_mfn = (unsigned long)v;
>> - 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;
>> - if (xen_store_evtchn)
>> - xenstored_ready = 1;
>> - else {
>> + if (xen_pv_domain())
>> + usage = PV;
>> + if (xen_hvm_domain())
>> + usage = HVM;
The above is correct for domUs, and is overridden for dom0s:
>> + if (xen_hvm_domain() && xen_initial_domain())
>> + usage = LOCAL;
>> + if (xen_pv_domain() && !xen_start_info->store_evtchn)
>> + usage = LOCAL;
Instead of these checks, I think it should just be:
if (!xen_start_info->store_evtchn)
usage = LOCAL;
Any domain started after xenstore will have store_evtchn set, so if you don't
have this set, you are either going to be running xenstore locally, or will
use the ioctl to change it later (and so should still set up everything as if
it will be running locally).
>> + if (xen_pv_domain() && xen_start_info->store_evtchn)
>> + xenstored_ready = 1;
This part can now just be moved unconditionally into case PV.
>> +
>> + switch (usage) {
>> + case LOCAL:
>> err = xenstored_local_init();
>> if (err)
>> goto out_error;
>> - }
>> - xen_store_interface = mfn_to_virt(xen_store_mfn);
>> + xen_store_interface = mfn_to_virt(xen_store_mfn);
>> + break;
>> + case PV:
>> + 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);
>> + break;
>> + case HVM:
>> + err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
>> + if (err)
>> + goto out_error;
>> + xen_store_evtchn = (int)v;
>> + err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
>> + if (err)
>> + goto out_error;
>> + xen_store_mfn = (unsigned long)v;
>> + xen_store_interface =
>> + ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
>> + break;
>> + default:
>> + pr_warn("Xenstore state unknown\n");
>> + break;
>> }
>>
>> /* Initialize the interface to xenstore. */
>> diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
>> index d1c217b..f7feb3d 100644
>> --- a/drivers/xen/xenbus/xenbus_xs.c
>> +++ b/drivers/xen/xenbus/xenbus_xs.c
>> @@ -44,6 +44,7 @@
>> #include <linux/rwsem.h>
>> #include <linux/module.h>
>> #include <linux/mutex.h>
>> +#include <asm/xen/hypervisor.h>
>> #include <xen/xenbus.h>
>> #include <xen/xen.h>
>> #include "xenbus_comms.h"
>> --
>> 1.7.2.5
--
Daniel De Graaf
National Security Agency
next prev parent reply other threads:[~2012-08-07 18:44 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-06 14:25 [PATCH v2 00/23] Introduce Xen support on ARM Stefano Stabellini
2012-08-06 14:27 ` [PATCH v2 01/23] arm: initial Xen support Stefano Stabellini
2012-08-07 18:10 ` Konrad Rzeszutek Wilk
2012-08-08 16:31 ` Stefano Stabellini
2012-08-06 14:27 ` [PATCH v2 02/23] xen/arm: hypercalls Stefano Stabellini
2012-08-08 12:41 ` Dave Martin
2012-08-09 15:37 ` Stefano Stabellini
2012-08-09 16:50 ` Dave Martin
2012-08-06 14:27 ` [PATCH v2 06/23] xen: missing includes Stefano Stabellini
2012-08-07 18:14 ` Konrad Rzeszutek Wilk
2012-08-08 16:38 ` Stefano Stabellini
2012-08-06 14:27 ` [PATCH v2 10/23] xen/arm: compile and run xenbus Stefano Stabellini
2012-08-07 18:21 ` Konrad Rzeszutek Wilk
2012-08-07 18:44 ` Daniel De Graaf [this message]
2012-08-08 16:51 ` Stefano Stabellini
2012-08-08 17:01 ` Daniel De Graaf
[not found] ` <50229B70.3090507-+05T5uksL2qpZYMLLGbcSA@public.gmane.org>
2012-08-08 17:19 ` Stefano Stabellini
2012-08-08 17:33 ` Daniel De Graaf
2012-08-08 17:42 ` Stefano Stabellini
2012-08-09 16:54 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 17/23] xen/arm: implement alloc/free_xenballooned_pages with alloc_pages/kfree Stefano Stabellini
[not found] ` <1344263246-28036-17-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:31 ` Konrad Rzeszutek Wilk
[not found] ` <alpine.DEB.2.02.1208061428060.4645-7Z66fg9igcxYtxbxJUhB2Dgeux46jI+i@public.gmane.org>
2012-08-06 14:27 ` [PATCH v2 03/23] xen/arm: page.h definitions Stefano Stabellini
[not found] ` <1344263246-28036-3-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:13 ` Konrad Rzeszutek Wilk
2012-08-08 16:33 ` Stefano Stabellini
2012-08-06 14:27 ` [PATCH v2 04/23] xen/arm: sync_bitops Stefano Stabellini
[not found] ` <1344263246-28036-4-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:13 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 05/23] xen/arm: empty implementation of grant_table arch specific functions Stefano Stabellini
[not found] ` <1344263246-28036-5-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:13 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 07/23] xen/arm: Xen detection and shared_info page mapping Stefano Stabellini
[not found] ` <1344263246-28036-7-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-06 16:23 ` [Xen-devel] " David Vrabel
2012-08-08 16:24 ` Stefano Stabellini
2012-08-07 18:17 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 08/23] xen/arm: Introduce xen_pfn_t for pfn and mfn types Stefano Stabellini
[not found] ` <1344263246-28036-8-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:18 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 09/23] xen/arm: Introduce xen_ulong_t for unsigned long Stefano Stabellini
[not found] ` <1344263246-28036-9-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:18 ` Konrad Rzeszutek Wilk
2012-08-08 16:42 ` Stefano Stabellini
2012-08-06 14:27 ` [PATCH v2 11/23] xen: do not compile manage, balloon, pci, acpi and cpu_hotplug on ARM Stefano Stabellini
[not found] ` <1344263246-28036-11-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:23 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 12/23] xen/arm: introduce CONFIG_XEN " Stefano Stabellini
[not found] ` <1344263246-28036-12-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:23 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 13/23] xen/arm: get privilege status Stefano Stabellini
[not found] ` <1344263246-28036-13-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:24 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 14/23] xen/arm: initialize grant_table on ARM Stefano Stabellini
2012-08-06 14:27 ` [PATCH v2 15/23] xen/arm: receive Xen events " Stefano Stabellini
2012-08-07 18:30 ` Konrad Rzeszutek Wilk
[not found] ` <20120807183036.GR15053-6K5HmflnPlqSPmnEAIUT9EEOCMrvLtNR@public.gmane.org>
2012-08-08 18:05 ` Stefano Stabellini
2012-08-06 14:27 ` [PATCH v2 16/23] xen: clear IRQ_NOAUTOEN and IRQ_NOREQUEST Stefano Stabellini
[not found] ` <1344263246-28036-16-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:31 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 18/23] xen: allow privcmd for HVM guests Stefano Stabellini
[not found] ` <1344263246-28036-18-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:31 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 19/23] xen/arm: compile blkfront and blkback Stefano Stabellini
[not found] ` <1344263246-28036-19-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:32 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 20/23] xen/arm: compile netback Stefano Stabellini
[not found] ` <1344263246-28036-20-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:32 ` Konrad Rzeszutek Wilk
2012-08-06 14:27 ` [PATCH v2 21/23] xen: update xen_add_to_physmap interface Stefano Stabellini
[not found] ` <1344263246-28036-21-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:33 ` Konrad Rzeszutek Wilk
2012-08-08 17:22 ` Stefano Stabellini
2012-08-06 14:27 ` [PATCH v2 22/23] arm/v2m: initialize arch_timers even if v2m_timer is not present Stefano Stabellini
2012-08-06 14:27 ` [PATCH v2 23/23] [HACK] xen/arm: implement xen_remap_domain_mfn_range Stefano Stabellini
[not found] ` <1344263246-28036-23-git-send-email-stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>
2012-08-07 18:39 ` 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=50216228.7010407@tycho.nsa.gov \
--to=dgdegra@tycho.nsa.gov \
--cc=Ian.Campbell@citrix.com \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=konrad.wilk@oracle.com \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.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 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).