From nobody Tue Feb 10 06:43:27 2026 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 1530279853326372.8526676768673; Fri, 29 Jun 2018 06:44:13 -0700 (PDT) Received: from localhost ([::1]:42225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYth4-00025s-Js for importer@patchew.org; Fri, 29 Jun 2018 09:44:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYtUH-0007he-EA for qemu-devel@nongnu.org; Fri, 29 Jun 2018 09:31:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYtUC-0007HG-8w for qemu-devel@nongnu.org; Fri, 29 Jun 2018 09:30:57 -0400 Received: from greensocs.com ([193.104.36.180]:58615) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYtU2-0006mW-BL; Fri, 29 Jun 2018 09:30:42 -0400 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 2FA854434B4; Fri, 29 Jun 2018 15:30:38 +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 2SfvjpbkcP5g; Fri, 29 Jun 2018 15:30:37 +0200 (CEST) Received: by greensocs.com (Postfix, from userid 998) id 3C16E4434B6; Fri, 29 Jun 2018 15:30:37 +0200 (CEST) Received: from michell-laptop.hive.antfield.fr (LFbn-LYO-1-488-36.w2-7.abo.wanadoo.fr [2.7.77.36]) (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 768594434AB; Fri, 29 Jun 2018 15:30:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1530279038; bh=MIz3Xya7Bfs70SeBav01e9oe2TZ/yq+G0OAvywSvOto=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ncxUPI8/UwmEDDiC9vU9sxQXHXE8/0xk3DJO6X69HM4S4Jwy8cymo4IRabCUYZ57a GYkK54nBrZMxDCf1Z0bkQKJfnwbwovSUwL89E6MtBT+ZV1q3ZcZQ/zCFLPY5+YckVY 6VqZeca2tXHkd06Cc67aOpvRt0MNWT70GvLxHIdw= 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=dQDCi1cK; dkim=pass (1024-bit key) header.d=greensocs.com header.b=vO1QPaZR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1530279037; bh=MIz3Xya7Bfs70SeBav01e9oe2TZ/yq+G0OAvywSvOto=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dQDCi1cKCo4pZ10+VbS9/xberr0FCBO4HtmgNAyGJNI8P7EKU8zJoDVY8c8a6lIeG Am7UK6SvbBfipbNkpwfupz8/IjEaye//WOMsnDx4OqKKaQy3S0yY0UBfV4/gLIzYbM wyCIINALKij6Jshse197hhF9t56HanjzAHS0rlWE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1530279036; bh=MIz3Xya7Bfs70SeBav01e9oe2TZ/yq+G0OAvywSvOto=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vO1QPaZRpwoihA7xC09UPu5FvEhEBk9LzD4kwxH7TthFaFG7Osn4okoPiZ9Ik7nTw qi/btPUYz/nWwDgclzyT5J5szVu0IiJszrL3wXLg189ZWJ/H2vbhjy2pei0eKaO74D 4gwbUc63bR8pbc5sBPFqewLWFbFMqSx/RWbptaxo= From: Luc Michel To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2018 15:29:44 +0200 Message-Id: <20180629132954.24269-11-luc.michel@greensocs.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629132954.24269-1-luc.michel@greensocs.com> References: <20180629132954.24269-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 v3 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 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 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 --- hw/intc/arm_gic.c | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index d55a88bb33..d61c2dd557 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,12 +303,22 @@ static int gic_get_prio_from_apr_bits(GICState *s, in= t cpu) * on the set bits in the Active Priority Registers. */ int i; - for (i =3D 0; i < GIC_NR_APRS; i++) { - uint32_t apr =3D s->apr[i][cpu] | s->nsapr[i][cpu]; + int min_bpr =3D gic_is_vcpu(cpu) ? GIC_VIRT_MIN_BPR : GIC_MIN_BPR; + int nr_aprs =3D gic_is_vcpu(cpu) ? GIC_VIRT_NR_APRS : GIC_NR_APRS; + + for (i =3D 0; i < nr_aprs; i++) { + uint32_t apr; + + if (gic_is_vcpu(cpu)) { + apr =3D s->h_apr[gic_get_vcpu_real_id(cpu)]; + } else { + apr =3D s->apr[i][cpu] | s->nsapr[i][cpu]; + } + if (!apr) { continue; } - return (i * 32 + ctz32(apr)) << (GIC_MIN_BPR + 1); + return (i * 32 + ctz32(apr)) << (min_bpr + 1); } return 0x100; } @@ -325,9 +342,19 @@ static void gic_drop_prio(GICState *s, int cpu, int gr= oup) * might not do so, and interrupts that should not preempt might do so. */ int i; + int nr_aprs =3D gic_is_vcpu(cpu) ? GIC_VIRT_NR_APRS : GIC_NR_APRS; + + for (i =3D 0; i < nr_aprs; i++) { + uint32_t *papr =3D NULL; + + if (gic_is_vcpu(cpu)) { + papr =3D &s->h_apr[gic_get_vcpu_real_id(cpu)]; + } else if (group) { + papr =3D &s->nsapr[i][cpu]; + } else { + papr =3D &s->apr[i][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; } --=20 2.17.1