From patchwork Tue Feb 27 15:15:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 129832 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp400778edc; Tue, 27 Feb 2018 07:20:20 -0800 (PST) X-Google-Smtp-Source: AG47ELtIX3aIpUkvP7rpHOYZGQSKWhfBEF66j0NYYOwAX9iaI3UoF1BznRNTWqLjfIT8ubUHqmsJ X-Received: by 10.107.4.74 with SMTP id 71mr16302466ioe.76.1519744820180; Tue, 27 Feb 2018 07:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519744820; cv=none; d=google.com; s=arc-20160816; b=IdA7DW54eGj2VTn4cZzkcqvKRmPzhF5rqZ9BenJz5w3MfKeTu+dxN7GanSOEK8w6mi tqW2pe9frfgvMy5KgYbogqnuMSm1mYJlj7mPh26EeGB3KoWEJYeb0y7+yXIIGhRuKHhP QOvKmrxxu/22iHmp4MnwauyXjDixxDA8GrWW9JNRR17v9g09ZrLVMuf6GFcViF9pPFNm QvgoMbD9LksxSb3rnT54y5aLZK7FFELDpU/AKjSTxR0RjGjTPIJI0NJyLEUL5Jax7ywh ah3GlAlQ6GNb9TTTMqjACO59Ii8rxpfWdNKqE9HRlWmkrx6vclyE9OBrZ83Lxa25KSJD 2S5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=InUX87GoL3/1s/S0kuu7q4wq2FVXTs2DhZAeSbkDykE=; b=QT+O7esYXjS9C1Qn0GgP8e56xrW4BddwIm2jRJ0mbiLLuGS0UL+IzpZgGBd7jCoTJs IYMOFHvvMhf77tV1mM3nGtT1gX5v9Z4GCg5g2E1/rzFVKO4VnQID6GBuzOlQUKr2Aw9y NnJ/YBlUJsrI86G5ZAnnuOERlbQ536ZVr4wCep48VjC5YeqfHJj035a8KhcjBTweo7oq f+KCAgMWEEZtjz8Us3lu93K4bNqIIYB4s9W+MFBzUIn00PUJx7wbhp12KkdtmVgtkknQ Ouu2xO+8Wdc4pUCgeZ/rdZQvqI/431qqBixQzQO7t8M0MXNfVqDUwjnwJ1onwbiD3z97 QVOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id y78si7362848iof.151.2018.02.27.07.20.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 07:20:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eqh1O-0005Uj-6y; Tue, 27 Feb 2018 15:18:26 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eqh1M-0005UA-LG for xen-devel@lists.xenproject.org; Tue, 27 Feb 2018 15:18:24 +0000 X-Inumbo-ID: 67eeb856-1bd1-11e8-b9b1-635ca7ef6cff Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 67eeb856-1bd1-11e8-b9b1-635ca7ef6cff; Tue, 27 Feb 2018 15:18:04 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 70CCB164F; Tue, 27 Feb 2018 07:16:08 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 61DFB3F25C; Tue, 27 Feb 2018 07:16:07 -0800 (PST) From: julien.grall@arm.com To: xen-devel@lists.xenproject.org Date: Tue, 27 Feb 2018 15:15:54 +0000 Message-Id: <20180227151555.1953-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180227151555.1953-1-julien.grall@arm.com> References: <20180227151555.1953-1-julien.grall@arm.com> Cc: stewart.hildebrand@dornerworks.com, andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH 2/3] xen/arm: domain_build: Rework the way to allocate the event channel interrupt X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Julien Grall At the moment, a placeholder will be created in the device-tree for the event channel information. Later in the domain construction, the interrupt for the event channel upcall will be allocated the device-tree fixed up. Looking at the code, the current split is not necessary because all the PPIs used by the hardware domain will by the time we create the node in the device-tree. >From now, mandate that all interrupts are registered before acpi_prepare() and dtb_prepare(). This allows us to rework the event channel code and remove one placeholder. Note, this will also help to fix the BUG(...) condition in set_interrupt_ppi which is completely wrong. See in a follow-up patch. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 74 +++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index a5e5c82355..ed1a393bb5 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -576,7 +576,10 @@ static int make_memory_node(const struct domain *d, return res; } -static int make_hypervisor_node(const struct kernel_info *kinfo, +static void evtchn_allocate(struct domain *d); + +static int make_hypervisor_node(struct domain *d, + const struct kernel_info *kinfo, const struct dt_device_node *parent) { const char compat[] = @@ -620,10 +623,18 @@ static int make_hypervisor_node(const struct kernel_info *kinfo, return res; /* - * Placeholder for the event channel interrupt. The values will be - * replaced later. + * It is safe to allocate the event channel here because all the + * PPIs used by the hardware domain have been registered. + */ + evtchn_allocate(d); + + /* + * Interrupt event channel upcall: + * - Active-low level-sensitive + * - All CPUs + * TODO: Handle properly the cpumask; */ - set_interrupt_ppi(intr, ~0, 0xf, IRQ_TYPE_INVALID); + set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf, IRQ_TYPE_LEVEL_LOW); res = fdt_property_interrupts(fdt, &intr, 1); if ( res ) return res; @@ -1282,7 +1293,11 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, if ( node == dt_host ) { - res = make_hypervisor_node(kinfo, node); + /* + * The hypervisor node should always be created after all nodes + * from the host DT have been parsed. + */ + res = make_hypervisor_node(d, kinfo, node); if ( res ) return res; @@ -1939,6 +1954,12 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) if ( rc != 0 ) return rc; + /* + * All PPIs have been registered, allocate the event channel + * interrupts. + */ + evtchn_allocate(d); + return 0; } #else @@ -2014,16 +2035,18 @@ static void initrd_load(struct kernel_info *kinfo) panic("Unable to copy the initrd in the hwdom memory"); } -static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo) +/* + * Allocate the event channel PPIs and setup the HVM_PARAM_CALLBACK_IRQ. + * The allocated IRQ will be found in d->arch.evtchn_irq. + * + * Note that this should only be called once all PPIs used by the + * hardware domain have been registered. + */ +static void evtchn_allocate(struct domain *d) { - int res, node; + int res; u64 val; - gic_interrupt_t intr; - /* - * The allocation of the event channel IRQ has been deferred until - * now. At this time, all PPIs used by DOM0 have been registered. - */ res = vgic_allocate_ppi(d); if ( res < 0 ) panic("Unable to allocate a PPI for the event channel interrupt\n"); @@ -2041,31 +2064,6 @@ static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo) HVM_PARAM_CALLBACK_TYPE_PPI_FLAG_MASK); val |= d->arch.evtchn_irq; d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = val; - - /* - * When booting Dom0 using ACPI, Dom0 can only get the event channel - * interrupt via hypercall. - */ - if ( !acpi_disabled ) - return; - - /* Fix up "interrupts" in /hypervisor node */ - node = fdt_path_offset(kinfo->fdt, "/hypervisor"); - if ( node < 0 ) - panic("Cannot find the /hypervisor node"); - - /* Interrupt event channel upcall: - * - Active-low level-sensitive - * - All CPUs - * - * TODO: Handle properly the cpumask - */ - set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf, - IRQ_TYPE_LEVEL_LOW); - res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts", - &intr, sizeof(intr)); - if ( res ) - panic("Cannot fix up \"interrupts\" property of the hypervisor node"); } static void __init find_gnttab_region(struct domain *d, @@ -2177,8 +2175,6 @@ int construct_dom0(struct domain *d) kernel_load(&kinfo); /* initrd_load will fix up the fdt, so call it before dtb_load */ initrd_load(&kinfo); - /* Allocate the event channel IRQ and fix up the device tree */ - evtchn_fixup(d, &kinfo); dtb_load(&kinfo); /* Now that we are done restore the original p2m and current. */