From patchwork Mon Mar 5 16:04:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 130670 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2853758lja; Mon, 5 Mar 2018 08:07:08 -0800 (PST) X-Google-Smtp-Source: AG47ELsipWjWVnytMfYde8+RoAOin2NibmEKFT2en2IulSf6Cqmvt4GShoKxXKtAM+9iJwKEZNGa X-Received: by 10.107.24.194 with SMTP id 185mr18438691ioy.157.1520266028726; Mon, 05 Mar 2018 08:07:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520266028; cv=none; d=google.com; s=arc-20160816; b=dXyGKNS/nPOFCAdvkh6ObBFYViT/qZnGa1ZhikjeBinqI0wPWHVy/SiJyWTdwj9dPr so59fqDF3pK70PCWwGzas9wVOqKedCbDmQQH7wxlLbz5eUr0MhfZZqMALkN8u5ztZP4d pQQZGb+IBp7G1TMQ0OOoV0J5LYu/gT2LjYQZBC0zn8U247oRRvNTix8MW0Gs6bDotl+o Zx2y8OOOB++jhYGph6g4mBKoBjGMWaM1KqpNsDHzsb01ueY5oifyzxGjJgPTLKOB8XjE VArDBWU/R1mGbQVjzvK2OwuqonY5Vf0QykwJEsXKxRDTXvXSG0bNy7ycHVk4az9BBQ0J HvSg== 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=QPTMiWNLsbTDR4QUnJ6IynvcoDoz+90NPNhSTwkRlvs=; b=FWV27xSw9C895eAxoVwJk6ewGHJYLDJaCUNCR9eg9effZr+Uzlj7SsermlrjxroZqx Dc228V86sFWaTGeQPDMKc4+4/SN5W8vHbDtt42VAX1oHG9Xsal6pBqSeZpsmxj26Cuea Zjyay3tOlOAdAYJQ/ub3hgMDpbr8BcylRaLT7Vcq+f7FUQFUC1cUmfnEoSxbsw5L+Pm2 l119LVqkZQssGjd9rJRzNyiUZikZJpnykxRDCQOpozFkZK6BUOEXIcej6w/GgvqnZoMG BLxgHYiRF+WBooZ06aHMFWEOyeb1qi2Eq6fj+JNhxHUsy02JDPRQv2hiewnNR4+G5vwb IAUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hSXm4arY; 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 d85si9220613ioj.14.2018.03.05.08.07.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 08:07:08 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hSXm4arY; 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 1essc2-0000iG-IZ; Mon, 05 Mar 2018 16:05:18 +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 1essc1-0000f4-VY for xen-devel@lists.xenproject.org; Mon, 05 Mar 2018 16:05:18 +0000 X-Inumbo-ID: d5f452de-208e-11e8-ba59-bc764e045a96 Received: from mail-wr0-x242.google.com (unknown [2a00:1450:400c:c0c::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id d5f452de-208e-11e8-ba59-bc764e045a96; Mon, 05 Mar 2018 17:04:09 +0100 (CET) Received: by mail-wr0-x242.google.com with SMTP id k9so17806296wre.9 for ; Mon, 05 Mar 2018 08:05:14 -0800 (PST) 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=DXRI834Jm/ki88KkWlghhdu5QVCn6DzLSLwNIkj4H5E=; b=hSXm4arYrct7CYzJ9NqmljLvFNg5xkEM5ARXXMlNclQoaiCHBtte5nof0nV89KG3+J a8fk7w26kLFu2ieDKYiBszwc85Skd5Lxme21cyyrioSlLhXCqFNqO/Lvm2ypFcDYdnYf LF4rJhaV3f6ZUSyxeadnY40+wJs1tEY4EcKJk= 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=DXRI834Jm/ki88KkWlghhdu5QVCn6DzLSLwNIkj4H5E=; b=JiZLZtC002/fwRdKhAfboOGfKiV31fK6IA9X7+qzPNFcJotkfGGE4DdJJLZVu1/ZTf xmH/0LasLvTg2g9pTZ6ymCJvf4Dk5wyTBMCdtVJP4MXosg5XCdSw4h2Gv72ws8tytanM CFTPxlAEVy4BuSC94mggcgK1lYbXJzxfWZyk7el0HPz+wp7++nRPdLIYQ696q9f2jjH4 8FKDjitgIHX9C6TF3Wct8eXVPnOIMcfMiSNtFQOKRzq7ros13jxLrzbybMAFWuHG1keH EF/dYcwPUtJrg3NJulokG24SFDwgsGWQ1mPRvT6G5i/GuafVSHJ//87ktI28JQQWf2PZ VwaQ== X-Gm-Message-State: APf1xPCH3qvkgJitMdzRPjJTEBT45wOeGMad+LdbO2qWhAkvU++4szbr TaaDG32/4pzvyb2PgIZegr/RCw== X-Received: by 10.223.156.208 with SMTP id h16mr14046397wre.123.1520265913454; Mon, 05 Mar 2018 08:05:13 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id y6sm6574381wmy.14.2018.03.05.08.05.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Mar 2018 08:05:13 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 5 Mar 2018 16:04:08 +0000 Message-Id: <20180305160415.16760-51-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180305160415.16760-1-andre.przywara@linaro.org> References: <20180305160415.16760-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 50/57] 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 --- Changelog RFC ... v1: - actually implement arch_move_irqs() (instead of just stubbing it) xen/arch/arm/vgic/vgic.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index e1952c872d..5e767927c0 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -790,6 +790,48 @@ 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; + irq_desc_t *desc; + + 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) + desc = irq_to_desc(irq->hwintid); + else + desc = NULL; + + spin_unlock_irqrestore(&irq->irq_lock, flags); + + if ( desc ) + vgic_sync_hardware_irq(d, desc, irq); + + vgic_put_irq(d, irq); + } +} + struct irq_desc *vgic_get_hw_irq_desc(struct domain *d, struct vcpu *v, unsigned int virq) {