From patchwork Fri Feb 9 14:39:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127848 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp679949ljc; Fri, 9 Feb 2018 06:42:19 -0800 (PST) X-Google-Smtp-Source: AH8x226IzOXr8+zayNZKYLmscQDm6sDIFJjs54OxaXRqYFDiWMz5RzIIq+8GBLJ7E3P2z6EGX/kY X-Received: by 10.36.67.67 with SMTP id s64mr3696517itb.131.1518187339263; Fri, 09 Feb 2018 06:42:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518187339; cv=none; d=google.com; s=arc-20160816; b=hYKSGv5TKzoOR9XLqekALOfB4NZHdzUxpz4icN7WeclsfBhaw5H4HddiZaa+OspACi 6nI72ndqPc+IzbRtsqtXT4zU5QN5C2wNA9X1DaXuhHjRXfpT6SQ7Djs/buUK1rW9+9jf 2JoqAqMO4Gj/22IOhnbn/VeUfRcQgbx83aH+h4AuaS9we2jSf1LG8f4Xw/5wPKdUKq8+ JjRXfn5x9llzWgWTc6fGLYD+VeejsceNF01Pyk9j7SeBnQDMROSZVNkB8ZdtzDpchOXC 3aAC7qYpbuj0MamuBLl1jscaNnHOzQkFJyBRpdG3gqoe1rrKtqs0gE5yue4g2bQdI575 PdVg== 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=3q+oqnDc2++Q9jz3XTIQPbgqc331bkPZLqnrh2ofBRM=; b=YOS5xWFGlaO2Zvz1QikpeD9X8El6iOkpueH4Y4Eaz3C+4MxoyCFIYMcktgGuSUXnv8 cSc4oh785xW2ICqiKKZbc6X88LDCznVifDhIuMO1Z4GpnSNrXoAWeM+gyVuia6cEchjo kQpWA1NfnXkiHAzYMTXoCeLSSMjSCBKbeYHmxjutcKygLHTQhPR3wKx+ktlqzCCpPN+T MeLemiJWaoChDJ2/ueXSEHfA4OAj1ZjT2VumBRpB8gV++VacHZmYBMfjE7uic1lvWV7q xDKL42IqvbZ/yLCk0HrhPW5rgZsAQrTzY2byTUWMZ+zY8YQ1CyF1nlbvj7HhfoLle6OW r2Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MUJ6h0Kw; 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 j84si963886iod.105.2018.02.09.06.42.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 06:42:19 -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=MUJ6h0Kw; 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 1ek9qg-0001Dg-De; Fri, 09 Feb 2018 14:40:22 +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 1ek9qf-00019Z-16 for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 14:40:21 +0000 X-Inumbo-ID: 15da5b5a-0da7-11e8-ba59-bc764e045a96 Received: from mail-wr0-x242.google.com (unknown [2a00:1450:400c:c0c::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 15da5b5a-0da7-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 15:39:52 +0100 (CET) Received: by mail-wr0-x242.google.com with SMTP id v65so1678932wrc.11 for ; Fri, 09 Feb 2018 06:40:20 -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=xFKBa46uwvgdPkraM67loD3dcuCWBlyV/8+EJKTDiAQ=; b=MUJ6h0KwX1QmxTSL0jkM4oelNUul2GL2ehG8AlPd6oVa0M+sLz/ODxuCz1bxkHjAnx NjXZK+7jWT+maOMx8sUIvaK6LdeYTgim13uoDxSULQexfOIWe6K+cXAlKVr0ynhn8otY Wmq8n7VU7kXyDm/fy/09UHHL2IBCEKE1AzLmM= 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=xFKBa46uwvgdPkraM67loD3dcuCWBlyV/8+EJKTDiAQ=; b=ayH1S/FOyXC8gLXlEPMQA82q4XZvBPLE3wlanTCWLSNP49bC5UkpNRTgkRkhektBgh efk1UZkFLbqTfrt3WsVA92gUzmVY/K6WBoQ/2/xKcrdb4jNoCQsMevomjFiuwfkNtBmp fGVK5SRoTNhxCUq31jojn1XF4Hls6LumWekzlH4zJpbNdbvjk9J8PIjhllW1SozkNNCa JEerKvYCWLo9RdNIwDj0s2X6C466fDFFxO+HW6ZrGhNaKnSqxzg3P53YXK+WPiy/snOJ 6TphcTukUCWDQVnYLRZWeL7OFiLcUFmOCk/vDcXpSDwZWH8MpfLMRXZc0jh9jDzta5er jl5g== X-Gm-Message-State: APf1xPB4DoW3XwFHlaS+IT5NV0QWN8IvgyYsvib9U+AHXKkgZExhtuyX Ht5KZU3ot3QL8JTrN/gsdtvYuQ== X-Received: by 10.223.135.65 with SMTP id 1mr2696179wrz.238.1518187218975; Fri, 09 Feb 2018 06:40:18 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:40:18 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org Date: Fri, 9 Feb 2018 14:39:20 +0000 Message-Id: <20180209143937.28866-33-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 32/49] ARM: new VGIC: Add ACTIVE 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 active register handlers are shared between the v2 and v3 emulation, so their implementation goes into vgic-mmio.c, to be easily referenced from the v3 emulation as well later. Since activation/deactivation of an interrupt may happen entirely in the guest without it ever exiting, we need some extra logic to properly track the active state. For clearing the active state, we would basically have to halt the guest to make sure this is properly propagated into the respective VCPUs. This is not yet implemented in Xen. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic/vgic-mmio-v2.c | 4 +- xen/arch/arm/vgic/vgic-mmio.c | 94 ++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic/vgic-mmio.h | 11 +++++ 3 files changed, 107 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio-v2.c index ceb86900a0..eba24d9866 100644 --- a/xen/arch/arm/vgic/vgic-mmio-v2.c +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -86,10 +86,10 @@ static const struct vgic_register_region vgic_v2_dist_registers[] = { vgic_mmio_read_pending, vgic_mmio_write_cpending, NULL, NULL, 1, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ISACTIVER, - vgic_mmio_read_raz, vgic_mmio_write_wi, NULL, NULL, 1, + vgic_mmio_read_active, vgic_mmio_write_sactive, NULL, NULL, 1, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ICACTIVER, - vgic_mmio_read_raz, vgic_mmio_write_wi, NULL, NULL, 1, + vgic_mmio_read_active, vgic_mmio_write_cactive, NULL, NULL, 1, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_IPRIORITYR, vgic_mmio_read_raz, vgic_mmio_write_wi, NULL, NULL, 8, diff --git a/xen/arch/arm/vgic/vgic-mmio.c b/xen/arch/arm/vgic/vgic-mmio.c index 9a65e39d78..ac3aa03fbc 100644 --- a/xen/arch/arm/vgic/vgic-mmio.c +++ b/xen/arch/arm/vgic/vgic-mmio.c @@ -215,6 +215,100 @@ void vgic_mmio_write_cpending(struct vcpu *vcpu, } } +unsigned long vgic_mmio_read_active(struct vcpu *vcpu, + paddr_t addr, unsigned int len) +{ + u32 intid = VGIC_ADDR_TO_INTID(addr, 1); + u32 value = 0; + int i; + + /* Loop over all IRQs affected by this read */ + for ( i = 0; i < len * 8; i++ ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, vcpu, intid + i); + + if ( irq->active ) + value |= (1U << i); + + vgic_put_irq(vcpu->domain, irq); + } + + return value; +} + +static void vgic_mmio_change_active(struct vcpu *vcpu, struct vgic_irq *irq, + bool new_active_state) +{ +} + +static void vgic_change_active_prepare(struct vcpu *vcpu, u32 intid) +{ +} + +static void vgic_change_active_finish(struct vcpu *vcpu, u32 intid) +{ +} + +static void __vgic_mmio_write_cactive(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val) +{ + u32 intid = VGIC_ADDR_TO_INTID(addr, 1); + int i; + + for_each_set_bit( i, &val, len * 8 ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, vcpu, intid + i); + vgic_mmio_change_active(vcpu, irq, false); + vgic_put_irq(vcpu->domain, irq); + } +} + +void vgic_mmio_write_cactive(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val) +{ + u32 intid = VGIC_ADDR_TO_INTID(addr, 1); + + spin_lock(&vcpu->domain->domain_lock); + vgic_change_active_prepare(vcpu, intid); + + __vgic_mmio_write_cactive(vcpu, addr, len, val); + + vgic_change_active_finish(vcpu, intid); + spin_unlock(&vcpu->domain->domain_lock); +} + +static void __vgic_mmio_write_sactive(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val) +{ + u32 intid = VGIC_ADDR_TO_INTID(addr, 1); + int i; + + for_each_set_bit( i, &val, len * 8 ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, vcpu, intid + i); + vgic_mmio_change_active(vcpu, irq, true); + vgic_put_irq(vcpu->domain, irq); + } +} + +void vgic_mmio_write_sactive(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val) +{ + u32 intid = VGIC_ADDR_TO_INTID(addr, 1); + + spin_lock(&vcpu->domain->domain_lock); + vgic_change_active_prepare(vcpu, intid); + + __vgic_mmio_write_sactive(vcpu, addr, len, val); + + vgic_change_active_finish(vcpu, intid); + spin_unlock(&vcpu->domain->domain_lock); +} + static int match_region(const void *key, const void *elt) { const unsigned int offset = (unsigned long)key; diff --git a/xen/arch/arm/vgic/vgic-mmio.h b/xen/arch/arm/vgic/vgic-mmio.h index 209afbbb9a..39e854232e 100644 --- a/xen/arch/arm/vgic/vgic-mmio.h +++ b/xen/arch/arm/vgic/vgic-mmio.h @@ -159,6 +159,17 @@ void vgic_mmio_write_cpending(struct vcpu *vcpu, paddr_t addr, unsigned int len, unsigned long val); +unsigned long vgic_mmio_read_active(struct vcpu *vcpu, + paddr_t addr, unsigned int len); + +void vgic_mmio_write_cactive(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val); + +void vgic_mmio_write_sactive(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val); + unsigned int vgic_v2_init_dist_iodev(struct vgic_io_device *dev); /* Find the proper register handler entry given a certain address offset */