From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531589175463732.5645555920713; Sat, 14 Jul 2018 10:26:15 -0700 (PDT) Received: from localhost ([::1]:42116 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOJA-0004oj-0f for importer@patchew.org; Sat, 14 Jul 2018 13:26:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9z-0005uY-Pq for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9u-0004fv-Ns for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:43 -0400 Received: from greensocs.com ([193.104.36.180]:57254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9i-0004MJ-Mn; Sat, 14 Jul 2018 13:16:27 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id ABACBC7AFD; Sat, 14 Jul 2018 19:16:17 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k2KDPD18WUPq; Sat, 14 Jul 2018 19:16:16 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 1EA33C7AF0; Sat, 14 Jul 2018 19:16:16 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id B5CF1C7ADD; Sat, 14 Jul 2018 19:16:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588577; bh=q4/enpn2IaIlnEm1C8XrEXMNtBWMjmkBmAzBketEWPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZMvXbmRN8rF6S11mmr4tcJl4nC7UQLpetuauWHvYy8p4I5gxOuLSI6jgXc+g268au mSn88UQId6PGbhzKHhiiA2Mmrz9sEtBuDs1aIAda2T6rVQwrzEeUTpFmA+g7UZe760 3Yu3IZ+NLkyDJCFqTFZy+ZDb/dtZJxU6PFm6/q3c= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=IH+Ph4Ek; dkim=pass (1024-bit key) header.d=greensocs.com header.b=FjUylJ3M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588576; bh=q4/enpn2IaIlnEm1C8XrEXMNtBWMjmkBmAzBketEWPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IH+Ph4EkFfQhO+1goZujOc111ckBcr1jvGhehnaclNnSmoRKVZVbhXH/yl8u1acN5 2cl4/U5xf0zdmcdCMU0u8tllqC06yorLXJZUBJ0TyBHWsO2s2cr5ithOSY6+uNzfh3 zqzJab4iKmu76U4lep8qK6LHviaru8JWogzT0g6Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588575; bh=q4/enpn2IaIlnEm1C8XrEXMNtBWMjmkBmAzBketEWPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FjUylJ3Mn+KKryF4wxRJlTZQfF/b4IL8NH/n+s95q3QZ/us3I1BvFueLwXV25bdUV OdOJr5UDLGtZw2YXInnIMm1gYPdehvaZaVuK+TOg8EfVaFNUo7GhEp2CoMfnusIvWh wAgMgaeeZcV6pXP3k46SqYRtcfVLlJUFsLcXvC78= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:42 +0200 Message-Id: <20180714171601.5734-2-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 01/20] intc/arm_gic: Refactor operations on the distributor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 3 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In preparation for the virtualization extensions implementation, refactor the name of the functions and macros that act on the GIC distributor to make that fact explicit. It will be useful to differentiate them from the ones that will act on the virtual interfaces. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Sai Pavan Boddu Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 163 +++++++++++++++++++++------------------ hw/intc/arm_gic_common.c | 6 +- hw/intc/arm_gic_kvm.c | 23 +++--- hw/intc/gic_internal.h | 51 ++++++------ 4 files changed, 127 insertions(+), 116 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index ea0323f969..6f3074ba88 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -92,11 +92,12 @@ void gic_update(GICState *s) best_prio =3D 0x100; best_irq =3D 1023; for (irq =3D 0; irq < s->num_irq; irq++) { - if (GIC_TEST_ENABLED(irq, cm) && gic_test_pending(s, irq, cm) = && - (!GIC_TEST_ACTIVE(irq, cm)) && - (irq < GIC_INTERNAL || GIC_TARGET(irq) & cm)) { - if (GIC_GET_PRIORITY(irq, cpu) < best_prio) { - best_prio =3D GIC_GET_PRIORITY(irq, cpu); + if (GIC_DIST_TEST_ENABLED(irq, cm) && + gic_test_pending(s, irq, cm) && + (!GIC_DIST_TEST_ACTIVE(irq, cm)) && + (irq < GIC_INTERNAL || GIC_DIST_TARGET(irq) & cm)) { + if (GIC_DIST_GET_PRIORITY(irq, cpu) < best_prio) { + best_prio =3D GIC_DIST_GET_PRIORITY(irq, cpu); best_irq =3D irq; } } @@ -112,7 +113,7 @@ void gic_update(GICState *s) if (best_prio < s->priority_mask[cpu]) { s->current_pending[cpu] =3D best_irq; if (best_prio < s->running_priority[cpu]) { - int group =3D GIC_TEST_GROUP(best_irq, cm); + int group =3D GIC_DIST_TEST_GROUP(best_irq, cm); =20 if (extract32(s->ctlr, group, 1) && extract32(s->cpu_ctlr[cpu], group, 1)) { @@ -145,7 +146,7 @@ void gic_set_pending_private(GICState *s, int cpu, int = irq) } =20 DPRINTF("Set %d pending cpu %d\n", irq, cpu); - GIC_SET_PENDING(irq, cm); + GIC_DIST_SET_PENDING(irq, cm); gic_update(s); } =20 @@ -153,13 +154,13 @@ static void gic_set_irq_11mpcore(GICState *s, int irq= , int level, int cm, int target) { if (level) { - GIC_SET_LEVEL(irq, cm); - if (GIC_TEST_EDGE_TRIGGER(irq) || GIC_TEST_ENABLED(irq, cm)) { + GIC_DIST_SET_LEVEL(irq, cm); + if (GIC_DIST_TEST_EDGE_TRIGGER(irq) || GIC_DIST_TEST_ENABLED(irq, = cm)) { DPRINTF("Set %d pending mask %x\n", irq, target); - GIC_SET_PENDING(irq, target); + GIC_DIST_SET_PENDING(irq, target); } } else { - GIC_CLEAR_LEVEL(irq, cm); + GIC_DIST_CLEAR_LEVEL(irq, cm); } } =20 @@ -167,13 +168,13 @@ static void gic_set_irq_generic(GICState *s, int irq,= int level, int cm, int target) { if (level) { - GIC_SET_LEVEL(irq, cm); + GIC_DIST_SET_LEVEL(irq, cm); DPRINTF("Set %d pending mask %x\n", irq, target); - if (GIC_TEST_EDGE_TRIGGER(irq)) { - GIC_SET_PENDING(irq, target); + if (GIC_DIST_TEST_EDGE_TRIGGER(irq)) { + GIC_DIST_SET_PENDING(irq, target); } } else { - GIC_CLEAR_LEVEL(irq, cm); + GIC_DIST_CLEAR_LEVEL(irq, cm); } } =20 @@ -192,7 +193,7 @@ static void gic_set_irq(void *opaque, int irq, int leve= l) /* The first external input line is internal interrupt 32. */ cm =3D ALL_CPU_MASK; irq +=3D GIC_INTERNAL; - target =3D GIC_TARGET(irq); + target =3D GIC_DIST_TARGET(irq); } else { int cpu; irq -=3D (s->num_irq - GIC_INTERNAL); @@ -204,7 +205,7 @@ static void gic_set_irq(void *opaque, int irq, int leve= l) =20 assert(irq >=3D GIC_NR_SGIS); =20 - if (level =3D=3D GIC_TEST_LEVEL(irq, cm)) { + if (level =3D=3D GIC_DIST_TEST_LEVEL(irq, cm)) { return; } =20 @@ -224,7 +225,7 @@ static uint16_t gic_get_current_pending_irq(GICState *s= , int cpu, uint16_t pending_irq =3D s->current_pending[cpu]; =20 if (pending_irq < GIC_MAXIRQ && gic_has_groups(s)) { - int group =3D GIC_TEST_GROUP(pending_irq, (1 << cpu)); + int group =3D GIC_DIST_TEST_GROUP(pending_irq, (1 << cpu)); /* On a GIC without the security extensions, reading this register * behaves in the same way as a secure access to a GIC with them. */ @@ -255,7 +256,7 @@ static int gic_get_group_priority(GICState *s, int cpu,= int irq) =20 if (gic_has_groups(s) && !(s->cpu_ctlr[cpu] & GICC_CTLR_CBPR) && - GIC_TEST_GROUP(irq, (1 << cpu))) { + GIC_DIST_TEST_GROUP(irq, (1 << cpu))) { bpr =3D s->abpr[cpu] - 1; assert(bpr >=3D 0); } else { @@ -268,7 +269,7 @@ static int gic_get_group_priority(GICState *s, int cpu,= int irq) */ mask =3D ~0U << ((bpr & 7) + 1); =20 - return GIC_GET_PRIORITY(irq, cpu) & mask; + return GIC_DIST_GET_PRIORITY(irq, cpu) & mask; } =20 static void gic_activate_irq(GICState *s, int cpu, int irq) @@ -281,14 +282,14 @@ static void gic_activate_irq(GICState *s, int cpu, in= t irq) int regno =3D preemption_level / 32; int bitno =3D preemption_level % 32; =20 - if (gic_has_groups(s) && GIC_TEST_GROUP(irq, (1 << cpu))) { + if (gic_has_groups(s) && GIC_DIST_TEST_GROUP(irq, (1 << cpu))) { s->nsapr[regno][cpu] |=3D (1 << bitno); } else { s->apr[regno][cpu] |=3D (1 << bitno); } =20 s->running_priority[cpu] =3D prio; - GIC_SET_ACTIVE(irq, 1 << cpu); + GIC_DIST_SET_ACTIVE(irq, 1 << cpu); } =20 static int gic_get_prio_from_apr_bits(GICState *s, int cpu) @@ -357,7 +358,7 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemT= xAttrs attrs) return irq; } =20 - if (GIC_GET_PRIORITY(irq, cpu) >=3D s->running_priority[cpu]) { + if (GIC_DIST_GET_PRIORITY(irq, cpu) >=3D s->running_priority[cpu]) { DPRINTF("ACK, pending interrupt (%d) has insufficient priority\n",= irq); return 1023; } @@ -366,7 +367,8 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemT= xAttrs attrs) /* Clear pending flags for both level and edge triggered interrupt= s. * Level triggered IRQs will be reasserted once they become inacti= ve. */ - GIC_CLEAR_PENDING(irq, GIC_TEST_MODEL(irq) ? ALL_CPU_MASK : cm); + GIC_DIST_CLEAR_PENDING(irq, GIC_DIST_TEST_MODEL(irq) ? ALL_CPU_MASK + : cm); ret =3D irq; } else { if (irq < GIC_NR_SGIS) { @@ -378,7 +380,9 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemT= xAttrs attrs) src =3D ctz32(s->sgi_pending[irq][cpu]); s->sgi_pending[irq][cpu] &=3D ~(1 << src); if (s->sgi_pending[irq][cpu] =3D=3D 0) { - GIC_CLEAR_PENDING(irq, GIC_TEST_MODEL(irq) ? ALL_CPU_MASK = : cm); + GIC_DIST_CLEAR_PENDING(irq, + GIC_DIST_TEST_MODEL(irq) ? ALL_CPU_= MASK + : cm); } ret =3D irq | ((src & 0x7) << 10); } else { @@ -386,7 +390,8 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemT= xAttrs attrs) * interrupts. (level triggered interrupts with an active line * remain pending, see gic_test_pending) */ - GIC_CLEAR_PENDING(irq, GIC_TEST_MODEL(irq) ? ALL_CPU_MASK : cm= ); + GIC_DIST_CLEAR_PENDING(irq, GIC_DIST_TEST_MODEL(irq) ? ALL_CPU= _MASK + : cm); ret =3D irq; } } @@ -397,11 +402,11 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, Me= mTxAttrs attrs) return ret; } =20 -void gic_set_priority(GICState *s, int cpu, int irq, uint8_t val, +void gic_dist_set_priority(GICState *s, int cpu, int irq, uint8_t val, MemTxAttrs attrs) { if (s->security_extn && !attrs.secure) { - if (!GIC_TEST_GROUP(irq, (1 << cpu))) { + if (!GIC_DIST_TEST_GROUP(irq, (1 << cpu))) { return; /* Ignore Non-secure access of Group0 IRQ */ } val =3D 0x80 | (val >> 1); /* Non-secure view */ @@ -414,13 +419,13 @@ void gic_set_priority(GICState *s, int cpu, int irq, = uint8_t val, } } =20 -static uint32_t gic_get_priority(GICState *s, int cpu, int irq, +static uint32_t gic_dist_get_priority(GICState *s, int cpu, int irq, MemTxAttrs attrs) { - uint32_t prio =3D GIC_GET_PRIORITY(irq, cpu); + uint32_t prio =3D GIC_DIST_GET_PRIORITY(irq, cpu); =20 if (s->security_extn && !attrs.secure) { - if (!GIC_TEST_GROUP(irq, (1 << cpu))) { + if (!GIC_DIST_TEST_GROUP(irq, (1 << cpu))) { return 0; /* Non-secure access cannot read priority of Group0 = IRQ */ } prio =3D (prio << 1) & 0xff; /* Non-secure view */ @@ -543,7 +548,7 @@ static bool gic_eoi_split(GICState *s, int cpu, MemTxAt= trs attrs) static void gic_deactivate_irq(GICState *s, int cpu, int irq, MemTxAttrs a= ttrs) { int cm =3D 1 << cpu; - int group =3D gic_has_groups(s) && GIC_TEST_GROUP(irq, cm); + int group =3D gic_has_groups(s) && GIC_DIST_TEST_GROUP(irq, cm); =20 if (!gic_eoi_split(s, cpu, attrs)) { /* This is UNPREDICTABLE; we choose to ignore it */ @@ -557,7 +562,7 @@ static void gic_deactivate_irq(GICState *s, int cpu, in= t irq, MemTxAttrs attrs) return; } =20 - GIC_CLEAR_ACTIVE(irq, cm); + GIC_DIST_CLEAR_ACTIVE(irq, cm); } =20 void gic_complete_irq(GICState *s, int cpu, int irq, MemTxAttrs attrs) @@ -584,14 +589,15 @@ void gic_complete_irq(GICState *s, int cpu, int irq, = MemTxAttrs attrs) if (s->revision =3D=3D REV_11MPCORE) { /* Mark level triggered interrupts as pending if they are still raised. */ - if (!GIC_TEST_EDGE_TRIGGER(irq) && GIC_TEST_ENABLED(irq, cm) - && GIC_TEST_LEVEL(irq, cm) && (GIC_TARGET(irq) & cm) !=3D 0) { + if (!GIC_DIST_TEST_EDGE_TRIGGER(irq) && GIC_DIST_TEST_ENABLED(irq,= cm) + && GIC_DIST_TEST_LEVEL(irq, cm) + && (GIC_DIST_TARGET(irq) & cm) !=3D 0) { DPRINTF("Set %d pending mask %x\n", irq, cm); - GIC_SET_PENDING(irq, cm); + GIC_DIST_SET_PENDING(irq, cm); } } =20 - group =3D gic_has_groups(s) && GIC_TEST_GROUP(irq, cm); + group =3D gic_has_groups(s) && GIC_DIST_TEST_GROUP(irq, cm); =20 if (s->security_extn && !attrs.secure && !group) { DPRINTF("Non-secure EOI for Group0 interrupt %d ignored\n", irq); @@ -607,7 +613,7 @@ void gic_complete_irq(GICState *s, int cpu, int irq, Me= mTxAttrs attrs) =20 /* In GICv2 the guest can choose to split priority-drop and deactivate= */ if (!gic_eoi_split(s, cpu, attrs)) { - GIC_CLEAR_ACTIVE(irq, cm); + GIC_DIST_CLEAR_ACTIVE(irq, cm); } gic_update(s); } @@ -655,7 +661,7 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr off= set, MemTxAttrs attrs) goto bad_reg; } for (i =3D 0; i < 8; i++) { - if (GIC_TEST_GROUP(irq + i, cm)) { + if (GIC_DIST_TEST_GROUP(irq + i, cm)) { res |=3D (1 << i); } } @@ -675,11 +681,11 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr o= ffset, MemTxAttrs attrs) res =3D 0; for (i =3D 0; i < 8; i++) { if (s->security_extn && !attrs.secure && - !GIC_TEST_GROUP(irq + i, 1 << cpu)) { + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { continue; /* Ignore Non-secure access of Group0 IRQ */ } =20 - if (GIC_TEST_ENABLED(irq + i, cm)) { + if (GIC_DIST_TEST_ENABLED(irq + i, cm)) { res |=3D (1 << i); } } @@ -696,7 +702,7 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr off= set, MemTxAttrs attrs) mask =3D (irq < GIC_INTERNAL) ? cm : ALL_CPU_MASK; for (i =3D 0; i < 8; i++) { if (s->security_extn && !attrs.secure && - !GIC_TEST_GROUP(irq + i, 1 << cpu)) { + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { continue; /* Ignore Non-secure access of Group0 IRQ */ } =20 @@ -713,11 +719,11 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr o= ffset, MemTxAttrs attrs) mask =3D (irq < GIC_INTERNAL) ? cm : ALL_CPU_MASK; for (i =3D 0; i < 8; i++) { if (s->security_extn && !attrs.secure && - !GIC_TEST_GROUP(irq + i, 1 << cpu)) { + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { continue; /* Ignore Non-secure access of Group0 IRQ */ } =20 - if (GIC_TEST_ACTIVE(irq + i, mask)) { + if (GIC_DIST_TEST_ACTIVE(irq + i, mask)) { res |=3D (1 << i); } } @@ -726,7 +732,7 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr off= set, MemTxAttrs attrs) irq =3D (offset - 0x400) + GIC_BASE_IRQ; if (irq >=3D s->num_irq) goto bad_reg; - res =3D gic_get_priority(s, cpu, irq, attrs); + res =3D gic_dist_get_priority(s, cpu, irq, attrs); } else if (offset < 0xc00) { /* Interrupt CPU Target. */ if (s->num_cpu =3D=3D 1 && s->revision !=3D REV_11MPCORE) { @@ -740,7 +746,7 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr off= set, MemTxAttrs attrs) if (irq >=3D 29 && irq <=3D 31) { res =3D cm; } else { - res =3D GIC_TARGET(irq); + res =3D GIC_DIST_TARGET(irq); } } } else if (offset < 0xf00) { @@ -751,14 +757,16 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr o= ffset, MemTxAttrs attrs) res =3D 0; for (i =3D 0; i < 4; i++) { if (s->security_extn && !attrs.secure && - !GIC_TEST_GROUP(irq + i, 1 << cpu)) { + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { continue; /* Ignore Non-secure access of Group0 IRQ */ } =20 - if (GIC_TEST_MODEL(irq + i)) + if (GIC_DIST_TEST_MODEL(irq + i)) { res |=3D (1 << (i * 2)); - if (GIC_TEST_EDGE_TRIGGER(irq + i)) + } + if (GIC_DIST_TEST_EDGE_TRIGGER(irq + i)) { res |=3D (2 << (i * 2)); + } } } else if (offset < 0xf10) { goto bad_reg; @@ -776,7 +784,7 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr off= set, MemTxAttrs attrs) } =20 if (s->security_extn && !attrs.secure && - !GIC_TEST_GROUP(irq, 1 << cpu)) { + !GIC_DIST_TEST_GROUP(irq, 1 << cpu)) { res =3D 0; /* Ignore Non-secure access of Group0 IRQ */ } else { res =3D s->sgi_pending[irq][cpu]; @@ -872,10 +880,10 @@ static void gic_dist_writeb(void *opaque, hwaddr offs= et, int cm =3D (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU= _MASK; if (value & (1 << i)) { /* Group1 (Non-secure) */ - GIC_SET_GROUP(irq + i, cm); + GIC_DIST_SET_GROUP(irq + i, cm); } else { /* Group0 (Secure) */ - GIC_CLEAR_GROUP(irq + i, cm); + GIC_DIST_CLEAR_GROUP(irq + i, cm); } } } @@ -894,25 +902,26 @@ static void gic_dist_writeb(void *opaque, hwaddr offs= et, for (i =3D 0; i < 8; i++) { if (value & (1 << i)) { int mask =3D - (irq < GIC_INTERNAL) ? (1 << cpu) : GIC_TARGET(irq + i= ); + (irq < GIC_INTERNAL) ? (1 << cpu) + : GIC_DIST_TARGET(irq + i); int cm =3D (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MAS= K; =20 if (s->security_extn && !attrs.secure && - !GIC_TEST_GROUP(irq + i, 1 << cpu)) { + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { continue; /* Ignore Non-secure access of Group0 IRQ */ } =20 - if (!GIC_TEST_ENABLED(irq + i, cm)) { + if (!GIC_DIST_TEST_ENABLED(irq + i, cm)) { DPRINTF("Enabled IRQ %d\n", irq + i); trace_gic_enable_irq(irq + i); } - GIC_SET_ENABLED(irq + i, cm); + GIC_DIST_SET_ENABLED(irq + i, cm); /* If a raised level triggered IRQ enabled then mark is as pending. */ - if (GIC_TEST_LEVEL(irq + i, mask) - && !GIC_TEST_EDGE_TRIGGER(irq + i)) { + if (GIC_DIST_TEST_LEVEL(irq + i, mask) + && !GIC_DIST_TEST_EDGE_TRIGGER(irq + i)) { DPRINTF("Set %d pending mask %x\n", irq + i, mask); - GIC_SET_PENDING(irq + i, mask); + GIC_DIST_SET_PENDING(irq + i, mask); } } } @@ -930,15 +939,15 @@ static void gic_dist_writeb(void *opaque, hwaddr offs= et, int cm =3D (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MAS= K; =20 if (s->security_extn && !attrs.secure && - !GIC_TEST_GROUP(irq + i, 1 << cpu)) { + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { continue; /* Ignore Non-secure access of Group0 IRQ */ } =20 - if (GIC_TEST_ENABLED(irq + i, cm)) { + if (GIC_DIST_TEST_ENABLED(irq + i, cm)) { DPRINTF("Disabled IRQ %d\n", irq + i); trace_gic_disable_irq(irq + i); } - GIC_CLEAR_ENABLED(irq + i, cm); + GIC_DIST_CLEAR_ENABLED(irq + i, cm); } } } else if (offset < 0x280) { @@ -953,11 +962,11 @@ static void gic_dist_writeb(void *opaque, hwaddr offs= et, for (i =3D 0; i < 8; i++) { if (value & (1 << i)) { if (s->security_extn && !attrs.secure && - !GIC_TEST_GROUP(irq + i, 1 << cpu)) { + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { continue; /* Ignore Non-secure access of Group0 IRQ */ } =20 - GIC_SET_PENDING(irq + i, GIC_TARGET(irq + i)); + GIC_DIST_SET_PENDING(irq + i, GIC_DIST_TARGET(irq + i)); } } } else if (offset < 0x300) { @@ -971,7 +980,7 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, =20 for (i =3D 0; i < 8; i++) { if (s->security_extn && !attrs.secure && - !GIC_TEST_GROUP(irq + i, 1 << cpu)) { + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { continue; /* Ignore Non-secure access of Group0 IRQ */ } =20 @@ -979,7 +988,7 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, for per-CPU interrupts. It's unclear whether this is the corect behavior. */ if (value & (1 << i)) { - GIC_CLEAR_PENDING(irq + i, ALL_CPU_MASK); + GIC_DIST_CLEAR_PENDING(irq + i, ALL_CPU_MASK); } } } else if (offset < 0x400) { @@ -990,7 +999,7 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, irq =3D (offset - 0x400) + GIC_BASE_IRQ; if (irq >=3D s->num_irq) goto bad_reg; - gic_set_priority(s, cpu, irq, value, attrs); + gic_dist_set_priority(s, cpu, irq, value, attrs); } else if (offset < 0xc00) { /* Interrupt CPU Target. RAZ/WI on uniprocessor GICs, with the * annoying exception of the 11MPCore's GIC. @@ -1016,21 +1025,21 @@ static void gic_dist_writeb(void *opaque, hwaddr of= fset, value |=3D 0xaa; for (i =3D 0; i < 4; i++) { if (s->security_extn && !attrs.secure && - !GIC_TEST_GROUP(irq + i, 1 << cpu)) { + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { continue; /* Ignore Non-secure access of Group0 IRQ */ } =20 if (s->revision =3D=3D REV_11MPCORE) { if (value & (1 << (i * 2))) { - GIC_SET_MODEL(irq + i); + GIC_DIST_SET_MODEL(irq + i); } else { - GIC_CLEAR_MODEL(irq + i); + GIC_DIST_CLEAR_MODEL(irq + i); } } if (value & (2 << (i * 2))) { - GIC_SET_EDGE_TRIGGER(irq + i); + GIC_DIST_SET_EDGE_TRIGGER(irq + i); } else { - GIC_CLEAR_EDGE_TRIGGER(irq + i); + GIC_DIST_CLEAR_EDGE_TRIGGER(irq + i); } } } else if (offset < 0xf10) { @@ -1044,10 +1053,10 @@ static void gic_dist_writeb(void *opaque, hwaddr of= fset, irq =3D (offset - 0xf10); =20 if (!s->security_extn || attrs.secure || - GIC_TEST_GROUP(irq, 1 << cpu)) { + GIC_DIST_TEST_GROUP(irq, 1 << cpu)) { s->sgi_pending[irq][cpu] &=3D ~value; if (s->sgi_pending[irq][cpu] =3D=3D 0) { - GIC_CLEAR_PENDING(irq, 1 << cpu); + GIC_DIST_CLEAR_PENDING(irq, 1 << cpu); } } } else if (offset < 0xf30) { @@ -1058,8 +1067,8 @@ static void gic_dist_writeb(void *opaque, hwaddr offs= et, irq =3D (offset - 0xf20); =20 if (!s->security_extn || attrs.secure || - GIC_TEST_GROUP(irq, 1 << cpu)) { - GIC_SET_PENDING(irq, 1 << cpu); + GIC_DIST_TEST_GROUP(irq, 1 << cpu)) { + GIC_DIST_SET_PENDING(irq, 1 << cpu); s->sgi_pending[irq][cpu] |=3D value; } } else { @@ -1106,7 +1115,7 @@ static void gic_dist_writel(void *opaque, hwaddr offs= et, mask =3D ALL_CPU_MASK; break; } - GIC_SET_PENDING(irq, mask); + GIC_DIST_SET_PENDING(irq, mask); target_cpu =3D ctz32(mask); while (target_cpu < GIC_NCPU) { s->sgi_pending[irq][target_cpu] |=3D (1 << cpu); diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c index aee50a20e0..295ee9cc5e 100644 --- a/hw/intc/arm_gic_common.c +++ b/hw/intc/arm_gic_common.c @@ -204,8 +204,8 @@ static void arm_gic_common_reset(DeviceState *dev) } } for (i =3D 0; i < GIC_NR_SGIS; i++) { - GIC_SET_ENABLED(i, ALL_CPU_MASK); - GIC_SET_EDGE_TRIGGER(i); + GIC_DIST_SET_ENABLED(i, ALL_CPU_MASK); + GIC_DIST_SET_EDGE_TRIGGER(i); } =20 for (i =3D 0; i < ARRAY_SIZE(s->priority2); i++) { @@ -222,7 +222,7 @@ static void arm_gic_common_reset(DeviceState *dev) } if (s->security_extn && s->irq_reset_nonsecure) { for (i =3D 0; i < GIC_MAXIRQ; i++) { - GIC_SET_GROUP(i, ALL_CPU_MASK); + GIC_DIST_SET_GROUP(i, ALL_CPU_MASK); } } =20 diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c index 86665080bd..4b611c8d6d 100644 --- a/hw/intc/arm_gic_kvm.c +++ b/hw/intc/arm_gic_kvm.c @@ -140,10 +140,10 @@ static void translate_group(GICState *s, int irq, int= cpu, int cm =3D (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MASK; =20 if (to_kernel) { - *field =3D GIC_TEST_GROUP(irq, cm); + *field =3D GIC_DIST_TEST_GROUP(irq, cm); } else { if (*field & 1) { - GIC_SET_GROUP(irq, cm); + GIC_DIST_SET_GROUP(irq, cm); } } } @@ -154,10 +154,10 @@ static void translate_enabled(GICState *s, int irq, i= nt cpu, int cm =3D (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MASK; =20 if (to_kernel) { - *field =3D GIC_TEST_ENABLED(irq, cm); + *field =3D GIC_DIST_TEST_ENABLED(irq, cm); } else { if (*field & 1) { - GIC_SET_ENABLED(irq, cm); + GIC_DIST_SET_ENABLED(irq, cm); } } } @@ -171,7 +171,7 @@ static void translate_pending(GICState *s, int irq, int= cpu, *field =3D gic_test_pending(s, irq, cm); } else { if (*field & 1) { - GIC_SET_PENDING(irq, cm); + GIC_DIST_SET_PENDING(irq, cm); /* TODO: Capture is level-line is held high in the kernel */ } } @@ -183,10 +183,10 @@ static void translate_active(GICState *s, int irq, in= t cpu, int cm =3D (irq < GIC_INTERNAL) ? (1 << cpu) : ALL_CPU_MASK; =20 if (to_kernel) { - *field =3D GIC_TEST_ACTIVE(irq, cm); + *field =3D GIC_DIST_TEST_ACTIVE(irq, cm); } else { if (*field & 1) { - GIC_SET_ACTIVE(irq, cm); + GIC_DIST_SET_ACTIVE(irq, cm); } } } @@ -195,10 +195,10 @@ static void translate_trigger(GICState *s, int irq, i= nt cpu, uint32_t *field, bool to_kernel) { if (to_kernel) { - *field =3D (GIC_TEST_EDGE_TRIGGER(irq)) ? 0x2 : 0x0; + *field =3D (GIC_DIST_TEST_EDGE_TRIGGER(irq)) ? 0x2 : 0x0; } else { if (*field & 0x2) { - GIC_SET_EDGE_TRIGGER(irq); + GIC_DIST_SET_EDGE_TRIGGER(irq); } } } @@ -207,9 +207,10 @@ static void translate_priority(GICState *s, int irq, i= nt cpu, uint32_t *field, bool to_kernel) { if (to_kernel) { - *field =3D GIC_GET_PRIORITY(irq, cpu) & 0xff; + *field =3D GIC_DIST_GET_PRIORITY(irq, cpu) & 0xff; } else { - gic_set_priority(s, cpu, irq, *field & 0xff, MEMTXATTRS_UNSPECIFIE= D); + gic_dist_set_priority(s, cpu, irq, + *field & 0xff, MEMTXATTRS_UNSPECIFIED); } } =20 diff --git a/hw/intc/gic_internal.h b/hw/intc/gic_internal.h index 7fe87b13de..6f8d242904 100644 --- a/hw/intc/gic_internal.h +++ b/hw/intc/gic_internal.h @@ -27,30 +27,31 @@ =20 #define GIC_BASE_IRQ 0 =20 -#define GIC_SET_ENABLED(irq, cm) s->irq_state[irq].enabled |=3D (cm) -#define GIC_CLEAR_ENABLED(irq, cm) s->irq_state[irq].enabled &=3D ~(cm) -#define GIC_TEST_ENABLED(irq, cm) ((s->irq_state[irq].enabled & (cm)) !=3D= 0) -#define GIC_SET_PENDING(irq, cm) s->irq_state[irq].pending |=3D (cm) -#define GIC_CLEAR_PENDING(irq, cm) s->irq_state[irq].pending &=3D ~(cm) -#define GIC_SET_ACTIVE(irq, cm) s->irq_state[irq].active |=3D (cm) -#define GIC_CLEAR_ACTIVE(irq, cm) s->irq_state[irq].active &=3D ~(cm) -#define GIC_TEST_ACTIVE(irq, cm) ((s->irq_state[irq].active & (cm)) !=3D 0) -#define GIC_SET_MODEL(irq) s->irq_state[irq].model =3D true -#define GIC_CLEAR_MODEL(irq) s->irq_state[irq].model =3D false -#define GIC_TEST_MODEL(irq) s->irq_state[irq].model -#define GIC_SET_LEVEL(irq, cm) s->irq_state[irq].level |=3D (cm) -#define GIC_CLEAR_LEVEL(irq, cm) s->irq_state[irq].level &=3D ~(cm) -#define GIC_TEST_LEVEL(irq, cm) ((s->irq_state[irq].level & (cm)) !=3D 0) -#define GIC_SET_EDGE_TRIGGER(irq) s->irq_state[irq].edge_trigger =3D true -#define GIC_CLEAR_EDGE_TRIGGER(irq) s->irq_state[irq].edge_trigger =3D fal= se -#define GIC_TEST_EDGE_TRIGGER(irq) (s->irq_state[irq].edge_trigger) -#define GIC_GET_PRIORITY(irq, cpu) (((irq) < GIC_INTERNAL) ? \ +#define GIC_DIST_SET_ENABLED(irq, cm) (s->irq_state[irq].enabled |=3D (cm)) +#define GIC_DIST_CLEAR_ENABLED(irq, cm) (s->irq_state[irq].enabled &=3D ~(= cm)) +#define GIC_DIST_TEST_ENABLED(irq, cm) ((s->irq_state[irq].enabled & (cm))= !=3D 0) +#define GIC_DIST_SET_PENDING(irq, cm) (s->irq_state[irq].pending |=3D (cm)) +#define GIC_DIST_CLEAR_PENDING(irq, cm) (s->irq_state[irq].pending &=3D ~(= cm)) +#define GIC_DIST_SET_ACTIVE(irq, cm) (s->irq_state[irq].active |=3D (cm)) +#define GIC_DIST_CLEAR_ACTIVE(irq, cm) (s->irq_state[irq].active &=3D ~(cm= )) +#define GIC_DIST_TEST_ACTIVE(irq, cm) ((s->irq_state[irq].active & (cm)) != =3D 0) +#define GIC_DIST_SET_MODEL(irq) (s->irq_state[irq].model =3D true) +#define GIC_DIST_CLEAR_MODEL(irq) (s->irq_state[irq].model =3D false) +#define GIC_DIST_TEST_MODEL(irq) (s->irq_state[irq].model) +#define GIC_DIST_SET_LEVEL(irq, cm) (s->irq_state[irq].level |=3D (cm)) +#define GIC_DIST_CLEAR_LEVEL(irq, cm) (s->irq_state[irq].level &=3D ~(cm)) +#define GIC_DIST_TEST_LEVEL(irq, cm) ((s->irq_state[irq].level & (cm)) != =3D 0) +#define GIC_DIST_SET_EDGE_TRIGGER(irq) (s->irq_state[irq].edge_trigger =3D= true) +#define GIC_DIST_CLEAR_EDGE_TRIGGER(irq) \ + (s->irq_state[irq].edge_trigger =3D false) +#define GIC_DIST_TEST_EDGE_TRIGGER(irq) (s->irq_state[irq].edge_trigger) +#define GIC_DIST_GET_PRIORITY(irq, cpu) (((irq) < GIC_INTERNAL) ? = \ s->priority1[irq][cpu] : \ s->priority2[(irq) - GIC_INTERNAL]) -#define GIC_TARGET(irq) s->irq_target[irq] -#define GIC_CLEAR_GROUP(irq, cm) (s->irq_state[irq].group &=3D ~(cm)) -#define GIC_SET_GROUP(irq, cm) (s->irq_state[irq].group |=3D (cm)) -#define GIC_TEST_GROUP(irq, cm) ((s->irq_state[irq].group & (cm)) !=3D 0) +#define GIC_DIST_TARGET(irq) (s->irq_target[irq]) +#define GIC_DIST_CLEAR_GROUP(irq, cm) (s->irq_state[irq].group &=3D ~(cm)) +#define GIC_DIST_SET_GROUP(irq, cm) (s->irq_state[irq].group |=3D (cm)) +#define GIC_DIST_TEST_GROUP(irq, cm) ((s->irq_state[irq].group & (cm)) != =3D 0) =20 #define GICD_CTLR_EN_GRP0 (1U << 0) #define GICD_CTLR_EN_GRP1 (1U << 1) @@ -79,8 +80,8 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemTxA= ttrs attrs); void gic_complete_irq(GICState *s, int cpu, int irq, MemTxAttrs attrs); void gic_update(GICState *s); void gic_init_irqs_and_distributor(GICState *s); -void gic_set_priority(GICState *s, int cpu, int irq, uint8_t val, - MemTxAttrs attrs); +void gic_dist_set_priority(GICState *s, int cpu, int irq, uint8_t val, + MemTxAttrs attrs); =20 static inline bool gic_test_pending(GICState *s, int irq, int cm) { @@ -93,7 +94,7 @@ static inline bool gic_test_pending(GICState *s, int irq,= int cm) * GICD_ISPENDR to set the state pending. */ return (s->irq_state[irq].pending & cm) || - (!GIC_TEST_EDGE_TRIGGER(irq) && GIC_TEST_LEVEL(irq, cm)); + (!GIC_DIST_TEST_EDGE_TRIGGER(irq) && GIC_DIST_TEST_LEVEL(irq, = cm)); } } =20 --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531588788212924.2834856963548; Sat, 14 Jul 2018 10:19:48 -0700 (PDT) Received: from localhost ([::1]:42066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOCo-0007ea-Ff for importer@patchew.org; Sat, 14 Jul 2018 13:19:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9q-0005mX-SH for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9o-0004Xz-G0 for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:34 -0400 Received: from greensocs.com ([193.104.36.180]:57255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9i-0004MM-Mv; Sat, 14 Jul 2018 13:16:26 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id BFF3FC7AFE; Sat, 14 Jul 2018 19:16:17 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id epXyKaisCYkb; Sat, 14 Jul 2018 19:16:17 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id E6A6FC7AF9; Sat, 14 Jul 2018 19:16:16 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 1D45CC7AE3; Sat, 14 Jul 2018 19:16:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588577; bh=cH6+vpEmFdzTYRqDq6gwPorocs7nHSz3mVlAilMImI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AsV+XrcVNCdUjvRjaYlH4YJOlI36CrVrag5RXYp3afKjLWbTTmKQ8LVwaqH/efaPc HbEHEFF28DKNf22QcSokgleOdS/0Go2y3HhLj90JtU87GkKxkW3fCCdEiMY1jpsSaa vu+cGCD/YpGcxKKnivftGuvC8LeKYfagTEHj6Lrg= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=QuDcugKU; dkim=pass (1024-bit key) header.d=greensocs.com header.b=QuDcugKU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588576; bh=cH6+vpEmFdzTYRqDq6gwPorocs7nHSz3mVlAilMImI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QuDcugKUnlIDXEijgzSjngjzLC9DDBISgY9jG2OII/1w0fQ3J+bHbfKt+44GHGByr oSxqCgWL0UQ7Con+CzSZHFb2jjgtikiYowq7ONScu8puXzSVCy1HtLgZ8uwT2hASrP GvRGYNUO2rvOgK0Uxon1w+IyUa6hFN/08F+f5CL0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588576; bh=cH6+vpEmFdzTYRqDq6gwPorocs7nHSz3mVlAilMImI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QuDcugKUnlIDXEijgzSjngjzLC9DDBISgY9jG2OII/1w0fQ3J+bHbfKt+44GHGByr oSxqCgWL0UQ7Con+CzSZHFb2jjgtikiYowq7ONScu8puXzSVCy1HtLgZ8uwT2hASrP GvRGYNUO2rvOgK0Uxon1w+IyUa6hFN/08F+f5CL0= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:43 +0200 Message-Id: <20180714171601.5734-3-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 02/20] intc/arm_gic: Implement GICD_ISACTIVERn and GICD_ICACTIVERn registers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Implement GICD_ISACTIVERn and GICD_ICACTIVERn registers in the GICv2. Those registers allow to set or clear the active state of an IRQ in the distributor. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 61 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 6f3074ba88..accc03523b 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -711,8 +711,16 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr of= fset, MemTxAttrs attrs) } } } else if (offset < 0x400) { - /* Interrupt Active. */ - irq =3D (offset - 0x300) * 8 + GIC_BASE_IRQ; + /* Interrupt Set/Clear Active. */ + if (offset < 0x380) { + irq =3D (offset - 0x300) * 8; + } else if (s->revision =3D=3D 2) { + irq =3D (offset - 0x380) * 8; + } else { + goto bad_reg; + } + + irq +=3D GIC_BASE_IRQ; if (irq >=3D s->num_irq) goto bad_reg; res =3D 0; @@ -991,9 +999,54 @@ static void gic_dist_writeb(void *opaque, hwaddr offse= t, GIC_DIST_CLEAR_PENDING(irq + i, ALL_CPU_MASK); } } + } else if (offset < 0x380) { + /* Interrupt Set Active. */ + if (s->revision !=3D 2) { + goto bad_reg; + } + + irq =3D (offset - 0x300) * 8 + GIC_BASE_IRQ; + if (irq >=3D s->num_irq) { + goto bad_reg; + } + + /* This register is banked per-cpu for PPIs */ + int cm =3D irq < GIC_INTERNAL ? (1 << cpu) : ALL_CPU_MASK; + + for (i =3D 0; i < 8; i++) { + if (s->security_extn && !attrs.secure && + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { + continue; /* Ignore Non-secure access of Group0 IRQ */ + } + + if (value & (1 << i)) { + GIC_DIST_SET_ACTIVE(irq + i, cm); + } + } } else if (offset < 0x400) { - /* Interrupt Active. */ - goto bad_reg; + /* Interrupt Clear Active. */ + if (s->revision !=3D 2) { + goto bad_reg; + } + + irq =3D (offset - 0x380) * 8 + GIC_BASE_IRQ; + if (irq >=3D s->num_irq) { + goto bad_reg; + } + + /* This register is banked per-cpu for PPIs */ + int cm =3D irq < GIC_INTERNAL ? (1 << cpu) : ALL_CPU_MASK; + + for (i =3D 0; i < 8; i++) { + if (s->security_extn && !attrs.secure && + !GIC_DIST_TEST_GROUP(irq + i, 1 << cpu)) { + continue; /* Ignore Non-secure access of Group0 IRQ */ + } + + if (value & (1 << i)) { + GIC_DIST_CLEAR_ACTIVE(irq + i, cm); + } + } } else if (offset < 0x800) { /* Interrupt Priority. */ irq =3D (offset - 0x400) + GIC_BASE_IRQ; --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531588788040370.50138569178137; Sat, 14 Jul 2018 10:19:48 -0700 (PDT) Received: from localhost ([::1]:42068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOCr-0007gT-IN for importer@patchew.org; Sat, 14 Jul 2018 13:19:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9q-0005m7-JM for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9o-0004YJ-Jx for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:34 -0400 Received: from greensocs.com ([193.104.36.180]:57253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9i-0004MP-OK; Sat, 14 Jul 2018 13:16:27 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 9BCD5C7FA2; Sat, 14 Jul 2018 19:16:18 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id if4eSR_Bzi6J; Sat, 14 Jul 2018 19:16:17 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 8D73DC7AE3; Sat, 14 Jul 2018 19:16:17 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id D8D84C7ADD; Sat, 14 Jul 2018 19:16:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588578; bh=m9WDuVhJ8xqlUr5PbtNbOeZfVH9fE/HRNe6eO4F6f3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wt4RSS8lT65ZpoUKFBkpvCnbBNOEzJn7CHz7zkfC2GykoQqucFefIZNfYBiHy3sM/ 65Ry5TDxCAHdy2hgcHLgVOqzlM8rPAv6ZSvn2NdWpx0UYcNExYC0hhGHnbjRqETuZq 3hoWaQ/2UgSaGWxy7WlIzmcdYEb6pjb3gZk9r/Z0= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=5d+5xGjZ; dkim=pass (1024-bit key) header.d=greensocs.com header.b=5d+5xGjZ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588577; bh=m9WDuVhJ8xqlUr5PbtNbOeZfVH9fE/HRNe6eO4F6f3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=5d+5xGjZdsTlOMqUiP3BH5ar3nJ0WbcBY3fprTvrciwTtf6asLAyd9mLIBOwjGQQU ieGqvcaxsUbPHVLnkGFusFP0xd0RcYEkmGjbTD3NNxDBXWijI8/rl8XY3OEtOokoms MJL7aJI1pzi74LvKI/4CBkVwCE7zlMeIIlVvQfYo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588577; bh=m9WDuVhJ8xqlUr5PbtNbOeZfVH9fE/HRNe6eO4F6f3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=5d+5xGjZdsTlOMqUiP3BH5ar3nJ0WbcBY3fprTvrciwTtf6asLAyd9mLIBOwjGQQU ieGqvcaxsUbPHVLnkGFusFP0xd0RcYEkmGjbTD3NNxDBXWijI8/rl8XY3OEtOokoms MJL7aJI1pzi74LvKI/4CBkVwCE7zlMeIIlVvQfYo= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:44 +0200 Message-Id: <20180714171601.5734-4-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 03/20] intc/arm_gic: Remove some dead code and put some functions static X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Some functions are now only used in arm_gic.c, put them static. Some of them where only used by the NVIC implementation and are not used anymore, so remove them. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 23 ++--------------------- hw/intc/gic_internal.h | 4 ---- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index accc03523b..9fe70e5519 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -71,7 +71,7 @@ static inline bool gic_has_groups(GICState *s) =20 /* TODO: Many places that call this routine could be optimized. */ /* Update interrupt status after enabled or pending bits have been changed= . */ -void gic_update(GICState *s) +static void gic_update(GICState *s) { int best_irq; int best_prio; @@ -137,19 +137,6 @@ void gic_update(GICState *s) } } =20 -void gic_set_pending_private(GICState *s, int cpu, int irq) -{ - int cm =3D 1 << cpu; - - if (gic_test_pending(s, irq, cm)) { - return; - } - - DPRINTF("Set %d pending cpu %d\n", irq, cpu); - GIC_DIST_SET_PENDING(irq, cm); - gic_update(s); -} - static void gic_set_irq_11mpcore(GICState *s, int irq, int level, int cm, int target) { @@ -565,7 +552,7 @@ static void gic_deactivate_irq(GICState *s, int cpu, in= t irq, MemTxAttrs attrs) GIC_DIST_CLEAR_ACTIVE(irq, cm); } =20 -void gic_complete_irq(GICState *s, int cpu, int irq, MemTxAttrs attrs) +static void gic_complete_irq(GICState *s, int cpu, int irq, MemTxAttrs att= rs) { int cm =3D 1 << cpu; int group; @@ -1472,12 +1459,6 @@ static const MemoryRegionOps gic_cpu_ops =3D { .endianness =3D DEVICE_NATIVE_ENDIAN, }; =20 -/* This function is used by nvic model */ -void gic_init_irqs_and_distributor(GICState *s) -{ - gic_init_irqs_and_mmio(s, gic_set_irq, gic_ops); -} - static void arm_gic_realize(DeviceState *dev, Error **errp) { /* Device instance realize function for the GIC sysbus device */ diff --git a/hw/intc/gic_internal.h b/hw/intc/gic_internal.h index 6f8d242904..a2075a94db 100644 --- a/hw/intc/gic_internal.h +++ b/hw/intc/gic_internal.h @@ -75,11 +75,7 @@ /* The special cases for the revision property: */ #define REV_11MPCORE 0 =20 -void gic_set_pending_private(GICState *s, int cpu, int irq); uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemTxAttrs attrs); -void gic_complete_irq(GICState *s, int cpu, int irq, MemTxAttrs attrs); -void gic_update(GICState *s); -void gic_init_irqs_and_distributor(GICState *s); void gic_dist_set_priority(GICState *s, int cpu, int irq, uint8_t val, MemTxAttrs attrs); =20 --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153158895637816.095082264280677; Sat, 14 Jul 2018 10:22:36 -0700 (PDT) Received: from localhost ([::1]:42087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOFf-0001Xt-7F for importer@patchew.org; Sat, 14 Jul 2018 13:22:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9q-0005mO-NG for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9o-0004Y4-Gd for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:34 -0400 Received: from greensocs.com ([193.104.36.180]:57252) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9i-0004ML-Mj; Sat, 14 Jul 2018 13:16:26 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 32443C7AE3; Sat, 14 Jul 2018 19:16:19 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZUA-Qmim85Te; Sat, 14 Jul 2018 19:16:18 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 5B75DC7AF0; Sat, 14 Jul 2018 19:16:18 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id A2EACC7ADD; Sat, 14 Jul 2018 19:16:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588579; bh=R0qo1qb4zMgWwyZkI0Car8T0C8eMP8Rof3Obc1oH8Wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vV4/QXMwNU/WfrOkEcLDINZVOcQM6V5jyPGDqPkyi529CUXoS8JYBl5ZuuOV/an/G iZIatPxa4K2cPoMvvOFvVFMnEO1//SIkgETe8CnkknDZmxQJTxMJe/LN0wOuroI212 3FZWJfDsyIOhZWwoeMHziWUnXiLdA0IUQYk3cDO0= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=enhlSUeg; dkim=pass (1024-bit key) header.d=greensocs.com header.b=enhlSUeg DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588578; bh=R0qo1qb4zMgWwyZkI0Car8T0C8eMP8Rof3Obc1oH8Wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=enhlSUegUdJVrF9/RvMlGwisL7rcUiCW02pZqc3GBcJfwmv0C5nCxyWBhpowhl+lF P8BvzD25zZ4FHvwyrWmkQfs65BQ3jmBtjjyHaUT480QGB0d8FNcGy6kFS9FrH4OiT2 Mkopq593x8hoXIwAmQRqscVvIjCyRJqpXHnvWXcQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588578; bh=R0qo1qb4zMgWwyZkI0Car8T0C8eMP8Rof3Obc1oH8Wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=enhlSUegUdJVrF9/RvMlGwisL7rcUiCW02pZqc3GBcJfwmv0C5nCxyWBhpowhl+lF P8BvzD25zZ4FHvwyrWmkQfs65BQ3jmBtjjyHaUT480QGB0d8FNcGy6kFS9FrH4OiT2 Mkopq593x8hoXIwAmQRqscVvIjCyRJqpXHnvWXcQ= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:45 +0200 Message-Id: <20180714171601.5734-5-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 04/20] vmstate.h: Provide VMSTATE_UINT16_SUB_ARRAY X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Provide a VMSTATE_UINT16_SUB_ARRAY macro to save a uint16_t sub-array in a VMState. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- include/migration/vmstate.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 42b946ce90..2b501d0466 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -923,6 +923,9 @@ extern const VMStateInfo vmstate_info_qtailq; #define VMSTATE_UINT16_ARRAY(_f, _s, _n) \ VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0) =20 +#define VMSTATE_UINT16_SUB_ARRAY(_f, _s, _start, _num) \ + VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint16, uint16= _t) + #define VMSTATE_UINT16_2DARRAY(_f, _s, _n1, _n2) \ VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, 0) =20 --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153158976781538.010325135796165; Sat, 14 Jul 2018 10:36:07 -0700 (PDT) Received: from localhost ([::1]:42167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOSk-0002UY-NA for importer@patchew.org; Sat, 14 Jul 2018 13:36:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9y-0005tw-W6 for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9v-0004gY-8g for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:42 -0400 Received: from greensocs.com ([193.104.36.180]:57312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9j-0004QJ-Dx; Sat, 14 Jul 2018 13:16:27 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 598C7319FCA; Sat, 14 Jul 2018 19:16:21 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C6N9ZyDMiwuh; Sat, 14 Jul 2018 19:16:20 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 65115C7AF0; Sat, 14 Jul 2018 19:16:19 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 6BD9AC7ADD; Sat, 14 Jul 2018 19:16:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588581; bh=okdUC6xHm2ykstp8lt4YTXKVivpndZ3Q+S3qmgUI6+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=7Pci2fGy12DySQ7mtM/8ikH1xnUKoZuQk2LZ0C0AHVcNfKaNpkimr5SUnnMiT3oRZ 8DOYj+Q84uFZGvcTMNKWUwSSs/C6pgIZLS+1NCnX+C4jVuyuAmycY/d1fr7Jexe9n5 DERvKj+xzsOFtk7d+Mfdkk6Ehpgpu6C2G1FXoqqE= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=eHUZ/HLy; dkim=pass (1024-bit key) header.d=greensocs.com header.b=eHUZ/HLy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588579; bh=okdUC6xHm2ykstp8lt4YTXKVivpndZ3Q+S3qmgUI6+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eHUZ/HLy+oX7AHXsb0Ece+EOHgfUirwhhZY6COU379RpV4qgUwltsoibPbpngpo1S y4dfm/lwdAdcLUxjU2/J7zKwIwwcH1u4dAscwUrTB8Jb08zfXP+C67goFjdxIsl26k JMg3Q0KYFSznPbWLaoiFag/V/0DgNyP60R8OxmqY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588579; bh=okdUC6xHm2ykstp8lt4YTXKVivpndZ3Q+S3qmgUI6+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eHUZ/HLy+oX7AHXsb0Ece+EOHgfUirwhhZY6COU379RpV4qgUwltsoibPbpngpo1S y4dfm/lwdAdcLUxjU2/J7zKwIwwcH1u4dAscwUrTB8Jb08zfXP+C67goFjdxIsl26k JMg3Q0KYFSznPbWLaoiFag/V/0DgNyP60R8OxmqY= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:46 +0200 Message-Id: <20180714171601.5734-6-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 05/20] intc/arm_gic: Add the virtualization extensions to the GIC state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the necessary parts of the virtualization extensions state to the GIC state. We choose to increase the size of the CPU interfaces state to add space for the vCPU interfaces (the GIC_NCPU_VCPU macro). This way, we'll be able to reuse most of the CPU interface code for the vCPUs. The only exception is the APR value, which is stored in h_apr in the virtual interface state for vCPUs. This is due to some complications with the GIC VMState, for which we don't want to break backward compatibility. APRs being stored in 2D arrays, increasing the second dimension would lead to some ugly VMState description. To avoid that, we keep it in h_apr for vCPUs. The vCPUs are numbered from GIC_NCPU to (GIC_NCPU * 2) - 1. The `gic_is_vcpu` function help to determine if a given CPU id correspond to a physical CPU or a virtual one. For the in-kernel KVM VGIC, since the exposed VGIC does not implement the virtualization extensions, we report an error if the corresponding property is set to true. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 2 +- hw/intc/arm_gic_common.c | 148 ++++++++++++++++++++++++++----- hw/intc/arm_gic_kvm.c | 8 +- hw/intc/gic_internal.h | 5 ++ include/hw/intc/arm_gic_common.h | 43 +++++++-- 5 files changed, 173 insertions(+), 33 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 9fe70e5519..aaa34426a1 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -1481,7 +1481,7 @@ static void arm_gic_realize(DeviceState *dev, Error *= *errp) } =20 /* This creates distributor and main CPU interface (s->cpuiomem[0]) */ - gic_init_irqs_and_mmio(s, gic_set_irq, gic_ops); + gic_init_irqs_and_mmio(s, gic_set_irq, gic_ops, NULL); =20 /* Extra core-specific regions for the CPU interfaces. This is * necessary for "franken-GIC" implementations, for example on diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c index 295ee9cc5e..547dc41185 100644 --- a/hw/intc/arm_gic_common.c +++ b/hw/intc/arm_gic_common.c @@ -46,6 +46,13 @@ static int gic_post_load(void *opaque, int version_id) return 0; } =20 +static bool gic_virt_state_needed(void *opaque) +{ + GICState *s =3D (GICState *)opaque; + + return s->virt_extn; +} + static const VMStateDescription vmstate_gic_irq_state =3D { .name =3D "arm_gic_irq_state", .version_id =3D 1, @@ -62,6 +69,30 @@ static const VMStateDescription vmstate_gic_irq_state = =3D { } }; =20 +static const VMStateDescription vmstate_gic_virt_state =3D { + .name =3D "arm_gic_virt_state", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D gic_virt_state_needed, + .fields =3D (VMStateField[]) { + /* Virtual interface */ + VMSTATE_UINT32_ARRAY(h_hcr, GICState, GIC_NCPU), + VMSTATE_UINT32_ARRAY(h_misr, GICState, GIC_NCPU), + VMSTATE_UINT32_2DARRAY(h_lr, GICState, GIC_MAX_LR, GIC_NCPU), + VMSTATE_UINT32_ARRAY(h_apr, GICState, GIC_NCPU), + + /* Virtual CPU interfaces */ + VMSTATE_UINT32_SUB_ARRAY(cpu_ctlr, GICState, GIC_NCPU, GIC_NCPU), + VMSTATE_UINT16_SUB_ARRAY(priority_mask, GICState, GIC_NCPU, GIC_NC= PU), + VMSTATE_UINT16_SUB_ARRAY(running_priority, GICState, GIC_NCPU, GIC= _NCPU), + VMSTATE_UINT16_SUB_ARRAY(current_pending, GICState, GIC_NCPU, GIC_= NCPU), + VMSTATE_UINT8_SUB_ARRAY(bpr, GICState, GIC_NCPU, GIC_NCPU), + VMSTATE_UINT8_SUB_ARRAY(abpr, GICState, GIC_NCPU, GIC_NCPU), + + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_gic =3D { .name =3D "arm_gic", .version_id =3D 12, @@ -70,26 +101,31 @@ static const VMStateDescription vmstate_gic =3D { .post_load =3D gic_post_load, .fields =3D (VMStateField[]) { VMSTATE_UINT32(ctlr, GICState), - VMSTATE_UINT32_ARRAY(cpu_ctlr, GICState, GIC_NCPU), + VMSTATE_UINT32_SUB_ARRAY(cpu_ctlr, GICState, 0, GIC_NCPU), VMSTATE_STRUCT_ARRAY(irq_state, GICState, GIC_MAXIRQ, 1, vmstate_gic_irq_state, gic_irq_state), VMSTATE_UINT8_ARRAY(irq_target, GICState, GIC_MAXIRQ), VMSTATE_UINT8_2DARRAY(priority1, GICState, GIC_INTERNAL, GIC_NCPU), VMSTATE_UINT8_ARRAY(priority2, GICState, GIC_MAXIRQ - GIC_INTERNAL= ), VMSTATE_UINT8_2DARRAY(sgi_pending, GICState, GIC_NR_SGIS, GIC_NCPU= ), - VMSTATE_UINT16_ARRAY(priority_mask, GICState, GIC_NCPU), - VMSTATE_UINT16_ARRAY(running_priority, GICState, GIC_NCPU), - VMSTATE_UINT16_ARRAY(current_pending, GICState, GIC_NCPU), - VMSTATE_UINT8_ARRAY(bpr, GICState, GIC_NCPU), - VMSTATE_UINT8_ARRAY(abpr, GICState, GIC_NCPU), + VMSTATE_UINT16_SUB_ARRAY(priority_mask, GICState, 0, GIC_NCPU), + VMSTATE_UINT16_SUB_ARRAY(running_priority, GICState, 0, GIC_NCPU), + VMSTATE_UINT16_SUB_ARRAY(current_pending, GICState, 0, GIC_NCPU), + VMSTATE_UINT8_SUB_ARRAY(bpr, GICState, 0, GIC_NCPU), + VMSTATE_UINT8_SUB_ARRAY(abpr, GICState, 0, GIC_NCPU), VMSTATE_UINT32_2DARRAY(apr, GICState, GIC_NR_APRS, GIC_NCPU), VMSTATE_UINT32_2DARRAY(nsapr, GICState, GIC_NR_APRS, GIC_NCPU), VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_gic_virt_state, + NULL } }; =20 void gic_init_irqs_and_mmio(GICState *s, qemu_irq_handler handler, - const MemoryRegionOps *ops) + const MemoryRegionOps *ops, + const MemoryRegionOps *virt_ops) { SysBusDevice *sbd =3D SYS_BUS_DEVICE(s); int i =3D s->num_irq - GIC_INTERNAL; @@ -116,6 +152,11 @@ void gic_init_irqs_and_mmio(GICState *s, qemu_irq_hand= ler handler, for (i =3D 0; i < s->num_cpu; i++) { sysbus_init_irq(sbd, &s->parent_vfiq[i]); } + if (s->virt_extn) { + for (i =3D 0; i < s->num_cpu; i++) { + sysbus_init_irq(sbd, &s->maintenance_irq[i]); + } + } =20 /* Distributor */ memory_region_init_io(&s->iomem, OBJECT(s), ops, s, "gic_dist", 0x1000= ); @@ -127,6 +168,17 @@ void gic_init_irqs_and_mmio(GICState *s, qemu_irq_hand= ler handler, memory_region_init_io(&s->cpuiomem[0], OBJECT(s), ops ? &ops[1] : NULL, s, "gic_cpu", s->revision =3D=3D 2 ? 0x2000 : 0x= 100); sysbus_init_mmio(sbd, &s->cpuiomem[0]); + + if (s->virt_extn) { + memory_region_init_io(&s->vifaceiomem[0], OBJECT(s), virt_ops, + s, "gic_viface", 0x1000); + sysbus_init_mmio(sbd, &s->vifaceiomem[0]); + + memory_region_init_io(&s->vcpuiomem, OBJECT(s), + virt_ops ? &virt_ops[1] : NULL, + s, "gic_vcpu", 0x2000); + sysbus_init_mmio(sbd, &s->vcpuiomem); + } } =20 static void arm_gic_common_realize(DeviceState *dev, Error **errp) @@ -163,6 +215,48 @@ static void arm_gic_common_realize(DeviceState *dev, E= rror **errp) "the security extensions"); return; } + + if (s->virt_extn) { + if (s->revision !=3D 2) { + error_setg(errp, "GIC virtualization extensions are only " + "supported by revision 2"); + return; + } + + /* For now, set the number of implemented LRs to 4, as found in mo= st + * real GICv2. This could be promoted as a QOM property if we need= to + * emulate a variant with another num_lrs. + */ + s->num_lrs =3D 4; + } +} + +static inline void arm_gic_common_reset_irq_state(GICState *s, int first_c= pu, + int resetprio) +{ + int i, j; + + for (i =3D first_cpu; i < first_cpu + s->num_cpu; i++) { + if (s->revision =3D=3D REV_11MPCORE) { + s->priority_mask[i] =3D 0xf0; + } else { + s->priority_mask[i] =3D resetprio; + } + s->current_pending[i] =3D 1023; + s->running_priority[i] =3D 0x100; + s->cpu_ctlr[i] =3D 0; + s->bpr[i] =3D gic_is_vcpu(i) ? GIC_VIRT_MIN_BPR : GIC_MIN_BPR; + s->abpr[i] =3D gic_is_vcpu(i) ? GIC_VIRT_MIN_ABPR : GIC_MIN_ABPR; + + if (!gic_is_vcpu(i)) { + for (j =3D 0; j < GIC_INTERNAL; j++) { + s->priority1[j][i] =3D resetprio; + } + for (j =3D 0; j < GIC_NR_SGIS; j++) { + s->sgi_pending[j][i] =3D 0; + } + } + } } =20 static void arm_gic_common_reset(DeviceState *dev) @@ -185,24 +279,15 @@ static void arm_gic_common_reset(DeviceState *dev) } =20 memset(s->irq_state, 0, GIC_MAXIRQ * sizeof(gic_irq_state)); - for (i =3D 0 ; i < s->num_cpu; i++) { - if (s->revision =3D=3D REV_11MPCORE) { - s->priority_mask[i] =3D 0xf0; - } else { - s->priority_mask[i] =3D resetprio; - } - s->current_pending[i] =3D 1023; - s->running_priority[i] =3D 0x100; - s->cpu_ctlr[i] =3D 0; - s->bpr[i] =3D GIC_MIN_BPR; - s->abpr[i] =3D GIC_MIN_ABPR; - for (j =3D 0; j < GIC_INTERNAL; j++) { - s->priority1[j][i] =3D resetprio; - } - for (j =3D 0; j < GIC_NR_SGIS; j++) { - s->sgi_pending[j][i] =3D 0; - } + arm_gic_common_reset_irq_state(s, 0, resetprio); + + if (s->virt_extn) { + /* vCPU states are stored at indexes GIC_NCPU .. GIC_NCPU+num_cpu. + * The exposed vCPU interface does not have security extensions. + */ + arm_gic_common_reset_irq_state(s, GIC_NCPU, 0); } + for (i =3D 0; i < GIC_NR_SGIS; i++) { GIC_DIST_SET_ENABLED(i, ALL_CPU_MASK); GIC_DIST_SET_EDGE_TRIGGER(i); @@ -226,6 +311,19 @@ static void arm_gic_common_reset(DeviceState *dev) } } =20 + if (s->virt_extn) { + for (i =3D 0; i < s->num_lrs; i++) { + for (j =3D 0; j < s->num_cpu; j++) { + s->h_lr[i][j] =3D 0; + } + } + + for (i =3D 0; i < s->num_cpu; i++) { + s->h_hcr[i] =3D 0; + s->h_misr[i] =3D 0; + } + } + s->ctlr =3D 0; } =20 @@ -255,6 +353,8 @@ static Property arm_gic_common_properties[] =3D { DEFINE_PROP_UINT32("revision", GICState, revision, 1), /* True if the GIC should implement the security extensions */ DEFINE_PROP_BOOL("has-security-extensions", GICState, security_extn, 0= ), + /* True if the GIC should implement the virtualization extensions */ + DEFINE_PROP_BOOL("has-virtualization-extensions", GICState, virt_extn,= 0), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c index 4b611c8d6d..a611e8ee12 100644 --- a/hw/intc/arm_gic_kvm.c +++ b/hw/intc/arm_gic_kvm.c @@ -511,6 +511,12 @@ static void kvm_arm_gic_realize(DeviceState *dev, Erro= r **errp) return; } =20 + if (s->virt_extn) { + error_setg(errp, "the in-kernel VGIC does not implement the " + "virtualization extensions"); + return; + } + if (!kvm_arm_gic_can_save_restore(s)) { error_setg(&s->migration_blocker, "This operating system kernel do= es " "not support vGICv2 migration"); @@ -522,7 +528,7 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error= **errp) } } =20 - gic_init_irqs_and_mmio(s, kvm_arm_gicv2_set_irq, NULL); + gic_init_irqs_and_mmio(s, kvm_arm_gicv2_set_irq, NULL, NULL); =20 for (i =3D 0; i < s->num_irq - GIC_INTERNAL; i++) { qemu_irq irq =3D qdev_get_gpio_in(dev, i); diff --git a/hw/intc/gic_internal.h b/hw/intc/gic_internal.h index a2075a94db..c85427c8e3 100644 --- a/hw/intc/gic_internal.h +++ b/hw/intc/gic_internal.h @@ -94,4 +94,9 @@ static inline bool gic_test_pending(GICState *s, int irq,= int cm) } } =20 +static inline bool gic_is_vcpu(int cpu) +{ + return cpu >=3D GIC_NCPU; +} + #endif /* QEMU_ARM_GIC_INTERNAL_H */ diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_com= mon.h index af3ca18e2f..b5585fec45 100644 --- a/include/hw/intc/arm_gic_common.h +++ b/include/hw/intc/arm_gic_common.h @@ -30,6 +30,8 @@ #define GIC_NR_SGIS 16 /* Maximum number of possible CPU interfaces, determined by GIC architectu= re */ #define GIC_NCPU 8 +/* Maximum number of possible CPU interfaces with their respective vCPU */ +#define GIC_NCPU_VCPU (GIC_NCPU * 2) =20 #define MAX_NR_GROUP_PRIO 128 #define GIC_NR_APRS (MAX_NR_GROUP_PRIO / 32) @@ -37,6 +39,17 @@ #define GIC_MIN_BPR 0 #define GIC_MIN_ABPR (GIC_MIN_BPR + 1) =20 +/* Architectural maximum number of list registers in the virtual interface= */ +#define GIC_MAX_LR 64 + +/* Only 32 priority levels and 32 preemption levels in the vCPU interfaces= */ +#define GIC_VIRT_MAX_GROUP_PRIO_BITS 5 +#define GIC_VIRT_MAX_NR_GROUP_PRIO (1 << GIC_VIRT_MAX_GROUP_PRIO_BITS) +#define GIC_VIRT_NR_APRS (GIC_VIRT_MAX_NR_GROUP_PRIO / 32) + +#define GIC_VIRT_MIN_BPR 2 +#define GIC_VIRT_MIN_ABPR (GIC_VIRT_MIN_BPR + 1) + typedef struct gic_irq_state { /* The enable bits are only banked for per-cpu interrupts. */ uint8_t enabled; @@ -57,6 +70,8 @@ typedef struct GICState { qemu_irq parent_fiq[GIC_NCPU]; qemu_irq parent_virq[GIC_NCPU]; qemu_irq parent_vfiq[GIC_NCPU]; + qemu_irq maintenance_irq[GIC_NCPU]; + /* GICD_CTLR; for a GIC with the security extensions the NS banked ver= sion * of this register is just an alias of bit 1 of the S banked version. */ @@ -64,7 +79,7 @@ typedef struct GICState { /* GICC_CTLR; again, the NS banked version is just aliases of bits of * the S banked register, so our state only needs to store the S versi= on. */ - uint32_t cpu_ctlr[GIC_NCPU]; + uint32_t cpu_ctlr[GIC_NCPU_VCPU]; =20 gic_irq_state irq_state[GIC_MAXIRQ]; uint8_t irq_target[GIC_MAXIRQ]; @@ -78,9 +93,9 @@ typedef struct GICState { */ uint8_t sgi_pending[GIC_NR_SGIS][GIC_NCPU]; =20 - uint16_t priority_mask[GIC_NCPU]; - uint16_t running_priority[GIC_NCPU]; - uint16_t current_pending[GIC_NCPU]; + uint16_t priority_mask[GIC_NCPU_VCPU]; + uint16_t running_priority[GIC_NCPU_VCPU]; + uint16_t current_pending[GIC_NCPU_VCPU]; =20 /* If we present the GICv2 without security extensions to a guest, * the guest can configure the GICC_CTLR to configure group 1 binary p= oint @@ -88,8 +103,8 @@ typedef struct GICState { * For a GIC with Security Extensions we use use bpr for the * secure copy and abpr as storage for the non-secure copy of the regi= ster. */ - uint8_t bpr[GIC_NCPU]; - uint8_t abpr[GIC_NCPU]; + uint8_t bpr[GIC_NCPU_VCPU]; + uint8_t abpr[GIC_NCPU_VCPU]; =20 /* The APR is implementation defined, so we choose a layout identical = to * the KVM ABI layout for QEMU's implementation of the gic: @@ -100,6 +115,15 @@ typedef struct GICState { uint32_t apr[GIC_NR_APRS][GIC_NCPU]; uint32_t nsapr[GIC_NR_APRS][GIC_NCPU]; =20 + /* Virtual interface control registers */ + uint32_t h_hcr[GIC_NCPU]; + uint32_t h_misr[GIC_NCPU]; + uint32_t h_lr[GIC_MAX_LR][GIC_NCPU]; + uint32_t h_apr[GIC_NCPU]; + + /* Number of LRs implemented in this GIC instance */ + uint32_t num_lrs; + uint32_t num_cpu; =20 MemoryRegion iomem; /* Distributor */ @@ -108,9 +132,13 @@ typedef struct GICState { */ struct GICState *backref[GIC_NCPU]; MemoryRegion cpuiomem[GIC_NCPU + 1]; /* CPU interfaces */ + MemoryRegion vifaceiomem[GIC_NCPU + 1]; /* Virtual interfaces */ + MemoryRegion vcpuiomem; /* vCPU interface */ + uint32_t num_irq; uint32_t revision; bool security_extn; + bool virt_extn; bool irq_reset_nonsecure; /* configure IRQs as group 1 (NS) on reset? = */ int dev_fd; /* kvm device fd if backed by kvm vgic support */ Error *migration_blocker; @@ -134,6 +162,7 @@ typedef struct ARMGICCommonClass { } ARMGICCommonClass; =20 void gic_init_irqs_and_mmio(GICState *s, qemu_irq_handler handler, - const MemoryRegionOps *ops); + const MemoryRegionOps *ops, + const MemoryRegionOps *virt_ops); =20 #endif --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531588799991888.9643009449724; Sat, 14 Jul 2018 10:19:59 -0700 (PDT) Received: from localhost ([::1]:42070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOD7-0007uz-75 for importer@patchew.org; Sat, 14 Jul 2018 13:19:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9q-0005lm-71 for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9o-0004Xp-6k for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:34 -0400 Received: from greensocs.com ([193.104.36.180]:57311) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9j-0004QI-Du; Sat, 14 Jul 2018 13:16:27 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 3AC45C7AFF; Sat, 14 Jul 2018 19:16:22 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 81UODOVOf1P5; Sat, 14 Jul 2018 19:16:21 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id EE6A8C7AF4; Sat, 14 Jul 2018 19:16:20 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 6CC8EC7ADD; Sat, 14 Jul 2018 19:16:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588582; bh=LGnVqOQ1ydGryJv7quPh10kFCdk81AGnaVJGiNWVrAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=u/QAJT2Erni/BAEcMldG4dkHGRKCtaooPNAc5cwOmqKxQyi3CLPUxcqCBqG199IlT jENUQNaByED3A79S+iMVhIoKEPMWwL5/7YxD3GVylaX9DaB5N88ARfOTNCqW13JZai 1ZwJkdmTb5jKyzZz36mRQvb3417nVf6z0Kap8xVw= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=disQtvfK; dkim=pass (1024-bit key) header.d=greensocs.com header.b=disQtvfK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588580; bh=LGnVqOQ1ydGryJv7quPh10kFCdk81AGnaVJGiNWVrAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=disQtvfKn66Q7rIX+PEaRkjWpA/MOo7jdZZ+ukTTK600kk82vIt5+QVFkZvjpIYqe XWHrWLQ/ufYz7G+apm81OyLat1Vpv6JI2d/9ZSXfPqvwH2cc2jJ3MbvL2WDWwkjKaf GGT1zGvLGevfG2roPh4WR0wUO/XEIAXiNzvWtVmo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588580; bh=LGnVqOQ1ydGryJv7quPh10kFCdk81AGnaVJGiNWVrAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=disQtvfKn66Q7rIX+PEaRkjWpA/MOo7jdZZ+ukTTK600kk82vIt5+QVFkZvjpIYqe XWHrWLQ/ufYz7G+apm81OyLat1Vpv6JI2d/9ZSXfPqvwH2cc2jJ3MbvL2WDWwkjKaf GGT1zGvLGevfG2roPh4WR0wUO/XEIAXiNzvWtVmo= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:47 +0200 Message-Id: <20180714171601.5734-7-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 06/20] intc/arm_gic: Add virtual interface register definitions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the register definitions for the virtual interface of the GICv2. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/gic_internal.h | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/hw/intc/gic_internal.h b/hw/intc/gic_internal.h index c85427c8e3..1aa888a576 100644 --- a/hw/intc/gic_internal.h +++ b/hw/intc/gic_internal.h @@ -21,6 +21,7 @@ #ifndef QEMU_ARM_GIC_INTERNAL_H #define QEMU_ARM_GIC_INTERNAL_H =20 +#include "hw/registerfields.h" #include "hw/intc/arm_gic.h" =20 #define ALL_CPU_MASK ((unsigned)(((1 << GIC_NCPU) - 1))) @@ -64,6 +65,70 @@ #define GICC_CTLR_EOIMODE (1U << 9) #define GICC_CTLR_EOIMODE_NS (1U << 10) =20 +REG32(GICH_HCR, 0x0) + FIELD(GICH_HCR, EN, 0, 1) + FIELD(GICH_HCR, UIE, 1, 1) + FIELD(GICH_HCR, LRENPIE, 2, 1) + FIELD(GICH_HCR, NPIE, 3, 1) + FIELD(GICH_HCR, VGRP0EIE, 4, 1) + FIELD(GICH_HCR, VGRP0DIE, 5, 1) + FIELD(GICH_HCR, VGRP1EIE, 6, 1) + FIELD(GICH_HCR, VGRP1DIE, 7, 1) + FIELD(GICH_HCR, EOICount, 27, 5) + +#define GICH_HCR_MASK \ + (R_GICH_HCR_EN_MASK | R_GICH_HCR_UIE_MASK | \ + R_GICH_HCR_LRENPIE_MASK | R_GICH_HCR_NPIE_MASK | \ + R_GICH_HCR_VGRP0EIE_MASK | R_GICH_HCR_VGRP0DIE_MASK | \ + R_GICH_HCR_VGRP1EIE_MASK | R_GICH_HCR_VGRP1DIE_MASK | \ + R_GICH_HCR_EOICount_MASK) + +REG32(GICH_VTR, 0x4) + FIELD(GICH_VTR, ListRegs, 0, 6) + FIELD(GICH_VTR, PREbits, 26, 3) + FIELD(GICH_VTR, PRIbits, 29, 3) + +REG32(GICH_VMCR, 0x8) + FIELD(GICH_VMCR, VMCCtlr, 0, 10) + FIELD(GICH_VMCR, VMABP, 18, 3) + FIELD(GICH_VMCR, VMBP, 21, 3) + FIELD(GICH_VMCR, VMPriMask, 27, 5) + +REG32(GICH_MISR, 0x10) + FIELD(GICH_MISR, EOI, 0, 1) + FIELD(GICH_MISR, U, 1, 1) + FIELD(GICH_MISR, LRENP, 2, 1) + FIELD(GICH_MISR, NP, 3, 1) + FIELD(GICH_MISR, VGrp0E, 4, 1) + FIELD(GICH_MISR, VGrp0D, 5, 1) + FIELD(GICH_MISR, VGrp1E, 6, 1) + FIELD(GICH_MISR, VGrp1D, 7, 1) + +REG32(GICH_EISR0, 0x20) +REG32(GICH_EISR1, 0x24) +REG32(GICH_ELRSR0, 0x30) +REG32(GICH_ELRSR1, 0x34) +REG32(GICH_APR, 0xf0) + +REG32(GICH_LR0, 0x100) + FIELD(GICH_LR0, VirtualID, 0, 10) + FIELD(GICH_LR0, PhysicalID, 10, 10) + FIELD(GICH_LR0, CPUID, 10, 3) + FIELD(GICH_LR0, EOI, 19, 1) + FIELD(GICH_LR0, Priority, 23, 5) + FIELD(GICH_LR0, State, 28, 2) + FIELD(GICH_LR0, Grp1, 30, 1) + FIELD(GICH_LR0, HW, 31, 1) + +/* Last LR register */ +REG32(GICH_LR63, 0x1fc) + +#define GICH_LR_MASK \ + (R_GICH_LR0_VirtualID_MASK | R_GICH_LR0_PhysicalID_MASK | \ + R_GICH_LR0_CPUID_MASK | R_GICH_LR0_EOI_MASK | \ + R_GICH_LR0_Priority_MASK | R_GICH_LR0_State_MASK | \ + R_GICH_LR0_Grp1_MASK | R_GICH_LR0_HW_MASK) + /* Valid bits for GICC_CTLR for GICv1, v1 with security extensions, * GICv2 and GICv2 with security extensions: */ --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531589154161275.5715133045243; Sat, 14 Jul 2018 10:25:54 -0700 (PDT) Received: from localhost ([::1]:42111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOIn-0004Wl-Oq for importer@patchew.org; Sat, 14 Jul 2018 13:25:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9u-0005nK-CZ for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9q-0004ak-5i for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:37 -0400 Received: from greensocs.com ([193.104.36.180]:57314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9j-0004QP-F8; Sat, 14 Jul 2018 13:16:27 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 9D366C7AF4; Sat, 14 Jul 2018 19:16:22 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BZ5dYFPUE-k8; Sat, 14 Jul 2018 19:16:21 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id C00BEC7AF0; Sat, 14 Jul 2018 19:16:21 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 0B04CC7ADD; Sat, 14 Jul 2018 19:16:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588582; bh=xNjnMLYUIBx96PTSTbfrQ2nqtjoguZlGigq1zNkz3Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CFpB6jS6VAaW/PweLXlxNEzqYmXGQjG27Bdv5rcCanEdZuczZnwzyN8LQPTnBcIy0 XnBEZXA7kRiyiQT9v8DTjs9sNJHboWh/m7P3gZpeI4Sn8/0a6tAgKqMZnTb7tExRXE /PgqcEZytKa5/NBfCc7Ei3kJJn8fFbkHtSz6jowQ= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=L5XnKzbA; dkim=pass (1024-bit key) header.d=greensocs.com header.b=L5XnKzbA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588581; bh=xNjnMLYUIBx96PTSTbfrQ2nqtjoguZlGigq1zNkz3Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=L5XnKzbAnqHaYx4w7FzUW8EERhKhcAQnNNs3J80Zp/lUc8V5tzgnUCI+/0EH++5BJ YO2VmotBbTxr4wLKykUP2uhg8wkouoTxKKLp3Ex5uYsVlKBKajiduZthXAM04f5G0N EgDjl3zsdeez5FqRtmGxZkBg103INCupd9pdLh60= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588581; bh=xNjnMLYUIBx96PTSTbfrQ2nqtjoguZlGigq1zNkz3Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=L5XnKzbAnqHaYx4w7FzUW8EERhKhcAQnNNs3J80Zp/lUc8V5tzgnUCI+/0EH++5BJ YO2VmotBbTxr4wLKykUP2uhg8wkouoTxKKLp3Ex5uYsVlKBKajiduZthXAM04f5G0N EgDjl3zsdeez5FqRtmGxZkBg103INCupd9pdLh60= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:48 +0200 Message-Id: <20180714171601.5734-8-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 07/20] intc/arm_gic: Add virtualization extensions helper macros and functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add some helper macros and functions related to the virtualization extensions to gic_internal.h. The GICH_LR_* macros help extracting specific fields of a list register value. The only tricky one is the priority field as only the MSB are stored. The value must be shifted accordingly to obtain the correct priority value. gic_is_vcpu() and gic_get_vcpu_real_id() help with (v)CPU id manipulation to abstract the fact that vCPU id are in the range [ GIC_NCPU; (GIC_NCPU + num_cpu) [. gic_lr_* and gic_virq_is_valid() help with the list registers. gic_get_lr_entry() returns the LR entry for a given (vCPU, irq) pair. It is meant to be used in contexts where we know for sure that the entry exists, so we assert that entry is actually found, and the caller can avoid the NULL check on the returned pointer. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 5 +++ hw/intc/gic_internal.h | 75 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index aaa34426a1..1ac0fe740c 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -61,6 +61,11 @@ static inline int gic_get_current_cpu(GICState *s) return 0; } =20 +static inline int gic_get_current_vcpu(GICState *s) +{ + return gic_get_current_cpu(s) + GIC_NCPU; +} + /* Return true if this GIC config has interrupt groups, which is * true if we're a GICv2, or a GICv1 with the security extensions. */ diff --git a/hw/intc/gic_internal.h b/hw/intc/gic_internal.h index 1aa888a576..56e203aeb9 100644 --- a/hw/intc/gic_internal.h +++ b/hw/intc/gic_internal.h @@ -129,6 +129,20 @@ REG32(GICH_LR63, 0x1fc) R_GICH_LR0_Priority_MASK | R_GICH_LR0_State_MASK | \ R_GICH_LR0_Grp1_MASK | R_GICH_LR0_HW_MASK) =20 +#define GICH_LR_STATE_INVALID 0 +#define GICH_LR_STATE_PENDING 1 +#define GICH_LR_STATE_ACTIVE 2 +#define GICH_LR_STATE_ACTIVE_PENDING 3 + +#define GICH_LR_VIRT_ID(entry) (FIELD_EX32(entry, GICH_LR0, VirtualID)) +#define GICH_LR_PHYS_ID(entry) (FIELD_EX32(entry, GICH_LR0, PhysicalID)) +#define GICH_LR_CPUID(entry) (FIELD_EX32(entry, GICH_LR0, CPUID)) +#define GICH_LR_EOI(entry) (FIELD_EX32(entry, GICH_LR0, EOI)) +#define GICH_LR_PRIORITY(entry) (FIELD_EX32(entry, GICH_LR0, Priority) << = 3) +#define GICH_LR_STATE(entry) (FIELD_EX32(entry, GICH_LR0, State)) +#define GICH_LR_GROUP(entry) (FIELD_EX32(entry, GICH_LR0, Grp1)) +#define GICH_LR_HW(entry) (FIELD_EX32(entry, GICH_LR0, HW)) + /* Valid bits for GICC_CTLR for GICv1, v1 with security extensions, * GICv2 and GICv2 with security extensions: */ @@ -164,4 +178,65 @@ static inline bool gic_is_vcpu(int cpu) return cpu >=3D GIC_NCPU; } =20 +static inline int gic_get_vcpu_real_id(int cpu) +{ + return (cpu >=3D GIC_NCPU) ? (cpu - GIC_NCPU) : cpu; +} + +/* Return true if the given vIRQ state exists in a LR and is either active= or + * pending and active. + * + * This function is used to check that a guest's `end of interrupt' or + * `interrupts deactivation' request is valid, and matches with a LR of an + * already acknowledged vIRQ (i.e. has the active bit set in its state). + */ +static inline bool gic_virq_is_valid(GICState *s, int irq, int vcpu) +{ + int cpu =3D gic_get_vcpu_real_id(vcpu); + int lr_idx; + + for (lr_idx =3D 0; lr_idx < s->num_lrs; lr_idx++) { + uint32_t *entry =3D &s->h_lr[lr_idx][cpu]; + + if ((GICH_LR_VIRT_ID(*entry) =3D=3D irq) && + (GICH_LR_STATE(*entry) & GICH_LR_STATE_ACTIVE)) { + return true; + } + } + + return false; +} + +/* Return a pointer on the LR entry matching the given vIRQ. + * + * This function is used to retrieve an LR for which we know for sure that= the + * corresponding vIRQ exists in the current context (i.e. its current stat= e is + * not `invalid'): + * - Either the corresponding vIRQ has been validated with gic_virq_is_v= alid() + * so it is `active' or `active and pending', + * - Or it was pending and has been selected by gic_get_best_virq(). It = is now + * `pending', `active' or `active and pending', depending on what the = guest + * already did with this vIRQ. + * + * Having multiple LRs with the same VirtualID leads to UNPREDICTABLE + * behaviour in the GIC. We choose to return the first one that matches. + */ +static inline uint32_t *gic_get_lr_entry(GICState *s, int irq, int vcpu) +{ + int cpu =3D gic_get_vcpu_real_id(vcpu); + int lr_idx; + + for (lr_idx =3D 0; lr_idx < s->num_lrs; lr_idx++) { + uint32_t *entry =3D &s->h_lr[lr_idx][cpu]; + + if ((GICH_LR_VIRT_ID(*entry) =3D=3D irq) && + (GICH_LR_STATE(*entry) !=3D GICH_LR_STATE_INVALID)) { + return entry; + } + } + + g_assert_not_reached(); + return NULL; +} + #endif /* QEMU_ARM_GIC_INTERNAL_H */ --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531588972159703.4241588048088; Sat, 14 Jul 2018 10:22:52 -0700 (PDT) Received: from localhost ([::1]:42088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOFu-0001mD-Tu for importer@patchew.org; Sat, 14 Jul 2018 13:22:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9u-0005nL-Cg for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9q-0004ad-5u for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:37 -0400 Received: from greensocs.com ([193.104.36.180]:57313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9j-0004QK-FM; Sat, 14 Jul 2018 13:16:27 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 23AEC428989; Sat, 14 Jul 2018 19:16:24 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9UOk_FjJZPKg; Sat, 14 Jul 2018 19:16:23 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 2730CC7AF0; Sat, 14 Jul 2018 19:16:23 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 0C684C7ADD; Sat, 14 Jul 2018 19:16:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588584; bh=/g8DvP0CyVaStsGYmLoYF7hy3zalpWgOknWrdSv0lxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tnppj3Xb5w4kPEMf9l25Tm6qqqT1xL+kzWy4f+I9TtU4XixKXEw8qld9hY7TXxpF9 OcV6RELpa27hNe5t+XNr2etyLpmk+QImp4Ox1qeLjmXVrD8AmRnPtKuKzgXc2H1583 4Hz/btajKUap0oDqdS+/AKs/pjiXIisbdgs89LxA= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=EIXLOevR; dkim=pass (1024-bit key) header.d=greensocs.com header.b=EIXLOevR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588583; bh=/g8DvP0CyVaStsGYmLoYF7hy3zalpWgOknWrdSv0lxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EIXLOevRHLYTLIVF/e8vEZhtX7pYfkPgDagL9LSf6OAAsOgbpj7A36DaC+m+JG18k VYNUz0bXa/GHNKaK86izBYV392AIkGSUggwqQeU/lsTNuGfG9AknRxJoDMDUDyQtT4 y/Tzq3hUmX8+T9vO0sqgrcwi3KVFaFMWiE/DYWCo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588583; bh=/g8DvP0CyVaStsGYmLoYF7hy3zalpWgOknWrdSv0lxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EIXLOevRHLYTLIVF/e8vEZhtX7pYfkPgDagL9LSf6OAAsOgbpj7A36DaC+m+JG18k VYNUz0bXa/GHNKaK86izBYV392AIkGSUggwqQeU/lsTNuGfG9AknRxJoDMDUDyQtT4 y/Tzq3hUmX8+T9vO0sqgrcwi3KVFaFMWiE/DYWCo= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:49 +0200 Message-Id: <20180714171601.5734-9-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 08/20] intc/arm_gic: Refactor secure/ns access check in the CPU interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" An access to the CPU interface is non-secure if the current GIC instance implements the security extensions, and the memory access is actually non-secure. Until then, it was checked with tests such as if (s->security_extn && !attrs.secure) { ... } in various places of the CPU interface code. With the implementation of the virtualization extensions, those tests must be updated to take into account whether we are in a vCPU interface or not. This is because the exposed vCPU interface does not implement security extensions. This commits replaces all those tests with a call to the gic_cpu_ns_access() function to check if the current access to the CPU interface is non-secure. This function takes into account whether the current CPU is a vCPU or not. Note that this function is used only in the (v)CPU interface code path. The distributor code path is left unchanged, as the distributor is not exposed to vCPUs at all. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 1ac0fe740c..53cc257ed8 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -74,6 +74,11 @@ static inline bool gic_has_groups(GICState *s) return s->revision =3D=3D 2 || s->security_extn; } =20 +static inline bool gic_cpu_ns_access(GICState *s, int cpu, MemTxAttrs attr= s) +{ + return !gic_is_vcpu(cpu) && s->security_extn && !attrs.secure; +} + /* TODO: Many places that call this routine could be optimized. */ /* Update interrupt status after enabled or pending bits have been changed= . */ static void gic_update(GICState *s) @@ -221,7 +226,7 @@ static uint16_t gic_get_current_pending_irq(GICState *s= , int cpu, /* On a GIC without the security extensions, reading this register * behaves in the same way as a secure access to a GIC with them. */ - bool secure =3D !s->security_extn || attrs.secure; + bool secure =3D !gic_cpu_ns_access(s, cpu, attrs); =20 if (group =3D=3D 0 && !secure) { /* Group0 interrupts hidden from Non-secure access */ @@ -428,7 +433,7 @@ static uint32_t gic_dist_get_priority(GICState *s, int = cpu, int irq, static void gic_set_priority_mask(GICState *s, int cpu, uint8_t pmask, MemTxAttrs attrs) { - if (s->security_extn && !attrs.secure) { + if (gic_cpu_ns_access(s, cpu, attrs)) { if (s->priority_mask[cpu] & 0x80) { /* Priority Mask in upper half */ pmask =3D 0x80 | (pmask >> 1); @@ -444,7 +449,7 @@ static uint32_t gic_get_priority_mask(GICState *s, int = cpu, MemTxAttrs attrs) { uint32_t pmask =3D s->priority_mask[cpu]; =20 - if (s->security_extn && !attrs.secure) { + if (gic_cpu_ns_access(s, cpu, attrs)) { if (pmask & 0x80) { /* Priority Mask in upper half, return Non-secure view */ pmask =3D (pmask << 1) & 0xff; @@ -460,7 +465,7 @@ static uint32_t gic_get_cpu_control(GICState *s, int cp= u, MemTxAttrs attrs) { uint32_t ret =3D s->cpu_ctlr[cpu]; =20 - if (s->security_extn && !attrs.secure) { + if (gic_cpu_ns_access(s, cpu, attrs)) { /* Construct the NS banked view of GICC_CTLR from the correct * bits of the S banked view. We don't need to move the bypass * control bits because we don't implement that (IMPDEF) part @@ -476,7 +481,7 @@ static void gic_set_cpu_control(GICState *s, int cpu, u= int32_t value, { uint32_t mask; =20 - if (s->security_extn && !attrs.secure) { + if (gic_cpu_ns_access(s, cpu, attrs)) { /* The NS view can only write certain bits in the register; * the rest are unchanged */ @@ -507,7 +512,7 @@ static uint8_t gic_get_running_priority(GICState *s, in= t cpu, MemTxAttrs attrs) return 0xff; } =20 - if (s->security_extn && !attrs.secure) { + if (gic_cpu_ns_access(s, cpu, attrs)) { if (s->running_priority[cpu] & 0x80) { /* Running priority in upper half of range: return the Non-sec= ure * view of the priority. @@ -531,7 +536,7 @@ static bool gic_eoi_split(GICState *s, int cpu, MemTxAt= trs attrs) /* Before GICv2 prio-drop and deactivate are not separable */ return false; } - if (s->security_extn && !attrs.secure) { + if (gic_cpu_ns_access(s, cpu, attrs)) { return s->cpu_ctlr[cpu] & GICC_CTLR_EOIMODE_NS; } return s->cpu_ctlr[cpu] & GICC_CTLR_EOIMODE; @@ -549,7 +554,7 @@ static void gic_deactivate_irq(GICState *s, int cpu, in= t irq, MemTxAttrs attrs) return; } =20 - if (s->security_extn && !attrs.secure && !group) { + if (gic_cpu_ns_access(s, cpu, attrs) && !group) { DPRINTF("Non-secure DI for Group0 interrupt %d ignored\n", irq); return; } @@ -591,7 +596,7 @@ static void gic_complete_irq(GICState *s, int cpu, int = irq, MemTxAttrs attrs) =20 group =3D gic_has_groups(s) && GIC_DIST_TEST_GROUP(irq, cm); =20 - if (s->security_extn && !attrs.secure && !group) { + if (gic_cpu_ns_access(s, cpu, attrs) && !group) { DPRINTF("Non-secure EOI for Group0 interrupt %d ignored\n", irq); return; } @@ -1265,7 +1270,7 @@ static MemTxResult gic_cpu_read(GICState *s, int cpu,= int offset, *data =3D gic_get_priority_mask(s, cpu, attrs); break; case 0x08: /* Binary Point */ - if (s->security_extn && !attrs.secure) { + if (gic_cpu_ns_access(s, cpu, attrs)) { if (s->cpu_ctlr[cpu] & GICC_CTLR_CBPR) { /* NS view of BPR when CBPR is 1 */ *data =3D MIN(s->bpr[cpu] + 1, 7); @@ -1292,7 +1297,7 @@ static MemTxResult gic_cpu_read(GICState *s, int cpu,= int offset, * With security extensions, secure access: ABPR (alias of NS BPR) * With security extensions, nonsecure access: RAZ/WI */ - if (!gic_has_groups(s) || (s->security_extn && !attrs.secure)) { + if (!gic_has_groups(s) || (gic_cpu_ns_access(s, cpu, attrs))) { *data =3D 0; } else { *data =3D s->abpr[cpu]; @@ -1304,7 +1309,7 @@ static MemTxResult gic_cpu_read(GICState *s, int cpu,= int offset, =20 if (regno >=3D GIC_NR_APRS || s->revision !=3D 2) { *data =3D 0; - } else if (s->security_extn && !attrs.secure) { + } else if (gic_cpu_ns_access(s, cpu, attrs)) { /* NS view of GICC_APR is the top half of GIC_NSAPR */ *data =3D gic_apr_ns_view(s, regno, cpu); } else { @@ -1317,7 +1322,7 @@ static MemTxResult gic_cpu_read(GICState *s, int cpu,= int offset, int regno =3D (offset - 0xe0) / 4; =20 if (regno >=3D GIC_NR_APRS || s->revision !=3D 2 || !gic_has_group= s(s) || - (s->security_extn && !attrs.secure)) { + gic_cpu_ns_access(s, cpu, attrs)) { *data =3D 0; } else { *data =3D s->nsapr[regno][cpu]; @@ -1344,7 +1349,7 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu= , int offset, gic_set_priority_mask(s, cpu, value, attrs); break; case 0x08: /* Binary Point */ - if (s->security_extn && !attrs.secure) { + if (gic_cpu_ns_access(s, cpu, attrs)) { if (s->cpu_ctlr[cpu] & GICC_CTLR_CBPR) { /* WI when CBPR is 1 */ return MEMTX_OK; @@ -1359,7 +1364,7 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu= , int offset, gic_complete_irq(s, cpu, value & 0x3ff, attrs); return MEMTX_OK; case 0x1c: /* Aliased Binary Point */ - if (!gic_has_groups(s) || (s->security_extn && !attrs.secure)) { + if (!gic_has_groups(s) || (gic_cpu_ns_access(s, cpu, attrs))) { /* unimplemented, or NS access: RAZ/WI */ return MEMTX_OK; } else { @@ -1373,7 +1378,7 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu= , int offset, if (regno >=3D GIC_NR_APRS || s->revision !=3D 2) { return MEMTX_OK; } - if (s->security_extn && !attrs.secure) { + if (gic_cpu_ns_access(s, cpu, attrs)) { /* NS view of GICC_APR is the top half of GIC_NSAPR */ gic_apr_write_ns_view(s, regno, cpu, value); } else { @@ -1388,7 +1393,7 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu= , int offset, if (regno >=3D GIC_NR_APRS || s->revision !=3D 2) { return MEMTX_OK; } - if (!gic_has_groups(s) || (s->security_extn && !attrs.secure)) { + if (!gic_has_groups(s) || (gic_cpu_ns_access(s, cpu, attrs))) { return MEMTX_OK; } s->nsapr[regno][cpu] =3D value; --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531589414116248.25377975864308; Sat, 14 Jul 2018 10:30:14 -0700 (PDT) Received: from localhost ([::1]:42139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feON3-0007xk-4W for importer@patchew.org; Sat, 14 Jul 2018 13:30:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9u-0005nJ-Cg for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9p-0004ZW-9z for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:36 -0400 Received: from greensocs.com ([193.104.36.180]:57315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9j-0004QV-FW; Sat, 14 Jul 2018 13:16:27 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 2AA7A388FC7; Sat, 14 Jul 2018 19:16:25 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WHKlFjokaTHh; Sat, 14 Jul 2018 19:16:24 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 08A60C7AF9; Sat, 14 Jul 2018 19:16:23 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 380EDC7ADD; Sat, 14 Jul 2018 19:16:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588585; bh=mj0E0fGdjtwxaKm72+hIt1Ta3Is13HKiu08Sv8mBdX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aSonkLPVvhfmmIBhIXUpyupL7iuOWNPWMQL1hSpJmVjnRF7p0UKqUYDiavr21R0AL kOGOgG23RU5x5UzU0K5wYY6mGe1iYmtgmPqUU6AHWxw6C/m/u4AgExxdS6Sad2Ggbn dRZ5CfpEGfN2xtEaW+xvZt3G9bdhAbmgqRPYSWn4= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=WvmDr/4f; dkim=pass (1024-bit key) header.d=greensocs.com header.b=pSkVRANX DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588584; bh=mj0E0fGdjtwxaKm72+hIt1Ta3Is13HKiu08Sv8mBdX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WvmDr/4fEr6lsWQqhg2MOF8TJT0fYDvOpSlWDkp68FzREaueWDq4AUIaiFPHBjArN w+uprJjQ7KJxH0DUdOCiO6Y8l20fBvCOA3AAWXSlbdXQqrT6qwbmAVMmdaAGliaeo2 N26n637EGR36l3p+j/4NgLC1Vr1VocdKs6E+X9/8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588583; bh=mj0E0fGdjtwxaKm72+hIt1Ta3Is13HKiu08Sv8mBdX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pSkVRANXxPgN9r4RnsN8S9z4Z+vikdbIHM5/4gRFdMYA/ihdX1HpX0a+YR63Hzm05 E0qxMEMnieOFI7dUkWC+XUmwwTJqocSyPAb30FPNueHVKw8JriUC987dJkNdNM5RLU /5arTWWfALcfdMvS/Xbtr/mWggfkQYYGo17C8skI= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:50 +0200 Message-Id: <20180714171601.5734-10-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 09/20] intc/arm_gic: Add virtualization enabled IRQ helper functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 3 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add some helper functions to gic_internal.h to get or change the state of an IRQ. When the current CPU is not a vCPU, the call is forwarded to the GIC distributor. Otherwise, it acts on the list register matching the IRQ in the current CPU virtual interface. gic_clear_active can have a side effect on the distributor, even in the vCPU case, when the correponding LR has the HW field set. Use those functions in the CPU interface code path to prepare for the vCPU interface implementation. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 32 +++++++--------- hw/intc/gic_internal.h | 83 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 18 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 53cc257ed8..ad241d12c2 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -222,7 +222,8 @@ static uint16_t gic_get_current_pending_irq(GICState *s= , int cpu, uint16_t pending_irq =3D s->current_pending[cpu]; =20 if (pending_irq < GIC_MAXIRQ && gic_has_groups(s)) { - int group =3D GIC_DIST_TEST_GROUP(pending_irq, (1 << cpu)); + int group =3D gic_test_group(s, pending_irq, cpu); + /* On a GIC without the security extensions, reading this register * behaves in the same way as a secure access to a GIC with them. */ @@ -253,7 +254,7 @@ static int gic_get_group_priority(GICState *s, int cpu,= int irq) =20 if (gic_has_groups(s) && !(s->cpu_ctlr[cpu] & GICC_CTLR_CBPR) && - GIC_DIST_TEST_GROUP(irq, (1 << cpu))) { + gic_test_group(s, irq, cpu)) { bpr =3D s->abpr[cpu] - 1; assert(bpr >=3D 0); } else { @@ -266,7 +267,7 @@ static int gic_get_group_priority(GICState *s, int cpu,= int irq) */ mask =3D ~0U << ((bpr & 7) + 1); =20 - return GIC_DIST_GET_PRIORITY(irq, cpu) & mask; + return gic_get_priority(s, irq, cpu) & mask; } =20 static void gic_activate_irq(GICState *s, int cpu, int irq) @@ -279,14 +280,14 @@ static void gic_activate_irq(GICState *s, int cpu, in= t irq) int regno =3D preemption_level / 32; int bitno =3D preemption_level % 32; =20 - if (gic_has_groups(s) && GIC_DIST_TEST_GROUP(irq, (1 << cpu))) { + if (gic_has_groups(s) && gic_test_group(s, irq, cpu)) { s->nsapr[regno][cpu] |=3D (1 << bitno); } else { s->apr[regno][cpu] |=3D (1 << bitno); } =20 s->running_priority[cpu] =3D prio; - GIC_DIST_SET_ACTIVE(irq, 1 << cpu); + gic_set_active(s, irq, cpu); } =20 static int gic_get_prio_from_apr_bits(GICState *s, int cpu) @@ -355,7 +356,7 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemT= xAttrs attrs) return irq; } =20 - if (GIC_DIST_GET_PRIORITY(irq, cpu) >=3D s->running_priority[cpu]) { + if (gic_get_priority(s, irq, cpu) >=3D s->running_priority[cpu]) { DPRINTF("ACK, pending interrupt (%d) has insufficient priority\n",= irq); return 1023; } @@ -364,8 +365,7 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemT= xAttrs attrs) /* Clear pending flags for both level and edge triggered interrupt= s. * Level triggered IRQs will be reasserted once they become inacti= ve. */ - GIC_DIST_CLEAR_PENDING(irq, GIC_DIST_TEST_MODEL(irq) ? ALL_CPU_MASK - : cm); + gic_clear_pending(s, irq, cpu); ret =3D irq; } else { if (irq < GIC_NR_SGIS) { @@ -377,9 +377,7 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemT= xAttrs attrs) src =3D ctz32(s->sgi_pending[irq][cpu]); s->sgi_pending[irq][cpu] &=3D ~(1 << src); if (s->sgi_pending[irq][cpu] =3D=3D 0) { - GIC_DIST_CLEAR_PENDING(irq, - GIC_DIST_TEST_MODEL(irq) ? ALL_CPU_= MASK - : cm); + gic_clear_pending(s, irq, cpu); } ret =3D irq | ((src & 0x7) << 10); } else { @@ -387,8 +385,7 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemT= xAttrs attrs) * interrupts. (level triggered interrupts with an active line * remain pending, see gic_test_pending) */ - GIC_DIST_CLEAR_PENDING(irq, GIC_DIST_TEST_MODEL(irq) ? ALL_CPU= _MASK - : cm); + gic_clear_pending(s, irq, cpu); ret =3D irq; } } @@ -544,8 +541,7 @@ static bool gic_eoi_split(GICState *s, int cpu, MemTxAt= trs attrs) =20 static void gic_deactivate_irq(GICState *s, int cpu, int irq, MemTxAttrs a= ttrs) { - int cm =3D 1 << cpu; - int group =3D gic_has_groups(s) && GIC_DIST_TEST_GROUP(irq, cm); + int group =3D gic_has_groups(s) && gic_test_group(s, irq, cpu); =20 if (!gic_eoi_split(s, cpu, attrs)) { /* This is UNPREDICTABLE; we choose to ignore it */ @@ -559,7 +555,7 @@ static void gic_deactivate_irq(GICState *s, int cpu, in= t irq, MemTxAttrs attrs) return; } =20 - GIC_DIST_CLEAR_ACTIVE(irq, cm); + gic_clear_active(s, irq, cpu); } =20 static void gic_complete_irq(GICState *s, int cpu, int irq, MemTxAttrs att= rs) @@ -594,7 +590,7 @@ static void gic_complete_irq(GICState *s, int cpu, int = irq, MemTxAttrs attrs) } } =20 - group =3D gic_has_groups(s) && GIC_DIST_TEST_GROUP(irq, cm); + group =3D gic_has_groups(s) && gic_test_group(s, irq, cpu); =20 if (gic_cpu_ns_access(s, cpu, attrs) && !group) { DPRINTF("Non-secure EOI for Group0 interrupt %d ignored\n", irq); @@ -610,7 +606,7 @@ static void gic_complete_irq(GICState *s, int cpu, int = irq, MemTxAttrs attrs) =20 /* In GICv2 the guest can choose to split priority-drop and deactivate= */ if (!gic_eoi_split(s, cpu, attrs)) { - GIC_DIST_CLEAR_ACTIVE(irq, cm); + gic_clear_active(s, irq, cpu); } gic_update(s); } diff --git a/hw/intc/gic_internal.h b/hw/intc/gic_internal.h index 56e203aeb9..d772d621fd 100644 --- a/hw/intc/gic_internal.h +++ b/hw/intc/gic_internal.h @@ -143,6 +143,13 @@ REG32(GICH_LR63, 0x1fc) #define GICH_LR_GROUP(entry) (FIELD_EX32(entry, GICH_LR0, Grp1)) #define GICH_LR_HW(entry) (FIELD_EX32(entry, GICH_LR0, HW)) =20 +#define GICH_LR_CLEAR_PENDING(entry) \ + ((entry) &=3D ~(GICH_LR_STATE_PENDING << R_GICH_LR0_State_SHIFT)) +#define GICH_LR_SET_ACTIVE(entry) \ + ((entry) |=3D (GICH_LR_STATE_ACTIVE << R_GICH_LR0_State_SHIFT)) +#define GICH_LR_CLEAR_ACTIVE(entry) \ + ((entry) &=3D ~(GICH_LR_STATE_ACTIVE << R_GICH_LR0_State_SHIFT)) + /* Valid bits for GICC_CTLR for GICv1, v1 with security extensions, * GICv2 and GICv2 with security extensions: */ @@ -239,4 +246,80 @@ static inline uint32_t *gic_get_lr_entry(GICState *s, = int irq, int vcpu) return NULL; } =20 +static inline bool gic_test_group(GICState *s, int irq, int cpu) +{ + if (gic_is_vcpu(cpu)) { + uint32_t *entry =3D gic_get_lr_entry(s, irq, cpu); + return GICH_LR_GROUP(*entry); + } else { + return GIC_DIST_TEST_GROUP(irq, 1 << cpu); + } +} + +static inline void gic_clear_pending(GICState *s, int irq, int cpu) +{ + if (gic_is_vcpu(cpu)) { + uint32_t *entry =3D gic_get_lr_entry(s, irq, cpu); + GICH_LR_CLEAR_PENDING(*entry); + } else { + /* Clear pending state for both level and edge triggered + * interrupts. (level triggered interrupts with an active line + * remain pending, see gic_test_pending) + */ + GIC_DIST_CLEAR_PENDING(irq, GIC_DIST_TEST_MODEL(irq) ? ALL_CPU_MASK + : (1 << cpu)); + } +} + +static inline void gic_set_active(GICState *s, int irq, int cpu) +{ + if (gic_is_vcpu(cpu)) { + uint32_t *entry =3D gic_get_lr_entry(s, irq, cpu); + GICH_LR_SET_ACTIVE(*entry); + } else { + GIC_DIST_SET_ACTIVE(irq, 1 << cpu); + } +} + +static inline void gic_clear_active(GICState *s, int irq, int cpu) +{ + if (gic_is_vcpu(cpu)) { + uint32_t *entry =3D gic_get_lr_entry(s, irq, cpu); + GICH_LR_CLEAR_ACTIVE(*entry); + + if (GICH_LR_HW(*entry)) { + /* Hardware interrupt. We must forward the deactivation reques= t to + * the distributor. + */ + int phys_irq =3D GICH_LR_PHYS_ID(*entry); + int rcpu =3D gic_get_vcpu_real_id(cpu); + + if (phys_irq < GIC_NR_SGIS || phys_irq >=3D GIC_MAXIRQ) { + /* UNPREDICTABLE behaviour, we choose to ignore the reques= t */ + return; + } + + /* This is equivalent to a NS write to DIR on the physical CPU + * interface. Hence group0 interrupt deactivation is ignored if + * the GIC is secure. + */ + if (!s->security_extn || GIC_DIST_TEST_GROUP(phys_irq, 1 << rc= pu)) { + GIC_DIST_CLEAR_ACTIVE(phys_irq, 1 << rcpu); + } + } + } else { + GIC_DIST_CLEAR_ACTIVE(irq, 1 << cpu); + } +} + +static inline int gic_get_priority(GICState *s, int irq, int cpu) +{ + if (gic_is_vcpu(cpu)) { + uint32_t *entry =3D gic_get_lr_entry(s, irq, cpu); + return GICH_LR_PRIORITY(*entry); + } else { + return GIC_DIST_GET_PRIORITY(irq, cpu); + } +} + #endif /* QEMU_ARM_GIC_INTERNAL_H */ --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531588977571992.0288505661389; Sat, 14 Jul 2018 10:22:57 -0700 (PDT) Received: from localhost ([::1]:42089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOG0-0001pN-Ce for importer@patchew.org; Sat, 14 Jul 2018 13:22:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9r-0005mr-8s for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9p-0004ZP-8v for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:35 -0400 Received: from greensocs.com ([193.104.36.180]:57316) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9j-0004QU-FT; Sat, 14 Jul 2018 13:16:27 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id A6DBE443480; Sat, 14 Jul 2018 19:16:25 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hopGqZN0Y-EY; Sat, 14 Jul 2018 19:16:24 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id C364DC7AF0; Sat, 14 Jul 2018 19:16:24 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 18B10C7ADD; Sat, 14 Jul 2018 19:16:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588585; bh=gAGn4PasunLM8q8SMWKDBFXch2i23lCbZ04LlKRrBME=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fUmqbDx3JsU1zuPFZd8sIqkF0qTFeP1CHDgRQcHN/7SnQy+kUg7uxYfhXVz+qiRqi PT88mjEa/m0nWmdKAmaxas5LuaL48XEg2uEv0uQ1BkQkfDGRfuiaoxXZPtjr0zvRxO fnJ6XGw09hX90zkM0Z7/rwobU1iiMxbp86SFHGoQ= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=bjz9MlO1; dkim=pass (1024-bit key) header.d=greensocs.com header.b=bjz9MlO1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588584; bh=gAGn4PasunLM8q8SMWKDBFXch2i23lCbZ04LlKRrBME=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bjz9MlO1anu/gWPjkJ+z2Sp21s0QTe7EvHq+rclzryNftJv8JP8FL/teSGctHgxSG UPPMVZ7HgtdcLBnUIUADNSXeSovh0TxEnJu9RF+aLtOIv2M80iThRXRhwhEAolILO2 88YkerfI4Cw8qoI+YJwRjsMzd42QDLKBv1JX5z7U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588584; bh=gAGn4PasunLM8q8SMWKDBFXch2i23lCbZ04LlKRrBME=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bjz9MlO1anu/gWPjkJ+z2Sp21s0QTe7EvHq+rclzryNftJv8JP8FL/teSGctHgxSG UPPMVZ7HgtdcLBnUIUADNSXeSovh0TxEnJu9RF+aLtOIv2M80iThRXRhwhEAolILO2 88YkerfI4Cw8qoI+YJwRjsMzd42QDLKBv1JX5z7U= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:51 +0200 Message-Id: <20180714171601.5734-11-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 10/20] intc/arm_gic: Implement virtualization extensions in gic_(activate_irq|drop_prio) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Implement virtualization extensions in gic_activate_irq() and gic_drop_prio() and in gic_get_prio_from_apr_bits() called by gic_drop_prio(). When the current CPU is a vCPU: - Use GIC_VIRT_MIN_BPR and GIC_VIRT_NR_APRS instead of their non-virt counterparts, - the vCPU APR is stored in the virtual interface, in h_apr. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 50 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index ad241d12c2..60704cabbb 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -276,16 +276,23 @@ static void gic_activate_irq(GICState *s, int cpu, in= t irq) * and update the running priority. */ int prio =3D gic_get_group_priority(s, cpu, irq); - int preemption_level =3D prio >> (GIC_MIN_BPR + 1); + int min_bpr =3D gic_is_vcpu(cpu) ? GIC_VIRT_MIN_BPR : GIC_MIN_BPR; + int preemption_level =3D prio >> (min_bpr + 1); int regno =3D preemption_level / 32; int bitno =3D preemption_level % 32; + uint32_t *papr =3D NULL; =20 - if (gic_has_groups(s) && gic_test_group(s, irq, cpu)) { - s->nsapr[regno][cpu] |=3D (1 << bitno); + if (gic_is_vcpu(cpu)) { + assert(regno =3D=3D 0); + papr =3D &s->h_apr[gic_get_vcpu_real_id(cpu)]; + } else if (gic_has_groups(s) && gic_test_group(s, irq, cpu)) { + papr =3D &s->nsapr[regno][cpu]; } else { - s->apr[regno][cpu] |=3D (1 << bitno); + papr =3D &s->apr[regno][cpu]; } =20 + *papr |=3D (1 << bitno); + s->running_priority[cpu] =3D prio; gic_set_active(s, irq, cpu); } @@ -296,6 +303,16 @@ static int gic_get_prio_from_apr_bits(GICState *s, int= cpu) * on the set bits in the Active Priority Registers. */ int i; + + if (gic_is_vcpu(cpu)) { + uint32_t apr =3D s->h_apr[gic_get_vcpu_real_id(cpu)]; + if (apr) { + return ctz32(apr) << (GIC_VIRT_MIN_BPR + 1); + } else { + return 0x100; + } + } + for (i =3D 0; i < GIC_NR_APRS; i++) { uint32_t apr =3D s->apr[i][cpu] | s->nsapr[i][cpu]; if (!apr) { @@ -324,16 +341,25 @@ static void gic_drop_prio(GICState *s, int cpu, int g= roup) * running priority will be wrong, so interrupts that should preempt * might not do so, and interrupts that should not preempt might do so. */ - int i; + if (gic_is_vcpu(cpu)) { + int rcpu =3D gic_get_vcpu_real_id(cpu); =20 - for (i =3D 0; i < GIC_NR_APRS; i++) { - uint32_t *papr =3D group ? &s->nsapr[i][cpu] : &s->apr[i][cpu]; - if (!*papr) { - continue; + if (s->h_apr[rcpu]) { + /* Clear lowest set bit */ + s->h_apr[rcpu] &=3D s->h_apr[rcpu] - 1; + } + } else { + int i; + + for (i =3D 0; i < GIC_NR_APRS; i++) { + uint32_t *papr =3D group ? &s->nsapr[i][cpu] : &s->apr[i][cpu]; + if (!*papr) { + continue; + } + /* Clear lowest set bit */ + *papr &=3D *papr - 1; + break; } - /* Clear lowest set bit */ - *papr &=3D *papr - 1; - break; } =20 s->running_priority[cpu] =3D gic_get_prio_from_apr_bits(s, cpu); --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153158915589495.83563578658095; Sat, 14 Jul 2018 10:25:55 -0700 (PDT) Received: from localhost ([::1]:42112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOIs-0004Z0-Gn for importer@patchew.org; Sat, 14 Jul 2018 13:25:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9x-0005qz-47 for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9u-0004fT-HB for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:41 -0400 Received: from greensocs.com ([193.104.36.180]:57317) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9j-0004Qd-G7; Sat, 14 Jul 2018 13:16:27 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 7B1E6C7AF0; Sat, 14 Jul 2018 19:16:26 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PcE-qdWwXLSY; Sat, 14 Jul 2018 19:16:25 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 914E0C7AF9; Sat, 14 Jul 2018 19:16:25 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id D688AC7ADD; Sat, 14 Jul 2018 19:16:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588586; bh=hjvPhdX2GCICeVw8K3GCAmxUM1WCOlflGQnWMSsw2MM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bKcLHemB4Cnjuf3n8LcZ3W9ajZndshxtZOBaLHIF3H7qONqOpK/TuouCnB1epJcmG bcJ3OEtK3HfAtUKQ4G64lVnPAXYFiKuaL8GYNScukpOUX11EWMnfpZuNa05EapwvqH zo03s9mOAtccKUINCKTHPTaw+5TdGME4Qm7/Q1Uo= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=ddEuQh8m; dkim=pass (1024-bit key) header.d=greensocs.com header.b=ddEuQh8m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588585; bh=hjvPhdX2GCICeVw8K3GCAmxUM1WCOlflGQnWMSsw2MM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ddEuQh8mrW50kSlfi30m5SK+z1AMLnChbgg3aM46jdClMN1nQuBYsgjVJdhx7/Aeo Vx6Xfdw1yvRhVxJGZEehX1ruCkE6K4CTccACez5ypj8xfiIIdskKmEOVFhUMZn1qYx XJ1BHeDrMimfaiZL/8NeIztPfnNoLNW3b3kT2GdQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588585; bh=hjvPhdX2GCICeVw8K3GCAmxUM1WCOlflGQnWMSsw2MM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ddEuQh8mrW50kSlfi30m5SK+z1AMLnChbgg3aM46jdClMN1nQuBYsgjVJdhx7/Aeo Vx6Xfdw1yvRhVxJGZEehX1ruCkE6K4CTccACez5ypj8xfiIIdskKmEOVFhUMZn1qYx XJ1BHeDrMimfaiZL/8NeIztPfnNoLNW3b3kT2GdQ= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:52 +0200 Message-Id: <20180714171601.5734-12-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 11/20] intc/arm_gic: Implement virtualization extensions in gic_acknowledge_irq X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Implement virtualization extensions in the gic_acknowledge_irq() function. This function changes the state of the highest priority IRQ from pending to active. When the current CPU is a vCPU, modifying the state of an IRQ modifies the corresponding LR entry. However if we clear the pending flag before setting the active one, we lose track of the LR entry as it becomes invalid. The next call to gic_get_lr_entry() will fail. To overcome this issue, we call gic_activate_irq() before gic_clear_pending(). This does not change the general behaviour of gic_acknowledge_irq. We also move the SGI case in gic_clear_pending_sgi() to enhance code readability as the virtualization extensions support adds a if-else level. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 52 ++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 60704cabbb..be9e2594d9 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -365,17 +365,44 @@ static void gic_drop_prio(GICState *s, int cpu, int g= roup) s->running_priority[cpu] =3D gic_get_prio_from_apr_bits(s, cpu); } =20 +static inline uint32_t gic_clear_pending_sgi(GICState *s, int irq, int cpu) +{ + int src; + uint32_t ret; + + if (!gic_is_vcpu(cpu)) { + /* Lookup the source CPU for the SGI and clear this in the + * sgi_pending map. Return the src and clear the overall pending + * state on this CPU if the SGI is not pending from any CPUs. + */ + assert(s->sgi_pending[irq][cpu] !=3D 0); + src =3D ctz32(s->sgi_pending[irq][cpu]); + s->sgi_pending[irq][cpu] &=3D ~(1 << src); + if (s->sgi_pending[irq][cpu] =3D=3D 0) { + gic_clear_pending(s, irq, cpu); + } + ret =3D irq | ((src & 0x7) << 10); + } else { + uint32_t *lr_entry =3D gic_get_lr_entry(s, irq, cpu); + src =3D GICH_LR_CPUID(*lr_entry); + + gic_clear_pending(s, irq, cpu); + ret =3D irq | (src << 10); + } + + return ret; +} + uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemTxAttrs attrs) { - int ret, irq, src; - int cm =3D 1 << cpu; + int ret, irq; =20 /* gic_get_current_pending_irq() will return 1022 or 1023 appropriately * for the case where this GIC supports grouping and the pending inter= rupt * is in the wrong group. */ irq =3D gic_get_current_pending_irq(s, cpu, attrs); - trace_gic_acknowledge_irq(cpu, irq); + trace_gic_acknowledge_irq(gic_get_vcpu_real_id(cpu), irq); =20 if (irq >=3D GIC_MAXIRQ) { DPRINTF("ACK, no pending interrupt or it is hidden: %d\n", irq); @@ -387,6 +414,8 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemT= xAttrs attrs) return 1023; } =20 + gic_activate_irq(s, cpu, irq); + if (s->revision =3D=3D REV_11MPCORE) { /* Clear pending flags for both level and edge triggered interrupt= s. * Level triggered IRQs will be reasserted once they become inacti= ve. @@ -395,28 +424,13 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, Me= mTxAttrs attrs) ret =3D irq; } else { if (irq < GIC_NR_SGIS) { - /* Lookup the source CPU for the SGI and clear this in the - * sgi_pending map. Return the src and clear the overall pend= ing - * state on this CPU if the SGI is not pending from any CPUs. - */ - assert(s->sgi_pending[irq][cpu] !=3D 0); - src =3D ctz32(s->sgi_pending[irq][cpu]); - s->sgi_pending[irq][cpu] &=3D ~(1 << src); - if (s->sgi_pending[irq][cpu] =3D=3D 0) { - gic_clear_pending(s, irq, cpu); - } - ret =3D irq | ((src & 0x7) << 10); + ret =3D gic_clear_pending_sgi(s, irq, cpu); } else { - /* Clear pending state for both level and edge triggered - * interrupts. (level triggered interrupts with an active line - * remain pending, see gic_test_pending) - */ gic_clear_pending(s, irq, cpu); ret =3D irq; } } =20 - gic_activate_irq(s, cpu, irq); gic_update(s); DPRINTF("ACK %d\n", irq); return ret; --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531588977465927.564269716584; Sat, 14 Jul 2018 10:22:57 -0700 (PDT) Received: from localhost ([::1]:42091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOG0-0001pv-5h for importer@patchew.org; Sat, 14 Jul 2018 13:22:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9u-0005nI-CR for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9q-0004bW-QO for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:36 -0400 Received: from greensocs.com ([193.104.36.180]:57319) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9j-0004Qn-LA; Sat, 14 Jul 2018 13:16:27 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 2B5EBC7AFB; Sat, 14 Jul 2018 19:16:27 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Mp5SvqOQmpak; Sat, 14 Jul 2018 19:16:26 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 60AD3C7ADD; Sat, 14 Jul 2018 19:16:26 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id A58F542898C; Sat, 14 Jul 2018 19:16:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588587; bh=EG46i0a1O3AX/avIOovDkdx0T7SdNQIq/Xhp8wq4+FI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZXlX+LGu/APcDBprLvbzoYlYPCYZ1jQknkDHEnc7jGBAOH39ZAWNbBJ4lghhP6Wki UTM5Hxw0Wxlmvsk/5b7Sb/fPukQ4BW0EnMH7xc54lJtejqhFfmCbMwg+YQEFLJ4WCD jJSAivbdESeDTd+dMZfH4Ibe8tPKU7dXIPwNdFPA= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=nxER826N; dkim=pass (1024-bit key) header.d=greensocs.com header.b=nxER826N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588586; bh=EG46i0a1O3AX/avIOovDkdx0T7SdNQIq/Xhp8wq4+FI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nxER826N7SyHQ62zQaHKQGOegbxxWDYjyxL9UMk4TNlnePZjhH8ySbpOklliXEZqm B8ftCxrf59DIKmoEn+T/bu/L7Kjg6LccPcKnDsFI1CFJkLCdzPTuD0sXoilI6W2EPF TvkOXmXUH2VmgDt8rT0i15QEK6Hx26gPwkgwVPM8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588586; bh=EG46i0a1O3AX/avIOovDkdx0T7SdNQIq/Xhp8wq4+FI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nxER826N7SyHQ62zQaHKQGOegbxxWDYjyxL9UMk4TNlnePZjhH8ySbpOklliXEZqm B8ftCxrf59DIKmoEn+T/bu/L7Kjg6LccPcKnDsFI1CFJkLCdzPTuD0sXoilI6W2EPF TvkOXmXUH2VmgDt8rT0i15QEK6Hx26gPwkgwVPM8= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:53 +0200 Message-Id: <20180714171601.5734-13-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 12/20] intc/arm_gic: Implement virtualization extensions in gic_(deactivate|complete_irq) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Implement virtualization extensions in the gic_deactivate_irq() and gic_complete_irq() functions. When a guest tries to deactivat or end an IRQ that does not exist in the LRs, the EOICount field of the virtual interface HCR register is incremented by one, and the request is ignored. Signed-off-by: Luc Michel --- hw/intc/arm_gic.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index be9e2594d9..50cbbfbe24 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -590,6 +590,15 @@ static void gic_deactivate_irq(GICState *s, int cpu, i= nt irq, MemTxAttrs attrs) return; } =20 + if (gic_is_vcpu(cpu) && !gic_virq_is_valid(s, irq, cpu)) { + /* This vIRQ does not have an LR entry which is either active or + * pending and active. Increment EOICount and ignore the write. + */ + int rcpu =3D gic_get_vcpu_real_id(cpu); + s->h_hcr[rcpu] +=3D 1 << R_GICH_HCR_EOICount_SHIFT; + return; + } + if (gic_cpu_ns_access(s, cpu, attrs) && !group) { DPRINTF("Non-secure DI for Group0 interrupt %d ignored\n", irq); return; @@ -604,6 +613,15 @@ static void gic_complete_irq(GICState *s, int cpu, int= irq, MemTxAttrs attrs) int group; =20 DPRINTF("EOI %d\n", irq); + if (gic_is_vcpu(cpu) && !gic_virq_is_valid(s, irq, cpu)) { + /* This vIRQ does not have an LR entry which is either active or + * pending and active. Increment EOICount and ignore the write. + */ + int rcpu =3D gic_get_vcpu_real_id(cpu); + s->h_hcr[rcpu] +=3D 1 << R_GICH_HCR_EOICount_SHIFT; + return; + } + if (irq >=3D s->num_irq) { /* This handles two cases: * 1. If software writes the ID of a spurious interrupt [ie 1023] --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531589297457771.949856617058; Sat, 14 Jul 2018 10:28:17 -0700 (PDT) Received: from localhost ([::1]:42132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOLA-0006YD-FU for importer@patchew.org; Sat, 14 Jul 2018 13:28:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9v-0005oc-8w for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9r-0004cF-DK for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:39 -0400 Received: from greensocs.com ([193.104.36.180]:57331) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9k-0004Sm-HL; Sat, 14 Jul 2018 13:16:28 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 0721FC7AF9; Sat, 14 Jul 2018 19:16:28 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MSDtLllt23UU; Sat, 14 Jul 2018 19:16:27 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 2E387C7AFC; Sat, 14 Jul 2018 19:16:27 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 792D742898C; Sat, 14 Jul 2018 19:16:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588588; bh=Bt7CiwOXI1Ge9roLoaK10EKjQ2cv9jRbjFAHV2MrjRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2qlVVwAhxec1YMoZ8AY8BiSVyyBhMFbIGph1dYKDX88JgvhLzXvHCZMctKZPXwF/q Njnnqzulr0Nc94n6guEhk2rSRWwCCAQxawANcrjgUYHDqYClWLYtf6HKwFLZJ4Ou6j mAayRiJ446zNvmEC8LEnQZ0TQBxNMNcSHYs5u3Es= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=KOuNkQ6x; dkim=pass (1024-bit key) header.d=greensocs.com header.b=KOuNkQ6x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588587; bh=Bt7CiwOXI1Ge9roLoaK10EKjQ2cv9jRbjFAHV2MrjRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KOuNkQ6xpwoImryLzbrhWjFIB3Q5Ushb1y6T4B1S0hX8Vbtb+k3wr8+NFdNVzbcPv 75uxJ8/4t3VS0buHEScWBSMY41X6e8f4zQL95fLdK0cXNQBqIbPsJ86GiWD9RvIb7M xdcwQUZtbaI/ce435HX/KwGU2LY/EbP9p1smVzHY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588587; bh=Bt7CiwOXI1Ge9roLoaK10EKjQ2cv9jRbjFAHV2MrjRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KOuNkQ6xpwoImryLzbrhWjFIB3Q5Ushb1y6T4B1S0hX8Vbtb+k3wr8+NFdNVzbcPv 75uxJ8/4t3VS0buHEScWBSMY41X6e8f4zQL95fLdK0cXNQBqIbPsJ86GiWD9RvIb7M xdcwQUZtbaI/ce435HX/KwGU2LY/EbP9p1smVzHY= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:54 +0200 Message-Id: <20180714171601.5734-14-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 13/20] intc/arm_gic: Implement virtualization extensions in gic_cpu_(read|write) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Implement virtualization extensions in the gic_cpu_read() and gic_cpu_write() functions. Those are the last bits missing to fully support virtualization extensions in the CPU interface path. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 50cbbfbe24..28ecf0c1fc 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -1360,9 +1360,12 @@ static MemTxResult gic_cpu_read(GICState *s, int cpu= , int offset, case 0xd0: case 0xd4: case 0xd8: case 0xdc: { int regno =3D (offset - 0xd0) / 4; + int nr_aprs =3D gic_is_vcpu(cpu) ? GIC_VIRT_NR_APRS : GIC_NR_APRS; =20 - if (regno >=3D GIC_NR_APRS || s->revision !=3D 2) { + if (regno >=3D nr_aprs || s->revision !=3D 2) { *data =3D 0; + } else if (gic_is_vcpu(cpu)) { + *data =3D s->h_apr[gic_get_vcpu_real_id(cpu)]; } else if (gic_cpu_ns_access(s, cpu, attrs)) { /* NS view of GICC_APR is the top half of GIC_NSAPR */ *data =3D gic_apr_ns_view(s, regno, cpu); @@ -1376,7 +1379,7 @@ static MemTxResult gic_cpu_read(GICState *s, int cpu,= int offset, int regno =3D (offset - 0xe0) / 4; =20 if (regno >=3D GIC_NR_APRS || s->revision !=3D 2 || !gic_has_group= s(s) || - gic_cpu_ns_access(s, cpu, attrs)) { + gic_cpu_ns_access(s, cpu, attrs) || gic_is_vcpu(cpu)) { *data =3D 0; } else { *data =3D s->nsapr[regno][cpu]; @@ -1411,7 +1414,8 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu= , int offset, s->abpr[cpu] =3D MAX(value & 0x7, GIC_MIN_ABPR); } } else { - s->bpr[cpu] =3D MAX(value & 0x7, GIC_MIN_BPR); + int min_bpr =3D gic_is_vcpu(cpu) ? GIC_VIRT_MIN_BPR : GIC_MIN_= BPR; + s->bpr[cpu] =3D MAX(value & 0x7, min_bpr); } break; case 0x10: /* End Of Interrupt */ @@ -1428,11 +1432,14 @@ static MemTxResult gic_cpu_write(GICState *s, int c= pu, int offset, case 0xd0: case 0xd4: case 0xd8: case 0xdc: { int regno =3D (offset - 0xd0) / 4; + int nr_aprs =3D gic_is_vcpu(cpu) ? GIC_VIRT_NR_APRS : GIC_NR_APRS; =20 - if (regno >=3D GIC_NR_APRS || s->revision !=3D 2) { + if (regno >=3D nr_aprs || s->revision !=3D 2) { return MEMTX_OK; } - if (gic_cpu_ns_access(s, cpu, attrs)) { + if (gic_is_vcpu(cpu)) { + s->h_apr[gic_get_vcpu_real_id(cpu)] =3D value; + } else if (gic_cpu_ns_access(s, cpu, attrs)) { /* NS view of GICC_APR is the top half of GIC_NSAPR */ gic_apr_write_ns_view(s, regno, cpu, value); } else { @@ -1447,6 +1454,9 @@ static MemTxResult gic_cpu_write(GICState *s, int cpu= , int offset, if (regno >=3D GIC_NR_APRS || s->revision !=3D 2) { return MEMTX_OK; } + if (gic_is_vcpu(cpu)) { + return MEMTX_OK; + } if (!gic_has_groups(s) || (gic_cpu_ns_access(s, cpu, attrs))) { return MEMTX_OK; } --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531589526157824.2181516933175; Sat, 14 Jul 2018 10:32:06 -0700 (PDT) Received: from localhost ([::1]:42151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOOi-0000Xh-9B for importer@patchew.org; Sat, 14 Jul 2018 13:31:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9w-0005qb-T8 for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9u-0004fq-Mj for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:40 -0400 Received: from greensocs.com ([193.104.36.180]:57343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9l-0004UN-TA; Sat, 14 Jul 2018 13:16:30 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id DB88FC7AF0; Sat, 14 Jul 2018 19:16:28 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zp0ytQcj14Oy; Sat, 14 Jul 2018 19:16:28 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id F2207C7ADD; Sat, 14 Jul 2018 19:16:27 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 40AC1C7AE3; Sat, 14 Jul 2018 19:16:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588588; bh=gz2wz+zEPSs+qe9FFQpxhPmAyov+ZYPoqU7uxXP/pZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eFhN31X7kMGqPOCSeQ0SZaS7xuyBFpkvkXAl+EOoBdEqWFInWZ8ts8jt8eMT1P62C xfj+QYQvG8Xn9Cdkl3YtvE2dyF0oGR9K9FpUjMi9S5SJKHqBgp5Gy2UlQ71NVr8iB3 bcnMYVqVqYZ5mtNRoYhlPYpAVMq5XMy7A/KPBxcY= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=Ekq/0qtI; dkim=pass (1024-bit key) header.d=greensocs.com header.b=Ekq/0qtI DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588587; bh=gz2wz+zEPSs+qe9FFQpxhPmAyov+ZYPoqU7uxXP/pZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ekq/0qtIJuUfWECkpf5GsCpjHCEo0rQuTJPzx10A+/OWHPpsUzM0u+Og/WXzOqm1v VCKSFFXfChlk46L0FfDJQeHwuySfie8zOIfLRitwaSx2nxhxG+TF6m511ZmhBnpzh0 sYNQs4CFDg6PoO+UG/V6+vy3Ic7qu4emH1VnzI2M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588587; bh=gz2wz+zEPSs+qe9FFQpxhPmAyov+ZYPoqU7uxXP/pZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ekq/0qtIJuUfWECkpf5GsCpjHCEo0rQuTJPzx10A+/OWHPpsUzM0u+Og/WXzOqm1v VCKSFFXfChlk46L0FfDJQeHwuySfie8zOIfLRitwaSx2nxhxG+TF6m511ZmhBnpzh0 sYNQs4CFDg6PoO+UG/V6+vy3Ic7qu4emH1VnzI2M= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:55 +0200 Message-Id: <20180714171601.5734-15-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 14/20] intc/arm_gic: Wire the vCPU interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the read/write functions to handle accesses to the vCPU interface. Those accesses are forwarded to the real CPU interface, with the CPU id being converted to the corresponding vCPU id (vCPU id =3D CPU id + GIC_NCPU). As for the CPU interface, we create a base region for the vCPU interface that fetches the current vCPU id using the current_cpu global variable, and one mirror region per vCPU which maps to that specific vCPU id. This is required by the GIC architecture specification. Signed-off-by: Luc Michel --- hw/intc/arm_gic.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 28ecf0c1fc..be44015c39 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -1514,6 +1514,23 @@ static MemTxResult gic_do_cpu_write(void *opaque, hw= addr addr, return gic_cpu_write(s, id, addr, value, attrs); } =20 +static MemTxResult gic_thisvcpu_read(void *opaque, hwaddr addr, uint64_t *= data, + unsigned size, MemTxAttrs attrs) +{ + GICState *s =3D (GICState *)opaque; + + return gic_cpu_read(s, gic_get_current_vcpu(s), addr, data, attrs); +} + +static MemTxResult gic_thisvcpu_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + GICState *s =3D (GICState *)opaque; + + return gic_cpu_write(s, gic_get_current_vcpu(s), addr, value, attrs); +} + static const MemoryRegionOps gic_ops[2] =3D { { .read_with_attrs =3D gic_dist_read, @@ -1533,6 +1550,19 @@ static const MemoryRegionOps gic_cpu_ops =3D { .endianness =3D DEVICE_NATIVE_ENDIAN, }; =20 +static const MemoryRegionOps gic_virt_ops[2] =3D { + { + .read_with_attrs =3D NULL, + .write_with_attrs =3D NULL, + .endianness =3D DEVICE_NATIVE_ENDIAN, + }, + { + .read_with_attrs =3D gic_thisvcpu_read, + .write_with_attrs =3D gic_thisvcpu_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + } +}; + static void arm_gic_realize(DeviceState *dev, Error **errp) { /* Device instance realize function for the GIC sysbus device */ @@ -1554,8 +1584,11 @@ static void arm_gic_realize(DeviceState *dev, Error = **errp) return; } =20 - /* This creates distributor and main CPU interface (s->cpuiomem[0]) */ - gic_init_irqs_and_mmio(s, gic_set_irq, gic_ops, NULL); + /* This creates distributor, main CPU interface (s->cpuiomem[0]) and if + * enabled, virtualization extensions related interfaces (main virtual + * interface (s->vifaceiomem[0]) and virtual CPU interface). + */ + gic_init_irqs_and_mmio(s, gic_set_irq, gic_ops, gic_virt_ops); =20 /* Extra core-specific regions for the CPU interfaces. This is * necessary for "franken-GIC" implementations, for example on --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531589687261811.6790777420867; Sat, 14 Jul 2018 10:34:47 -0700 (PDT) Received: from localhost ([::1]:42157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feORS-0001jZ-99 for importer@patchew.org; Sat, 14 Jul 2018 13:34:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9z-0005uT-Gd for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9x-0004jx-G9 for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:43 -0400 Received: from greensocs.com ([193.104.36.180]:57359) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9m-0004Vu-Ua; Sat, 14 Jul 2018 13:16:31 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 67AB8C7AF9; Sat, 14 Jul 2018 19:16:30 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xlXcmYzqB2qb; Sat, 14 Jul 2018 19:16:29 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 022DCC7AF4; Sat, 14 Jul 2018 19:16:28 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 0D612C7AE3; Sat, 14 Jul 2018 19:16:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588590; bh=SKtJqMG+GH1kcHIFSEAAr3x3C2DWg3274Gh33dT4l8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qTx2OfnmgHfhPOLZlHgIDJZuXgUUZyYVXWVjtUKaTEqgmCq/wylS7EN2AC+na9nQv Yz2VR71A2bJXeFY6pSFPRuniDTv0k+UKq0q0aR7ECS3SzcC/0b40Ue0449wCWxE7+F Waq+bCoJsvPPqw+fUknh9+CaYhNzW77/HSMfnS6Q= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=V47TOg7Q; dkim=pass (1024-bit key) header.d=greensocs.com header.b=kCpViizu DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588589; bh=SKtJqMG+GH1kcHIFSEAAr3x3C2DWg3274Gh33dT4l8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V47TOg7QRDXCFvasllnBxDf9M+Glw2bNfNXgc+vEYC2DYFWZjjY+/+QhazOGOeA1l 0F+/zpLg3q4whQ+P5wfVt7Nk15H+HTXyEB/i4Nn/l+Ky/2XsHyJUOzmOnpiQxUpmq2 XKS9Zfp/YaL3RSd3uLbBAfgqXEclkT+eOFmTYkyM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588588; bh=SKtJqMG+GH1kcHIFSEAAr3x3C2DWg3274Gh33dT4l8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kCpViizu+jvrJ6rq4nshvmkb1fiCqI6/DNiW1rSQE9IJ882fO7BO44N8cmNBezjnW /XXUI4bduoTbCEkusDSt7KVH6+88RRFq0e4VTPYH68pi+L5qyyButHOxnfhXGhekpR RBQuhAVV1Xql177JfAZEuUFaoSjWFgNnbAQTukMM= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:56 +0200 Message-Id: <20180714171601.5734-16-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 15/20] intc/arm_gic: Implement the virtual interface registers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 3 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Implement the read and write functions for the virtual interface of the virtualization extensions in the GICv2. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 235 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 233 insertions(+), 2 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index be44015c39..d8e9cf0a3a 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -147,6 +147,24 @@ static void gic_update(GICState *s) } } =20 +/* Return true if this LR is empty, i.e. the corresponding bit + * in ELRSR is set. + */ +static inline bool gic_lr_entry_is_free(uint32_t entry) +{ + return (GICH_LR_STATE(entry) =3D=3D GICH_LR_STATE_INVALID) + && (GICH_LR_HW(entry) || !GICH_LR_EOI(entry)); +} + +/* Return true if this LR should trigger an EOI maintenance interrupt, i.e= . the + * corrsponding bit in EISR is set. + */ +static inline bool gic_lr_entry_is_eoi(uint32_t entry) +{ + return (GICH_LR_STATE(entry) =3D=3D GICH_LR_STATE_INVALID) + && !GICH_LR_HW(entry) && GICH_LR_EOI(entry); +} + static void gic_set_irq_11mpcore(GICState *s, int irq, int level, int cm, int target) { @@ -1531,6 +1549,200 @@ static MemTxResult gic_thisvcpu_write(void *opaque,= hwaddr addr, return gic_cpu_write(s, gic_get_current_vcpu(s), addr, value, attrs); } =20 +static uint32_t gic_compute_eisr(GICState *s, int cpu, int lr_start) +{ + int lr_idx; + uint32_t ret =3D 0; + + for (lr_idx =3D lr_start; lr_idx < s->num_lrs; lr_idx++) { + uint32_t *entry =3D &s->h_lr[lr_idx][cpu]; + ret =3D deposit32(ret, lr_idx - lr_start, 1, + gic_lr_entry_is_eoi(*entry)); + } + + return ret; +} + +static uint32_t gic_compute_elrsr(GICState *s, int cpu, int lr_start) +{ + int lr_idx; + uint32_t ret =3D 0; + + for (lr_idx =3D lr_start; lr_idx < s->num_lrs; lr_idx++) { + uint32_t *entry =3D &s->h_lr[lr_idx][cpu]; + ret =3D deposit32(ret, lr_idx - lr_start, 1, + gic_lr_entry_is_free(*entry)); + } + + return ret; +} + +static void gic_vmcr_write(GICState *s, uint32_t value, MemTxAttrs attrs) +{ + int vcpu =3D gic_get_current_vcpu(s); + uint32_t ctlr; + uint32_t abpr; + uint32_t bpr; + uint32_t prio_mask; + + ctlr =3D FIELD_EX32(value, GICH_VMCR, VMCCtlr); + abpr =3D FIELD_EX32(value, GICH_VMCR, VMABP); + bpr =3D FIELD_EX32(value, GICH_VMCR, VMBP); + prio_mask =3D FIELD_EX32(value, GICH_VMCR, VMPriMask) << 3; + + gic_set_cpu_control(s, vcpu, ctlr, attrs); + s->abpr[vcpu] =3D MAX(abpr, GIC_VIRT_MIN_ABPR); + s->bpr[vcpu] =3D MAX(bpr, GIC_VIRT_MIN_BPR); + gic_set_priority_mask(s, vcpu, prio_mask, attrs); +} + +static MemTxResult gic_hyp_read(void *opaque, int cpu, hwaddr addr, + uint64_t *data, MemTxAttrs attrs) +{ + GICState *s =3D ARM_GIC(opaque); + int vcpu =3D cpu + GIC_NCPU; + + switch (addr) { + case A_GICH_HCR: /* Hypervisor Control */ + *data =3D s->h_hcr[cpu]; + break; + + case A_GICH_VTR: /* VGIC Type */ + *data =3D FIELD_DP32(0, GICH_VTR, ListRegs, s->num_lrs - 1); + *data =3D FIELD_DP32(*data, GICH_VTR, PREbits, + GIC_VIRT_MAX_GROUP_PRIO_BITS - 1); + *data =3D FIELD_DP32(*data, GICH_VTR, PRIbits, + (7 - GIC_VIRT_MIN_BPR) - 1); + break; + + case A_GICH_VMCR: /* Virtual Machine Control */ + *data =3D FIELD_DP32(0, GICH_VMCR, VMCCtlr, + extract32(s->cpu_ctlr[vcpu], 0, 10)); + *data =3D FIELD_DP32(*data, GICH_VMCR, VMABP, s->abpr[vcpu]); + *data =3D FIELD_DP32(*data, GICH_VMCR, VMBP, s->bpr[vcpu]); + *data =3D FIELD_DP32(*data, GICH_VMCR, VMPriMask, + extract32(s->priority_mask[vcpu], 3, 5)); + break; + + case A_GICH_MISR: /* Maintenance Interrupt Status */ + *data =3D s->h_misr[cpu]; + break; + + case A_GICH_EISR0: /* End of Interrupt Status 0 and 1 */ + case A_GICH_EISR1: + *data =3D gic_compute_eisr(s, cpu, (addr - A_GICH_EISR0) * 8); + break; + + case A_GICH_ELRSR0: /* Empty List Status 0 and 1 */ + case A_GICH_ELRSR1: + *data =3D gic_compute_elrsr(s, cpu, (addr - A_GICH_ELRSR0) * 8); + break; + + case A_GICH_APR: /* Active Priorities */ + *data =3D s->h_apr[cpu]; + break; + + case A_GICH_LR0 ... A_GICH_LR63: /* List Registers */ + { + int lr_idx =3D (addr - A_GICH_LR0) / 4; + + if (lr_idx > s->num_lrs) { + *data =3D 0; + } else { + *data =3D s->h_lr[lr_idx][cpu]; + } + break; + } + + default: + qemu_log_mask(LOG_GUEST_ERROR, + "gic_hyp_read: Bad offset %" HWADDR_PRIx "\n", addr); + return MEMTX_OK; + } + + return MEMTX_OK; +} + +static MemTxResult gic_hyp_write(void *opaque, int cpu, hwaddr addr, + uint64_t value, MemTxAttrs attrs) +{ + GICState *s =3D ARM_GIC(opaque); + int vcpu =3D cpu + GIC_NCPU; + + switch (addr) { + case A_GICH_HCR: /* Hypervisor Control */ + s->h_hcr[cpu] =3D value & GICH_HCR_MASK; + break; + + case A_GICH_VMCR: /* Virtual Machine Control */ + gic_vmcr_write(s, value, attrs); + break; + + case A_GICH_APR: /* Active Priorities */ + s->h_apr[cpu] =3D value; + s->running_priority[vcpu] =3D gic_get_prio_from_apr_bits(s, vcpu); + break; + + case A_GICH_LR0 ... A_GICH_LR63: /* List Registers */ + { + int lr_idx =3D (addr - A_GICH_LR0) / 4; + + if (lr_idx > s->num_lrs) { + return MEMTX_OK; + } + + s->h_lr[lr_idx][cpu] =3D value & GICH_LR_MASK; + break; + } + + default: + qemu_log_mask(LOG_GUEST_ERROR, + "gic_hyp_write: Bad offset %" HWADDR_PRIx "\n", addr= ); + return MEMTX_OK; + } + + return MEMTX_OK; +} + +static MemTxResult gic_thiscpu_hyp_read(void *opaque, hwaddr addr, uint64_= t *data, + unsigned size, MemTxAttrs attrs) +{ + GICState *s =3D (GICState *)opaque; + + return gic_hyp_read(s, gic_get_current_cpu(s), addr, data, attrs); +} + +static MemTxResult gic_thiscpu_hyp_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + GICState *s =3D (GICState *)opaque; + + return gic_hyp_write(s, gic_get_current_cpu(s), addr, value, attrs); +} + +static MemTxResult gic_do_hyp_read(void *opaque, hwaddr addr, uint64_t *da= ta, + unsigned size, MemTxAttrs attrs) +{ + GICState **backref =3D (GICState **)opaque; + GICState *s =3D *backref; + int id =3D (backref - s->backref); + + return gic_hyp_read(s, id, addr, data, attrs); +} + +static MemTxResult gic_do_hyp_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + GICState **backref =3D (GICState **)opaque; + GICState *s =3D *backref; + int id =3D (backref - s->backref); + + return gic_hyp_write(s, id + GIC_NCPU, addr, value, attrs); + +} + static const MemoryRegionOps gic_ops[2] =3D { { .read_with_attrs =3D gic_dist_read, @@ -1552,8 +1764,8 @@ static const MemoryRegionOps gic_cpu_ops =3D { =20 static const MemoryRegionOps gic_virt_ops[2] =3D { { - .read_with_attrs =3D NULL, - .write_with_attrs =3D NULL, + .read_with_attrs =3D gic_thiscpu_hyp_read, + .write_with_attrs =3D gic_thiscpu_hyp_write, .endianness =3D DEVICE_NATIVE_ENDIAN, }, { @@ -1563,6 +1775,12 @@ static const MemoryRegionOps gic_virt_ops[2] =3D { } }; =20 +static const MemoryRegionOps gic_viface_ops =3D { + .read_with_attrs =3D gic_do_hyp_read, + .write_with_attrs =3D gic_do_hyp_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, +}; + static void arm_gic_realize(DeviceState *dev, Error **errp) { /* Device instance realize function for the GIC sysbus device */ @@ -1604,6 +1822,19 @@ static void arm_gic_realize(DeviceState *dev, Error = **errp) &s->backref[i], "gic_cpu", 0x100); sysbus_init_mmio(sbd, &s->cpuiomem[i+1]); } + + /* Extra core-specific regions for virtual interfaces. This is require= d by + * the GICv2 specification. + */ + if (s->virt_extn) { + for (i =3D 0; i < s->num_cpu; i++) { + memory_region_init_io(&s->vifaceiomem[i + 1], OBJECT(s), + &gic_viface_ops, &s->backref[i], + "gic_viface", 0x1000); + sysbus_init_mmio(sbd, &s->vifaceiomem[i + 1]); + } + } + } =20 static void arm_gic_class_init(ObjectClass *klass, void *data) --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 153158986745562.29734579962553; Sat, 14 Jul 2018 10:37:47 -0700 (PDT) Received: from localhost ([::1]:42215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOUA-0003HS-TW for importer@patchew.org; Sat, 14 Jul 2018 13:37:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOA0-0005ug-1s for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9y-0004l2-7k for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:44 -0400 Received: from greensocs.com ([193.104.36.180]:57367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9n-0004Wu-Kk; Sat, 14 Jul 2018 13:16:31 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 1AF1EC7AFD; Sat, 14 Jul 2018 19:16:31 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nsmrpcoTrFsA; Sat, 14 Jul 2018 19:16:30 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 21055C7ADD; Sat, 14 Jul 2018 19:16:30 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 1123EC7AE3; Sat, 14 Jul 2018 19:16:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588591; bh=yPWR/NPqq9B9XvhSaAF4Z+pIfgx2B5PTR8tDwWe3gdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QXi2msaiR1pAywMCcILDoBTqW86pEaJlBZIUxYKssiMihTCzN9DwCxGSHbn6Vh8MA FLY5YvK2tfjUXurQYPibcJnuYB1RrhnvKIvPIyvKcxMutg7YM+E1yjJ7zoVikQH4i1 rfWrRmXmQylJqlFUbMvFjEmoSRjcpaz7pYhWvcFY= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=pmCTZqeo; dkim=pass (1024-bit key) header.d=greensocs.com header.b=pmCTZqeo DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588590; bh=yPWR/NPqq9B9XvhSaAF4Z+pIfgx2B5PTR8tDwWe3gdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pmCTZqeol2NQ7GHUiuCF4PGrf2EO7V/OXM4maxLGdAma6VUbRD8Zhi1iZaETIc6rz 2ImkRav3lum8gmPDkIq8Tji5NOTxibeQ7WK4MtickHrfyw/EyPoYYSILLb9y/flBNQ fxuMCD1i75bZu3ffPLAKz5VaNR6DA79HppS+1ij4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588590; bh=yPWR/NPqq9B9XvhSaAF4Z+pIfgx2B5PTR8tDwWe3gdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pmCTZqeol2NQ7GHUiuCF4PGrf2EO7V/OXM4maxLGdAma6VUbRD8Zhi1iZaETIc6rz 2ImkRav3lum8gmPDkIq8Tji5NOTxibeQ7WK4MtickHrfyw/EyPoYYSILLb9y/flBNQ fxuMCD1i75bZu3ffPLAKz5VaNR6DA79HppS+1ij4= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:57 +0200 Message-Id: <20180714171601.5734-17-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 16/20] intc/arm_gic: Implement gic_update_virt() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the gic_update_virt() function to update the vCPU interface states and raise vIRQ and vFIQ as needed. This commit renames gic_update() to gic_update_internal() and generalizes it to handle both cases, with a `virt' parameter to track whether we are updating the CPU or vCPU interfaces. The main difference between CPU and vCPU is the way we select the best IRQ. This part has been split into the gic_get_best_(v)irq functions. For the virt case, the LRs are iterated to find the best candidate. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 186 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 146 insertions(+), 40 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index d8e9cf0a3a..85f1a03147 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -79,74 +79,149 @@ static inline bool gic_cpu_ns_access(GICState *s, int = cpu, MemTxAttrs attrs) return !gic_is_vcpu(cpu) && s->security_extn && !attrs.secure; } =20 +static inline void gic_get_best_irq(GICState *s, int cpu, + int *best_irq, int *best_prio, int *gr= oup) +{ + int irq; + int cm =3D 1 << cpu; + + *best_irq =3D 1023; + *best_prio =3D 0x100; + + for (irq =3D 0; irq < s->num_irq; irq++) { + if (GIC_DIST_TEST_ENABLED(irq, cm) && gic_test_pending(s, irq, cm)= && + (!GIC_DIST_TEST_ACTIVE(irq, cm)) && + (irq < GIC_INTERNAL || GIC_DIST_TARGET(irq) & cm)) { + if (GIC_DIST_GET_PRIORITY(irq, cpu) < *best_prio) { + *best_prio =3D GIC_DIST_GET_PRIORITY(irq, cpu); + *best_irq =3D irq; + } + } + } + + if (*best_irq < 1023) { + *group =3D GIC_DIST_TEST_GROUP(*best_irq, cm); + } +} + +static inline void gic_get_best_virq(GICState *s, int cpu, + int *best_irq, int *best_prio, int *g= roup) +{ + int lr_idx =3D 0; + + *best_irq =3D 1023; + *best_prio =3D 0x100; + + for (lr_idx =3D 0; lr_idx < s->num_lrs; lr_idx++) { + uint32_t lr_entry =3D s->h_lr[lr_idx][cpu]; + int state =3D GICH_LR_STATE(lr_entry); + + if (state =3D=3D GICH_LR_STATE_PENDING) { + int prio =3D GICH_LR_PRIORITY(lr_entry); + + if (prio < *best_prio) { + *best_prio =3D prio; + *best_irq =3D GICH_LR_VIRT_ID(lr_entry); + *group =3D GICH_LR_GROUP(lr_entry); + } + } + } +} + +/* Return true if IRQ signaling is enabled for the given cpu and at least = one + * of the given groups: + * - in the non-virt case, the distributor must be enabled for one of the + * given groups + * - in the virt case, the virtual interface must be enabled. + * - in all cases, the (v)CPU interface must be enabled for one of the g= iven + * groups. + */ +static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool vi= rt, + int group_mask) +{ + if (!virt && !(s->ctlr & group_mask)) { + return false; + } + + if (virt && !(s->h_hcr[cpu] & R_GICH_HCR_EN_MASK)) { + return false; + } + + if (!(s->cpu_ctlr[cpu] & group_mask)) { + return false; + } + + return true; +} + /* TODO: Many places that call this routine could be optimized. */ /* Update interrupt status after enabled or pending bits have been changed= . */ -static void gic_update(GICState *s) +static inline void gic_update_internal(GICState *s, bool virt) { int best_irq; int best_prio; - int irq; int irq_level, fiq_level; - int cpu; - int cm; + int cpu, cpu_iface; + int group =3D 0; + qemu_irq *irq_lines =3D virt ? s->parent_virq : s->parent_irq; + qemu_irq *fiq_lines =3D virt ? s->parent_vfiq : s->parent_fiq; =20 for (cpu =3D 0; cpu < s->num_cpu; cpu++) { - cm =3D 1 << cpu; - s->current_pending[cpu] =3D 1023; - if (!(s->ctlr & (GICD_CTLR_EN_GRP0 | GICD_CTLR_EN_GRP1)) - || !(s->cpu_ctlr[cpu] & (GICC_CTLR_EN_GRP0 | GICC_CTLR_EN_GRP1= ))) { - qemu_irq_lower(s->parent_irq[cpu]); - qemu_irq_lower(s->parent_fiq[cpu]); + cpu_iface =3D virt ? (cpu + GIC_NCPU) : cpu; + + s->current_pending[cpu_iface] =3D 1023; + if (!gic_irq_signaling_enabled(s, cpu, virt, + GICD_CTLR_EN_GRP0 | GICD_CTLR_EN_GR= P1)) { + qemu_irq_lower(irq_lines[cpu]); + qemu_irq_lower(fiq_lines[cpu]); continue; } - best_prio =3D 0x100; - best_irq =3D 1023; - for (irq =3D 0; irq < s->num_irq; irq++) { - if (GIC_DIST_TEST_ENABLED(irq, cm) && - gic_test_pending(s, irq, cm) && - (!GIC_DIST_TEST_ACTIVE(irq, cm)) && - (irq < GIC_INTERNAL || GIC_DIST_TARGET(irq) & cm)) { - if (GIC_DIST_GET_PRIORITY(irq, cpu) < best_prio) { - best_prio =3D GIC_DIST_GET_PRIORITY(irq, cpu); - best_irq =3D irq; - } - } + + if (virt) { + gic_get_best_virq(s, cpu, &best_irq, &best_prio, &group); + } else { + gic_get_best_irq(s, cpu, &best_irq, &best_prio, &group); } =20 if (best_irq !=3D 1023) { trace_gic_update_bestirq(cpu, best_irq, best_prio, - s->priority_mask[cpu], s->running_priority[cpu]); + s->priority_mask[cpu_iface], s->running_priority[cpu_iface= ]); } =20 irq_level =3D fiq_level =3D 0; =20 - if (best_prio < s->priority_mask[cpu]) { - s->current_pending[cpu] =3D best_irq; - if (best_prio < s->running_priority[cpu]) { - int group =3D GIC_DIST_TEST_GROUP(best_irq, cm); - - if (extract32(s->ctlr, group, 1) && - extract32(s->cpu_ctlr[cpu], group, 1)) { - if (group =3D=3D 0 && s->cpu_ctlr[cpu] & GICC_CTLR_FIQ= _EN) { + if (best_prio < s->priority_mask[cpu_iface]) { + s->current_pending[cpu_iface] =3D best_irq; + if (best_prio < s->running_priority[cpu_iface]) { + if (gic_irq_signaling_enabled(s, cpu, virt, 1 << group)) { + if (group =3D=3D 0 && + s->cpu_ctlr[cpu_iface] & GICC_CTLR_FIQ_EN) { DPRINTF("Raised pending FIQ %d (cpu %d)\n", - best_irq, cpu); + best_irq, cpu_iface); fiq_level =3D 1; - trace_gic_update_set_irq(cpu, "fiq", fiq_level); + trace_gic_update_set_irq(cpu, virt ? "vfiq" : "fiq= ", + fiq_level); } else { DPRINTF("Raised pending IRQ %d (cpu %d)\n", - best_irq, cpu); + best_irq, cpu_iface); irq_level =3D 1; - trace_gic_update_set_irq(cpu, "irq", irq_level); + trace_gic_update_set_irq(cpu, virt ? "virq" : "irq= ", + irq_level); } } } } =20 - qemu_set_irq(s->parent_irq[cpu], irq_level); - qemu_set_irq(s->parent_fiq[cpu], fiq_level); + qemu_set_irq(irq_lines[cpu], irq_level); + qemu_set_irq(fiq_lines[cpu], fiq_level); } } =20 +static void gic_update(GICState *s) +{ + gic_update_internal(s, false); +} + /* Return true if this LR is empty, i.e. the corresponding bit * in ELRSR is set. */ @@ -165,6 +240,11 @@ static inline bool gic_lr_entry_is_eoi(uint32_t entry) && !GICH_LR_HW(entry) && GICH_LR_EOI(entry); } =20 +static void gic_update_virt(GICState *s) +{ + gic_update_internal(s, true); +} + static void gic_set_irq_11mpcore(GICState *s, int irq, int level, int cm, int target) { @@ -449,7 +529,11 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, Mem= TxAttrs attrs) } } =20 - gic_update(s); + if (gic_is_vcpu(cpu)) { + gic_update_virt(s); + } else { + gic_update(s); + } DPRINTF("ACK %d\n", irq); return ret; } @@ -614,6 +698,11 @@ static void gic_deactivate_irq(GICState *s, int cpu, i= nt irq, MemTxAttrs attrs) */ int rcpu =3D gic_get_vcpu_real_id(cpu); s->h_hcr[rcpu] +=3D 1 << R_GICH_HCR_EOICount_SHIFT; + + /* Update the virtual interface in case a maintenance interrupt sh= ould + * be raised. + */ + gic_update_virt(s); return; } =20 @@ -637,6 +726,11 @@ static void gic_complete_irq(GICState *s, int cpu, int= irq, MemTxAttrs attrs) */ int rcpu =3D gic_get_vcpu_real_id(cpu); s->h_hcr[rcpu] +=3D 1 << R_GICH_HCR_EOICount_SHIFT; + + /* Update the virtual interface in case a maintenance interrupt sh= ould + * be raised. + */ + gic_update_virt(s); return; } =20 @@ -684,7 +778,12 @@ static void gic_complete_irq(GICState *s, int cpu, int= irq, MemTxAttrs attrs) if (!gic_eoi_split(s, cpu, attrs)) { gic_clear_active(s, irq, cpu); } - gic_update(s); + + if (gic_is_vcpu(cpu)) { + gic_update_virt(s); + } else { + gic_update(s); + } } =20 static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs att= rs) @@ -1490,7 +1589,13 @@ static MemTxResult gic_cpu_write(GICState *s, int cp= u, int offset, "gic_cpu_write: Bad offset %x\n", (int)offset); return MEMTX_OK; } - gic_update(s); + + if (gic_is_vcpu(cpu)) { + gic_update_virt(s); + } else { + gic_update(s); + } + return MEMTX_OK; } =20 @@ -1701,6 +1806,7 @@ static MemTxResult gic_hyp_write(void *opaque, int cp= u, hwaddr addr, return MEMTX_OK; } =20 + gic_update_virt(s); return MEMTX_OK; } =20 --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531589147066409.5344892913532; Sat, 14 Jul 2018 10:25:47 -0700 (PDT) Received: from localhost ([::1]:42109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOIb-0004MA-7x for importer@patchew.org; Sat, 14 Jul 2018 13:25:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9y-0005tN-H6 for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9w-0004in-QY for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:42 -0400 Received: from greensocs.com ([193.104.36.180]:57388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9p-0004Zk-Kn; Sat, 14 Jul 2018 13:16:33 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 13792C7ADD; Sat, 14 Jul 2018 19:16:33 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5W9HTGdt_srp; Sat, 14 Jul 2018 19:16:32 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 3332AC7AF4; Sat, 14 Jul 2018 19:16:31 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 3BBA8C7AE3; Sat, 14 Jul 2018 19:16:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588593; bh=i1BwjH3XT+OrsK2Nj8m0xiz7tDcSdqowdxOMe+UKIks=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bYpaGqZoxJhsn6zziZvPggjOPVoUEKtRFbrI1QoUA0SsF9R96DdL2sM60rJbqlHvj DCgbSm6/Puuhj9Gr18AYkkj/DJZPokntGfnF9vLS9pgJy2SIhS9AJN/hdhFOQ2m0j1 UtIniTwLzDwyqPBN4zP3y5qikVQlqGlaIUiKvUbY= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=qbXMgKJ9; dkim=pass (1024-bit key) header.d=greensocs.com header.b=qbXMgKJ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588591; bh=i1BwjH3XT+OrsK2Nj8m0xiz7tDcSdqowdxOMe+UKIks=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qbXMgKJ9ODnQklMe7JiwxtM8ic6iZ04Zpd1d/PEOISyzDpuohcUixgBEkZVva/gf6 yR9MkF9yzq0QkCS7YUd0yCVCX1iVqvxDRSVL2KNv/GtA7X3MsGKpnPdr+rcRaxa9p2 lMwuSb4gHxyiwIhDuTWcqkLJATq4bKaG3DYkDuiU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588591; bh=i1BwjH3XT+OrsK2Nj8m0xiz7tDcSdqowdxOMe+UKIks=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qbXMgKJ9ODnQklMe7JiwxtM8ic6iZ04Zpd1d/PEOISyzDpuohcUixgBEkZVva/gf6 yR9MkF9yzq0QkCS7YUd0yCVCX1iVqvxDRSVL2KNv/GtA7X3MsGKpnPdr+rcRaxa9p2 lMwuSb4gHxyiwIhDuTWcqkLJATq4bKaG3DYkDuiU= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:58 +0200 Message-Id: <20180714171601.5734-18-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 17/20] intc/arm_gic: Implement maintenance interrupt generation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Implement the maintenance interrupt generation that is part of the GICv2 virtualization extensions. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 85f1a03147..4155fbe667 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -240,9 +240,106 @@ static inline bool gic_lr_entry_is_eoi(uint32_t entry) && !GICH_LR_HW(entry) && GICH_LR_EOI(entry); } =20 +static inline void gic_extract_lr_info(GICState *s, int cpu, + int *num_eoi, int *num_valid, int *num_pen= ding) +{ + int lr_idx; + + *num_eoi =3D 0; + *num_valid =3D 0; + *num_pending =3D 0; + + for (lr_idx =3D 0; lr_idx < s->num_lrs; lr_idx++) { + uint32_t *entry =3D &s->h_lr[lr_idx][cpu]; + + if (gic_lr_entry_is_eoi(*entry)) { + (*num_eoi)++; + } + + if (GICH_LR_STATE(*entry) !=3D GICH_LR_STATE_INVALID) { + (*num_valid)++; + } + + if (GICH_LR_STATE(*entry) =3D=3D GICH_LR_STATE_PENDING) { + (*num_pending)++; + } + } +} + +static void gic_compute_misr(GICState *s, int cpu) +{ + uint32_t value =3D 0; + int vcpu =3D cpu + GIC_NCPU; + + int num_eoi, num_valid, num_pending; + + gic_extract_lr_info(s, cpu, &num_eoi, &num_valid, &num_pending); + + /* EOI */ + if (num_eoi) { + value |=3D R_GICH_MISR_EOI_MASK; + } + + /* U: true if only 0 or 1 LR entry is valid */ + if ((s->h_hcr[cpu] & R_GICH_HCR_UIE_MASK) && (num_valid < 2)) { + value |=3D R_GICH_MISR_U_MASK; + } + + /* LRENP: EOICount is not 0 */ + if ((s->h_hcr[cpu] & R_GICH_HCR_LRENPIE_MASK) && + ((s->h_hcr[cpu] & R_GICH_HCR_EOICount_MASK) !=3D 0)) { + value |=3D R_GICH_MISR_LRENP_MASK; + } + + /* NP: no pending interrupts */ + if ((s->h_hcr[cpu] & R_GICH_HCR_NPIE_MASK) && (num_pending =3D=3D 0)) { + value |=3D R_GICH_MISR_NP_MASK; + } + + /* VGrp0E: group0 virq signaling enabled */ + if ((s->h_hcr[cpu] & R_GICH_HCR_VGRP0EIE_MASK) && + (s->cpu_ctlr[vcpu] & GICC_CTLR_EN_GRP0)) { + value |=3D R_GICH_MISR_VGrp0E_MASK; + } + + /* VGrp0D: group0 virq signaling disabled */ + if ((s->h_hcr[cpu] & R_GICH_HCR_VGRP0DIE_MASK) && + !(s->cpu_ctlr[vcpu] & GICC_CTLR_EN_GRP0)) { + value |=3D R_GICH_MISR_VGrp0D_MASK; + } + + /* VGrp1E: group1 virq signaling enabled */ + if ((s->h_hcr[cpu] & R_GICH_HCR_VGRP1EIE_MASK) && + (s->cpu_ctlr[vcpu] & GICC_CTLR_EN_GRP1)) { + value |=3D R_GICH_MISR_VGrp1E_MASK; + } + + /* VGrp1D: group1 virq signaling disabled */ + if ((s->h_hcr[cpu] & R_GICH_HCR_VGRP1DIE_MASK) && + !(s->cpu_ctlr[vcpu] & GICC_CTLR_EN_GRP1)) { + value |=3D R_GICH_MISR_VGrp1D_MASK; + } + + s->h_misr[cpu] =3D value; +} + +static void gic_update_maintenance(GICState *s) +{ + int cpu =3D 0; + int maint_level; + + for (cpu =3D 0; cpu < s->num_cpu; cpu++) { + gic_compute_misr(s, cpu); + maint_level =3D (s->h_hcr[cpu] & R_GICH_HCR_EN_MASK) && s->h_misr[= cpu]; + + qemu_set_irq(s->maintenance_irq[cpu], maint_level); + } +} + static void gic_update_virt(GICState *s) { gic_update_internal(s, true); + gic_update_maintenance(s); } =20 static void gic_set_irq_11mpcore(GICState *s, int irq, int level, --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531589395456542.9377196689857; Sat, 14 Jul 2018 10:29:55 -0700 (PDT) Received: from localhost ([::1]:42138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOMk-0007gj-Dg for importer@patchew.org; Sat, 14 Jul 2018 13:29:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9z-0005u5-4X for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9x-0004k5-Gl for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:43 -0400 Received: from greensocs.com ([193.104.36.180]:57408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9q-0004bC-Nc; Sat, 14 Jul 2018 13:16:35 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 28D4CC7AFD; Sat, 14 Jul 2018 19:16:34 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3gDXWf990x2J; Sat, 14 Jul 2018 19:16:33 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 13F88C7AE3; Sat, 14 Jul 2018 19:16:32 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 4BF51C7ADD; Sat, 14 Jul 2018 19:16:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588594; bh=HfO+D7ZdbpsDFmIwVCToXNZbCsQtb1nXmnk4bOtXSqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ja9NagPl1tUGZb5F6Gnsjog5gD23u3juxrBCKUbgI1F/kA8R/3w0GXpJvCp1eicKN 6E1CZDTwJiJ9r6/H7IXXlqUq8VZm7MOsGtFOoxD2wtOUv8Yd8wa0Tf2M70kjSBOcTK 4Bi40TbbGt7dQicWA2ZVNvknceXuHT6qmOvB458c= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=CmF+7Ffn; dkim=pass (1024-bit key) header.d=greensocs.com header.b=l56X17Q4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588592; bh=HfO+D7ZdbpsDFmIwVCToXNZbCsQtb1nXmnk4bOtXSqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CmF+7FfnQd6PhR/EDgO3vFbszAG1gL2IQ6hCzPJaTrjpqVYCJ39g+1qN2etJsXXSL 3P/8eHEdxHOnL9zUwkbSirwp5Hc4xTlr8zS0cSYUq5CrmvQH69m+/rMiAdmc/HrHKT Qkg7vwanW5QqxuBonuAYoCAYsQzn0tGuXtTqrpOQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588591; bh=HfO+D7ZdbpsDFmIwVCToXNZbCsQtb1nXmnk4bOtXSqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l56X17Q4dKV/mRa1B9Z1JhE0tjiNFYDPa15HjTZWS+dWVrJxdQLjqBmkIF1WtfqHF stW+/pcdSgaaz/yx4eNy6/9oYV1+Krv92x8uD/gZDXxZc8owns7rtsVuHAs4EGTC44 bneVV0/5azTPlwJxCh4+KnLWh9NpgzrEr9ezS9q0= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:15:59 +0200 Message-Id: <20180714171601.5734-19-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 18/20] intc/arm_gic: Improve traces X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 3 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add some traces to the ARM GIC to catch register accesses (distributor, (v)cpu interface and virtual interface), and to take into account virtualization extensions (print `vcpu` instead of `cpu` when needed). Also add some virtualization extensions specific traces: LR updating and maintenance IRQ generation. Signed-off-by: Luc Michel Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell --- hw/intc/arm_gic.c | 31 +++++++++++++++++++++++++------ hw/intc/trace-events | 12 ++++++++++-- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 4155fbe667..bb06c90cfc 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -184,8 +184,10 @@ static inline void gic_update_internal(GICState *s, bo= ol virt) } =20 if (best_irq !=3D 1023) { - trace_gic_update_bestirq(cpu, best_irq, best_prio, - s->priority_mask[cpu_iface], s->running_priority[cpu_iface= ]); + trace_gic_update_bestirq(virt ? "vcpu" : "cpu", cpu, + best_irq, best_prio, + s->priority_mask[cpu_iface], + s->running_priority[cpu_iface]); } =20 irq_level =3D fiq_level =3D 0; @@ -332,6 +334,7 @@ static void gic_update_maintenance(GICState *s) gic_compute_misr(s, cpu); maint_level =3D (s->h_hcr[cpu] & R_GICH_HCR_EN_MASK) && s->h_misr[= cpu]; =20 + trace_gic_update_maintenance_irq(cpu, maint_level); qemu_set_irq(s->maintenance_irq[cpu], maint_level); } } @@ -597,7 +600,8 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemT= xAttrs attrs) * is in the wrong group. */ irq =3D gic_get_current_pending_irq(s, cpu, attrs); - trace_gic_acknowledge_irq(gic_get_vcpu_real_id(cpu), irq); + trace_gic_acknowledge_irq(gic_is_vcpu(cpu) ? "vcpu" : "cpu", + gic_get_vcpu_real_id(cpu), irq); =20 if (irq >=3D GIC_MAXIRQ) { DPRINTF("ACK, no pending interrupt or it is hidden: %d\n", irq); @@ -1098,20 +1102,23 @@ static MemTxResult gic_dist_read(void *opaque, hwad= dr offset, uint64_t *data, switch (size) { case 1: *data =3D gic_dist_readb(opaque, offset, attrs); - return MEMTX_OK; + break; case 2: *data =3D gic_dist_readb(opaque, offset, attrs); *data |=3D gic_dist_readb(opaque, offset + 1, attrs) << 8; - return MEMTX_OK; + break; case 4: *data =3D gic_dist_readb(opaque, offset, attrs); *data |=3D gic_dist_readb(opaque, offset + 1, attrs) << 8; *data |=3D gic_dist_readb(opaque, offset + 2, attrs) << 16; *data |=3D gic_dist_readb(opaque, offset + 3, attrs) << 24; - return MEMTX_OK; + break; default: return MEMTX_ERROR; } + + trace_gic_dist_read(offset, size, *data); + return MEMTX_OK; } =20 static void gic_dist_writeb(void *opaque, hwaddr offset, @@ -1450,6 +1457,8 @@ static void gic_dist_writel(void *opaque, hwaddr offs= et, static MemTxResult gic_dist_write(void *opaque, hwaddr offset, uint64_t da= ta, unsigned size, MemTxAttrs attrs) { + trace_gic_dist_write(offset, size, data); + switch (size) { case 1: gic_dist_writeb(opaque, offset, data, attrs); @@ -1606,12 +1615,18 @@ static MemTxResult gic_cpu_read(GICState *s, int cp= u, int offset, *data =3D 0; break; } + + trace_gic_cpu_read(gic_is_vcpu(cpu) ? "vcpu" : "cpu", + gic_get_vcpu_real_id(cpu), offset, *data); return MEMTX_OK; } =20 static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset, uint32_t value, MemTxAttrs attrs) { + trace_gic_cpu_write(gic_is_vcpu(cpu) ? "vcpu" : "cpu", + gic_get_vcpu_real_id(cpu), offset, value); + switch (offset) { case 0x00: /* Control */ gic_set_cpu_control(s, cpu, value, attrs); @@ -1862,6 +1877,7 @@ static MemTxResult gic_hyp_read(void *opaque, int cpu= , hwaddr addr, return MEMTX_OK; } =20 + trace_gic_hyp_read(addr, *data); return MEMTX_OK; } =20 @@ -1871,6 +1887,8 @@ static MemTxResult gic_hyp_write(void *opaque, int cp= u, hwaddr addr, GICState *s =3D ARM_GIC(opaque); int vcpu =3D cpu + GIC_NCPU; =20 + trace_gic_hyp_write(addr, value); + switch (addr) { case A_GICH_HCR: /* Hypervisor Control */ s->h_hcr[cpu] =3D value & GICH_HCR_MASK; @@ -1894,6 +1912,7 @@ static MemTxResult gic_hyp_write(void *opaque, int cp= u, hwaddr addr, } =20 s->h_lr[lr_idx][cpu] =3D value & GICH_LR_MASK; + trace_gic_lr_entry(cpu, lr_idx, s->h_lr[lr_idx][cpu]); break; } =20 diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 55e8c2570c..47fa4ad5c1 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -92,9 +92,17 @@ aspeed_vic_write(uint64_t offset, unsigned size, uint32_= t data) "To 0x%" PRIx64 gic_enable_irq(int irq) "irq %d enabled" gic_disable_irq(int irq) "irq %d disabled" gic_set_irq(int irq, int level, int cpumask, int target) "irq %d level %d = cpumask 0x%x target 0x%x" -gic_update_bestirq(int cpu, int irq, int prio, int priority_mask, int runn= ing_priority) "cpu %d irq %d priority %d cpu priority mask %d cpu running p= riority %d" +gic_update_bestirq(const char *s, int cpu, int irq, int prio, int priority= _mask, int running_priority) "%s %d irq %d priority %d cpu priority mask %d= cpu running priority %d" gic_update_set_irq(int cpu, const char *name, int level) "cpu[%d]: %s =3D = %d" -gic_acknowledge_irq(int cpu, int irq) "cpu %d acknowledged irq %d" +gic_acknowledge_irq(const char *s, int cpu, int irq) "%s %d acknowledged i= rq %d" +gic_cpu_write(const char *s, int cpu, int addr, uint32_t val) "%s %d iface= write at 0x%08x 0x%08" PRIx32 +gic_cpu_read(const char *s, int cpu, int addr, uint32_t val) "%s %d iface = read at 0x%08x: 0x%08" PRIx32 +gic_hyp_read(int addr, uint32_t val) "hyp read at 0x%08x: 0x%08" PRIx32 +gic_hyp_write(int addr, uint32_t val) "hyp write at 0x%08x: 0x%08" PRIx32 +gic_dist_read(int addr, unsigned int size, uint32_t val) "dist read at 0x%= 08x size %u: 0x%08" PRIx32 +gic_dist_write(int addr, unsigned int size, uint32_t val) "dist write at 0= x%08x size %u: 0x%08" PRIx32 +gic_lr_entry(int cpu, int entry, uint32_t val) "cpu %d: new lr entry %d: 0= x%08" PRIx32 +gic_update_maintenance_irq(int cpu, int val) "cpu %d: maintenance =3D %d" =20 # hw/intc/arm_gicv3_cpuif.c gicv3_icc_pmr_read(uint32_t cpu, uint64_t val) "GICv3 ICC_PMR read cpu 0x%= x value 0x%" PRIx64 --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531589600291504.0186438930757; Sat, 14 Jul 2018 10:33:20 -0700 (PDT) Received: from localhost ([::1]:42154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOQ3-00017i-6a for importer@patchew.org; Sat, 14 Jul 2018 13:33:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9z-0005uC-6e for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9x-0004jj-Aq for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:43 -0400 Received: from greensocs.com ([193.104.36.180]:57404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9q-0004b3-Kx; Sat, 14 Jul 2018 13:16:35 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 1A65AC7AFE; Sat, 14 Jul 2018 19:16:34 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cmr6Fo_VkXP9; Sat, 14 Jul 2018 19:16:33 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id F00ACC7AF0; Sat, 14 Jul 2018 19:16:32 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 29768C7ADD; Sat, 14 Jul 2018 19:16:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588594; bh=Q5Z4T9FiiCDb1ZSxXIEFBRZhAjd3zLVEqvA3U7XETW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kJ/o+k3bMI0sgR8PjX+JdIiNGAHi9ZyI84MSrAK2E79X/jes65W6qjFbOCFAlMkdm v+pDEgYBKg8f7fP6b/dk/c+VEMFpk5x8OGudjR8OSON/8cwJ2CgFBOynqvWs/46PbR HHOKf25Vz1VpnnFPfogZ3Vv6vQMNWjPhPtW9yLJM= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=4kyzAkgV; dkim=pass (1024-bit key) header.d=greensocs.com header.b=4kyzAkgV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588592; bh=Q5Z4T9FiiCDb1ZSxXIEFBRZhAjd3zLVEqvA3U7XETW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=4kyzAkgVni3KTjcdYwRP+A5KhN8f9l7WQErYsHw/JYzzOpyXFBHTLKsgqYE8XGQcJ +TICvVKe7WhY0vFKPHBA4feUyXtQpIkCROGyi37poM8TEnNH5jRWj6pUB4kTirABeb +1s53wv9IsrcvGfvm83RwxyIcqywaHRMcrRyFOHE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588592; bh=Q5Z4T9FiiCDb1ZSxXIEFBRZhAjd3zLVEqvA3U7XETW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=4kyzAkgVni3KTjcdYwRP+A5KhN8f9l7WQErYsHw/JYzzOpyXFBHTLKsgqYE8XGQcJ +TICvVKe7WhY0vFKPHBA4feUyXtQpIkCROGyi37poM8TEnNH5jRWj6pUB4kTirABeb +1s53wv9IsrcvGfvm83RwxyIcqywaHRMcrRyFOHE= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:16:00 +0200 Message-Id: <20180714171601.5734-20-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 19/20] xlnx-zynqmp: Improve GIC wiring and MMIO mapping X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This commit improve the way the GIC is realized and connected in the ZynqMP SoC. The security extensions are enabled only if requested in the machine state. The same goes for the virtualization extensions. All the GIC to APU CPU(s) IRQ lines are now connected, including FIQ, vIRQ and vFIQ. The missing CPU to GIC timers IRQ connections are also added (HYP and SEC timers). The GIC maintenance IRQs are back-wired to the correct GIC PPIs. Finally, the MMIO mappings are reworked to take into account the ZynqMP specifics. The GIC (v)CPU interface is aliased 16 times: * for the first 0x1000 bytes from 0xf9010000 to 0xf901f000 * for the second 0x1000 bytes from 0xf9020000 to 0xf902f000 Mappings of the virtual interface and virtual CPU interface are mapped only when virtualization extensions are requested. The XlnxZynqMPGICRegion struct has been enhanced to be able to catch all this information. Signed-off-by: Luc Michel Reviewed-by: Edgar E. Iglesias --- hw/arm/xlnx-zynqmp.c | 92 ++++++++++++++++++++++++++++++++---- include/hw/arm/xlnx-zynqmp.h | 4 +- 2 files changed, 86 insertions(+), 10 deletions(-) diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index 29df35fb75..42c29b8d06 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -29,12 +29,17 @@ =20 #define ARM_PHYS_TIMER_PPI 30 #define ARM_VIRT_TIMER_PPI 27 +#define ARM_HYP_TIMER_PPI 26 +#define ARM_SEC_TIMER_PPI 29 +#define GIC_MAINTENANCE_PPI 25 =20 #define GEM_REVISION 0x40070106 =20 #define GIC_BASE_ADDR 0xf9000000 #define GIC_DIST_ADDR 0xf9010000 #define GIC_CPU_ADDR 0xf9020000 +#define GIC_VIFACE_ADDR 0xf9040000 +#define GIC_VCPU_ADDR 0xf9060000 =20 #define SATA_INTR 133 #define SATA_ADDR 0xFD0C0000 @@ -111,11 +116,54 @@ static const int adma_ch_intr[XLNX_ZYNQMP_NUM_ADMA_CH= ] =3D { typedef struct XlnxZynqMPGICRegion { int region_index; uint32_t address; + uint32_t offset; + bool virt; } XlnxZynqMPGICRegion; =20 static const XlnxZynqMPGICRegion xlnx_zynqmp_gic_regions[] =3D { - { .region_index =3D 0, .address =3D GIC_DIST_ADDR, }, - { .region_index =3D 1, .address =3D GIC_CPU_ADDR, }, + /* Distributor */ + { + .region_index =3D 0, + .address =3D GIC_DIST_ADDR, + .offset =3D 0, + .virt =3D false + }, + + /* CPU interface */ + { + .region_index =3D 1, + .address =3D GIC_CPU_ADDR, + .offset =3D 0, + .virt =3D false + }, + { + .region_index =3D 1, + .address =3D GIC_CPU_ADDR + 0x10000, + .offset =3D 0x1000, + .virt =3D false + }, + + /* Virtual interface */ + { + .region_index =3D 2, + .address =3D GIC_VIFACE_ADDR, + .offset =3D 0, + .virt =3D true + }, + + /* Virtual CPU interface */ + { + .region_index =3D 3, + .address =3D GIC_VCPU_ADDR, + .offset =3D 0, + .virt =3D true + }, + { + .region_index =3D 3, + .address =3D GIC_VCPU_ADDR + 0x10000, + .offset =3D 0x1000, + .virt =3D true + }, }; =20 static inline int arm_gic_ppi_index(int cpu_nr, int ppi_index) @@ -286,6 +334,9 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error= **errp) qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", GIC_NUM_SPI_INTR + 32= ); qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 2); qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", num_apus); + qdev_prop_set_bit(DEVICE(&s->gic), "has-security-extensions", s->secur= e); + qdev_prop_set_bit(DEVICE(&s->gic), + "has-virtualization-extensions", s->virt); =20 /* Realize APUs before realizing the GIC. KVM requires this. */ for (i =3D 0; i < num_apus; i++) { @@ -330,19 +381,23 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Err= or **errp) for (i =3D 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) { SysBusDevice *gic =3D SYS_BUS_DEVICE(&s->gic); const XlnxZynqMPGICRegion *r =3D &xlnx_zynqmp_gic_regions[i]; - MemoryRegion *mr =3D sysbus_mmio_get_region(gic, r->region_index); + MemoryRegion *mr; uint32_t addr =3D r->address; int j; =20 - sysbus_mmio_map(gic, r->region_index, addr); + if (r->virt && !s->virt) { + continue; + } =20 + mr =3D sysbus_mmio_get_region(gic, r->region_index); for (j =3D 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) { MemoryRegion *alias =3D &s->gic_mr[i][j]; =20 - addr +=3D XLNX_ZYNQMP_GIC_REGION_SIZE; memory_region_init_alias(alias, OBJECT(s), "zynqmp-gic-alias",= mr, - 0, XLNX_ZYNQMP_GIC_REGION_SIZE); + r->offset, XLNX_ZYNQMP_GIC_REGION_SIZ= E); memory_region_add_subregion(system_memory, addr, alias); + + addr +=3D XLNX_ZYNQMP_GIC_REGION_SIZE; } } =20 @@ -352,12 +407,33 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Err= or **errp) sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i, qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]), ARM_CPU_IRQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus, + qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]), + ARM_CPU_FIQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus * 2, + qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]), + ARM_CPU_VIRQ)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus * 3, + qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]), + ARM_CPU_VFIQ)); irq =3D qdev_get_gpio_in(DEVICE(&s->gic), arm_gic_ppi_index(i, ARM_PHYS_TIMER_PPI)); - qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 0, irq); + qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_PHYS, irq); irq =3D qdev_get_gpio_in(DEVICE(&s->gic), arm_gic_ppi_index(i, ARM_VIRT_TIMER_PPI)); - qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 1, irq); + qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_VIRT, irq); + irq =3D qdev_get_gpio_in(DEVICE(&s->gic), + arm_gic_ppi_index(i, ARM_HYP_TIMER_PPI)); + qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_HYP, irq); + irq =3D qdev_get_gpio_in(DEVICE(&s->gic), + arm_gic_ppi_index(i, ARM_SEC_TIMER_PPI)); + qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_SEC, irq); + + if (s->virt) { + irq =3D qdev_get_gpio_in(DEVICE(&s->gic), + arm_gic_ppi_index(i, GIC_MAINTENANCE_PP= I)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus * 4, = irq); + } } =20 if (s->has_rpu) { diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h index 82b6ec2486..98f925ab84 100644 --- a/include/hw/arm/xlnx-zynqmp.h +++ b/include/hw/arm/xlnx-zynqmp.h @@ -53,7 +53,7 @@ #define XLNX_ZYNQMP_OCM_RAM_0_ADDRESS 0xFFFC0000 #define XLNX_ZYNQMP_OCM_RAM_SIZE 0x10000 =20 -#define XLNX_ZYNQMP_GIC_REGIONS 2 +#define XLNX_ZYNQMP_GIC_REGIONS 6 =20 /* ZynqMP maps the ARM GIC regions (GICC, GICD ...) at consecutive 64k off= sets * and under-decodes the 64k region. This mirrors the 4k regions to every = 4k @@ -62,7 +62,7 @@ */ =20 #define XLNX_ZYNQMP_GIC_REGION_SIZE 0x1000 -#define XLNX_ZYNQMP_GIC_ALIASES (0x10000 / XLNX_ZYNQMP_GIC_REGION_SIZE= - 1) +#define XLNX_ZYNQMP_GIC_ALIASES (0x10000 / XLNX_ZYNQMP_GIC_REGION_SIZE) =20 #define XLNX_ZYNQMP_MAX_LOW_RAM_SIZE 0x80000000ull =20 --=20 2.18.0 From nobody Tue Nov 4 21:33:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531589290893215.88089430142315; Sat, 14 Jul 2018 10:28:10 -0700 (PDT) Received: from localhost ([::1]:42131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feOL3-0006T0-Rc for importer@patchew.org; Sat, 14 Jul 2018 13:28:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9z-0005uZ-SM for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feO9y-0004kv-6A for qemu-devel@nongnu.org; Sat, 14 Jul 2018 13:16:43 -0400 Received: from greensocs.com ([193.104.36.180]:57416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feO9r-0004cD-Jh; Sat, 14 Jul 2018 13:16:35 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 14815C7ADD; Sat, 14 Jul 2018 19:16:35 +0200 (CEST) Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kTOvSzRLzl1R; Sat, 14 Jul 2018 19:16:34 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id D20EAC7AF4; Sat, 14 Jul 2018 19:16:33 +0200 (CEST) Received: from localhost.localdomain (unknown [105.98.38.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luc.michel@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 11F6EC7AFC; Sat, 14 Jul 2018 19:16:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588595; bh=esp1nOyziMiRlTKv5G+V138lxt+39GJFnBP+noIkr2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BQZejTEAWduDMNB0UQXCIIPNbnkMBvnn7nURXvJnbzYx00WMpxqxof4bdROd50fF9 y0solfs2UrYsuM9dbYesg8tpRAXH4DSx3e/2LdSJIB1Ttu4oUUZ3BzQDXRAg9guGMl pnOc9yB3yP4JjtJYJveoyvUeNX+GbB5S3ourqsAQ= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=zr720Jp7; dkim=pass (1024-bit key) header.d=greensocs.com header.b=zr720Jp7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588593; bh=esp1nOyziMiRlTKv5G+V138lxt+39GJFnBP+noIkr2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zr720Jp7T2iVeCWfj0au9CDN3AmlzWSzw+Rf5/FfY2GfDZYS4S62tJ3mql1Bk9oCX NTzKc8xhBqoGn708mV2E2+trg4ITOhHXA3tt8DZeNpXXgb/XhRe5o4XdbgOHHhgTfH 4XWcN+esmSzBhE+qM4wEkjXr+xiXOP/Y5hvJNB/o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1531588593; bh=esp1nOyziMiRlTKv5G+V138lxt+39GJFnBP+noIkr2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zr720Jp7T2iVeCWfj0au9CDN3AmlzWSzw+Rf5/FfY2GfDZYS4S62tJ3mql1Bk9oCX NTzKc8xhBqoGn708mV2E2+trg4ITOhHXA3tt8DZeNpXXgb/XhRe5o4XdbgOHHhgTfH 4XWcN+esmSzBhE+qM4wEkjXr+xiXOP/Y5hvJNB/o= From: Luc Michel To: qemu-devel@nongnu.org Date: Sat, 14 Jul 2018 19:16:01 +0200 Message-Id: <20180714171601.5734-21-luc.michel@greensocs.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180714171601.5734-1-luc.michel@greensocs.com> References: <20180714171601.5734-1-luc.michel@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH v4 20/20] arm/virt: Add support for GICv2 virtualization extensions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , mark.burton@greensocs.com, saipava@xilinx.com, edgari@xilinx.com, qemu-arm@nongnu.org, Jan Kiszka , Luc Michel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add support for GICv2 virtualization extensions by mapping the necessary I/O regions and connecting the maintenance IRQ lines. Declare those additions in the device tree and in the ACPI tables. Signed-off-by: Luc Michel Reviewed-by: Peter Maydell --- hw/arm/virt-acpi-build.c | 6 +++-- hw/arm/virt.c | 52 +++++++++++++++++++++++++++++++++------- include/hw/arm/virt.h | 4 +++- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 6ea47e2588..ce31abd62c 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -659,6 +659,8 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) gicc->length =3D sizeof(*gicc); if (vms->gic_version =3D=3D 2) { gicc->base_address =3D cpu_to_le64(memmap[VIRT_GIC_CPU].base); + gicc->gich_base_address =3D cpu_to_le64(memmap[VIRT_GIC_HYP].b= ase); + gicc->gicv_base_address =3D cpu_to_le64(memmap[VIRT_GIC_VCPU].= base); } gicc->cpu_interface_number =3D cpu_to_le32(i); gicc->arm_mpidr =3D cpu_to_le64(armcpu->mp_affinity); @@ -668,8 +670,8 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) if (arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { gicc->performance_interrupt =3D cpu_to_le32(PPI(VIRTUAL_PMU_IR= Q)); } - if (vms->virt && vms->gic_version =3D=3D 3) { - gicc->vgic_interrupt =3D cpu_to_le32(PPI(ARCH_GICV3_MAINT_IRQ)= ); + if (vms->virt) { + gicc->vgic_interrupt =3D cpu_to_le32(PPI(ARCH_GIC_MAINT_IRQ)); } } =20 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 281ddcdf6e..0807be985c 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -131,6 +131,8 @@ static const MemMapEntry a15memmap[] =3D { [VIRT_GIC_DIST] =3D { 0x08000000, 0x00010000 }, [VIRT_GIC_CPU] =3D { 0x08010000, 0x00010000 }, [VIRT_GIC_V2M] =3D { 0x08020000, 0x00001000 }, + [VIRT_GIC_HYP] =3D { 0x08030000, 0x00010000 }, + [VIRT_GIC_VCPU] =3D { 0x08040000, 0x00010000 }, /* The space in between here is reserved for GICv3 CPU/vCPU/HYP */ [VIRT_GIC_ITS] =3D { 0x08080000, 0x00020000 }, /* This redistributor space allows up to 2*64kB*123 CPUs */ @@ -440,18 +442,33 @@ static void fdt_add_gic_node(VirtMachineState *vms) =20 if (vms->virt) { qemu_fdt_setprop_cells(vms->fdt, nodename, "interrupts", - GIC_FDT_IRQ_TYPE_PPI, ARCH_GICV3_MAINT_= IRQ, + GIC_FDT_IRQ_TYPE_PPI, ARCH_GIC_MAINT_IR= Q, GIC_FDT_IRQ_FLAGS_LEVEL_HI); } } else { /* 'cortex-a15-gic' means 'GIC v2' */ qemu_fdt_setprop_string(vms->fdt, nodename, "compatible", "arm,cortex-a15-gic"); - qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg", - 2, vms->memmap[VIRT_GIC_DIST].base, - 2, vms->memmap[VIRT_GIC_DIST].size, - 2, vms->memmap[VIRT_GIC_CPU].base, - 2, vms->memmap[VIRT_GIC_CPU].size); + if (!vms->virt) { + qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg", + 2, vms->memmap[VIRT_GIC_DIST].bas= e, + 2, vms->memmap[VIRT_GIC_DIST].siz= e, + 2, vms->memmap[VIRT_GIC_CPU].base, + 2, vms->memmap[VIRT_GIC_CPU].size= ); + } else { + qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg", + 2, vms->memmap[VIRT_GIC_DIST].bas= e, + 2, vms->memmap[VIRT_GIC_DIST].siz= e, + 2, vms->memmap[VIRT_GIC_CPU].base, + 2, vms->memmap[VIRT_GIC_CPU].size, + 2, vms->memmap[VIRT_GIC_HYP].base, + 2, vms->memmap[VIRT_GIC_HYP].size, + 2, vms->memmap[VIRT_GIC_VCPU].bas= e, + 2, vms->memmap[VIRT_GIC_VCPU].siz= e); + qemu_fdt_setprop_cells(vms->fdt, nodename, "interrupts", + GIC_FDT_IRQ_TYPE_PPI, ARCH_GIC_MAINT_IR= Q, + GIC_FDT_IRQ_FLAGS_LEVEL_HI); + } } =20 qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", vms->gic_phandle); @@ -573,6 +590,11 @@ static void create_gic(VirtMachineState *vms, qemu_irq= *pic) qdev_prop_set_uint32(gicdev, "redist-region-count[1]", MIN(smp_cpus - redist0_count, redist1_capacity)); } + } else { + if (!kvm_irqchip_in_kernel()) { + qdev_prop_set_bit(gicdev, "has-virtualization-extensions", + vms->virt); + } } qdev_init_nofail(gicdev); gicbusdev =3D SYS_BUS_DEVICE(gicdev); @@ -584,6 +606,10 @@ static void create_gic(VirtMachineState *vms, qemu_irq= *pic) } } else { sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_CPU].base); + if (vms->virt) { + sysbus_mmio_map(gicbusdev, 2, vms->memmap[VIRT_GIC_HYP].base); + sysbus_mmio_map(gicbusdev, 3, vms->memmap[VIRT_GIC_VCPU].base); + } } =20 /* Wire the outputs from each CPU's generic timer and the GICv3 @@ -610,9 +636,17 @@ static void create_gic(VirtMachineState *vms, qemu_irq= *pic) ppibase + timer_irq[irq= ])); } =20 - qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt",= 0, - qdev_get_gpio_in(gicdev, ppibase - + ARCH_GICV3_MAINT_IR= Q)); + if (type =3D=3D 3) { + qemu_irq irq =3D qdev_get_gpio_in(gicdev, + ppibase + ARCH_GIC_MAINT_IRQ); + qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interru= pt", + 0, irq); + } else if (vms->virt) { + qemu_irq irq =3D qdev_get_gpio_in(gicdev, + ppibase + ARCH_GIC_MAINT_IRQ); + sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, irq); + } + qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, qdev_get_gpio_in(gicdev, ppibase + VIRTUAL_PMU_IRQ)); diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 9a870ccb6a..4cc57a7ef6 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -42,7 +42,7 @@ #define NUM_VIRTIO_TRANSPORTS 32 #define NUM_SMMU_IRQS 4 =20 -#define ARCH_GICV3_MAINT_IRQ 9 +#define ARCH_GIC_MAINT_IRQ 9 =20 #define ARCH_TIMER_VIRT_IRQ 11 #define ARCH_TIMER_S_EL1_IRQ 13 @@ -60,6 +60,8 @@ enum { VIRT_GIC_DIST, VIRT_GIC_CPU, VIRT_GIC_V2M, + VIRT_GIC_HYP, + VIRT_GIC_VCPU, VIRT_GIC_ITS, VIRT_GIC_REDIST, VIRT_GIC_REDIST2, --=20 2.18.0