From patchwork Fri Feb 9 14:39:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127819 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp679545ljc; Fri, 9 Feb 2018 06:41:55 -0800 (PST) X-Google-Smtp-Source: AH8x225ncLebIuUaal+x17yUrxwPLudMHFLUcBfULDxFRdiLfkaSdBA/Ta3HhjJqHzhsjfHGxd8W X-Received: by 10.36.61.142 with SMTP id n136mr3842387itn.6.1518187315627; Fri, 09 Feb 2018 06:41:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518187315; cv=none; d=google.com; s=arc-20160816; b=rPSFN7A1i9ZFjTGV/fo+FHy03w4+MwZFMwpV2UfmGS7wNQW+mhe8WBkW+b4GTH+Ufr 2tX1PmvBDQ2rHX51SiAIfVJX5yD9ZKgEsXERywLscZiwf8R0IJjq/f6efOzs06VbTIpy IwO9GO3rJscd2ORb3/oiyv6NDujd/Nomd3QYvauodVcRWv+7wwpTbjBE2J4YZNhOKDMP GZNfzsAe7SVCj+fXaWlzeAC2dk/jHYiBvXlSR9RaBtx3MmPKQ7xt1oBhg3tsOZrTPlPx jEIYrjDhi+SdglR7f42NP6U7nBb9G/Eo0YWhMGrtinUw6dSQe/ozpmoQbtcktkc+MgAg RzBg== 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=WOMD2u4ZHA6gmyfhppSCCC5YUb0qkYr1J23N+4K1wCg=; b=rG66W5l5GeDWmTuqfc5dtakAl8rhAjmvWrHphVkh/Q/6vrmK2k5wYr7iyEIBV/dQN8 w3Q1VgISjEWmka3TYlb6dZmvmDWWDOKuto0CzGNXEWebDmU20KTc0FWZcmXmlVFqySHE zSGh7z74vSLCIw40PVbKFCdJi9wBFDiDoy2iBkXDtTvIrSU+ycJp+G7bUCrOnu0ZdD8y euAcOLt4pS9xgfBSmHsjSwU6K4t/YrJ2zYAj6k8I6r7K536emp1j20SIABOUfoueWenP uIoW4hrkrSVrhWFlKSRjGUB2po8/2Hifr5qhZyLbNXlnrGh3JyoxmB+gfjUvKD6roUhp Od3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ROxxNXc9; 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 q1si1680049iof.47.2018.02.09.06.41.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 06:41:55 -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=ROxxNXc9; 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 1ek9qc-00010Q-Bx; Fri, 09 Feb 2018 14:40:18 +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 1ek9qb-0000xB-CZ for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 14:40:17 +0000 X-Inumbo-ID: 135fd8e4-0da7-11e8-ba59-bc764e045a96 Received: from mail-wm0-x243.google.com (unknown [2a00:1450:400c:c09::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 135fd8e4-0da7-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 15:39:47 +0100 (CET) Received: by mail-wm0-x243.google.com with SMTP id f3so16718374wmc.1 for ; Fri, 09 Feb 2018 06:40:15 -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=btlY8oGVZRk5p1ASpEsi1ac+DDQgJgZl9vIM3InTkiM=; b=ROxxNXc93nTqhzt5aFGTHF3jg6V/NWd4dFP2Z9oZNVQs+q/HBvWcmi3/sheb6OeK/i iYDL9tm0HP8bBnChL5Cic8p7nUpxDtyYvZRAGn5EXX47jpBTgN0wQvU5LIJTgBwDAPX1 2kxR6S+Bem/1Z21YirV+qvtjlujIp1hG4TYUI= 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=btlY8oGVZRk5p1ASpEsi1ac+DDQgJgZl9vIM3InTkiM=; b=sOOSiIiosurj2CEFOizhKi5WULuGnMHOtHE+fQt6jYOZM5xzViunHFQz9SiV3XlHqd eHPzBFnDVYn1JszqgHKc/ODJbKZKiL5WHoiz+19FSPxowaKqoejHdAkkl2WjNiKEg7V7 B0T+jU5xQHTTgaHneU2AKz75cfDSnhRFvzQBTcvA7OErgslUvTsKdgruU2BPt7pzCsvm kft4nZU6aMOZ5fObKyXQMqJR2L8kg4ot6m2cYFYiBG70+Q/pL9n6s8L7SjZJCnej6WU3 CeeW+Np2tCQqDn0QwxHF/nU2oU28SGaz1cdlucVgEM+PvBCssoP+6+PvFIyflAWkspV7 S4Xw== X-Gm-Message-State: APf1xPBu9sL0iNc7mbcPia37EMDI10gl9RObsxkvgWDd4+dLXxcOtLH6 iuFVq/24j3AT4bUZPdaFn90bBw== X-Received: by 10.28.241.4 with SMTP id p4mr2089654wmh.103.1518187214793; Fri, 09 Feb 2018 06:40:14 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:40:14 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org Date: Fri, 9 Feb 2018 14:39:16 +0000 Message-Id: <20180209143937.28866-29-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 28/49] ARM: new VGIC: Add GICv2 MMIO handling framework 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" Create vgic-mmio-v2.c to describe GICv2 emulation specific handlers using the initializer macros provided by the VGIC MMIO framework. Provide a function to register the GICv2 distributor registers to the Xen MMIO framework. The actual handler functions are still stubs in this patch. This is based on Linux commit fb848db39661, written by Andre Przywara. Signed-off-by: Andre Przywara --- xen/arch/arm/vgic/vgic-mmio-v2.c | 83 ++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic/vgic-mmio.c | 26 +++++++++++++ xen/arch/arm/vgic/vgic-mmio.h | 2 + xen/arch/arm/vgic/vgic.h | 2 + 4 files changed, 113 insertions(+) create mode 100644 xen/arch/arm/vgic/vgic-mmio-v2.c diff --git a/xen/arch/arm/vgic/vgic-mmio-v2.c b/xen/arch/arm/vgic/vgic-mmio-v2.c new file mode 100644 index 0000000000..ee685a5a07 --- /dev/null +++ b/xen/arch/arm/vgic/vgic-mmio-v2.c @@ -0,0 +1,83 @@ +/* + * VGICv2 MMIO handling functions + * Imported from Linux ("new" KVM VGIC) and heavily adapted to Xen. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include + +#include "vgic.h" +#include "vgic-mmio.h" + +static const struct vgic_register_region vgic_v2_dist_registers[] = { + REGISTER_DESC_WITH_LENGTH(GICD_CTLR, + vgic_mmio_read_raz, vgic_mmio_write_wi, 12, + VGIC_ACCESS_32bit), + REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_IGROUPR, + vgic_mmio_read_rao, vgic_mmio_write_wi, NULL, NULL, 1, + VGIC_ACCESS_32bit), + REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ISENABLER, + vgic_mmio_read_raz, vgic_mmio_write_wi, NULL, NULL, 1, + VGIC_ACCESS_32bit), + REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ICENABLER, + vgic_mmio_read_raz, vgic_mmio_write_wi, NULL, NULL, 1, + VGIC_ACCESS_32bit), + REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ISPENDR, + vgic_mmio_read_raz, vgic_mmio_write_wi, NULL, NULL, 1, + VGIC_ACCESS_32bit), + REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ICPENDR, + vgic_mmio_read_raz, vgic_mmio_write_wi, 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_ACCESS_32bit), + REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ICACTIVER, + vgic_mmio_read_raz, vgic_mmio_write_wi, 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, + 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_ACCESS_32bit | VGIC_ACCESS_8bit), + REGISTER_DESC_WITH_BITS_PER_IRQ(GICD_ICFGR, + vgic_mmio_read_raz, vgic_mmio_write_wi, NULL, NULL, 2, + VGIC_ACCESS_32bit), + REGISTER_DESC_WITH_LENGTH(GICD_SGIR, + vgic_mmio_read_raz, vgic_mmio_write_wi, 4, + VGIC_ACCESS_32bit), + REGISTER_DESC_WITH_LENGTH(GICD_CPENDSGIR, + vgic_mmio_read_raz, vgic_mmio_write_wi, 16, + VGIC_ACCESS_32bit | VGIC_ACCESS_8bit), + REGISTER_DESC_WITH_LENGTH(GICD_SPENDSGIR, + vgic_mmio_read_raz, vgic_mmio_write_wi, 16, + VGIC_ACCESS_32bit | VGIC_ACCESS_8bit), +}; + +unsigned int vgic_v2_init_dist_iodev(struct vgic_io_device *dev) +{ + dev->regions = vgic_v2_dist_registers; + dev->nr_regions = ARRAY_SIZE(vgic_v2_dist_registers); + + return SZ_4K; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/vgic/vgic-mmio.c b/xen/arch/arm/vgic/vgic-mmio.c index 3c70945466..59703a6909 100644 --- a/xen/arch/arm/vgic/vgic-mmio.c +++ b/xen/arch/arm/vgic/vgic-mmio.c @@ -182,6 +182,32 @@ struct mmio_handler_ops xen_io_gic_ops = { .write = dispatch_mmio_write, }; +int vgic_register_dist_iodev(struct domain *d, paddr_t dist_base_address, + enum vgic_type type) +{ + struct vgic_io_device *io_device = &d->arch.vgic.dist_iodev; + int ret = 0; + unsigned int len; + + switch (type) + { + case VGIC_V2: + len = vgic_v2_init_dist_iodev(io_device); + break; + default: + BUG_ON(1); + } + + io_device->base_addr = dist_base_address; + io_device->iodev_type = IODEV_DIST; + io_device->redist_vcpu = NULL; + + register_mmio_handler(d, &xen_io_gic_ops, dist_base_address, len, + io_device); + + return ret; +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/vgic/vgic-mmio.h b/xen/arch/arm/vgic/vgic-mmio.h index 375b70561d..10ac682296 100644 --- a/xen/arch/arm/vgic/vgic-mmio.h +++ b/xen/arch/arm/vgic/vgic-mmio.h @@ -137,6 +137,8 @@ unsigned long vgic_mmio_read_rao(struct vcpu *vcpu, void vgic_mmio_write_wi(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 */ const struct vgic_register_region * vgic_find_mmio_region(const struct vgic_register_region *regions, diff --git a/xen/arch/arm/vgic/vgic.h b/xen/arch/arm/vgic/vgic.h index 426b34d0ce..7747d3f3e0 100644 --- a/xen/arch/arm/vgic/vgic.h +++ b/xen/arch/arm/vgic/vgic.h @@ -49,6 +49,8 @@ void vgic_v2_fold_lr_state(struct vcpu *vcpu); void vgic_v2_populate_lr(struct vcpu *vcpu, struct vgic_irq *irq, int lr); void vgic_v2_clear_lr(struct vcpu *vcpu, int lr); void vgic_v2_set_underflow(struct vcpu *vcpu); +int vgic_register_dist_iodev(struct domain *d, paddr_t dist_base_address, + enum vgic_type); void vgic_v2_save_state(struct vcpu *vcpu); void vgic_v2_restore_state(struct vcpu *vcpu);