From patchwork Fri Feb 9 14:38:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127838 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp679813ljc; Fri, 9 Feb 2018 06:42:10 -0800 (PST) X-Google-Smtp-Source: AH8x225dp7YFIgUfs7HpSyU06ljM5j7fdC/L+pPqwDaSEx7BU6yIpVIfKoHok182tZRV5jkm+Cpa X-Received: by 10.107.170.234 with SMTP id g103mr3382191ioj.240.1518187330011; Fri, 09 Feb 2018 06:42:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518187330; cv=none; d=google.com; s=arc-20160816; b=PMbx6rCURJDq/4Fj/jxga3UmZ51O4pu6oZjx9NAalblX87h5RfJ+yAu6nGPuvNA11U 9r6Id3lpBW+/0H6+AM37h8ppfcCzb+pkp/IDi8ZQJCxv+5yn98qISib91y6CUHux8jio crws6NSYz987CFvkcL7zWGCDkERNn+El6gONPr1Y7IBmJo9N+YRY7Glv5NUtOsVjJZPH 34GwLGpUhZ4nL1qsOH8y7TwT2eDASU07hXhvjAv3l5dns0ANCdEQREdAYnoPuMZSIlcW 35xgI6jlGZdWeZKNntlmEcekaQrm4etEwRk+JJr3wEoOG2NQyu48T81toZQJE9DO89av ewFQ== 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=g4YQuzDCt4xydK0kzroSQ2vX29RM73RiKOO68TiXAqE=; b=terXajFuJas87yZE47sm7p4ucSXl5YxuAcZaLy2lkhUFoiuWQEC5MfBwNq7JVH7bYy aHgck6LuslGYuX7MMxXciUbTo6PaRBEeZ3NxS17u3UsNSia1Fn70bIcYQhHMEqTM4Z1z 4YFqLkflNgtnexvSxBYojkeXqC/53qFzJADs2Jm+Lwk5Uguwlc0lsZZOg36C/xYeRt2H n7Tm8GCfdSx/3nR+jIhrld6ZF28uDxgNo7R38Wa3N9VEkY3+JnjQ0uY6be1wGItspUn6 GXKilIBHUenJNxCrrUJIztLsr2dhyi+odS97XsgiL/crBnbr+oftncs6xP5G+GEeHfwA wlnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=P8mt5NrV; 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 128si1704680iof.301.2018.02.09.06.42.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 06:42:09 -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=P8mt5NrV; 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 1ek9qK-0008B9-AT; Fri, 09 Feb 2018 14:40:00 +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-00088J-Hr for xen-devel@lists.xenproject.org; Fri, 09 Feb 2018 14:39:58 +0000 X-Inumbo-ID: 081ac5fc-0da7-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 081ac5fc-0da7-11e8-ba59-bc764e045a96; Fri, 09 Feb 2018 15:39:28 +0100 (CET) Received: by mail-wm0-x242.google.com with SMTP id v71so16698804wmv.2 for ; Fri, 09 Feb 2018 06:39:56 -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=uHIYScc/giB+AkcAlAs2kcRW00q/z/cVccJVs7ZUs7U=; b=P8mt5NrVGk8zNxhuf3Vn9uoglrXKUlGsBfYjeocrh3O+3a8Pqv/HPwcRDf222P86VB nPQfXT/BSk7OilD2vt79oVZAAvRgb74gJlov6uP09aVbIfiyPSAT1H0EtBjfMO5KG6+B 4tMFOXGWDVYyqpzgzSeqfgXkqrERGuM7tLNt8= 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=uHIYScc/giB+AkcAlAs2kcRW00q/z/cVccJVs7ZUs7U=; b=a3iBDAZhRm0IlGlXUjUHhFiMy8RJLFgEUhWiEG2o9yKyVjeTXnivfQk+2bEpQJZKYD vJSFnMhiq6x0mgqZGtmfV6gQFOxy8KvMUfbtERXx3Nfn8sHjaQjl4vEZal9R6I65oNBj MqKY/zqgPx798WqSXN0WRE1SXGp+wjlBm4txEN5Y/07vw/vzzezBmXKM/E/PJAmVk6NB vA9vcGiMlwtU9Ywt/cuQXekj8dgxipifL44BSO77ABCbdFxyf0cC/UVAu+7/f3Kncdxl P7LL5OJbfRGd6in9bSENwARGP1VrUianiHJ4QH7ysZZBpU+Ie4lsPZzGYwCreR+/L/S6 FUVg== X-Gm-Message-State: APf1xPCX7d/+skWTXipOxoevN9awTIgZ2wzfZtRej0EgOIko8Q/xLcoz gEPYPV4DIMgVKllgNlfucdZy6w== X-Received: by 10.28.23.14 with SMTP id 14mr2354043wmx.5.1518187195776; Fri, 09 Feb 2018 06:39:55 -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.39.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:39:55 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall , xen-devel@lists.xenproject.org Date: Fri, 9 Feb 2018 14:38:58 +0000 Message-Id: <20180209143937.28866-11-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 10/49] ARM: VGIC: carve out struct vgic_cpu and struct vgic_dist 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" Currently we describe the VGIC specific fields in an structure *embedded* in struct arch_domain and struct arch_vcpu. These members there are however related to the current VGIC implementation, and will be substantially different in the future. To allow coexistence of two implementations, move the definition of these embedded structures into vgic.h, and just use the opaque type in the arch specific structures. This allows easy switching between different implementations later. Signed-off-by: Andre Przywara Reviewed-by: Julien Grall --- xen/include/asm-arm/domain.h | 85 +----------------------------------------- xen/include/asm-arm/vgic.h | 88 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 83 deletions(-) diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 2fef32eaee..968ffb0c81 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -74,57 +74,7 @@ struct arch_domain uint64_t offset; } virt_timer_base; - struct { - /* Version of the vGIC */ - enum gic_version version; - /* GIC HW version specific vGIC driver handler */ - const struct vgic_ops *handler; - /* - * Covers access to other members of this struct _except_ for - * shared_irqs where each member contains its own locking. - * - * If both class of lock is required then this lock must be - * taken first. If multiple rank locks are required (including - * the per-vcpu private_irqs rank) then they must be taken in - * rank order. - */ - spinlock_t lock; - uint32_t ctlr; - int nr_spis; /* Number of SPIs */ - unsigned long *allocated_irqs; /* bitmap of IRQs allocated */ - struct vgic_irq_rank *shared_irqs; - /* - * SPIs are domain global, SGIs and PPIs are per-VCPU and stored in - * struct arch_vcpu. - */ - struct pending_irq *pending_irqs; - /* Base address for guest GIC */ - paddr_t dbase; /* Distributor base address */ -#ifdef CONFIG_HAS_GICV3 - /* GIC V3 addressing */ - /* List of contiguous occupied by the redistributors */ - struct vgic_rdist_region { - paddr_t base; /* Base address */ - paddr_t size; /* Size */ - unsigned int first_cpu; /* First CPU handled */ - } *rdist_regions; - int nr_regions; /* Number of rdist regions */ - unsigned long int nr_lpis; - uint64_t rdist_propbase; - struct rb_root its_devices; /* Devices mapped to an ITS */ - spinlock_t its_devices_lock; /* Protects the its_devices tree */ - struct radix_tree_root pend_lpi_tree; /* Stores struct pending_irq's */ - rwlock_t pend_lpi_tree_lock; /* Protects the pend_lpi_tree */ - struct list_head vits_list; /* List of virtual ITSes */ - unsigned int intid_bits; - /* - * TODO: if there are more bool's being added below, consider - * a flags variable instead. - */ - bool rdists_enabled; /* Is any redistributor enabled? */ - bool has_its; -#endif - } vgic; + struct vgic_dist vgic; struct vuart { #define VUART_BUF_SIZE 128 @@ -248,38 +198,7 @@ struct arch_vcpu union gic_state_data gic; uint64_t lr_mask; - struct { - /* - * SGIs and PPIs are per-VCPU, SPIs are domain global and in - * struct arch_domain. - */ - struct pending_irq pending_irqs[32]; - struct vgic_irq_rank *private_irqs; - - /* This list is ordered by IRQ priority and it is used to keep - * track of the IRQs that the VGIC injected into the guest. - * Depending on the availability of LR registers, the IRQs might - * actually be in an LR, and therefore injected into the guest, - * or queued in gic.lr_pending. - * As soon as an IRQ is EOI'd by the guest and removed from the - * corresponding LR it is also removed from this list. */ - struct list_head inflight_irqs; - /* lr_pending is used to queue IRQs (struct pending_irq) that the - * vgic tried to inject in the guest (calling gic_set_guest_irq) but - * no LRs were available at the time. - * As soon as an LR is freed we remove the first IRQ from this - * list and write it to the LR register. - * lr_pending is a subset of vgic.inflight_irqs. */ - struct list_head lr_pending; - spinlock_t lock; - - /* GICv3: redistributor base and flags for this vCPU */ - paddr_t rdist_base; - uint64_t rdist_pendbase; -#define VGIC_V3_RDIST_LAST (1 << 0) /* last vCPU of the rdist */ -#define VGIC_V3_LPIS_ENABLED (1 << 1) - uint8_t flags; - } vgic; + struct vgic_cpu vgic; /* Timer registers */ uint32_t cntkctl; diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index b75fdeb068..4e1c37f091 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -19,6 +19,9 @@ #define __ASM_ARM_VGIC_H__ #include +#include +#include +#include #include #include @@ -123,6 +126,91 @@ struct vgic_irq_rank { uint8_t vcpu[32]; }; +struct vgic_dist { + /* Version of the vGIC */ + enum gic_version version; + /* GIC HW version specific vGIC driver handler */ + const struct vgic_ops *handler; + /* + * Covers access to other members of this struct _except_ for + * shared_irqs where each member contains its own locking. + * + * If both class of lock is required then this lock must be + * taken first. If multiple rank locks are required (including + * the per-vcpu private_irqs rank) then they must be taken in + * rank order. + */ + spinlock_t lock; + uint32_t ctlr; + int nr_spis; /* Number of SPIs */ + unsigned long *allocated_irqs; /* bitmap of IRQs allocated */ + struct vgic_irq_rank *shared_irqs; + /* + * SPIs are domain global, SGIs and PPIs are per-VCPU and stored in + * struct arch_vcpu. + */ + struct pending_irq *pending_irqs; + /* Base address for guest GIC */ + paddr_t dbase; /* Distributor base address */ +#ifdef CONFIG_HAS_GICV3 + /* GIC V3 addressing */ + /* List of contiguous occupied by the redistributors */ + struct vgic_rdist_region { + paddr_t base; /* Base address */ + paddr_t size; /* Size */ + unsigned int first_cpu; /* First CPU handled */ + } *rdist_regions; + int nr_regions; /* Number of rdist regions */ + unsigned long int nr_lpis; + uint64_t rdist_propbase; + struct rb_root its_devices; /* Devices mapped to an ITS */ + spinlock_t its_devices_lock; /* Protects the its_devices tree */ + struct radix_tree_root pend_lpi_tree; /* Stores struct pending_irq's */ + rwlock_t pend_lpi_tree_lock; /* Protects the pend_lpi_tree */ + struct list_head vits_list; /* List of virtual ITSes */ + unsigned int intid_bits; + /* + * TODO: if there are more bool's being added below, consider + * a flags variable instead. + */ + bool rdists_enabled; /* Is any redistributor enabled? */ + bool has_its; +#endif +}; + +struct vgic_cpu { + /* + * SGIs and PPIs are per-VCPU, SPIs are domain global and in + * struct arch_domain. + */ + struct pending_irq pending_irqs[32]; + struct vgic_irq_rank *private_irqs; + + /* This list is ordered by IRQ priority and it is used to keep + * track of the IRQs that the VGIC injected into the guest. + * Depending on the availability of LR registers, the IRQs might + * actually be in an LR, and therefore injected into the guest, + * or queued in gic.lr_pending. + * As soon as an IRQ is EOI'd by the guest and removed from the + * corresponding LR it is also removed from this list. */ + struct list_head inflight_irqs; + /* lr_pending is used to queue IRQs (struct pending_irq) that the + * vgic tried to inject in the guest (calling gic_set_guest_irq) but + * no LRs were available at the time. + * As soon as an LR is freed we remove the first IRQ from this + * list and write it to the LR register. + * lr_pending is a subset of vgic.inflight_irqs. */ + struct list_head lr_pending; + spinlock_t lock; + + /* GICv3: redistributor base and flags for this vCPU */ + paddr_t rdist_base; + uint64_t rdist_pendbase; +#define VGIC_V3_RDIST_LAST (1 << 0) /* last vCPU of the rdist */ +#define VGIC_V3_LPIS_ENABLED (1 << 1) + uint8_t flags; +}; + struct sgi_target { uint8_t aff1; uint16_t list;