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 56BF9606A32C for ; Fri, 4 Dec 2026 08:00:49 +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=O8IlrTXW Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZODh-0003An-Fx; Fri, 04 Dec 2026 03:00:43 -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 1xZODY-00037f-PM for qemu-devel@nongnu.org; Fri, 04 Dec 2026 03:00:33 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xZODU-0004hU-3p for qemu-devel@nongnu.org; Fri, 04 Dec 2026 03:00:32 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-490d59c3f0aso165741f8f.1 for ; Fri, 04 Dec 2026 00:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1796371226; x=1796976026; 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=Tj0QKNCdDqe5hIN0CDVXDWEDl6pgxwnA6mj44J0i2FI=; b=O8IlrTXWHjzOZAHx07uc2+pCNmIk+9VyMRcrjfBs1M5IduCgYjbyrzuZIrkQoNPz9J ca46AMfwfZhKvUwKxTwf17On50mQmy5lRLNzC6QQL465z5okWgH1lGJsmHxnfohEXT3V jYh3ySyutHJ/XqMgWO9q3zKGupWhqHKlzZso9A0YtMXYdNupzgPWjUwWjwdZlGnycFJ9 sS+5gXZI50XFD+V5DJCgJR84Z5MVmYmL2d7fMu8XZEf9Yurq+K4TWbkCgn3AhzzZa9tN ow2tkMCRIgiLmKtSfEG2DQ9GeJsGiIKCL7SZZw3EzsFUZMTbQgosRvE7MeCtV0sgWJR0 +TCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796371226; x=1796976026; 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=Tj0QKNCdDqe5hIN0CDVXDWEDl6pgxwnA6mj44J0i2FI=; b=FXAUGDC7kZRG3bM2mMRy7Oy2zVu6QehMZg5ko7dnsl9H3JrGJaNmkHYEZ6aGlQCW8X 5FqXzoKfjNsUGrI/ekn6hnrS2FJ0gCmO+TvW7OXcns8tY4EDV3HXjO34z2uHkk9vjGaG zKUt99ZuVk3Kl0FGtbT6eRww9P8YeoRdNFwsT+wfsBqRAl3J68UtcKIIgDifa7BciBcB A6fqk/ei1J2XgYeO20hpG2SCXALRgQY0uW9BFAj+mGI+SeHi1yuWU2UQYwOb+a+pQZua jQjfeVuagZXUGIo0eRLAfapJgkis3tUMXTjG89zspxj7MgPa3xzj5DIFbBjv3iCYMeTJ JRBQ== X-Forwarded-Encrypted: i=1; AL+hErE467lfmDgW7JR3VnQUmg/wVA3/k6+SrO3IOUcWEMB+ia9SzkqgR6UMwl79JyRSSPRbxTSoijLAgq7h@nongnu.org X-Gm-Message-State: APuU4Z/+XidbrfLWaJm7myuvD7sFp2+j0TyU7418X8ymXi0nPTVH7gyR 7kebiaqefdgMV/8pekBIifuaAl1BLZKLYDzXD7xOSfRwTZG9YXO8HDl/MXodqUdc8Ek= X-Gm-Gg: AZFdTZe56cUMfyQKQAjVzGR+8z+KgqbWXuyirDzuZKxZwnRuUVpgNX4HZYWhCJFwqY3 xgy1YFGQOE7+ccm22N8WOFPuq6fGXV9YM8XII/0JUHyHxNrW5M/04tNUswbCC+wpg2Z3LETrAtJ B6nMp55O3Uy7RThym57UGGBS+Ig+RkEhX6v/MAUt9xeeFm8j8dBKBHIJtIXlXNHhpGBtnAcCrps XN9fQm7RKAa1VwP4+r0xNMTpw0d5tvWJVb06OPs56cWPPvv9pqeHFk+wQ/MteHkSxB3m1UTkXZm zR7OtDSfZvM4spEfdZxtYk5l4gIAVoJ6rffCu4Xmo9eQft7ZtQ0YVzl7vMOxZ/PaSF0w3SFVp2R 8ZueqsgZgBRncMR4ZgGcVS90dQMd7JouoF61Bzr4L0/HD9h0KVx+IOPywOQW9NPAX/gbO4Wbu+U 36w8iy7QODnZs4mlR142f7oNlddz4DShHes4hWg1EYIvcTjbumCV2QXnrThG7AA9ijf+QwZ1TNI Ht7ZA+mTi3STyU2D7rt4TtaeP7mi+H/2pFkxxkUKlzbdrDPt+x6zYJeMneS6yYUs/j3ws7iixOm X3PSVbylp7CPrzuU3Ek2awMc9cg6PsY2bh3EFe6MB7FuHbYuR12WNYwFz+IICeHxPp55Uk72jcJ hnP4FHuIVQlcV0bDBXbzg1xZ2Mu4M61euJ+eEqC/PmFaU/Xc0ciyONfVasJl+d2DzdmbpIH9BkU 33gkBKU4XXB1HMkBp9qGIN6QrWISLMioGLbmMWjV/7N27/VV6U0q1t7DUKT0UUDekfdtQx X-Received: by 2002:a05:6000:184d:b0:48e:bf0:352 with SMTP id ffacd0b85a97d-4d1e291e269mr2457573f8f.5.1796371226089; Fri, 04 Dec 2026 00:00:26 -0800 (PST) Received: from meli-email.org (athedsl-4431069.home.otenet.gr. [79.129.140.205]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d1723b8b54sm3393777f8f.17.2026.12.04.00.00.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Dec 2026 00:00:25 -0800 (PST) Date: Fri, 04 Dec 2026 09:56:36 +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 42/77] hw/intc/arm_gicv5: Ask CPUs whether IRS needs virtualization support User-Agent: meli/0.9.0 References: <20261203111118.1380524-1-peter.maydell@linaro.org> <20261203111118.1380524-43-peter.maydell@linaro.org> In-Reply-To: <20261203111118.1380524-43-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::429; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wr1-x429.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=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: >The GICv5 IRS must support virtualization if any CPU in the system >has EL2 (by spec rule R_KDSPG). Add a has_virt field to the >GICv5Common struct to track this, and automatically set it if any >connected CPU has EL2. > >We get the CPU to tell us whether it needs virtualization in the >return value of gicv5_set_gicv5state(); this allows us to maintain >the arm's-length relationship between the IRS and the CPU (and in >particular we don't need to include cpu.h in arm_gicv5_common.c, as >we would if we directly called arm_feature() there). > >We could alternatively have provided a has-virtualization QOM >property, but then the board code would need to take care to >explicitly configure the IRS to match the CPUs. Yes, the approach in this patch sounds better than the QOM prop alternative. Reviewed-by: Manos Pitsidianakis > >(The GICv3 doesn't have an equivalent to this, because in the GICv3 >design virtualization is handled entirely by the CPU interface and >software; in GICv5 the IRS has hardware support, to reduce the work >software needs to do.) > >None of the code we are about to add in future commits that tests the >has_virt flag will be accessible until we remove the check in virt.c >that prevents creation of a machine with the GICv5 and an EL2 CPU, so >no behaviour will change until we have completed the entire >virtualization support feature and allow the user to select it. > >Signed-off-by: Peter Maydell >--- > include/hw/intc/arm_gicv5_common.h | 2 ++ > include/hw/intc/arm_gicv5_stream.h | 15 +++++++++++---- > hw/intc/arm_gicv5_common.c | 9 ++++++++- > target/arm/cpu.c | 17 +++++++++++------ > 4 files changed, 32 insertions(+), 11 deletions(-) > >diff --git a/include/hw/intc/arm_gicv5_common.h b/include/hw/intc/arm_gicv5_common.h >index a47f639e84c..d8f6f5d5db9 100644 >--- a/include/hw/intc/arm_gicv5_common.h >+++ b/include/hw/intc/arm_gicv5_common.h >@@ -127,6 +127,8 @@ struct GICv5Common { > uint32_t spi_base; > uint32_t spi_irs_range; > uint32_t spi_range; >+ >+ bool has_virt; > }; > > struct GICv5CommonClass { >diff --git a/include/hw/intc/arm_gicv5_stream.h b/include/hw/intc/arm_gicv5_stream.h >index f6d32c6beca..ea27d6aec0f 100644 >--- a/include/hw/intc/arm_gicv5_stream.h >+++ b/include/hw/intc/arm_gicv5_stream.h >@@ -16,6 +16,12 @@ > > typedef struct GICv5Common GICv5Common; > >+typedef enum GICv5CPUIFStatus { >+ GICV5_CPUIF_MISSING, /* CPU does not have GICv5 cpuif support */ >+ GICV5_CPUIF_PRESENT, /* CPU has GICv5 cpuif */ >+ GICV5_CPUIF_NEEDS_VIRT, /* CPU has GICv5, and needs virt support in IRS */ >+} GICv5CPUIFStatus; >+ > /** > * gicv5_set_gicv5state > * @cpu: CPU object to tell about its IRS >@@ -27,11 +33,12 @@ typedef struct GICv5Common GICv5Common; > * IRS must call this when it is realized, for each CPU it is > * connected to. > * >- * Returns true on success, false if the CPU doesn't implement the >- * GICv5 CPU interface. >+ * The return value indicates whether the CPU has a GICv5 CPU >+ * interface, and if it does whether it needs virtualization support >+ * from the IRS. > */ >-bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, uint32_t iaffid, >- uint32_t cpuidx); >+GICv5CPUIFStatus gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, >+ uint32_t iaffid, uint32_t cpuidx); > > /* > * The architected Stream Protocol is asynchronous; commands can be >diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c >index cfadfee4f05..17fd67b5ccd 100644 >--- a/hw/intc/arm_gicv5_common.c >+++ b/hw/intc/arm_gicv5_common.c >@@ -176,11 +176,18 @@ static void gicv5_common_realize(DeviceState *dev, Error **errp) > } > > for (int i = 0; i < cs->num_cpus; i++) { >- if (!gicv5_set_gicv5state(cs->cpus[i], cs, cs->cpu_iaffids[i], i)) { >+ switch (gicv5_set_gicv5state(cs->cpus[i], cs, cs->cpu_iaffids[i], i)) { >+ case GICV5_CPUIF_MISSING: > error_setg(errp, > "CPU %d (IAFFID 0x%x) does not implement GICv5 CPU interface", > i, cs->cpu_iaffids[i]); > return; >+ case GICV5_CPUIF_PRESENT: >+ break; >+ case GICV5_CPUIF_NEEDS_VIRT: >+ /* R_KDSPG: IRS must implement virtualization if any CPU has EL2 */ >+ cs->has_virt = true; >+ break; > } > } > >diff --git a/target/arm/cpu.c b/target/arm/cpu.c >index dde03ffdd6f..aba81bfcdb0 100644 >--- a/target/arm/cpu.c >+++ b/target/arm/cpu.c >@@ -1215,20 +1215,25 @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) > } > > #ifndef CONFIG_USER_ONLY >-bool gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, uint32_t iaffid, >- uint32_t cpuidx) >+GICv5CPUIFStatus gicv5_set_gicv5state(ARMCPU *cpu, GICv5Common *cs, >+ uint32_t iaffid, uint32_t cpuidx) > { > /* >- * Set this CPU's gicv5state pointer to point to the GIC that we are >- * connected to, and record our IAFFID and CPU index. >+ * Set this CPU's gicv5state pointer to point to the GIC that we >+ * are connected to, record our IAFFID and cpuidx, and let the IRS >+ * know if it needs to implement virtualization support. > */ > if (!cpu_isar_feature(aa64_gcie, cpu)) { >- return false; >+ return GICV5_CPUIF_MISSING; > } > cpu->env.gicv5.gicv5state = cs; > cpu->env.gicv5.iaffid = iaffid; > cpu->env.gicv5.cpuidx = cpuidx; >- return true; >+ if (arm_feature(&cpu->env, ARM_FEATURE_EL2)) { >+ return GICV5_CPUIF_NEEDS_VIRT; >+ } else { >+ return GICV5_CPUIF_PRESENT; >+ } > } > #endif > >-- >2.43.0 >