From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 188A6606A32C for ; Fri, 4 Dec 2026 07:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=cJA3khg5 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZO3P-00070K-5B; Fri, 04 Dec 2026 02:50:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZO3K-0006zs-VQ for qemu-arm@nongnu.org; Fri, 04 Dec 2026 02:50:00 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xZO3I-0006Vt-HJ for qemu-arm@nongnu.org; Fri, 04 Dec 2026 02:49:58 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-4a34ffd3e39so362557f8f.0 for ; Thu, 03 Dec 2026 23:49:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1796370595; x=1796975395; darn=nongnu.org; h=content-type:content-transfer-encoding:mime-version:message-id :in-reply-to:references:user-agent:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to:content-type; bh=/e8fUHa3nb1LEPGphpz39ID8BKkE5JQDYoTJDDJ3sMk=; b=cJA3khg5banwMsojuq5sPftSmPuTDKX6Htyw8A+TCcagwxCF0u/+/MWo0XKQHFEkV1 kHmeAaQLM1ctasQk6n6TaqiYiWzduiJZmindkb6v851yUF8tFYzs323TPl4ozd7YSXYd jz6xcND6qBslbokbjvf2XYhcwkFLk/K3hFJIcvTrTg6/2MLbdgHxy0TYGfkj/OHYkihc dOeOhzx4y1vLavjrEL69puSQ3rT1157T00nq4mp5EHx343l59QEjptw0Sw2+MwM1Lkzu zi/sVRL2u/XO9MER8OOdwrK3M9AzRqMkFD0o4468dCVCzLEC/KZopeWtRnxDzEgTq/cN XTQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796370595; x=1796975395; h=content-type:content-transfer-encoding:mime-version:message-id :in-reply-to:references:user-agent:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=/e8fUHa3nb1LEPGphpz39ID8BKkE5JQDYoTJDDJ3sMk=; b=raJH23c0egbntDwcqVYZs9WJv/5T36ReYE9S153lIa8EaRVnCj3xeBMreHqzPrs7uV HEa0QPwS6az+xI1b83VzT0H6dUrQr1UN1dGE4ZG5XY6E83VK/oOR1R8Ih6CqFCPeIc6s 8hy66WZKwS6bPr19abSQAZyOUONaPYiXURX8vVG4beb4i68eCbdKS7nQHpxuu4HpEW2J QRnjhaqc9DNnqYRFqXPtvfwW7nDf3zNKh77fpBmoG6AIyoB7dcpyvQgaXCSPrngZkQcm 3GvYMUYdMbQIxvnjZy/xW+qJAsXfEvU2ik5D8sDmnCothlCT7ebA8Mg28h7SatLb6T2+ J/ig== X-Forwarded-Encrypted: i=1; AL+hErEzuwvHQxbS9ztEb2mSikDy1Ry1KHkYnN7zXg6fZpmcvn8x4RjU4jweVluvYLAa0cVB3miqTNwiHw==@nongnu.org X-Gm-Message-State: APuU4Z/M+xqxZBkyeKZqkhiNMr/uFdPTGcvGDQwDsNq2E57uCGAzp9Iq lMvF2ZL69xbC4RES/Cqex9QTt4WqmesdXeZYMND4xqLHr23FZcQbmVxaEuB4Sz4G+t4= X-Gm-Gg: AZFdTZd3hIDaKWlrprGRp87qYk/wtnlezmKnil/jccyY3Dg0xl7wsx6VxL2hFR5TKBw aAVeC51PVpEai78KaAusN7vimBs/PLj4OS2JjSP9fycuGL3W4MZuj0sf/XEzATzhGkVlapdnsXN pNdz298pJG3Tuuth7opYIhLN0gqzw/Qsz2HmWqCiH6HC37LjHIVStt+SFsz/o3VYnhaC6spFsfA SEOt0rImHrltG3uMpDfkPgMZGp6aSJecLUwvyR1McRGycxTcfWCAVLLAA5rjx6ldohU9oqwHb3W sydM1KNDZknRMH+OtvXsXNw4/Be4S0SYXHy3WBZsJ+TtPLkVmQPPK6hcgDjtOFT/A5yG5NGSVX+ ITEoufCo4IyMnHosRx+Gp7nel/tDvlHKm4NyuBYvOO4qJu99A/9W3dTsiyDQ/H6Vf0L5zB8YIZX K654g+d58ErBz/2F6Hdsz84BlreaTOXdKEoejEFZ6kBGqada5NcRBBFCCdLPsgYFGaoZGBITLn6 J8Ad8bTiHi6oEIKeE/s6tQ7OpcqRWI0SwLMdb/htJEtAt4cO/xKB5kc4iySVPmjq4eypjK2QC8M szcnZq0kBQ0ySuAzbsRnHj528xf5HVKnKuGQXYYqxu5SfNN/DOJSF5FIXyyxs/NqKDUoh+mUq8B KIznAZh4v5HjqZ/6jXptPCptH+XzCGmEzxNzZVvLLAaIcfMdQtB/mad9lMwfinS5aOthTgMzKge YaT6wAuRAJLkGCIPa7STgtEn2SWAMjVZCHeQ3rqyzqa5xamCr254DOWCP7Kc9AzJ5mI+a6 X-Received: by 2002:a05:600c:4514:b0:4bb:60b1:4409 with SMTP id 5b1f17b1804b1-4bbeb8d1ff0mr19590025e9.19.1796370594764; Thu, 03 Dec 2026 23:49:54 -0800 (PST) Received: from meli-email.org (athedsl-4431069.home.otenet.gr. [79.129.140.205]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d174d08a6fsm3837313f8f.56.2026.12.03.23.49.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Dec 2026 23:49:54 -0800 (PST) Date: Fri, 04 Dec 2026 09:47:56 +0200 From: Manos Pitsidianakis To: Peter Maydell , qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Philippe Mathieu-Daud=?UTF-8?B?w6k=?= , Manos Pitsidianakis Subject: Re: [PATCH v2 22/77] target/arm: GICv5 cpuif: Calculate current virtual PPI HPPI User-Agent: meli/0.9.0 References: <20261203111118.1380524-1-peter.maydell@linaro.org> <20261203111118.1380524-23-peter.maydell@linaro.org> In-Reply-To: <20261203111118.1380524-23-peter.maydell@linaro.org> Message-ID: X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8"; format=flowed Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu, 03 Dec 2026 13:10, Peter Maydell wrote: >Implement gic_recalc_virt_ppi_hppi(), which calculates the current >HPPI PPI for the virtual interrupt domain, using similar logic to >gic_recalc_ppi_hppi(). We call this from everywhere where we update >the state of the virtual PPIs. > >Signed-off-by: Peter Maydell >--- > target/arm/cpu.h | 2 ++ > target/arm/tcg/gicv5-cpuif.c | 51 ++++++++++++++++++++++++++++++++++++ > target/arm/tcg/trace-events | 1 + > 3 files changed, 54 insertions(+) > >diff --git a/target/arm/cpu.h b/target/arm/cpu.h >index 90768300d55..5abfd2c95f7 100644 >--- a/target/arm/cpu.h >+++ b/target/arm/cpu.h >@@ -598,6 +598,8 @@ typedef struct CPUArchState { > > /* Cached highest-priority pending PPI for each domain */ > GICv5PendingIrq ppi_hppi[NUM_GICV5_DOMAINS]; >+ /* And for the virtual interrupt domain */ >+ GICv5PendingIrq virt_ppi_hppi; > > uint64_t ich_apr_el2; > uint64_t ich_vctlr_el2; >diff --git a/target/arm/tcg/gicv5-cpuif.c b/target/arm/tcg/gicv5-cpuif.c >index 63364d9189f..910d72ff65e 100644 >--- a/target/arm/tcg/gicv5-cpuif.c >+++ b/target/arm/tcg/gicv5-cpuif.c >@@ -298,6 +298,45 @@ static void gic_recalc_ppi_hppi(CPUARMState *env) > gicv5_update_irq_fiq(env); > } > >+static void gic_recalc_virt_ppi_hppi(CPUARMState *env) >+{ >+ /* >+ * Recalculate the HPPI PPI for the virtual interrupt domain: this is >+ * the best PPI which is enabled, pending and not active. >+ */ >+ env->gicv5_cpuif.virt_ppi_hppi = GICV5_PENDING_IRQ_NONE; >+ >+ for (int i = 0; i < ARRAY_SIZE(env->gicv5_cpuif.ich_ppi_active); i++) { >+ uint64_t en_pend_nact = env->gicv5_cpuif.ich_ppi_enable[i] & >+ env->gicv5_cpuif.ich_ppi_pend[i] & >+ ~env->gicv5_cpuif.ich_ppi_active[i]; >+ >+ while (en_pend_nact) { >+ uint8_t prio; >+ int ppi; >+ int bit = ctz64(en_pend_nact); >+ >+ en_pend_nact &= ~(1ULL << bit); >+ >+ ppi = i * 64 + bit; >+ prio = extract64(env->gicv5_cpuif.ich_ppi_priority[ppi / 8], >+ (ppi & 7) * 8, 5); >+ >+ if (prio < env->gicv5_cpuif.virt_ppi_hppi.prio) { >+ uint32_t intid = 0; >+ >+ intid = FIELD_DP32(intid, INTID, ID, ppi); >+ intid = FIELD_DP32(intid, INTID, TYPE, GICV5_PPI); >+ env->gicv5_cpuif.virt_ppi_hppi.intid = intid; >+ env->gicv5_cpuif.virt_ppi_hppi.prio = prio; >+ } >+ } >+ } >+ >+ trace_gicv5_recalc_virt_ppi_hppi(env->gicv5_cpuif.virt_ppi_hppi.intid, >+ env->gicv5_cpuif.virt_ppi_hppi.prio); >+} Question: Is this the process described in I_VDZVT or am I looking at the wrong thing? >+ > void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain) > { > /* >@@ -460,6 +499,7 @@ static void gic_ppi_cactive_write(CPUARMState *env, const ARMCPRegInfo *ri, > if (gicv5_icv_access(env)) { > value &= ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; > env->gicv5_cpuif.ich_ppi_active[ri->opc2 & 1] &= ~value; >+ gic_recalc_virt_ppi_hppi(env); > } else { > uint64_t old = raw_read(env, ri); > raw_write(env, ri, old & ~value); >@@ -473,6 +513,7 @@ static void gic_ppi_sactive_write(CPUARMState *env, const ARMCPRegInfo *ri, > if (gicv5_icv_access(env)) { > value &= ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; > env->gicv5_cpuif.ich_ppi_active[ri->opc2 & 1] |= value; >+ gic_recalc_virt_ppi_hppi(env); > } else { > uint64_t old = raw_read(env, ri); > raw_write(env, ri, old | value); >@@ -502,6 +543,7 @@ static void gic_ppi_cpend_write(CPUARMState *env, const ARMCPRegInfo *ri, > if (gicv5_icv_access(env)) { > value &= ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; > env->gicv5_cpuif.ich_ppi_pend[ri->opc2 & 1] &= ~value; >+ gic_recalc_virt_ppi_hppi(env); > } else { > uint64_t old = raw_read(env, ri); > raw_write(env, ri, old & ~value); >@@ -519,6 +561,7 @@ static void gic_ppi_spend_write(CPUARMState *env, const ARMCPRegInfo *ri, > if (gicv5_icv_access(env)) { > value &= ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; > env->gicv5_cpuif.ich_ppi_pend[ri->opc2 & 1] |= value; >+ gic_recalc_virt_ppi_hppi(env); > } else { > uint64_t old = raw_read(env, ri); > raw_write(env, ri, old | value); >@@ -544,6 +587,7 @@ static void gic_ppi_enable_write(CPUARMState *env, const ARMCPRegInfo *ri, > if (gicv5_icv_access(env)) { > value &= ~env->gicv5_cpuif.ich_ppi_hvi[ri->opc2 & 1]; > env->gicv5_cpuif.ich_ppi_enable[ri->opc2 & 1] = value; >+ gic_recalc_virt_ppi_hppi(env); > } else { > raw_write(env, ri, value); > gic_recalc_ppi_hppi(env); >@@ -610,6 +654,7 @@ static void gic_ppi_priority_write(CPUARMState *env, const ARMCPRegInfo *ri, > uint64_t hvi_mask = gic_ppi_prio_hvi_mask(env, idx); > > env->gicv5_cpuif.ich_ppi_priority[idx] = value & ~hvi_mask; >+ gic_recalc_virt_ppi_hppi(env); > } else { > raw_write(env, ri, value); > gic_recalc_ppi_hppi(env); >@@ -620,36 +665,42 @@ static void gic_ich_ppi_enable_write(CPUARMState *env, const ARMCPRegInfo *ri, > uint64_t value) > { > raw_write(env, ri, value); >+ gic_recalc_virt_ppi_hppi(env); > } > > static void gic_ich_ppi_pend_write(CPUARMState *env, const ARMCPRegInfo *ri, > uint64_t value) > { > raw_write(env, ri, value); >+ gic_recalc_virt_ppi_hppi(env); > } > > static void gic_ich_ppi_active_write(CPUARMState *env, const ARMCPRegInfo *ri, > uint64_t value) > { > raw_write(env, ri, value); >+ gic_recalc_virt_ppi_hppi(env); > } > > static void gic_ich_ppi_priority_write(CPUARMState *env, const ARMCPRegInfo *ri, > uint64_t value) > { > raw_write(env, ri, value); >+ gic_recalc_virt_ppi_hppi(env); > } > > static void gic_ich_ppi_dvi_write(CPUARMState *env, const ARMCPRegInfo *ri, > uint64_t value) > { > raw_write(env, ri, value); >+ gic_recalc_virt_ppi_hppi(env); > } > > static void gic_ich_ppi_hvi_write(CPUARMState *env, const ARMCPRegInfo *ri, > uint64_t value) > { > raw_write(env, ri, value); >+ gic_recalc_virt_ppi_hppi(env); > } > > static void gic_ich_vctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, >diff --git a/target/arm/tcg/trace-events b/target/arm/tcg/trace-events >index bf1803c8722..da25ec994cc 100644 >--- a/target/arm/tcg/trace-events >+++ b/target/arm/tcg/trace-events >@@ -3,6 +3,7 @@ > > # gicv5-cpuif.c > gicv5_recalc_ppi_hppi(int domain, uint32_t id, uint8_t prio) "domain %d new PPI HPPI id 0x%x prio %u" >+gicv5_recalc_virt_ppi_hppi(uint32_t id, uint8_t prio) "virtual domain new PPI HPPI id 0x%x prio %u" > gicv5_gicr_cdia_fail(int domain, const char *reason) "domain %d CDIA attempt failed: %s" > gicv5_gicr_cdia(int domain, uint32_t id) "domain %d CDIA acknowledge of interrupt 0x%x" > gicv5_cdeoi(int domain) "domain %d CDEOI performing priority drop" >-- >2.43.0 >