From patchwork Thu Feb 19 18:12:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 44850 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EB70A21554 for ; Thu, 19 Feb 2015 18:14:54 +0000 (UTC) Received: by labgm9 with SMTP id gm9sf909897lab.2 for ; Thu, 19 Feb 2015 10:14:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=DIGMxlV3CRfzNnJuEgGp59FWPNtyq2X+KTo6AFRAqgE=; b=XXwe7JLrIAfic8RIRBd6yidlmNs2mtaQuXCXbJT9rnN5/NjwfshH7bFMG4aZ2uqkpP H77lvjas6aO6BSi3x+yQZUz666Je+pmfOIoC1daRVa35WsaXXg2aC/IKqS2uBvoE8654 7nGIkcpgdsZTQFHi4xcqlShapv69wRchHeCEZq+GgqgYhFm6UEWQ7R8qynCZkR/0ZRTN WFAy05ZhqTgT98taZ8hpisUNenghZJzEYT0IqfpzlZ8p1pbdGTdLiuOmtxnxHcNaE1DP oxpEEnP46onHeQeg7w/FZKnl/3v3ONc2YNiqeYg0soChxnbkyiHFt9rDwBnOFpvZPpk2 grIA== X-Gm-Message-State: ALoCoQlqtzMcfnAOOkxvI5dQBmVQQDRzhk1Pxf/ede9OWvuLtwef56YIx9zQVxoj4zklFfyFR6+U X-Received: by 10.112.35.135 with SMTP id h7mr765289lbj.23.1424369693898; Thu, 19 Feb 2015 10:14:53 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.25.134 with SMTP id c6ls180531lag.103.gmail; Thu, 19 Feb 2015 10:14:53 -0800 (PST) X-Received: by 10.152.29.198 with SMTP id m6mr5290141lah.102.1424369693752; Thu, 19 Feb 2015 10:14:53 -0800 (PST) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id vh9si17813054lac.2.2015.02.19.10.14.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Feb 2015 10:14:53 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lams18 with SMTP id s18so1246893lam.11 for ; Thu, 19 Feb 2015 10:14:53 -0800 (PST) X-Received: by 10.112.181.41 with SMTP id dt9mr5328767lbc.56.1424369693133; Thu, 19 Feb 2015 10:14:53 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp662328lbj; Thu, 19 Feb 2015 10:14:52 -0800 (PST) X-Received: by 10.220.123.73 with SMTP id o9mr3300323vcr.77.1424369691175; Thu, 19 Feb 2015 10:14:51 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id cj18si12396603vdb.100.2015.02.19.10.14.50 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 19 Feb 2015 10:14:51 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YOVaf-0005Ej-HH; Thu, 19 Feb 2015 18:12:45 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YOVad-0005Da-0R for xen-devel@lists.xenproject.org; Thu, 19 Feb 2015 18:12:43 +0000 Received: from [85.158.143.35] by server-3.bemta-4.messagelabs.com id F8/58-29399-A9726E45; Thu, 19 Feb 2015 18:12:42 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-21.messagelabs.com!1424369561!11982094!1 X-Originating-IP: [209.85.212.182] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30403 invoked from network); 19 Feb 2015 18:12:41 -0000 Received: from mail-wi0-f182.google.com (HELO mail-wi0-f182.google.com) (209.85.212.182) by server-7.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 19 Feb 2015 18:12:41 -0000 Received: by mail-wi0-f182.google.com with SMTP id l15so11043561wiw.3 for ; Thu, 19 Feb 2015 10:12:41 -0800 (PST) X-Received: by 10.194.71.110 with SMTP id t14mr11868807wju.58.1424369559719; Thu, 19 Feb 2015 10:12:39 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id fo9sm31249051wib.16.2015.02.19.10.12.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Feb 2015 10:12:38 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 19 Feb 2015 18:12:04 +0000 Message-Id: <1424369524-16909-3-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424369524-16909-1-git-send-email-julien.grall@linaro.org> References: <1424369524-16909-1-git-send-email-julien.grall@linaro.org> Cc: ian.campbell@citrix.com, Julien Grall , tim@xen.org, stefano.stabellini@citrix.com, parth.dixit@linaro.org, christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH v4 2/2] xen/arm: Automatically find a PPI for the DOM0 event channel interrupt X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Use the new vgic interface to know which virtual PPI is free and use it for the event channel code. At the DOM0 creation time, Xen doesn't know which vIRQ will be free. All the vIRQ will be reserved when we parse the device tree. So we can allocate the vIRQ just after the device tree has been parsed. It's safe to defer the allocation because no vIRQ can be injected as long as the vCPU is not online. As the device tree node "hypervisor" containing the description of the event channel interrupt is created earlier, add a placeholder which will be fix up once Xen has allocated the PPI. Also correct the check in arch_domain_create to use is_hardware_domain. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- Changes in v4: - Add Ian's ack Changes in v3: - Create placeholder in make_hypervisor_node - Introduce a new function evtchn_fixup to allocate the interrupt and fixup the device tree - Use the newly function vgic_reserve_ppi - Typoes Changes in v2: - Correct the BUG_ON in arch_domain_create - Use if (...) BUG() rather than BUG_ON() --- xen/arch/arm/domain.c | 17 +++++++----- xen/arch/arm/domain_build.c | 51 +++++++++++++++++++++++++++++------- xen/arch/arm/platform.c | 7 ----- xen/arch/arm/platforms/xgene-storm.c | 1 - xen/include/asm-arm/platform.h | 4 --- 5 files changed, 53 insertions(+), 27 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 7a690b2..fdba081 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -542,13 +542,18 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags) if ( (rc = domain_vtimer_init(d)) != 0 ) goto fail; - if ( d->domain_id ) + /* + * The hardware domain will get a PPI later in + * arch/arm/domain_build.c depending on the + * interrupt map of the hardware. + */ + if ( !is_hardware_domain(d) ) + { d->arch.evtchn_irq = GUEST_EVTCHN_PPI; - else - d->arch.evtchn_irq = platform_dom0_evtchn_ppi(); - - if ( !vgic_reserve_virq(d, d->arch.evtchn_irq) ) - BUG(); + /* At this stage vgic_reserve_virq should never fail */ + if ( !vgic_reserve_virq(d, GUEST_EVTCHN_PPI) ) + BUG(); + } /* * Virtual UART is only used by linux early printk and decompress code. diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index c1df1fc..550193e 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -627,16 +627,10 @@ static int make_hypervisor_node(struct domain *d, return res; /* - * interrupts is evtchn upcall: - * - Active-low level-sensitive - * - All cpus - * - * TODO: Handle correctly the cpumask + * Placeholder for the event channel interrupt. The values will be + * replaced later. */ - DPRINT(" Event channel interrupt to %u\n", d->arch.evtchn_irq); - set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf, - DT_IRQ_TYPE_LEVEL_LOW); - + set_interrupt_ppi(intr, ~0, 0xf, DT_IRQ_TYPE_INVALID); res = fdt_property_interrupts(fdt, &intr, 1); if ( res ) return res; @@ -1277,6 +1271,43 @@ static void initrd_load(struct kernel_info *kinfo) } } +static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo) +{ + int res, node; + 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"); + + d->arch.evtchn_irq = res; + + printk("Allocating PPI %u for event channel interrupt\n", + d->arch.evtchn_irq); + + /* 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, + DT_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"); +} + int construct_dom0(struct domain *d) { struct kernel_info kinfo = {}; @@ -1338,6 +1369,8 @@ 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. */ diff --git a/xen/arch/arm/platform.c b/xen/arch/arm/platform.c index cb4cda8..d016797 100644 --- a/xen/arch/arm/platform.c +++ b/xen/arch/arm/platform.c @@ -160,13 +160,6 @@ bool_t platform_device_is_blacklisted(const struct dt_device_node *node) return dt_match_node(blacklist, node); } -unsigned int platform_dom0_evtchn_ppi(void) -{ - if ( platform && platform->dom0_evtchn_ppi ) - return platform->dom0_evtchn_ppi; - return GUEST_EVTCHN_PPI; -} - void platform_dom0_gnttab(paddr_t *start, paddr_t *size) { if ( platform && platform->dom0_gnttab_size ) diff --git a/xen/arch/arm/platforms/xgene-storm.c b/xen/arch/arm/platforms/xgene-storm.c index ef3ba63..eee650e 100644 --- a/xen/arch/arm/platforms/xgene-storm.c +++ b/xen/arch/arm/platforms/xgene-storm.c @@ -232,7 +232,6 @@ PLATFORM_START(xgene_storm, "APM X-GENE STORM") .quirks = xgene_storm_quirks, .specific_mapping = xgene_storm_specific_mapping, - .dom0_evtchn_ppi = 24, .dom0_gnttab_start = 0x1f800000, .dom0_gnttab_size = 0x20000, PLATFORM_END diff --git a/xen/include/asm-arm/platform.h b/xen/include/asm-arm/platform.h index eefaca6..4eba37b 100644 --- a/xen/include/asm-arm/platform.h +++ b/xen/include/asm-arm/platform.h @@ -38,10 +38,6 @@ struct platform_desc { */ const struct dt_device_match *blacklist_dev; /* - * The IRQ (PPI) to use to inject event channels to dom0. - */ - unsigned int dom0_evtchn_ppi; - /* * The location of a region of physical address space which dom0 * can use for grant table mappings. If size is zero defaults to * 0xb0000000-0xb0020000.