From patchwork Wed Mar 21 16:32:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 132209 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp2355930ljb; Wed, 21 Mar 2018 09:34:52 -0700 (PDT) X-Google-Smtp-Source: AG47ELvcM3+dibU04KQm8DR+q9ZH796JzrroCxAQSj/SMSJjT8OAzgkuidNKXTATO1WjWF21RfVd X-Received: by 10.107.131.207 with SMTP id n76mr19190342ioi.158.1521650092379; Wed, 21 Mar 2018 09:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521650092; cv=none; d=google.com; s=arc-20160816; b=WuCXYsgOffT1fNgFt8JK6evS2bp8be9dVUVUlbTLi+5jhYAMG5I7AfouoXcWkj1STA 6Yw68FVcJUsodZQSHERZSU2rACX6d/IkAHg9ci4SKdJIdlj5IbiYFFbQJz399aDkx8Ho woZGoJc6TWjPqrRr6ulhbx2OdYmCGBVwPk4rkPEr7jKLjBOCEcecQQVb7f2Oewsez7lL QPL8lNbW3rdNt1p+aptwShd6xKqmsrtAlRo1ZTDdqnJ5bxUBOO3iM8XOwpq04fpJU7L+ niHY3VyuizQBrg1MFO7d99FatCmbKzhtd5hEeTlEhVSAAr+yiyUrgUwSvudI0vpdHMrF GuUA== 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:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=ELkdz314nVkIXAgdgBA7Lnwfoz14Mg/qw2Kz/0JAUlk=; b=XYHyiDGWJ2BjoT4KIiwVLGHHlwH4uyRyzPvga57q6db8AE1DyMvWQwx1Lzfv7Z8pQC YeswOlyTo5/VhN8QSloODYahzwdPUF8Veyq+YM8nQxTzSOMwZYfeJKKZPYNZiULXQwxo +ZB82UYwftqMwrfT6xfTAsyxE73kNIRv9QQ185JuRwvZ9v65WXmQF0mq9Brpf+hLpSRS dR8zSHyl+D4DEUkUY6NqoH/eCC8Om0CJbPi8LQc2WzAXj2VOavkkvmkDPxYYKN2PDEcK akVwIlQVWELv4x/MQXQLgJ/58Rld6nZCAhDEzqwatofX2KbAUm0jhfPj5U/AGxgyU9sZ EJ/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=DcMtie7e; 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 e17-v6si3428649itd.13.2018.03.21.09.34.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Mar 2018 09:34:52 -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=DcMtie7e; 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.89) (envelope-from ) id 1eygfx-0002mW-LT; Wed, 21 Mar 2018 16:33:21 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1eygfu-0002fA-HI for xen-devel@lists.xenproject.org; Wed, 21 Mar 2018 16:33:18 +0000 X-Inumbo-ID: 85e2736e-2d25-11e8-9728-bc764e045a96 Received: from mail-wm0-x241.google.com (unknown [2a00:1450:400c:c09::241]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 85e2736e-2d25-11e8-9728-bc764e045a96; Wed, 21 Mar 2018 17:33:02 +0100 (CET) Received: by mail-wm0-x241.google.com with SMTP id l9so10911144wmh.2 for ; Wed, 21 Mar 2018 09:33:17 -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=9c+X9A02qNaDm5XYZBLBWAAqp7N8gYwBdNWW+Wcd0Hw=; b=DcMtie7ep8FBgK3qjTFcCU0HzDjX1UEg9GSY5MA9nfsOHSRqrgmIeeowybLqM/QI+z i3mdPphS3s/9d//o7mc+WXfRiHogXZPD2DHb1k8m8gNVF6f8K47ImqrG6QK12C426x7a OEOLut3enYItDgQf3drStV6YfdrHV+fL5RxaU= 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=9c+X9A02qNaDm5XYZBLBWAAqp7N8gYwBdNWW+Wcd0Hw=; b=cO0nDdDjaU4G6ZFCNlwVLhxXnyUPmahpAlHSVdR3exGo2CoanGSGICDkO15PaGZM7F vvJta/SHcaxEkd+eAyBjOsWoA5lY+iJtdqc/MnoeDDzHRgLtqOqNlaV3Dks3SKcfHXzg ykckuhNlxInpuXug34DTBL4rRutBZqUnZHMpv4ljZy21YtWMI4b151nFwIhy7y/Iiwsn GWnvCKjBEgzBM7OtV+skxJngusElou0xWxu7lMHhhQbY2iDxf8xdDqT0nxlyYiBayKXs qRRFHLLytf64gT+z5OqK73vIc8Tog79ckpr21bsRaSaWyNoGiAP4AIPH5VpPvQRJBOlu jXKA== X-Gm-Message-State: AElRT7HGssOmQjvg9BJ9iZEr2l7r9vQGuyCZlApiXcP0aYPj2M+vxqfd /t7UoN99NsE71LlNCYFfgWttGg== X-Received: by 10.28.69.133 with SMTP id l5mr2945990wmi.152.1521649996046; Wed, 21 Mar 2018 09:33:16 -0700 (PDT) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id n64sm4423724wmd.11.2018.03.21.09.33.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Mar 2018 09:33:15 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Wed, 21 Mar 2018 16:32:22 +0000 Message-Id: <20180321163235.12529-27-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180321163235.12529-1-andre.przywara@linaro.org> References: <20180321163235.12529-1-andre.przywara@linaro.org> Subject: [Xen-devel] [PATCH v3 26/39] ARM: new VGIC: Add SGIPENDR register handlers X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, Andre Przywara MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" As this register is v2 specific, its implementation lives entirely in vgic-mmio-v2.c. This register allows setting the source mask of an IPI. This is based on Linux commit ed40213ef9b0, written by Andre Przywara. Signed-off-by: Andre Przywara Reviewed-by: Julien Grall --- xen/arch/arm/vgic/vgic-mmio-v2.c | 81 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio-v2.c index 9ef80608c1..32e0f6fc33 100644 --- a/xen/arch/arm/vgic/vgic-mmio-v2.c +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -181,6 +181,83 @@ static void vgic_mmio_write_target(struct vcpu *vcpu, } } +static unsigned long vgic_mmio_read_sgipend(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; + + ASSERT(intid < VGIC_NR_SGIS); + + for ( i = 0; i < len; i++ ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, vcpu, intid + i); + + val |= (uint32_t)irq->source << (i * 8); + + vgic_put_irq(vcpu->domain, irq); + } + + return val; +} + +static void vgic_mmio_write_sgipendc(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val) +{ + uint32_t intid = VGIC_ADDR_TO_INTID(addr, 8); + unsigned int i; + unsigned long flags; + + ASSERT(intid < VGIC_NR_SGIS); + + for ( i = 0; i < len; i++ ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, vcpu, intid + i); + + spin_lock_irqsave(&irq->irq_lock, flags); + + irq->source &= ~((val >> (i * 8)) & 0xff); + if ( !irq->source ) + irq->pending_latch = false; + + spin_unlock_irqrestore(&irq->irq_lock, flags); + vgic_put_irq(vcpu->domain, irq); + } +} + +static void vgic_mmio_write_sgipends(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val) +{ + uint32_t intid = VGIC_ADDR_TO_INTID(addr, 8); + unsigned int i; + unsigned long flags; + + ASSERT(intid < VGIC_NR_SGIS); + + for ( i = 0; i < len; i++ ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, vcpu, intid + i); + + spin_lock_irqsave(&irq->irq_lock, flags); + + irq->source |= (val >> (i * 8)) & 0xff; + + if ( irq->source ) + { + irq->pending_latch = true; + vgic_queue_irq_unlock(vcpu->domain, irq, flags); + } + else + { + spin_unlock_irqrestore(&irq->irq_lock, flags); + } + 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, @@ -219,10 +296,10 @@ static const struct vgic_register_region vgic_v2_dist_registers[] = { vgic_mmio_read_raz, vgic_mmio_write_sgir, 4, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_LENGTH(GICD_CPENDSGIR, - vgic_mmio_read_raz, vgic_mmio_write_wi, 16, + vgic_mmio_read_sgipend, vgic_mmio_write_sgipendc, 16, VGIC_ACCESS_32bit | VGIC_ACCESS_8bit), REGISTER_DESC_WITH_LENGTH(GICD_SPENDSGIR, - vgic_mmio_read_raz, vgic_mmio_write_wi, 16, + vgic_mmio_read_sgipend, vgic_mmio_write_sgipends, 16, VGIC_ACCESS_32bit | VGIC_ACCESS_8bit), };