From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Djordje Todorovic <Djordje.Todorovic@htecgroup.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "qemu-riscv@nongnu.org" <qemu-riscv@nongnu.org>,
"cfu@mips.com" <cfu@mips.com>, "mst@redhat.com" <mst@redhat.com>,
"marcel.apfelbaum@gmail.com" <marcel.apfelbaum@gmail.com>,
"dbarboza@ventanamicro.com" <dbarboza@ventanamicro.com>
Subject: Re: [PATCH v6 01/14] hw/intc: Allow gaps in hartids for aclint and aplic
Date: Fri, 26 Sep 2025 08:14:07 +0200 [thread overview]
Message-ID: <98d7c011-93e2-4c49-aebd-8591b5dc734c@linaro.org> (raw)
In-Reply-To: <0c8036d4-9599-4249-bb20-76e35b970477@htecgroup.com>
On 24/9/25 10:00, Djordje Todorovic wrote:
>
> On 22. 9. 25. 08:52, Philippe Mathieu-Daudé wrote:
>> CAUTION: This email originated from outside of the organization. Do
>> not click links or open attachments unless you recognize the sender
>> and know the content is safe.
>>
>>
>> On 3/9/25 14:35, Djordje Todorovic wrote:
>>>
>>> On 1. 9. 25. 13:05, Philippe Mathieu-Daudé wrote:
>>>> CAUTION: This email originated from outside of the organization. Do
>>>> not click links or open attachments unless you recognize the sender
>>>> and know the content is safe.
>>>>
>>>>
>>>> On 1/9/25 10:17, Djordje Todorovic wrote:
>>>>> On 8. 8. 25. 17:52, Philippe Mathieu-Daudé wrote:
>>>>>
>>>>>> CAUTION: This email originated from outside of the organization. Do
>>>>>> not click links or open attachments unless you recognize the sender
>>>>>> and know the content is safe.
>>>>>>
>>>>>>
>>>>>> On 17/7/25 11:38, Djordje Todorovic wrote:
>>>>>>> This is needed for riscv based CPUs by MIPS since those may have
>>>>>>> sparse hart-ID layouts. ACLINT and APLIC still assume a dense
>>>>>>> range, and if a hart is missing, this causes NULL derefs.
>>>>>>>
>>>>>>> Signed-off-by: Chao-ying Fu <cfu@mips.com>
>>>>>>> Signed-off-by: Djordje Todorovic <djordje.todorovic@htecgroup.com>
>>>>>>> ---
>>>>>>> hw/intc/riscv_aclint.c | 21 +++++++++++++++++++--
>>>>>>> hw/intc/riscv_aplic.c | 11 ++++++++---
>>>>>>> 2 files changed, 27 insertions(+), 5 deletions(-)
>>> + CPU_FOREACH(cpu) {
>>> + if (cpu == NULL)
>>> + abort();
>>
>> Why do you end having a NULL vcpu in the global cpus_queue?
>> (this is the 'elsewhere problem').
>>
> Well, it is true, for our case, we would never get into vcpu == NULL case.
>
>
> After several attempts to come up with a better solution for this, I think
>
> we are back to the existing one. I will try to elaborate why.
>
> The sparse hart-ID layout in this case is not a programming mistake but
>
> an intentional hardware design characteristic of the P8700. The P8700
>
> RISC-V implementation has a sparse hart-ID layout where not all hart IDs
>
> in a range are populated. This is explicitly supported by the RISC-V APLIC
>
> specification. The current ACLINT/APLIC implementation assumes a dense
>
> range of hart IDs (from hartid_base to hartid_base + num_harts - 1).
>
> For the P8700 board:
>
> - We iterate through the theoretical hart ID range for a cluster
>
> - Some hart IDs legitimately don't have corresponding CPUs (sparse
> layout)
>
> - We need to skip these without failing
>
> The CPU_FOREACH approach doesn't work here because:
>
> - The cpu==NULL will never happen
>
> - It iterates over all CPUs system-wide, not just those in the current
>
> cluster
Correct, we simply need to iterate over the CPUs in the cluster, which
IFAICT this device model doesn't use (TYPE_CPU_CLUSTER).
next prev parent reply other threads:[~2025-09-26 6:16 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-17 9:38 [PATCH v6 00/14] riscv: Add support for MIPS P8700 CPU Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 01/14] hw/intc: Allow gaps in hartids for aclint and aplic Djordje Todorovic
2025-08-08 15:52 ` Philippe Mathieu-Daudé
2025-09-01 8:17 ` Djordje Todorovic
2025-09-01 11:05 ` Philippe Mathieu-Daudé
2025-09-03 12:35 ` Djordje Todorovic
2025-09-22 6:52 ` Philippe Mathieu-Daudé
2025-09-24 8:00 ` Djordje Todorovic
2025-09-26 6:14 ` Philippe Mathieu-Daudé [this message]
2025-07-17 9:38 ` [PATCH v6 02/14] target/riscv: Add cpu_set_exception_base Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 04/14] target/riscv: Add MIPS P8700 CSRs Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 03/14] target/riscv: Add MIPS P8700 CPU Djordje Todorovic
2025-08-08 17:02 ` Philippe Mathieu-Daudé
2025-09-01 8:17 ` Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 05/14] target/riscv: Add mips.ccmov instruction Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 06/14] target/riscv: Add mips.pref instruction Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 09/14] hw/misc: Add RISC-V CPC device implementation Djordje Todorovic
2025-08-08 16:21 ` Philippe Mathieu-Daudé
2025-07-17 9:38 ` [PATCH v6 07/14] target/riscv: Add Xmipslsp instructions Djordje Todorovic
2025-08-08 16:02 ` Philippe Mathieu-Daudé
2025-09-01 8:20 ` Djordje Todorovic
2025-09-01 8:30 ` Djordje Todorovic
2025-09-01 11:09 ` Philippe Mathieu-Daudé
2025-07-17 9:38 ` [PATCH v6 08/14] hw/misc: Add RISC-V CMGCR device implementation Djordje Todorovic
2025-08-08 16:00 ` Philippe Mathieu-Daudé
2025-08-08 16:07 ` Philippe Mathieu-Daudé
2025-09-01 8:24 ` Djordje Todorovic
2025-09-01 10:53 ` Philippe Mathieu-Daudé
2025-09-01 8:24 ` Djordje Todorovic
2025-08-08 16:05 ` Philippe Mathieu-Daudé
2025-09-01 8:22 ` Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 10/14] hw/riscv: Add support for RISCV CPS Djordje Todorovic
2025-08-08 16:26 ` Philippe Mathieu-Daudé
2025-09-01 8:30 ` Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 11/14] hw/riscv: Add support for MIPS Boston-aia board mode Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 12/14] hw/pci: Allow explicit function numbers in pci Djordje Todorovic
2025-08-08 16:29 ` Philippe Mathieu-Daudé
2025-09-01 8:31 ` Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 13/14] riscv/boston-aia: Add an e1000e NIC in slot 0 func 1 Djordje Todorovic
2025-07-17 9:38 ` [PATCH v6 14/14] test/functional: Add test for boston-aia board Djordje Todorovic
2025-08-08 16:32 ` Philippe Mathieu-Daudé
2025-09-01 8:35 ` Djordje Todorovic
2025-08-05 10:10 ` [PATCH v6 00/14] riscv: Add support for MIPS P8700 CPU Djordje Todorovic
2025-08-07 18:35 ` Daniel Henrique Barboza
2025-09-01 8:07 ` Djordje Todorovic
2025-08-08 16:42 ` Philippe Mathieu-Daudé
2025-09-01 8:15 ` Djordje Todorovic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=98d7c011-93e2-4c49-aebd-8591b5dc734c@linaro.org \
--to=philmd@linaro.org \
--cc=Djordje.Todorovic@htecgroup.com \
--cc=cfu@mips.com \
--cc=dbarboza@ventanamicro.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).