From patchwork Mon Mar 5 16:04:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 130681 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2853994lja; Mon, 5 Mar 2018 08:07:19 -0800 (PST) X-Google-Smtp-Source: AG47ELu5qkoK/RNYvjMY46K0ZKFqysmKsh4xxks6nOipHea3CF0kEu1TopLRxOu7o5rf4REEOw2E X-Received: by 10.36.222.214 with SMTP id d205mr14044412itg.125.1520266038915; Mon, 05 Mar 2018 08:07:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520266038; cv=none; d=google.com; s=arc-20160816; b=yCDlxzTOt214ves07H3NjfeGa57GkWLmPcCykygfdiTs4xTC3B9FEswoSt4K4va1WI rb0XP5f9BTFTR461xHpX4mNYsSVOpL2PhpmHXqs4uZLHVdcvb7FaI8rIgHdTvyjjbBT/ jR1ssUThHsuG1WqTOZ/27vJCDowvpRrp4txQnKM+jFZwl1iDpjz/OWdSgk4nt2wwuar7 dnETuL9MsAXogsyb45DrZEgu8ylZay2qA1a9v3KikiFVqmi6jCQGbVBg2eC73CqfRxf8 oqq8uM+genCU6qJMvCLMyKCCnnWVSuSL8FyyxCoS9l0SL9ZlhYxmmPTvHzP+bI9Kennv Z18A== 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=oQkhcdV24sOForAsrsJHyezf+pcLeeuc58Q0SUTqGmg=; b=yrRnJAVSAukkabra2ov6NtUpbevX9jqn3jy7sbT0vhZEKLxd/K61dXk/I+/Dn5uJau +Bu19/e11l3azTgRHsPSI5l01VnG54FNXyGW4OVBxK9kUAvZyPOCtJFKH7CnKKtrouQo L4FI9gdbx6Yw6nI3ONMSz94eUhSF5UfqHDgFJY+hpTRcs/wH1b//MWEEi4D66Voi8a5/ fLI9VMeaDZFc33jXGzU2TYK0c0e09qi5/GPvtybb7qgLzP0+f18zYfZGhqmgSYz1m/1c TiTezZrbTpBuYyVErp1annyq25odwJ6SK1seavLyCm9Sc2G4P4gz5F46nwZWoQNmb13x HpBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WpXgrbzA; 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 r65si6237970ith.151.2018.03.05.08.07.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 08:07:18 -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=WpXgrbzA; 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 1essbs-000081-Vo; Mon, 05 Mar 2018 16:05:08 +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 1essbs-000059-B9 for xen-devel@lists.xenproject.org; Mon, 05 Mar 2018 16:05:08 +0000 X-Inumbo-ID: d162e2bc-208e-11e8-ba59-bc764e045a96 Received: from mail-wm0-x243.google.com (unknown [2a00:1450:400c:c09::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id d162e2bc-208e-11e8-ba59-bc764e045a96; Mon, 05 Mar 2018 17:04:01 +0100 (CET) Received: by mail-wm0-x243.google.com with SMTP id i3so16517636wmi.4 for ; Mon, 05 Mar 2018 08:05:06 -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=I0bJiQNUrztdobTL4GKnefUIfyulpZ1riJLCfNt5pao=; b=WpXgrbzA2VO6WRG/xcIeCufz7Pv5EK2kLT+T/XUbHtCZVWV0MXuEq5Y8R5u+KXEvBA mhTdrl3wlgmHP29HeSMR/19J9WKFeBaqXW1JfIqSXnXSY4ORaDx+Y5ZVR9r+vXQ6GSkb IP2M2vXHnXOW3ug+URbhA3cuSGVlxES6ioPOg= 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=I0bJiQNUrztdobTL4GKnefUIfyulpZ1riJLCfNt5pao=; b=fCFUPLf4nYsrkVYWEeFZqxVoKG5tph/gg3x/xOhzVYunDsiRyL4nF5ZVnWDLlOg2vi Nfvh6jOjLYSxiEyDNe6Zg9X2gV0ZCMVxeWhWnTGN4SM5ix7G29g5NtpKqRY+YMKkZ8Fb JH4GwcMLAKrZpO0iAPYrt0UFhMErM7vi7rx8nQYxcC5rAV3zlh4fmhOp56BcMB6jH1w6 12L2NsOvGaL5lgaK8Fx+6h0IsZLHXwiOfgkPJJn0WwcUh7OrLOG8wvTi7OJzveDLyttt PmxjBro/jO3jcD7/MX1274qiJ56SBnxMcjzI/z0TJIGF3uc1vQsDjLk8hW95hzpb5q3f u9Vg== X-Gm-Message-State: AElRT7Gx+XETzLvwhuFQ1G3RO19X0vMBz/K1fCm0oZlHeBSOm//gIgoD TWMLGiZuJLNK7IsR6LMh+JPlZvw084Y= X-Received: by 10.28.84.19 with SMTP id i19mr8070478wmb.7.1520265905758; Mon, 05 Mar 2018 08:05:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Mar 2018 08:05:05 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 5 Mar 2018 16:04:00 +0000 Message-Id: <20180305160415.16760-43-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 42/57] ARM: new VGIC: Add TARGET registers handlers 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" The target register handlers are v2 emulation specific, so their implementation lives entirely in vgic-mmio-v2.c. We copy the old VGIC behaviour of assigning an IRQ to the first VCPU set in the target mask instead of making it possibly pending on multiple VCPUs. We update the physical affinity of a hardware mapped vIRQ on the way. This is based on Linux commit 2c234d6f1826, written by Andre Przywara. Signed-off-by: Andre Przywara --- Changelog RFC ... v1: - propagate affinity changes to hardware mapped IRQs xen/arch/arm/vgic/vgic-mmio-v2.c | 64 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio-v2.c index d19ddd3f1e..01c6a7198c 100644 --- a/xen/arch/arm/vgic/vgic-mmio-v2.c +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -72,6 +72,68 @@ static void vgic_mmio_write_v2_misc(struct vcpu *vcpu, } } +static unsigned long vgic_mmio_read_target(struct vcpu *vcpu, + paddr_t addr, unsigned int len) +{ + uint32_t intid = VGIC_ADDR_TO_INTID(addr, 8); + uint32_t val = 0; + unsigned int i; + + for ( i = 0; i < len; i++ ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, vcpu, intid + i); + + val |= (uint32_t)irq->targets << (i * 8); + + vgic_put_irq(vcpu->domain, irq); + } + + return val; +} + +static void vgic_mmio_write_target(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val) +{ + uint32_t intid = VGIC_ADDR_TO_INTID(addr, 8); + uint8_t cpu_mask = GENMASK(vcpu->domain->max_vcpus - 1, 0); + unsigned int i; + unsigned long flags; + + /* GICD_ITARGETSR[0-7] are read-only */ + if ( intid < VGIC_NR_PRIVATE_IRQS ) + return; + + for ( i = 0; i < len; i++ ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, NULL, intid + i); + struct irq_desc *desc; + + spin_lock_irqsave(&irq->irq_lock, flags); + + irq->targets = (val >> (i * 8)) & cpu_mask; + if ( irq->targets ) + { + irq->target_vcpu = vcpu->domain->vcpu[ffs(irq->targets) - 1]; + if ( irq->hw ) + desc = irq_to_desc(irq->hwintid); + else + desc = NULL; + } + else { + irq->target_vcpu = NULL; + desc = NULL; + } + + spin_unlock_irqrestore(&irq->irq_lock, flags); + + if ( desc ) + vgic_update_hardware_irq(desc, irq); + + vgic_put_irq(vcpu->domain, irq); + } +} + static const struct vgic_register_region vgic_v2_dist_registers[] = { REGISTER_DESC_WITH_LENGTH(GICD_CTLR, vgic_mmio_read_v2_misc, vgic_mmio_write_v2_misc, 12, @@ -101,7 +163,7 @@ static const struct vgic_register_region vgic_v2_dist_registers[] = { vgic_mmio_read_priority, vgic_mmio_write_priority, 8, VGIC_ACCESS_32bit | VGIC_ACCESS_8bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ITARGETSR, - vgic_mmio_read_raz, vgic_mmio_write_wi, 8, + vgic_mmio_read_target, vgic_mmio_write_target, 8, VGIC_ACCESS_32bit | VGIC_ACCESS_8bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ICFGR, vgic_mmio_read_config, vgic_mmio_write_config, 2,