From patchwork Thu Mar 15 20:30:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 131869 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp1579603ljb; Thu, 15 Mar 2018 13:33:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELvOeir9Ta/pzoqJKz8yNwstaPRiRdYdZEIgED8P+GD9usfUaIzvftHqhXxIaFVVzD9UswL7 X-Received: by 2002:a24:ee8b:: with SMTP id b133-v6mr8266727iti.48.1521146022257; Thu, 15 Mar 2018 13:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521146022; cv=none; d=google.com; s=arc-20160816; b=DxN71zFCfmQvZdGmd7OYbvN0Bd60mMjQxvf8qyFW0DbD52XayjKsdDQ7un5XzVcRIU sZf4yU0e1p+933RQANjnuE9m6GpfzCGlGK6ivH20r46yQLMRNqtYvfhxU+yZ83L5LpIp Wfp6BD9Czsz3z4awWQdM6SlHRfReZhidj4PGsyFwrqvMUPxsri6kNZJU0EVvhXWgBM9/ VE3TdEt6FRKu3LURxEJixQzGS0jMRpBpnsNZFOc+uY/9+D1gSE54NO4VyEhmYOVkXclz MwAmBt+iUSpcevW9CF617i4kNe17qXZMfes1v/0UGCvMn9JT++mq1dvAW4kElmgSK+Ud ZL5Q== 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:dkim-signature:arc-authentication-results; bh=EwqmNEbIEbzYmy65pFYtrhSMCN2bLKP9Mc50DmF6Vu4=; b=OY/9IIhJtzO7iZ4Y7TKqoBuFW3OoBMZJm6sQpeDsQBtVf6/Pm7+PkGLkiCnR6U9o06 6IH2PfdmLr4v4hsZT8waUkfYwPmG5g3VuFo/BD/On0/MNcFJsog8wvLMsm9IYTtEFr0F +LXEe0Q9hZbCD54wkTaHz6A9yx5xxqnc/DFjtq0eWfmCw0PEICAACP2h8sj+zjkThl+0 bD8yxQ5tZiBZcsSZ3SQgCiZDAuRtq9CVPbx83wZ/IzQuDa2OR8XrjucudOPC1dlyjP26 ZSTJeC0ZbQAxJS0hUJJ6FlhoxZVVaWb/4Vk155q8JY7T3p+fgKao6DMkARKknXo/i4Gy qGPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YrPfpI+P; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v4si3639871iof.103.2018.03.15.13.33.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 13:33:42 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YrPfpI+P; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.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 1ewZXU-0004VX-72; Thu, 15 Mar 2018 20:31:52 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewZXS-0004RB-Ra for xen-devel@lists.xenproject.org; Thu, 15 Mar 2018 20:31:50 +0000 X-Inumbo-ID: dfbe1573-288f-11e8-9728-bc764e045a96 Received: from mail-wm0-x244.google.com (unknown [2a00:1450:400c:c09::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id dfbe1573-288f-11e8-9728-bc764e045a96; Thu, 15 Mar 2018 21:31:44 +0100 (CET) Received: by mail-wm0-x244.google.com with SMTP id n3so33174wmd.1 for ; Thu, 15 Mar 2018 13:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VBYNvnurpS7JBk1zIU12bJUD3OFxXNFHPM7TmR5P1pE=; b=YrPfpI+PBNIgNU33dM3j9xgSbO6cUH9ZTpWamKA5iGihelrj4C46iG8RePo2ypKxmD tfsFT2b7jKMBOoVLBYSnv5ml7CQ85CdZhq+64uIgHRHtbuTqoVduPLvcPQSlo0u9+mgW alZhtfxCGT1ofPDKgz9TtrHQlSQ+P8Rf58jao= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VBYNvnurpS7JBk1zIU12bJUD3OFxXNFHPM7TmR5P1pE=; b=uHboEeWlXwBIHBzF7KPCem0ArSqcZFa6b2CoE9RAujokp3bNUhcZtLabkEH1op/XKJ S3ec/azry4AzpTLpKMbQdFpT8opaRfp4BgkSGx4fVtP3wF/Mndtf09DngPFV/DG6dmL7 9ZZxm7aTiYRhQM/FEByimj8jYbSm15uIYtE3AI5DFb78yB+eToSwACdKzpThWhmdbaFR XMu3Di8kKfyQAKW+Lnnak6oHwJyKux0oDgfISmjssBteYnRk4gARuHk36df3F9E4kHhc cmn5yCgPfy+WZuYzbj28f4ovKs63flR8DZe5CPFuLQAnpP1OSAIyPryVbFhJGQ8zouJh Crew== X-Gm-Message-State: AElRT7Fz1OHJjeQCOVW6Z7Eeoopna0qwGnSGdMHq3JemWHrMWnqKTEUi GtJn5fnSMlyF+Jn+rQXWff4VaA== X-Received: by 10.28.150.14 with SMTP id y14mr6251678wmd.5.1521145908455; Thu, 15 Mar 2018 13:31:48 -0700 (PDT) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id w125sm3217102wmw.20.2018.03.15.13.31.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Mar 2018 13:31:48 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 15 Mar 2018 20:30:43 +0000 Message-Id: <20180315203050.19791-39-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180315203050.19791-1-andre.przywara@linaro.org> References: <20180315203050.19791-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v2 38/45] ARM: new VGIC: Implement arch_move_irqs() 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" When a VCPU moves to another CPU, we need to adjust the target affinity of any hardware mapped vIRQs, to observe our "physical-follows-virtual" policy. Implement arch_move_irqs() to adjust the physical affinity of all hardware mapped vIRQs targetting this VCPU. Signed-off-by: Andre Przywara Reviewed-by: Julien Grall --- Changelog v1 ... v2: - use irq_set_affinity() directly, avoid vgic_sync_hardware_irq() and lock xen/arch/arm/vgic/vgic.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index 73cd43f0fa..1aae68ff83 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -781,6 +781,45 @@ void gic_dump_vgic_info(struct vcpu *v) spin_unlock_irqrestore(&v->arch.vgic.ap_list_lock, flags); } +/** + * arch_move_irqs() - migrate the physical affinity of hardware mapped vIRQs + * @v: the vCPU, already assigned to the new pCPU + * + * arch_move_irqs() updates the physical affinity of all virtual IRQs + * targetting this given vCPU. This only affects hardware mapped IRQs. The + * new pCPU to target is already set in v->processor. + * This is called by the core code after a vCPU has been migrated to a new + * physical CPU. + */ +void arch_move_irqs(struct vcpu *v) +{ + struct domain *d = v->domain; + unsigned int i; + + /* We only target SPIs with this function */ + for ( i = 0; i < d->arch.vgic.nr_spis; i++ ) + { + struct vgic_irq *irq = vgic_get_irq(d, NULL, i + VGIC_NR_PRIVATE_IRQS); + unsigned long flags; + + if ( !irq ) + continue; + + spin_lock_irqsave(&irq->irq_lock, flags); + + /* only vIRQs that are not on a vCPU yet , but targetting this vCPU */ + if ( irq->hw && !irq->vcpu && irq->target_vcpu == v) + { + irq_desc_t *desc = irq_to_desc(irq->hwintid); + + irq_set_affinity(desc, cpumask_of(v->processor)); + } + + spin_unlock_irqrestore(&irq->irq_lock, flags); + vgic_put_irq(d, irq); + } +} + struct irq_desc *vgic_get_hw_irq_desc(struct domain *d, struct vcpu *v, unsigned int virq) {