From patchwork Mon Mar 5 16:04:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 130663 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2853658lja; Mon, 5 Mar 2018 08:07:04 -0800 (PST) X-Google-Smtp-Source: AG47ELu3O5s1vwN6tIfzm4q3NRFODwEbDKp47/vodBHekELD0Sm71WD86OGaxgNK5YTUtZGo/LE4 X-Received: by 10.36.13.8 with SMTP id 8mr15137495itx.42.1520266024227; Mon, 05 Mar 2018 08:07:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520266024; cv=none; d=google.com; s=arc-20160816; b=yQEQYrw5jChbYQOG1+gs+BDNIt3n/rSuujvd0XtfA6UY39yvDc+3MmujU5wSF8PuSM m/Qf/lAnLQRIo5GfjNlsxTvmRNBiUadPvZR6G6v3YcdA52a8rd10uy5bYo8VHMJa/95y bvLGiBLHWhDS6iH+hl+YJc/O3B46M3mHQ3jOQmEPelaAOwFNQNqUsMka0BDtWjtDKUk+ TJ7vZORgmq+KnglLa15V05ameo5Ic8VeUw9q/bVRtP2cO70I57VISnFGRpin8K+09tGw BgaVnGdDsAJoH4aey+5u6dp45NbTE7qIr1fmeF21Ffj+5defxKHbPf3LYtFrv6/HdEk+ KZFg== 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=dTTJRwvoGxv+dOM1FSKM4HfxcjvakQXIoqsfRfgXeJA=; b=JMc8I/vXe2LudlLhlfZ13tyeClDbXNq8JnSCnqYkrMKVSiGXSydqeAGR5sErVN/sOT aHop4Ttn5kdywEY0GzSrviCq/f6jeSjPWa/H00E2GHosgagvhlzCjYuUcqlrfNPpRrdU 1NXDgs1aP64LGw3ExiDOS0e7dDglgwJ9DtcHtwNODMvVj/lhVrCV2b9vK8QP3UJd1ZZX wsHtrG+7cjLGI7Axttl8H/GLNNqx1C84kEEn3p+00aV+TAxA2WMD3vr0KtVACV9GSDzx oPPThd5voNIYmyIyIG7Ma1lBWejzyZbaGL7jkFAQFifB5S0J/S6mTL73aNK3cNTtH3za wyFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=H9bYIpwF; 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 n36si9092663ioe.138.2018.03.05.08.07.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 08:07:04 -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=H9bYIpwF; 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 1essbt-00009d-6T; Mon, 05 Mar 2018 16:05:09 +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-00006C-Kg for xen-devel@lists.xenproject.org; Mon, 05 Mar 2018 16:05:08 +0000 X-Inumbo-ID: d1f5df30-208e-11e8-ba59-bc764e045a96 Received: from mail-wm0-x242.google.com (unknown [2a00:1450:400c:c09::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id d1f5df30-208e-11e8-ba59-bc764e045a96; Mon, 05 Mar 2018 17:04:02 +0100 (CET) Received: by mail-wm0-x242.google.com with SMTP id t74so17014021wme.3 for ; Mon, 05 Mar 2018 08:05:07 -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=MEoK86IPDJQP+HmOvMQdWFqLzxuWOFOe5plzRmGy/lA=; b=H9bYIpwFBwS9MtqMMGY55MMrL94JnXGuH1EjuobSmGiCXIgXLQ1n0lgmtwGN5RyM56 CZ9+6gRMEqlF4j4xy6F1kk43bGfepjCmVipLN8/fT/fE4XQuJK6X+xvYW6Uk2RyIp8Zd xOEuFT2Nr6dzVRLNQKNMl1uste5cxl6+pBQ4M= 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=MEoK86IPDJQP+HmOvMQdWFqLzxuWOFOe5plzRmGy/lA=; b=VxDJIR2/iJDJaSvV7isEim1UekE4MqtycvogBKHkv/v/+stC2OXX9qiRXybHx2/gMh tMbiBrbZwCCnsinQVDBaywUuihidFYCqeBnDH7/HkwT2qwjhjcjQvaCuJrG3lmmdbdHU rtZscyikaRAlxXPUDwx7Guxsu2fMvQLCj3+TPb7+OKeQyq8FIEx8oHOfqsjmLN4Fslan 86kNeWXF9v/1+9g0SEdok6DpACpkz+TXvT2+FxNRXL2bAsdOtIwyuuK2EjqbTi4W0aYN 5PBkYlr6fiH1Lx96JexfrQE1vxK59I+lpvaDyYrfvErzTn/dUB0AP/VBG4Uch/bpCELA zd8Q== X-Gm-Message-State: AElRT7Ee1IKMtIRe6VrBHPfspT0CwZvs8HheOCV0aeKJGQDGkjCArirk w3tnKj9dVSHPpLlJYTRGBobpnw== X-Received: by 10.28.8.9 with SMTP id 9mr8111630wmi.54.1520265906716; Mon, 05 Mar 2018 08:05:06 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Mar 2018 08:05:06 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 5 Mar 2018 16:04:01 +0000 Message-Id: <20180305160415.16760-44-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 43/57] 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 --- Changelog RFC ... v1: - use symbolic names instead of magic values - iterates over set bits instead of every VCPU xen/arch/arm/vgic/vgic-mmio-v2.c | 47 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio-v2.c index 01c6a7198c..5f1fdb9a70 100644 --- a/xen/arch/arm/vgic/vgic-mmio-v2.c +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -72,6 +72,49 @@ 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; + unsigned int nr_vcpus = d->max_vcpus; + unsigned int intid = val & GICD_SGI_INTID_MASK; + unsigned long targets = (val & GICD_SGI_TARGET_MASK) >> + GICD_SGI_TARGET_SHIFT; + unsigned int vcpu_id; + + switch ( val & GICD_SGI_TARGET_LIST_MASK ) + { + case GICD_SGI_TARGET_LIST: /* as specified by targets */ + targets &= GENMASK(nr_vcpus, 0); /* limit to existing VCPUs */ + break; + case GICD_SGI_TARGET_OTHERS: + targets = GENMASK(nr_vcpus, 0); /* all, ... */ + targets &= ~(1U << source_vcpu->vcpu_id); /* but self */ + break; + case GICD_SGI_TARGET_SELF: /* this very vCPU only */ + targets = (1U << source_vcpu->vcpu_id); + break; + case 0x3: /* reserved */ + return; + } + + for_each_set_bit( vcpu_id, &targets, 8 ) + { + struct vcpu *vcpu = d->vcpu[vcpu_id]; + struct vgic_irq *irq = vgic_get_irq(d, vcpu, intid); + unsigned long flags; + + 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) { @@ -128,7 +171,7 @@ static void vgic_mmio_write_target(struct vcpu *vcpu, spin_unlock_irqrestore(&irq->irq_lock, flags); if ( desc ) - vgic_update_hardware_irq(desc, irq); + vgic_sync_hardware_irq(vcpu->domain, desc, irq); vgic_put_irq(vcpu->domain, irq); } @@ -169,7 +212,7 @@ static const struct vgic_register_region vgic_v2_dist_registers[] = { vgic_mmio_read_config, vgic_mmio_write_config, 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,