From patchwork Thu Jan 29 15:51:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 43946 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 66E752410D for ; Thu, 29 Jan 2015 15:54:06 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id b6sf21598219lbj.0 for ; Thu, 29 Jan 2015 07:54:03 -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=OQY+eYjTmveNZ2ec6fRvtIBSzBDzkUDR/gw2RgDELB4=; b=eTvwzNwGz55+CT2Ee2avT//mL6u0fRKspGGvX12WPxLdf+sZDBwKPnA6fhyLngP8x3 p4JOKM0YghxeV78FADX0Ye4/Npmw3dAaLLhTPQZm3TKkr9SdSTPejH7zRJdkKLJv4rt5 T0Y2EoncEH4h/liyVobVj7+Xe1hhjUR4XWBTaq2EkUuhrM3vdJcrXpqYiyvGgeMXuzXy lkzZeyXQ7h9CqNR3xrUqTGmLybW6JpdT1agj98BXoHuEPVdjv91Zk4KFSDk/oQD+cn4k hwl1cFPwVJzmkNvlO13fIr7EPcTpnkNy3TCE7EddKUYQLyeQ0OfrnhdyZyxUFNecqbF2 RKQw== X-Gm-Message-State: ALoCoQkmyRLMCT6vBnsrpWha4TyFkyBToSUSziWNghbZUt04OCWDsXXO+LmKkaRWN2TjKfcByxIz X-Received: by 10.112.175.10 with SMTP id bw10mr198845lbc.7.1422546842985; Thu, 29 Jan 2015 07:54:02 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.25.134 with SMTP id c6ls296356lag.103.gmail; Thu, 29 Jan 2015 07:54:02 -0800 (PST) X-Received: by 10.112.235.67 with SMTP id uk3mr1721217lbc.48.1422546842740; Thu, 29 Jan 2015 07:54:02 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id kl8si7778757lbc.86.2015.01.29.07.54.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 07:54:02 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id f15so29610290lbj.5 for ; Thu, 29 Jan 2015 07:54:02 -0800 (PST) X-Received: by 10.152.44.228 with SMTP id h4mr1615760lam.31.1422546842310; Thu, 29 Jan 2015 07:54:02 -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 h5csp1804506lbj; Thu, 29 Jan 2015 07:54:01 -0800 (PST) X-Received: by 10.221.44.193 with SMTP id uh1mr597554vcb.54.1422546840566; Thu, 29 Jan 2015 07:54:00 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id qo7si3632972vcb.72.2015.01.29.07.53.59 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Jan 2015 07:54:00 -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 1YGrO7-0006T1-Hy; Thu, 29 Jan 2015 15:52:11 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YGrO6-0006R3-3V for xen-devel@lists.xenproject.org; Thu, 29 Jan 2015 15:52:10 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id 71/81-03000-9275AC45; Thu, 29 Jan 2015 15:52:09 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-3.tower-21.messagelabs.com!1422546728!12962967!1 X-Originating-IP: [209.85.212.171] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3739 invoked from network); 29 Jan 2015 15:52:08 -0000 Received: from mail-wi0-f171.google.com (HELO mail-wi0-f171.google.com) (209.85.212.171) by server-3.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 29 Jan 2015 15:52:08 -0000 Received: by mail-wi0-f171.google.com with SMTP id l15so28067719wiw.4 for ; Thu, 29 Jan 2015 07:52:08 -0800 (PST) X-Received: by 10.180.109.193 with SMTP id hu1mr1237027wib.25.1422546728579; Thu, 29 Jan 2015 07:52:08 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id be2sm10975469wjb.38.2015.01.29.07.52.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 07:52:07 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 29 Jan 2015 15:51:34 +0000 Message-Id: <1422546694-22797-3-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422546694-22797-1-git-send-email-julien.grall@linaro.org> References: <1422546694-22797-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 v3 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.217.174 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 --- 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 5cb4258..97ace7e 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -543,13 +543,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.