From patchwork Mon Mar 5 16:04:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 130657 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2853593lja; Mon, 5 Mar 2018 08:07:01 -0800 (PST) X-Google-Smtp-Source: AG47ELvBx5lvJ+PohJV57L6mnh586H0sc8pOkfYPvoEx2wQa8eFTD8pVjgnw4gqTeWWu+lyeYvLI X-Received: by 10.36.105.84 with SMTP id e81mr13739345itc.123.1520266021381; Mon, 05 Mar 2018 08:07:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520266021; cv=none; d=google.com; s=arc-20160816; b=gK70yjHe9YHWuxU3lJSyqEcVcRb1jy0mLMe68ZERau6HnVdtphbqebAMxr+/bqW/Kw v57AM9fkO68BeSPqQBB1sahu0RXCE5XSvUwfYP9OLIsjVWm9SUJ7bGYNdSZMmA/G7muF UtqJ4NYIsDEZqnRs9sutLA/mJmB9IVSAyEQwbJREqX8KPHBD8DoULXdXIkr/z6j1dMt9 9jqF2Qw1USgW1Sqaf020fQ5BkX/AdwXmudcyVhXmjHO8+hzBaqvrspnTx+Amge41sxdy ZDSCsaggX2sCENvYwppO/Y3kdgKU9Fz8VjzxMkZi8EPtbl09hZ/tuOfubAzJu5X3TaZZ jBVw== 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=4SnVu72MZ08Bhfrxk5wLWDaoS6Uj2MonlN+ikPNRpGc=; b=M29C6v4JVYgwXxIo6PVd8EjBfuiNY/Jwi/GxuDG4Yw3Rj8riMlCmWTfBz/RMhLMVtE 3NW1KNKwaIzXZkcJCl68O6poSMXyZtCa0XvNJv5rzz3MMHee5+FdYTWhKRTJwoLuCpyu 44hOJxxwOVVmoUwqWzgCUIWprhM+FvETENpWW4ey8yiXzHDMfj+Wn2kVv0J74k9yTQCN cFt05b2Hh5swYJhP92A4To3LvWQNqX8E95bxzYYzBnsgF4yZYF3pIuz1qfu/N8mxNGFv HYxU0R7pq5p1EPt/RFJ/05flL+1rJj6xsV2m1CawVPVnjjx9hZqM4Qzemecq8AVNn7z3 WUnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BZ4QhB0U; 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 f202si5914227itf.30.2018.03.05.08.07.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 08:07:01 -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=BZ4QhB0U; 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 1essbv-0000HE-Ew; Mon, 05 Mar 2018 16:05:11 +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 1essbt-0000CT-SN for xen-devel@lists.xenproject.org; Mon, 05 Mar 2018 16:05:09 +0000 X-Inumbo-ID: d2995e78-208e-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 d2995e78-208e-11e8-ba59-bc764e045a96; Mon, 05 Mar 2018 17:04:03 +0100 (CET) Received: by mail-wr0-x243.google.com with SMTP id n7so17841092wrn.5 for ; Mon, 05 Mar 2018 08:05:08 -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=8D0oPKAL72HN6Ww3lAkxwoVx24eilc+w6ULkoi94gfw=; b=BZ4QhB0U3qb2c1SvgIr87TVC1DJOgOJCHyWgOBBYw117iAzO/UTuQajxDhlpZXANh8 YripCdkfpYJSgzLFtiLxNOfqWzbRiUAJKhHEzG5dinxwt3FuQu/l29+eI/FQcfCx0JWd fKrSd6YUGv2wYjIteVUqynczPLE0q4bb/gFYg= 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=8D0oPKAL72HN6Ww3lAkxwoVx24eilc+w6ULkoi94gfw=; b=e5/UG09zXy1tp9q5g9yz40FS6FVYs9pbYF4KNgkyS6uKx/OVPiVT2muaBwmlBLqVx8 xJmTMYJEoSVmvEp9vsmNTEkWTNY92++8u/EwkWyOaBRyi2M0QJBSdrxHbccT7C6SbhLa HSfWlvvEJ3pRw2BgY1Z8zvJui0oB3RoeVpN2aHH2jKGtGoGO+5+aHTqJqnOqmMnmHAUt Rxu9lLL7QXFNJVbyZFrE00AsGRKkLDJchQgPpC92jL9e1FcD/57vrOs6wzrAABDh3e5h 8NpbWNnBRT1ykb8MWw2L0qSt+Q+9d+EblG5SP3MGGdvYQ1J0eA+62dcHoKLwq7agYzS2 +kjg== X-Gm-Message-State: APf1xPDdTcgDSQ+S0xRh1M0STBI4Cc0JhLc/1AAMfJ9DtStqb2RdFXpo dJpgJcDG/pBuDDJWgsj36Ge6iw== X-Received: by 10.223.136.164 with SMTP id f33mr12894343wrf.77.1520265907652; Mon, 05 Mar 2018 08:05:07 -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.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Mar 2018 08:05:07 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 5 Mar 2018 16:04:02 +0000 Message-Id: <20180305160415.16760-45-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 44/57] 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 Reviewed-by: Julien Grall --- Changelog RFC ... v1: - use C99 and unsigned data types 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 5f1fdb9a70..dd9857e8a6 100644 --- a/xen/arch/arm/vgic/vgic-mmio-v2.c +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -177,6 +177,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, @@ -215,10 +292,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), };