From nobody Wed Aug 26 11:33:27 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hVMwR4pZyz6pwZt for ; Wed, 26 Aug 2026 11:33:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hVMwR4Cw3z4FgS for ; Wed, 26 Aug 2026 11:33:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787744007; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ysV5QrapF2ioFNaqG4CzsOf55FpiVZdsiFaj7xFw2k8=; b=pLDhqFFYZUJxi1IkH08kEbOlkSd9CorUVYvMujcIXe0KTzKyPkpUWN7R/6rdGHbAiyRv5c psTDBZu/kmdIv2gh6n8VWIWC4mVCm6LHno4Y8spioMITPC75Zd+XML+lP5xL3czxb/xOkS GaucuiBDzq3yn5Qbn2ZAtxgF7HrCO9j4s34u+twCPTFZ4vc9dzncb/Tz+uo76pRNupgzfb u7lUfom9I3W6nqG6w/0uQRxw9bCxD+/SWxim70zgrAUZ9nd7H3BnZYTEBhzhhNz2phjYCC H96zG25DMep4sRL/7Rq4cqemI6Qtjhnv5sr1jlsW1EfDMkADI3akesPL7kwXog== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787744007; a=rsa-sha256; cv=none; b=aZPH2rxUluViX+x0yYaXekGNDRHJp71WaqtKGRSxZ8rzY8yhNRRpPQB5YoXq2z2qYY7vWe IZaCWt+jU/be6iAbPoCxBC0DZetVW3MQyJRGjgIjtMFntiOrTHZXGy8d+8pHS7aJAEPgXx 487FHWjxMZLYBks5ffgjZLpDu1V9+wPko50caWsD8MuH9+pZVheioXawiNI9ZMZnKiFKWU GKIvD9JOOejMi6EnJxq0HY9tZbvv7+4MrBZggaZj9VALzWzmUpfYIcIsI4tcL7MFbPxNzZ X0l00GGY2hCxms+vWMp7Nt7jatWLglp2Mg+fLd4GMDFfUCEStScsv6B6ewIaQg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787744007; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ysV5QrapF2ioFNaqG4CzsOf55FpiVZdsiFaj7xFw2k8=; b=p9brw3NQ6rsLXvF7aD3dm7bsVgs/ATetz0iGOGDgQK3hPACvB3+ElhxrV9S9CqiHSXWP/1 0K6o2dSr4VP5VyPE/95aWku1EOIbflpy+qH4KwNVi7S1d8MSzJqzM3YqyW+czTrlSETNbc J8XvUUHN2GZZI0ZIUVjwT/euSNZxhU/OTpApIiKsj452sCfZaIJCvZSrH1QEumjgrAdCKg 6dAVEcD5yewY7LBvYgMmnIGuyIm+267ZkUFm4al5qzT0sAlbK1fk2znPlPfvGjfHs6cMPr 50xWFtAxN1jyjJv/X92i0LTlqzbAX8AtUMzr6ZmkoSpKLpewiqj1loXQFBK/4w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hVMwR2wz0zcJB for ; Wed, 26 Aug 2026 11:33:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 40c17 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 26 Aug 2026 11:33:27 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 7823d306d3b2 - main - arm64: vmm: Move vgic_v3 structures to header file List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7823d306d3b29b3be5fd74b610241c6307fc9e82 Auto-Submitted: auto-generated Date: Wed, 26 Aug 2026 11:33:27 +0000 Message-Id: <6a8ecf07.40c17.59e07e2d@gitrepo.freebsd.org> The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=7823d306d3b29b3be5fd74b610241c6307fc9e82 commit 7823d306d3b29b3be5fd74b610241c6307fc9e82 Author: Andrew Turner AuthorDate: 2026-05-13 10:27:19 +0000 Commit: Andrew Turner CommitDate: 2026-08-26 11:17:17 +0000 arm64: vmm: Move vgic_v3 structures to header file Move vgic_v3 structures in preparation for vgic interface rework for GICv5 support. Reviewed by: Sarah Walker Sponsored by: Arm Ltd --- sys/arm64/vmm/io/vgic_internal.h | 83 ++++++++++++++++++++++++++++++++++++++++ sys/arm64/vmm/io/vgic_v3.c | 53 ++----------------------- 2 files changed, 87 insertions(+), 49 deletions(-) diff --git a/sys/arm64/vmm/io/vgic_internal.h b/sys/arm64/vmm/io/vgic_internal.h new file mode 100644 index 000000000000..2f5cfc7c0891 --- /dev/null +++ b/sys/arm64/vmm/io/vgic_internal.h @@ -0,0 +1,83 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2018 Alexandru Elisei + * Copyright (C) 2020-2022 Andrew Turner + * Copyright (C) 2023 Arm Ltd + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _VGIC_INTERNAL_H_ +#define _VGIC_INTERNAL_H_ + +struct vgic_v3_irq { + /* List of IRQs that are active or pending */ + TAILQ_ENTRY(vgic_v3_irq) act_pend_list; + struct mtx irq_spinmtx; + uint64_t mpidr; + int target_vcpu; + uint32_t irq; + bool active; + bool pending; + bool enabled; + bool level; + bool on_aplist; + uint8_t priority; + uint8_t config; +#define VGIC_CONFIG_MASK 0x2 +#define VGIC_CONFIG_LEVEL 0x0 +#define VGIC_CONFIG_EDGE 0x2 +}; + +/* Global data not needed by EL2 */ +struct vgic_v3 { + struct mtx dist_mtx; + uint64_t dist_start; + size_t dist_end; + + uint64_t redist_start; + size_t redist_end; + + uint32_t gicd_ctlr; /* Distributor Control Register */ + + struct vgic_v3_irq *irqs; +}; + +/* Per-CPU data not needed by EL2 */ +struct vgic_v3_cpu { + /* + * We need a mutex for accessing the list registers because they are + * modified asynchronously by the virtual timer. + * + * Note that the mutex *MUST* be a spin mutex because an interrupt can + * be injected by a callout callback function, thereby modifying the + * list registers from a context where sleeping is forbidden. + */ + struct mtx lr_mtx; + + struct vgic_v3_irq *private_irqs; + TAILQ_HEAD(, vgic_v3_irq) irq_act_pend; + u_int ich_lr_used; +}; + +#endif /* _VGIC_INTERNAL_H_ */ diff --git a/sys/arm64/vmm/io/vgic_v3.c b/sys/arm64/vmm/io/vgic_v3.c index 09d1448c1803..763267a2a3c8 100644 --- a/sys/arm64/vmm/io/vgic_v3.c +++ b/sys/arm64/vmm/io/vgic_v3.c @@ -72,6 +72,7 @@ #include #include "vgic.h" +#include "vgic_internal.h" #include "vgic_v3.h" #include "vgic_v3_reg.h" @@ -92,55 +93,6 @@ struct vgic_v3_virt_features { size_t ich_apr_num; }; -struct vgic_v3_irq { - /* List of IRQs that are active or pending */ - TAILQ_ENTRY(vgic_v3_irq) act_pend_list; - struct mtx irq_spinmtx; - uint64_t mpidr; - int target_vcpu; - uint32_t irq; - bool active; - bool pending; - bool enabled; - bool level; - bool on_aplist; - uint8_t priority; - uint8_t config; -#define VGIC_CONFIG_MASK 0x2 -#define VGIC_CONFIG_LEVEL 0x0 -#define VGIC_CONFIG_EDGE 0x2 -}; - -/* Global data not needed by EL2 */ -struct vgic_v3 { - struct mtx dist_mtx; - uint64_t dist_start; - size_t dist_end; - - uint64_t redist_start; - size_t redist_end; - - uint32_t gicd_ctlr; /* Distributor Control Register */ - - struct vgic_v3_irq *irqs; -}; - -/* Per-CPU data not needed by EL2 */ -struct vgic_v3_cpu { - /* - * We need a mutex for accessing the list registers because they are - * modified asynchronously by the virtual timer. - * - * Note that the mutex *MUST* be a spin mutex because an interrupt can - * be injected by a callout callback function, thereby modifying the - * list registers from a context where sleeping is forbidden. - */ - struct mtx lr_mtx; - - struct vgic_v3_irq private_irqs[VGIC_PRV_I_NUM]; - TAILQ_HEAD(, vgic_v3_irq) irq_act_pend; - u_int ich_lr_used; -}; /* How many IRQs we support (SGIs + PPIs + SPIs). Not including LPIs */ #define VGIC_NIRQS 1023 @@ -474,6 +426,9 @@ vgic_v3_cpuinit(device_t dev, struct hypctx *hypctx) mtx_init(&vgic_cpu->lr_mtx, "VGICv3 ICH_LR_EL2 lock", NULL, MTX_SPIN); + vgic_cpu->private_irqs = mallocarray(VGIC_PRV_I_NUM, + sizeof(*vgic_cpu->private_irqs), M_VGIC_V3, M_WAITOK | M_ZERO); + /* Set the SGI and PPI state */ for (irqid = 0; irqid < VGIC_PRV_I_NUM; irqid++) { irq = &vgic_cpu->private_irqs[irqid];