From patchwork Fri Feb 9 14:39:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127836 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp679768ljc; Fri, 9 Feb 2018 06:42:08 -0800 (PST) X-Google-Smtp-Source: AH8x22556FDHCEJLP9xNT1fkXbejnCMG/oEGJkFjLhJWs1ZHph4eHPeVw4QK+reDipD+292/p6DE X-Received: by 10.107.13.143 with SMTP id 137mr3397028ion.265.1518187328077; 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=NIx4hfyoBviIl6qJhznF+USasHdwx0SK+NgzuIU6wCPBR5oWH6HS/AUeZdUG+YsMVY i9Ejh7lF7flu8I9z07GOnDyxiAMfl9E0cGWHDX1AxvU5uAmTFVi/HUmjkQhKCYYRpigD UoSIS1NeJRE9b1ptZS99DIPSskG/mgufIhaIELQoZmQ8DPKXutoWpoT5jmcVa9s99s0g yOovLz/WRmxHcPYYAj3jlyFVJjRkjJ2LYP8/fRKA70gAoO+My3xSClTN/9I9kisPAtET 0Hodrdpoqtn9x7ymfUVYgBG1Zn1x8juhRTerFpddvjR4n4osl/Jg1mO2N0OK95ym9HG0 ukhQ== 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=slpj8S5EyctlQVHonH7ZNFwdp6+avaMU/Rqk1IMHfaw=; b=HR1cwXTKCMTCgDeNfjNgd2QaI8H4ZUr4JWsojgjzT9aoNX+DKx3zHizWgAa7OVp4Jp ywNiN8dOada04ZF9Ampf/iST+LJqDsKSIirNNPunj6vVy/HNJs3Syd+F0GrYG/6Ee/PX LpMbUueaEv55hrJczKbONGyEkxMMvhGVDICEdGGM8ENKdir/5VCJ7EL851GWcg/NBxN6 Eix46jsCzfStdrwhEIN77Xd1NPUjgR7P7QHg6oYOgh74/GIXWlwi6ZBaivHA9DmQM2yf OBwCTGjvIDN3NuAHkYAYxs9WXPcU4YFPAOOynC8CNJsoqqsSJDHM2nsiGIN9c7ayZgT2 vmRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IXrvk9uH; 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 c11si1416898ioe.324.2018.02.09.06.42.07 (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=IXrvk9uH; 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 1ek9qk-0001S4-KD; Fri, 09 Feb 2018 14:40:26 +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 1ek9qj-0001Ma-9W for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 14:40:25 +0000 X-Inumbo-ID: 1841750d-0da7-11e8-ba59-bc764e045a96 Received: from mail-wr0-x241.google.com (unknown [2a00:1450:400c:c0c::241]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 1841750d-0da7-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 15:39:55 +0100 (CET) Received: by mail-wr0-x241.google.com with SMTP id u60so5744548wrb.8 for ; Fri, 09 Feb 2018 06:40:24 -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=jT27bROa3NgPRC1uS3ixDgyq3qb2a5AVtK3oLBwlKoE=; b=IXrvk9uHkZKVffvKAdPRcXb8gGffuY4BJ3KMAEQaY3Y4CXX/86oSGDY4KGFrFesJsC 0Ir6owoxGhqBoCFZXYUvyfmFRDxuXRZSS8gzbUGKkMH5VOxINUkIFD2iB/RgX5fOxp/a e2kboYfOdaioLcGLDMBKkzYw5G5HxSyetuzlE= 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=jT27bROa3NgPRC1uS3ixDgyq3qb2a5AVtK3oLBwlKoE=; b=mff+gR7E+yU54M5XDT7o2J/0QQmWNGuJ1GqG/s5l2fyzVqjmWCx984rUK9HXlaYKGd YkdMIz3Me3hFWWHyQgozN3sQHycQYdPiWQPkNh8gLaQzGUGnOQtvqkKchaqLmI86TMTz bWkG/gMozhEIMqZE0WqSp9VUZ2fAFJ45W89PYuXWid9jzIVBefrCP9CCvwOVbulzXAOD l40yAcdJuGAD/I+NwUE65Pzk/oY91hI4J1TmJjLy2CWcB55WHwCl3UMsGqbp3TqKc7aM h3Rp1S5Vw/TCh6cyh6p+0xGiv2pIzzhxOEYIjXs+Mmrgh/B9jkoaZA7aGRrGXTiVT4fg MjXQ== X-Gm-Message-State: APf1xPCeQ50wr40J0HxDLvlnoO0jt5SyyG0WkKRPNdkNQEZJcM+NVRlX /ozvjNsFVHDr5DMUxuUj1LjKig== X-Received: by 10.223.184.102 with SMTP id u35mr2577045wrf.143.1518187223051; Fri, 09 Feb 2018 06:40:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:40:22 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org Date: Fri, 9 Feb 2018 14:39:24 +0000 Message-Id: <20180209143937.28866-37-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 36/49] ARM: new VGIC: Add SGIR register handler 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" Triggering an IPI via this register is v2 specific, so the implementation lives entirely in vgic-mmio-v2.c. This is based on Linux commit 55cc01fb9004, written by Andre Przywara. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic/vgic-mmio-v2.c | 47 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio-v2.c index c59f2c1ba7..3f67b4659a 100644 --- a/xen/arch/arm/vgic/vgic-mmio-v2.c +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -66,6 +66,51 @@ static void vgic_mmio_write_v2_misc(struct vcpu *vcpu, } } +static void vgic_mmio_write_sgir(struct vcpu *source_vcpu, + paddr_t addr, unsigned int len, + unsigned long val) +{ + struct domain *d = source_vcpu->domain; + int nr_vcpus = d->max_vcpus; + int intid = val & 0xf; + int targets = (val >> 16) & 0xff; + int mode = (val >> 24) & 0x03; + struct vcpu *vcpu; + unsigned long flags; + + switch (mode) + { + case 0x0: /* as specified by targets */ + break; + case 0x1: + targets = (1U << nr_vcpus) - 1; /* all, ... */ + targets &= ~(1U << source_vcpu->vcpu_id); /* but self */ + break; + case 0x2: /* this very vCPU only */ + targets = (1U << source_vcpu->vcpu_id); + break; + case 0x3: /* reserved */ + return; + } + + for_each_vcpu(d, vcpu) + { + struct vgic_irq *irq; + + if ( !(targets & (1U << vcpu->vcpu_id)) ) + continue; + + irq = vgic_get_irq(d, vcpu, intid); + + spin_lock_irqsave(&irq->irq_lock, flags); + irq->pending_latch = true; + irq->source |= 1U << source_vcpu->vcpu_id; + + vgic_queue_irq_unlock(d, irq, flags); + vgic_put_irq(d, irq); + } +} + static unsigned long vgic_mmio_read_target(struct vcpu *vcpu, paddr_t addr, unsigned int len) { @@ -151,7 +196,7 @@ static const struct vgic_register_region vgic_v2_dist_registers[] = { vgic_mmio_read_config, vgic_mmio_write_config, NULL, NULL, 2, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_LENGTH(GICD_SGIR, - vgic_mmio_read_raz, vgic_mmio_write_wi, 4, + 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,