From patchwork Fri Feb 9 14:39:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127835 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp679780ljc; Fri, 9 Feb 2018 06:42:08 -0800 (PST) X-Google-Smtp-Source: AH8x226z4C3s1Auo4xGXNLLmuT22WevCiaEDDSIAvgk9WeLcSO3EuObUQzP/3W4Sx3s+9qVHp6Og X-Received: by 10.36.4.82 with SMTP id 79mr3667974itb.89.1518187328379; Fri, 09 Feb 2018 06:42:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518187328; cv=none; d=google.com; s=arc-20160816; b=B/93SI3+6rq4QIFJ1QV3cqLFcOoBx+wK09j1fZYacxrYG4hcMy3sIO/Z1TIjF38ROe ZZb1fM42FDWLxEOMIMnp28YSGrlMmRqpALaJcZSooOeEAJpboCz2O/2HMEG1bNzOEd1J Ny4ER6aCvPaOGDD79V6aCiwLSbNqiTlOewaKU6WvkIupW0g733VQMRdqHzWCyNceXxDo Swr7B/gSWEF4ukkVYGx5itkbQOSAczUiR0k6W2v/QnxOr4QuUr/zSvvXJII3MfEgrRss 2BR67fVfuQCxwpYKWZcfliM3Dh51JOCh71NNqrF0clheM4Qb+ZW902GeJOJoQHzJVBF7 XjqQ== 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:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=pgg8egc6r6/TSdXHYLZX/MaCVrvsespoA0c7b9A51d8=; b=xrsFq7FItoZEPwoLsYy6sVgFCPWQwbXC79OFPFIYE9JX6eWqRRub1Slepbo+IY/OXz SMUlTPFQ59bhp7A0gWyHD2dPu2hp86JjjevDmkk0fmflSr6LbMjBToL7O/92u1LZPCUz ROalHvjjxAIujAO8+yBrM8GlKpbM/Xjc7E3JnYxziZnrrufwQbafohT5SCtGujYeLXdj 0NaeU8ARBYdVHhHPArSedTn+zreK9kVZ4s2zzSAmicZXXyA2ojOPruYxOlaPBs5jWiYG wApS3xDq+7up/+EMqSNx2X0xWluVw9lbD0ubrD035Kdl6KTOi7stEY2JLVfkZ6Rr4F+/ klWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Hmo0hL/M; 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 t124si1666387itf.146.2018.02.09.06.42.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 06:42: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=Hmo0hL/M; 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 1ek9ql-0001WP-Rd; Fri, 09 Feb 2018 14:40:27 +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 1ek9qk-0001Rd-KL for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 14:40:26 +0000 X-Inumbo-ID: 18eaef88-0da7-11e8-ba59-bc764e045a96 Received: from mail-wr0-x243.google.com (unknown [2a00:1450:400c:c0c::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 18eaef88-0da7-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 15:39:57 +0100 (CET) Received: by mail-wr0-x243.google.com with SMTP id 111so5588577wrb.13 for ; Fri, 09 Feb 2018 06:40:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=2TDgL9PpUhytNU8lRsiKekfeJAkzR3w28LinIsqKmqc=; b=Hmo0hL/MPXR4yrTRyGYLmfKv6WKAmwSx70nQHIjFzxr/k2hTBhjBfh3Rh2EO3tdAoy 8quOX8E462NXCzTmQI98FZcwD34XOVpydm6CgLyhB3CLUbGbY5TgyyyEtW2UwO5FKSNq TD8Hw9PkhDtTqDnJLSSjnU26u+D18N1QHfpqY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=2TDgL9PpUhytNU8lRsiKekfeJAkzR3w28LinIsqKmqc=; b=LSTTr5x07DVMxJ1wisJcWgAkHRe7csDZdjvDSLDXdOG7xWoVjMVSPR2a4xzb97FUe9 PDcZ5r4Ae6r4y4D7cSLTPP5nj25+vPY9/gsW3VMjyEECq/9WMrX7KonijQn5ZFXSelZd RhGxTGjT98asZyLPk9vDuc5RkfrlDuJBem3qUMyToxSHf0Dq/YjRQtDxu2M4Y3Tccf0Y dshNi4lDMzWzCs5cf+vWYNrYhCdb9DuAbZcEd2gRoQjqqW5CBkZObEVRnmBFBv74qZeG Owl941G3w7hZrYp5cYOVSCimYkRLyTPL0jWw2I/gg4FAsJqrhbk7HgszXwe3RcY6fKpS ApKw== X-Gm-Message-State: APf1xPAPEXtxkQWjM/yFUoztjfwrSXabvwvWvV1WqvSEqsyEwdotiUGj 6Wyfv7k8KkqqZaTpVCNEemJEYA== X-Received: by 10.223.209.80 with SMTP id b16mr2758136wri.86.1518187224129; Fri, 09 Feb 2018 06:40:24 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id b35sm2552229wra.13.2018.02.09.06.40.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:40:23 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org Date: Fri, 9 Feb 2018 14:39:25 +0000 Message-Id: <20180209143937.28866-38-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180209143937.28866-1-andre.przywara@linaro.org> References: <20180209143937.28866-1-andre.przywara@linaro.org> Subject: [Xen-devel] [RFC PATCH 37/49] ARM: new VGIC: Add SGIPENDR register 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" 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 --- xen/arch/arm/vgic/vgic-mmio-v2.c | 77 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio-v2.c index 3f67b4659a..c62307c3aa 100644 --- a/xen/arch/arm/vgic/vgic-mmio-v2.c +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -161,6 +161,79 @@ 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) +{ + u32 intid = addr & 0x0f; + int i; + u64 val = 0; + + for ( i = 0; i < len; i++ ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, + vcpu, intid + i); + + val |= (u64)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) +{ + u32 intid = addr & 0x0f; + int i; + unsigned long flags; + + 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) +{ + u32 intid = addr & 0x0f; + int i; + unsigned long flags; + + 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, @@ -199,10 +272,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), };