From patchwork Wed Jan 29 11:46:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 23829 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CDEFD202FA for ; Wed, 29 Jan 2014 11:48:47 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id w17sf3643183vbj.5 for ; Wed, 29 Jan 2014 03:48:47 -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:date:from:to:in-reply-to:message-id :references:user-agent:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=CemXLmmEVp0krRyKvj18xDLavDcWiCQtAcbWP/iVPWQ=; b=NfSx4NTujqXQUk86bS8Nu6IxHZ8+z+QbDxeH0D/DvhpFuNpYt13uzxTw3qfUivlmrn 71wQ867tDBR8xEoB0XwvkkMwlRGMeKQzwujYNVPEw1aFSmf3fihLx1PW9JIEBljd2H86 /y69YNFGFoa7RNe9PfAWwZoEwl8+uKM/7ls0zErOMfo5po9mSmCIIpuJt53OQ8R5mlWl i4iw2u+lW6TjgUnWXsoR2UI2OlU86vz4V280d6d5+X7jStGRAunPnNTGU/0ENFP0aP9b cyXmdUDdzQPeZMVCpLAgt+V/lrWcgw8Dme4bqQ5DyxSkofELm7ys4DFuWdg4VluVzFRd eIQw== X-Gm-Message-State: ALoCoQnwaiDv6PdLvcbrxpSegg4Oxe2t6e7xDGBhoEpELbWdkIfNGYvMexKlDiRdow+xMl+WXLY7 X-Received: by 10.236.41.234 with SMTP id h70mr2261578yhb.42.1390996126971; Wed, 29 Jan 2014 03:48:46 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.82.49 with SMTP id g46ls78553qgd.88.gmail; Wed, 29 Jan 2014 03:48:46 -0800 (PST) X-Received: by 10.220.251.73 with SMTP id mr9mr6211317vcb.2.1390996126830; Wed, 29 Jan 2014 03:48:46 -0800 (PST) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by mx.google.com with ESMTPS id kp12si719409vcb.16.2014.01.29.03.48.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 03:48:46 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.42; Received: by mail-vb0-f42.google.com with SMTP id i3so1096556vbh.29 for ; Wed, 29 Jan 2014 03:48:46 -0800 (PST) X-Received: by 10.58.37.67 with SMTP id w3mr1908206vej.22.1390996126744; Wed, 29 Jan 2014 03:48:46 -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.220.174.196 with SMTP id u4csp106350vcz; Wed, 29 Jan 2014 03:48:46 -0800 (PST) X-Received: by 10.140.48.104 with SMTP id n95mr10404224qga.90.1390996126064; Wed, 29 Jan 2014 03:48:46 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id x3si1506497qat.175.2014.01.29.03.48.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 29 Jan 2014 03:48:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) 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 1W8TbT-0003pI-Ae; Wed, 29 Jan 2014 11:46:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1W8TbR-0003pB-Iy for xen-devel@lists.xen.org; Wed, 29 Jan 2014 11:46:45 +0000 Received: from [85.158.137.68:14712] by server-10.bemta-3.messagelabs.com id 04/6E-07302-42AE8E25; Wed, 29 Jan 2014 11:46:44 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1390996002!12041592!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 32701 invoked from network); 29 Jan 2014 11:46:44 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-2.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 29 Jan 2014 11:46:44 -0000 X-IronPort-AV: E=Sophos;i="4.95,741,1384300800"; d="scan'208";a="95651745" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 29 Jan 2014 11:46:41 +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; Wed, 29 Jan 2014 06:46:41 -0500 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1W8TbM-0008Mb-MM; Wed, 29 Jan 2014 11:46:40 +0000 Date: Wed, 29 Jan 2014 11:46:36 +0000 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: Stefano Stabellini In-Reply-To: Message-ID: References: <1390844023-23123-1-git-send-email-oleksandr.tyshchenko@globallogic.com> <52E69CBC.3090207@linaro.org> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-DLP: MIA1 Cc: Oleksandr Tyshchenko , Julien Grall , Ian Campbell , xen-devel@lists.xen.org Subject: Re: [Xen-devel] [PATCH v1 0/2] xen/arm: maintenance_interrupt SMP fix 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: , 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: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: On Wed, 29 Jan 2014, Stefano Stabellini wrote: > On Wed, 29 Jan 2014, Oleksandr Tyshchenko wrote: > > Hello all, > > > > I just recollected about one hack which we created > > as we needed to route HW IRQ in domU. > > > > diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c > > index 9d793ba..d0227b9 100644 > > --- a/tools/libxl/libxl_create.c > > +++ b/tools/libxl/libxl_create.c > > @@ -989,8 +989,6 @@ static void domcreate_launch_dm(libxl__egc *egc, > > libxl__multidev *multidev, > > > > LOG(DEBUG, "dom%d irq %d", domid, irq); > > > > - ret = irq >= 0 ? xc_physdev_map_pirq(CTX->xch, domid, irq, &irq) > > - : -EOVERFLOW; > > if (!ret) > > ret = xc_domain_irq_permission(CTX->xch, domid, irq, 1); > > if (ret < 0) { > > diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c > > index 2e4b11f..b54c08e 100644 > > --- a/xen/arch/arm/vgic.c > > +++ b/xen/arch/arm/vgic.c > > @@ -85,7 +85,7 @@ int domain_vgic_init(struct domain *d) > > if ( d->domain_id == 0 ) > > d->arch.vgic.nr_lines = gic_number_lines() - 32; > > else > > - d->arch.vgic.nr_lines = 0; /* We don't need SPIs for the guest */ > > + d->arch.vgic.nr_lines = gic_number_lines() - 32; /* We do > > need SPIs for the guest */ > > > > d->arch.vgic.shared_irqs = > > xzalloc_array(struct vgic_irq_rank, DOMAIN_NR_RANKS(d)); > > diff --git a/xen/common/domctl.c b/xen/common/domctl.c > > index 75e2df3..ba88901 100644 > > --- a/xen/common/domctl.c > > +++ b/xen/common/domctl.c > > @@ -29,6 +29,7 @@ > > #include > > #include > > #include > > +#include > > > > static DEFINE_SPINLOCK(domctl_lock); > > DEFINE_SPINLOCK(vcpu_alloc_lock); > > @@ -782,8 +783,11 @@ long > > do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) > > ret = -EINVAL; > > else if ( xsm_irq_permission(XSM_HOOK, d, pirq, allow) ) > > ret = -EPERM; > > - else if ( allow ) > > - ret = pirq_permit_access(d, pirq); > > + else if ( allow ) { > > + struct dt_irq irq = {pirq + NR_LOCAL_IRQS,0}; > > + ret = pirq_permit_access(d, irq.irq); > > + gic_route_irq_to_guest(d, &irq, ""); > > + } > > else > > ret = pirq_deny_access(d, pirq); > > } > > (END) > > > > It seems, the following patch can violate the logic about routing > > physical IRQs only to CPU0. > > In gic_route_irq_to_guest() we need to call gic_set_irq_properties() > > where the one of the parameters is cpumask_of(smp_processor_id()). > > But in this part of code this function can be executed on CPU1. And as > > result this can cause to the fact that the wrong value would set to > > target CPU mask. > > > > Please, confirm my assumption. > > That is correct. > > > > If I am right we have to add a basic HW IRQ routing to DomU in a right way. > > We could add the cpumask parameter to gic_route_irq_to_guest. Or maybe > for now we could just hardcode the cpumask of cpu0 > gic_route_irq_to_guest. > > However keep in mind that if you plan on routing SPIs to guests other > than dom0, receiving all the interrupts on cpu0 might not be great for > performances. Thinking twice about it, it might be the only acceptable change for 4.4. diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index e6257a7..af96a31 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -776,8 +795,7 @@ int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq, level = dt_irq_is_level_triggered(irq); - gic_set_irq_properties(irq->irq, level, cpumask_of(smp_processor_id()), - 0xa0); + gic_set_irq_properties(irq->irq, level, cpumask_of(0), 0xa0); retval = __setup_irq(desc, irq->irq, action); if (retval) {