From patchwork Mon Mar 5 16:03:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 130664 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2853668lja; Mon, 5 Mar 2018 08:07:04 -0800 (PST) X-Google-Smtp-Source: AG47ELtdVLMGMEbHubdI6JGVy1lM4OOvRfdhUmcAG1Zlr/1Ojj6p9ukr4mmccwtKVN2Y2a5DJVZl X-Received: by 10.36.148.204 with SMTP id j195mr13944018ite.1.1520266024666; 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=pG6YOxHEP6QJX184PI79ipx8iraDccTlCBZXnxJykK9r9c7ZgXFQ9mQjwiHWUfZA6K w8rDfbqwA6ErcCNJIwV7RPA1Qc1mTyy4cPoY1+2t+Q80O2KebME30tve+42VK0RVUxqo VcUmMaIzFIv04hRTtEFI04X8IZlTdPHPs248s6jN3GPXuGUALPmXGIt2VKIwRuF2lCoL hL5Oem7MKwJqcoue7/QavcE1PGCtuRtt5x7XNNILCBt6gonockZo9/Ni6ok5KUHHBatL g2LRflLmWCJ+JqflRB8GQoI9yDQBFAgEMkE4orhtwMGWhqgOs8+2CJ3kpa/YfG3dcSEX 2eNg== 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=xehEk7WoXV7zjtZMCoH1iIjhrXUSSDLwv4ipI89d+8U=; b=VA0V0sHkJAI+XOwZDOkL0BiC7gzuuOd0W+1cVzEsHC7jT/e/j/taCz10ocFasn87Wu QdaDqqbYMvdP4w3Neg/q50ErbtghLUCuqPkQowjYkYHm3pr2QOu8UnDGfYbcQrvcepLe uv55BuXKgx0ACxjDHeRljSElSmS1hS+jTbK/yeWF3z8uiJ0wVjsU3UocmPzw6eyEVEm+ 2varG9hcuDOU1nWBUlxznfqf0yGahcFceVm76PGOZEh3KwEM8Avf67Pj++NgWEW/CixF niOxwqEVXsEjV/JyfSUw2PIN8KxYfJGQmgM3C/DL0jSbqThYoP+G1eD/ghzDCNpxlrk0 LZHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EariiYjc; 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 h25si6107869iti.144.2018.03.05.08.07.04 (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=EariiYjc; 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 1essbs-00006q-NH; Mon, 05 Mar 2018 16:05:08 +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 1essbq-0008S5-VU for xen-devel@lists.xenproject.org; Mon, 05 Mar 2018 16:05:07 +0000 X-Inumbo-ID: d0d1f81d-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 d0d1f81d-208e-11e8-ba59-bc764e045a96; Mon, 05 Mar 2018 17:04:00 +0100 (CET) Received: by mail-wm0-x242.google.com with SMTP id 188so16525262wme.1 for ; Mon, 05 Mar 2018 08:05:06 -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=i9zUtQoNyr4b1lxt9E+JAmw020QeBJCQljOeDCeAWMs=; b=EariiYjcDYXPFF2vinqUSjNbzXy17Iysay4OtY58Qoc7zm8Ni5ch3AA28Tg9iJiIEH d+K2idhyzKF3lXbm853RlRJvOw6qunvjoBWTdI97jSv4QkzGAshpZSNRrkbtVSeBLyei ezYfLxzSxlCUxPTdkbZNPshVs5eCweF1MR2Cw= 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=i9zUtQoNyr4b1lxt9E+JAmw020QeBJCQljOeDCeAWMs=; b=VbnEF+RyandkUPayjtSzvqP0FLqafnZXjreigQ6bynApO/utbVfrHq4nTmAbU9ZGwp qWFPM0vmjnSIrmdvV+clFoqd52SKwF1Hcn3USNcHIUg6zrUil74TFO823kIVJqMXMOY8 oIIWwdcdHErnXULcobDjEwRFrIMv/LzlQrKOrpIbLWvYB6xyi8BOVsCjNnQP6LzHCisJ N1yg02+t4F7dOsF9KAXxOROo6m/jgzN4wFeL/O6Efcs3PVPm8hD7EcZzbvkHfe02w/b6 rFMF5GpSZsvbKNZDjRpYc8+tle/yX37+10TNo0vD4+i8IipnmiVGEaSG+PPjrK7Qkr7M Cp3g== X-Gm-Message-State: AElRT7GYmmIMCdzDWdG7gAQ37drFhSIuort4s/J19Td5LNDUSdylCCqZ kXAlXMbX1/e50+KyyL/l4uhdPA== X-Received: by 10.28.135.142 with SMTP id j136mr9221119wmd.33.1520265904810; Mon, 05 Mar 2018 08:05:04 -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.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Mar 2018 08:05:04 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 5 Mar 2018 16:03:59 +0000 Message-Id: <20180305160415.16760-42-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 41/57] ARM: new VGIC: Add CONFIG 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 config 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. This is based on Linux commit 79717e4ac09c, written by Andre Przywara. Signed-off-by: Andre Przywara Reviewed-by: Julien Grall --- Changelog RFC ... v1: - use C99 data types xen/arch/arm/vgic/vgic-mmio-v2.c | 2 +- xen/arch/arm/vgic/vgic-mmio.c | 54 ++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic/vgic-mmio.h | 7 ++++++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio-v2.c index 29db9dec6f..d19ddd3f1e 100644 --- a/xen/arch/arm/vgic/vgic-mmio-v2.c +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -104,7 +104,7 @@ static const struct vgic_register_region vgic_v2_dist_registers[] = { vgic_mmio_read_raz, vgic_mmio_write_wi, 8, VGIC_ACCESS_32bit | VGIC_ACCESS_8bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ICFGR, - vgic_mmio_read_raz, vgic_mmio_write_wi, 2, + 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, diff --git a/xen/arch/arm/vgic/vgic-mmio.c b/xen/arch/arm/vgic/vgic-mmio.c index 538f08bc66..31f7cf706b 100644 --- a/xen/arch/arm/vgic/vgic-mmio.c +++ b/xen/arch/arm/vgic/vgic-mmio.c @@ -431,6 +431,60 @@ void vgic_mmio_write_priority(struct vcpu *vcpu, } } +unsigned long vgic_mmio_read_config(struct vcpu *vcpu, + paddr_t addr, unsigned int len) +{ + uint32_t intid = VGIC_ADDR_TO_INTID(addr, 2); + uint32_t value = 0; + int i; + + for ( i = 0; i < len * 4; i++ ) + { + struct vgic_irq *irq = vgic_get_irq(vcpu->domain, vcpu, intid + i); + + if ( irq->config == VGIC_CONFIG_EDGE ) + value |= (2U << (i * 2)); + + vgic_put_irq(vcpu->domain, irq); + } + + return value; +} + +void vgic_mmio_write_config(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val) +{ + uint32_t intid = VGIC_ADDR_TO_INTID(addr, 2); + int i; + unsigned long flags; + + for ( i = 0; i < len * 4; i++ ) + { + struct vgic_irq *irq; + + /* + * The configuration cannot be changed for SGIs in general, + * for PPIs this is IMPLEMENTATION DEFINED. The arch timer + * code relies on PPIs being level triggered, so we also + * make them read-only here. + */ + if ( intid + i < VGIC_NR_PRIVATE_IRQS ) + continue; + + irq = vgic_get_irq(vcpu->domain, vcpu, intid + i); + spin_lock_irqsave(&irq->irq_lock, flags); + + if ( test_bit(i * 2 + 1, &val) ) + irq->config = VGIC_CONFIG_EDGE; + else + irq->config = VGIC_CONFIG_LEVEL; + + spin_unlock_irqrestore(&irq->irq_lock, flags); + vgic_put_irq(vcpu->domain, irq); + } +} + 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 e3f9029344..bbf0d181ae 100644 --- a/xen/arch/arm/vgic/vgic-mmio.h +++ b/xen/arch/arm/vgic/vgic-mmio.h @@ -136,6 +136,13 @@ void vgic_mmio_write_priority(struct vcpu *vcpu, paddr_t addr, unsigned int len, unsigned long val); +unsigned long vgic_mmio_read_config(struct vcpu *vcpu, + paddr_t addr, unsigned int len); + +void vgic_mmio_write_config(struct vcpu *vcpu, + paddr_t addr, unsigned int len, + unsigned long val); + unsigned int vgic_v2_init_dist_iodev(struct vgic_io_device *dev); #endif