From patchwork Fri Feb 9 14:39:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127843 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp679872ljc; Fri, 9 Feb 2018 06:42:15 -0800 (PST) X-Google-Smtp-Source: AH8x225TW+Va1SIte/ypAiE/MfY5fyQU+N013Gd5RYh6sAIzru6DO2GK2ndXjCbEHlBOeBKtAXFW X-Received: by 10.107.168.217 with SMTP id e86mr3468126ioj.14.1518187334927; Fri, 09 Feb 2018 06:42:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518187334; cv=none; d=google.com; s=arc-20160816; b=z7ac9FJbQZ3IdrrUnUxG3hzJZRky6DLWIbNIQMfULt1s4t88NEVyKXGZ5FHYVyzmYZ NWvQxQhIvStpuFUY2vMbJMpKD5PPybF52TYFS7MuwQA6M7Oj1xwvKnaXR9VwKzTjK5BN xLefhE6DMSoW+MqLyNtNRcD6QQy7Q4YKrWTo3xZwEv1SVl2b0Qq+grAzVIOTvyjOrU59 fwnbe8yidjhVx8RrZL3anhmsCTgVYIH28F8kseSpMknWm7yFFqzbPpvY62CFqXIkN6fF lAeTe1FKV1GbpR3lVnxxKiiwSZ7kWM0Zi+8Cp5elCqLhopHqk0d0rKaMJnQI1K305Pq7 orEg== 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=8SS+br5lru+JEC4ZuQJ7ROjV/RFgDfNlYa6vrJTvejc=; b=FvUZITc0OXKOiFwWfOOZIWHwcDHWoPaa7pluRO0wdszu/Ld01oJqdcOsK3mfD3MU/O 9kZ5cxzlmc/z+H9+6mOyRyMiFbRl2gogLruU2dnZzW2be35UAImh0MTQ+qopgBE6bhvZ VnFW0Bt2UDOo/eVmWnMza9oTH4niuZJQKqTgiZD8XGbtvAYl3FopM9TxlTr7+u5AU4M9 9iAiDnNmT+KZf8PxBUCzFwxTJDLCI9AJKT9vf7V6bKfKmZ4RXuQw7nhcWpz9ESXXSRN6 GaBGCbIfHoxz8tbPo1Y4nS+fUgwP5Bz7zZVqiQOKzW/lgskm1byVcEUpAcDktBWIqGvm Dmrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KZ+PwiIX; 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 n21si1681995itn.17.2018.02.09.06.42.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 06:42:14 -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=KZ+PwiIX; 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 1ek9qj-0001Nk-B2; Fri, 09 Feb 2018 14:40:25 +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 1ek9qi-0001IT-00 for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 14:40:24 +0000 X-Inumbo-ID: 17aee971-0da7-11e8-ba59-bc764e045a96 Received: from mail-wr0-x244.google.com (unknown [2a00:1450:400c:c0c::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 17aee971-0da7-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 15:39:55 +0100 (CET) Received: by mail-wr0-x244.google.com with SMTP id k32so1972081wrk.4 for ; Fri, 09 Feb 2018 06:40:23 -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=/MrqRb3EgTHOokotcN7rgQp/ZkPEyCUoMvkjTt2k9Ls=; b=KZ+PwiIXGHl0XR8PsyOF30iKx022Cs6plP67h3v9XNiljNIfQCAg/a21ORngky8usc Cty9BD4GhuhfXZ+xOJ4MO5QvAngSLMchvsVICRgJ+f6txFt2gzFSn11GiQb7MlN1c7NF d+7cYRlggn8WcJDq0bHCTx3ix/U3IxIuTdlck= 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=/MrqRb3EgTHOokotcN7rgQp/ZkPEyCUoMvkjTt2k9Ls=; b=i51ctbf4zh/YsjVMutoBaDoldtyAMp+cONfO0IhqokcfGj0n558MtikDA6CpryySyD mqAQ4PEOjUSx02MALJSqbPlCHytI9qHAghAENJQzYXV6nwY5G7jDxG3JDnsAXjBrRmVJ WFnWRyuE4eMpTvV0h1/edmwjM7mpnxoa0PcJOOwdE9m76Jp6zAApjHrJLXFhw2WcoqLR EzzxgUOxVU45eN37bZ1arnRzVztQPpKh48N47A+aUgkh2s7Ah8GyybehGQJlmgxe0wM+ fiTAjy3/TQpPe0+R5l6/loA8V5TFhW616Cxhu/4sYWfy2BiqYwrhvJyjJB5NF+DdNeGV 1MJQ== X-Gm-Message-State: APf1xPAeYi73ZUFu4HMDoVEdp0ZFc4aJM1PDnv4Lz+swfbKbJA3eAplM 2pkQSS0IonU8LlRhyjuC4Mgm+w== X-Received: by 10.223.146.66 with SMTP id 60mr2889870wrj.85.1518187222068; Fri, 09 Feb 2018 06:40:22 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:40:21 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org Date: Fri, 9 Feb 2018 14:39:23 +0000 Message-Id: <20180209143937.28866-36-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 35/49] ARM: new VGIC: Add TARGET registers 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" The target register handlers are v2 emulation specific, so their implementation lives entirely in vgic-mmio-v2.c. We copy the old VGIC behaviour of assigning an IRQ to the first VCPU set in the target mask instead of making it possibly pending on multiple VCPUs. This is based on Linux commit 2c234d6f1826, written by Andre Przywara. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic/vgic-mmio-v2.c | 52 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio-v2.c index c0b88b347e..c59f2c1ba7 100644 --- a/xen/arch/arm/vgic/vgic-mmio-v2.c +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -66,6 +66,56 @@ static void vgic_mmio_write_v2_misc(struct vcpu *vcpu, } } +static unsigned long vgic_mmio_read_target(struct vcpu *vcpu, + paddr_t addr, unsigned int len) +{ + u32 intid = VGIC_ADDR_TO_INTID(addr, 8); + 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->targets << (i * 8); + + vgic_put_irq(vcpu->domain, irq); + } + + return val; +} + +static void vgic_mmio_write_target(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val) +{ + u32 intid = VGIC_ADDR_TO_INTID(addr, 8); + u8 cpu_mask = GENMASK(vcpu->domain->max_vcpus - 1, 0); + int i; + unsigned long flags; + + /* GICD_ITARGETSR[0-7] are read-only */ + if ( intid < VGIC_NR_PRIVATE_IRQS ) + return; + + for ( i = 0; i < len; i++ ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, + NULL, intid + i); + int target; + + spin_lock_irqsave(&irq->irq_lock, flags); + + irq->targets = (val >> (i * 8)) & cpu_mask; + target = irq->targets ? (ffs(irq->targets) - 1) : 0; + irq->target_vcpu = vcpu->domain->vcpu[target]; + + 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, @@ -95,7 +145,7 @@ static const struct vgic_register_region vgic_v2_dist_registers[] = { vgic_mmio_read_priority, vgic_mmio_write_priority, NULL, NULL, 8, VGIC_ACCESS_32bit | VGIC_ACCESS_8bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ITARGETSR, - vgic_mmio_read_raz, vgic_mmio_write_wi, NULL, NULL, 8, + vgic_mmio_read_target, vgic_mmio_write_target, NULL, NULL, 8, VGIC_ACCESS_32bit | VGIC_ACCESS_8bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ICFGR, vgic_mmio_read_config, vgic_mmio_write_config, NULL, NULL, 2,