RISC-V: ACPI: Add PPTT support
v2 cover RISC-V: ACPI: Add PPTT support
Hi all,
This series adds ACPI Processor Properties Topology Table (PPTT) support to the RISC-V virt machine. PPTT allows the guest to discover the processor and cache topology exposed by the machine, which is useful for making better scheduling and cache-management decisions.
The implementation describes the RISC-V virt cache hierarchy with separate L1 instruction and data caches, followed by unified L2 and L3 caches. It also enables the corresponding cache and cluster properties in the machine SMP description and wires the generated PPTT into the existing ACPI table build.
Unlike ARM, RISC-V doesn't have a way to discover the Cache topology from registers. Hence, I am hardcoding default values for the cache topology structures. These cache topology structures are added in virt.c itself so that a future series can add support for DT as well. In future, it can be enhanced to support vendor cpu/soc specific cache information to override this default hardcoded cache details.
The series also updates the bios-tables-test data and removes the temporary PPTT entry from the allowed-diff list. The generated table is 96 bytes and describes the package, cluster, and processor hierarchy for the virt machine.
This work follows the discussion and earlier work shared here:
https://lists.gnu.org/archive/html/qemu-riscv/2024-01/msg00928.html
I have retained the contribution from Sia Jee Heng and added his Signed-off-by tag to the relevant patch.
To enable cache structures in the PPTT, one should use similar to below command line option.
-M virt,smp-cache.0.cache=l1d,smp-cache.0.topology=core,smp-cache.1.cache=l1i,smp-cache.1.topology=core,smp-cache.2.cache=l2,smp-cache.2.topology=cluster,smp-cache.3.cache=l3,smp-cache.3.topology=socket
lscpu -C in linux can be used to display these cache structures.
Changes from v1:
1) Replaced loop with memcpy
2) Made virt_caches static in virt.c
3) Added Daniel's RB tags
Sunil V L (4):
Sunil V L (4):
tests/qtest/bios-tables-test: Allow PPTT for RISC-V hw/riscv/virt: Add ACPI PPTT table tests/qtest/bios-tables-test: Update riscv64 virt PPTT golden
reference
MAINTAINERS: Update Sunil's email id
MAINTAINERS | 2 +- hw/riscv/virt-acpi-build.c | 7 ++++ hw/riscv/virt.c | 51 ++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 4 +++ tests/data/acpi/riscv64/virt/PPTT | Bin 0 -> 96 bytes 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 tests/data/acpi/riscv64/virt/PPTT
Signature · 1 line
2.43.0
PATCH v2 1/4 tests/qtest/bios-tables-test: Allow PPTT for RISC-V
Allow changes to the riscv64 virt board to add PPTT support.
--- tests/data/acpi/riscv64/virt/PPTT | 0 tests/qtest/bios-tables-test-allowed-diff.h | 1 + 2 files changed, 1 insertion(+) create mode 100644 tests/data/acpi/riscv64/virt/PPTT
tests/data/acpi/riscv64/virt/PPTT new file +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
@@ -1 +1,2 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/riscv64/virt/PPTT",
Signature · 1 line
2.43.0
PATCH v2 2/4 hw/riscv/virt: Add ACPI PPTT table
In reply to Sunil V LGenerate the Processor Properties Topology Table (PPTT) for the RISC-V virt machine.
Describe the machine using separate L1 data and instruction caches plus unified L2 and L3 caches, and enable the corresponding cache and cluster SMP properties.
--- hw/riscv/virt-acpi-build.c | 7 ++++++ hw/riscv/virt.c | 51 ++++++++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 4 +++ 3 files changed, 62 insertions(+)
hw/riscv/virt-acpi-build.c +7 -0
@@ -882,7 +882,10 @@ static void virt_acpi_build(RISCVVirtState *s, AcpiBuildTables *tables)unsigned dsdt, xsdt;GArray *tables_blob = tables->table_data;MachineState *ms =MACHINE (s); +CPUCoreCaches caches[CPU_MAX_CACHES ]; +unsigned int num_caches; + num_caches =virt_get_caches (caches); table_offsets =g_array_new (false, true,sizeof (uint32_t ));
@@ -909,6 +912,10 @@ static void virt_acpi_build(RISCVVirtState *s, AcpiBuildTables *tables)build_rimt (tables_blob, tables->linker, s); } +acpi_add_table (table_offsets, tables_blob); +build_pptt (tables_blob, tables->linker, ms, s->oem_id, + s->oem_table_id, num_caches, caches); +acpi_add_table (table_offsets, tables_blob);if (ms->acpi_spcr_enabled) {
hw/riscv/virt.c +51 -0
69 lines not on this page · raw message
include/hw/riscv/virt.h +4 -0
@@ -121,10 +121,14 @@ enum {#define VIRT_PLIC_SIZE (__num_context) \ (VIRT_PLIC_CONTEXT_BASE + (__num_context) * VIRT_PLIC_CONTEXT_STRIDE) +#define CPU_MAX_CACHES 16 +bool virt_is_acpi_enabled (RISCVVirtState *s);bool virt_is_iommu_sys_enabled (RISCVVirtState *s);void virt_acpi_setup (RISCVVirtState *vms); +unsigned int virt_get_caches (CPUCoreCaches *caches); +/* * The virt machine physical address space used by some of the devices * namely ACLINT, PLIC, APLIC, and IMSIC depend on number of Sockets,
Signature · 1 line
2.43.0
Re: [PATCH v2 2/4] hw/riscv/virt: Add ACPI PPTT table
Quoted 10 lines · Sunil V L
Generate the Processor Properties Topology Table (PPTT) for the RISC-V virt machine.
Describe the machine using separate L1 data and instruction caches plus unified L2 and L3 caches, and enable the corresponding cache and cluster SMP properties.
Signed-off-by Sunil V L <[email protected]>Signed-off-by Sia Jee Heng <[email protected]>---
Quoted 126 lines
hw/riscv/virt-acpi-build.c | 7 ++++++ hw/riscv/virt.c | 51 ++++++++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 4 +++ 3 files changed, 62 insertions(+)hw/riscv/virt-acpi-build.c +7
-0@@ -882,7 +882,10 @@ static void virt_acpi_build(RISCVVirtState *s, AcpiBuildTables *tables)unsigned dsdt, xsdt;GArray *tables_blob = tables->table_data;MachineState *ms =MACHINE (s); +CPUCoreCaches caches[CPU_MAX_CACHES ]; +unsigned int num_caches; + num_caches =virt_get_caches (caches); table_offsets =g_array_new (false, true,sizeof (uint32_t ));@@ -909,6 +912,10 @@ static void virt_acpi_build(RISCVVirtState *s, AcpiBuildTables *tables)build_rimt (tables_blob, tables->linker, s); } +acpi_add_table (table_offsets, tables_blob); +build_pptt (tables_blob, tables->linker, ms, s->oem_id, + s->oem_table_id, num_caches, caches); +acpi_add_table (table_offsets, tables_blob);if (ms->acpi_spcr_enabled) {hw/riscv/virt.c +51
-0@@ -109,6 +109,45 @@ static const MemMapEntry virt_memmap[] = { [VIRT_DRAM] = { 0x80000000, 0x0 }, }; +static CPUCoreCaches virt_caches[] = { + { + .type =DATA_CACHE , + .sets =256 , + .size =64 * KiB, + .level =1 , + .linesize =64 , + .attributes =0x0 , + .associativity =4 , + }, + { + .type =INSTRUCTION_CACHE , + .sets =256 , + .size =64 * KiB, + .level =1 , + .linesize =64 , + .attributes =0x0 , + .associativity =4 , + }, + { + .type =UNIFIED_CACHE , + .sets =4096 , + .size =2048 * KiB, + .level =2 , + .linesize =64 , + .attributes =0x0 , + .associativity =8 , + }, + { + .type =UNIFIED_CACHE , + .sets =8192 , + .size =4096 * KiB, + .level =3 , + .linesize =64 , + .attributes =0x0 , + .associativity =8 , + }, +}; +/* PCIe high mmio is fixed for RV32 */ #define VIRT32_HIGH_PCIE_MMIO_BASE 0x300000000ULL#define VIRT32_HIGH_PCIE_MMIO_SIZE (4 * GiB)@@ -140,6 +179,12 @@ static void virt_flash_map(RISCVVirtState *s, sysmem, VIRT_FLASH_SECTOR_SIZE); } +unsigned int virt_get_caches (CPUCoreCaches *caches) +{ +memcpy (caches, virt_caches,sizeof (virt_caches)); +return ARRAY_SIZE (virt_caches); +} + static void create_fdt_socket_plic(RISCVVirtState *s, int socket, uint32_t *phandle, uint32_t *intc_phandles,@@ -1144,6 +1189,12 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data) mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props; mc->get_default_cpu_node_id = riscv_numa_get_default_cpu_node_id; mc->numa_mem_supported = true; + mc->smp_props.clusters_supported = true; + mc->smp_props.cache_supported[CACHE_LEVEL_AND_TYPE_L1D ] = true; + mc->smp_props.cache_supported[CACHE_LEVEL_AND_TYPE_L1I ] = true; + mc->smp_props.cache_supported[CACHE_LEVEL_AND_TYPE_L2 ] = true; + mc->smp_props.cache_supported[CACHE_LEVEL_AND_TYPE_L3 ] = true; +/* platform instead of architectural choice */ mc->cpu_cluster_has_numa_boundary = true; mc->default_ram_id ="riscv_virt_board.ram" ;include/hw/riscv/virt.h +4
-0@@ -121,10 +121,14 @@ enum {#define VIRT_PLIC_SIZE (__num_context) \ (VIRT_PLIC_CONTEXT_BASE + (__num_context) * VIRT_PLIC_CONTEXT_STRIDE) +#define CPU_MAX_CACHES 16 +bool virt_is_acpi_enabled (RISCVVirtState *s);bool virt_is_iommu_sys_enabled (RISCVVirtState *s);void virt_acpi_setup (RISCVVirtState *vms); +unsigned int virt_get_caches (CPUCoreCaches *caches); +/* * The virt machine physical address space used by some of the devices * namely ACLINT, PLIC, APLIC, and IMSIC depend on number of Sockets,
Re: [PATCH v2 2/4] hw/riscv/virt: Add ACPI PPTT table
In reply to Sunil V LQuoted 14 lines · Sunil V L
Generate the Processor Properties Topology Table (PPTT) for the RISC-V virt machine.
Describe the machine using separate L1 data and instruction caches plus unified L2 and L3 caches, and enable the corresponding cache and cluster SMP properties.
Signed-off-by Sunil V L <[email protected]>Signed-off-by Sia Jee Heng <[email protected]>--- hw/riscv/virt-acpi-build.c | 7 ++++++ hw/riscv/virt.c | 51 ++++++++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 4 +++ 3 files changed, 62 insertions(+)
[..]
Quoted 9 lines
include/hw/riscv/virt.h +1
-0@@ -121,10 +121,14 @@ enum {#define VIRT_PLIC_SIZE (__num_context) \ (VIRT_PLIC_CONTEXT_BASE + (__num_context) * VIRT_PLIC_CONTEXT_STRIDE) +#define CPU_MAX_CACHES 16
include/hw/riscv/virt.h enum { · line 134
Quoted 10 lines
include/hw/riscv/virt.h +3
-0+bool virt_is_acpi_enabled (RISCVVirtState *s);bool virt_is_iommu_sys_enabled (RISCVVirtState *s);void virt_acpi_setup (RISCVVirtState *vms); +unsigned int virt_get_caches (CPUCoreCaches *caches); +/* * The virt machine physical address space used by some of the devices * namely ACLINT, PLIC, APLIC, and IMSIC depend on number of Sockets,
This hunk no longer applies on riscv-to-apply.next. Do you plan to post a v3? My RQSC series [1] depends on this series.
Thanks,
Drew
PATCH v2 3/4 tests/qtest/bios-tables-test: Update riscv64 virt PPTT golden reference
In reply to Sunil V LUpdate the RISC-V PPTT reference to match the actual PPTT generated by QEMU.
Diffs from iasl:
+/*
+ * Intel ACPI Component Architecture
+ * AML/ASL+ Disassembler version 20230628 (64-bit version)
+ * Copyright (c) 2000 - 2023 Intel Corporation
+ *
+ * Disassembly of /tmp/aml-DN3NW3, Sun Oct 11 23:01:04 2026
+ *
+ * ACPI Data Table [PPTT]
+ *
+ * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue (in hex)
+ */
+
+[000h 0000 004h] Signature : "PPTT" [Processor Properties Topology Table]
+[004h 0004 004h] Table Length : 00000060
+[008h 0008 001h] Revision : 02
+[009h 0009 001h] Checksum : 27
+[00Ah 0010 006h] Oem ID : "BOCHS "
+[010h 0016 008h] Oem Table ID : "BXPC "
+[018h 0024 004h] Oem Revision : 00000001
+[01Ch 0028 004h] Asl Compiler ID : "BXPC"
+[020h 0032 004h] Asl Compiler Revision : 00000001
+
+
+[024h 0036 001h] Subtable Type : 00 [Processor Hierarchy Node]
+[025h 0037 001h] Length : 14
+[026h 0038 002h] Reserved : 0000
+[028h 0040 004h] Flags (decoded below) : 00000011
+ Physical package : 1
+ ACPI Processor ID valid : 0
+ Processor is a thread : 0
+ Node is a leaf : 0
+ Identical Implementation : 1
+[02Ch 0044 004h] Parent : 00000000
+[030h 0048 004h] ACPI Processor ID : 00000000
+[034h 0052 004h] Private Resource Number : 00000000
+
+[038h 0056 001h] Subtable Type : 00 [Processor Hierarchy Node]
+[039h 0057 001h] Length : 14
+[03Ah 0058 002h] Reserved : 0000
+[03Ch 0060 004h] Flags (decoded below) : 00000011
+ Physical package : 1
+ ACPI Processor ID valid : 0
+ Processor is a thread : 0
+ Node is a leaf : 0
+ Identical Implementation : 1
+[040h 0064 004h] Parent : 00000024
+[044h 0068 004h] ACPI Processor ID : 00000000
+[048h 0072 004h] Private Resource Number : 00000000
+
+[04Ch 0076 001h] Subtable Type : 00 [Processor Hierarchy Node]
+[04Dh 0077 001h] Length : 14
+[04Eh 0078 002h] Reserved : 0000
+[050h 0080 004h] Flags (decoded below) : 0000000A
+ Physical package : 0
+ ACPI Processor ID valid : 1
+ Processor is a thread : 0
+ Node is a leaf : 1
+ Identical Implementation : 0
+[054h 0084 004h] Parent : 00000038
+[058h 0088 004h] ACPI Processor ID : 00000000
+[05Ch 0092 004h] Private Resource Number : 00000000
+
+Raw Table Data: Length 96 (0x60)
+
+ 0000: 50 50 54 54 60 00 00 00 02 27 42 4F 43 48 53 20 // PPTT`....'BOCHS + 0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC + 0020: 01 00 00 00 00 14 00 00 11 00 00 00 00 00 00 00 // ................ + 0030: 00 00 00 00 00 00 00 00 00 14 00 00 11 00 00 00 // ................ + 0040: 24 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 // $............... + 0050: 0A 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 // ....8...........
--- tests/data/acpi/riscv64/virt/PPTT | Bin 0 -> 96 bytes tests/qtest/bios-tables-test-allowed-diff.h | 1 - 2 files changed, 1 deletion(-)
tests/data/acpi/riscv64/virt/PPTT binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
@@ -1,2 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/riscv64/virt/PPTT",
Signature · 1 line
2.43.0
PATCH v2 4/4 MAINTAINERS: Update Sunil's email id
In reply to Sunil V LUpdate my email ID to qualcomm.
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -2335,7 +2335,7 @@ S: Orphan F: hw/arm/virt-acpi-build.c RISC-V ACPI Subsystem -M: Sunil V L <[email protected]> +M: Sunil V L <[email protected]> L: [email protected] S: Maintained F: hw/riscv/virt-acpi-build.c
Signature · 1 line
2.43.0
Quoted 6 lines · Sunil V L
Hi all,
This series adds ACPI Processor Properties Topology Table (PPTT) support to the RISC-V virt machine. PPTT allows the guest to discover the processor and cache topology exposed by the machine, which is useful for making better scheduling and cache-management decisions.
Thanks for picking up PPTT support. I can now rebase the RQSC support
[1] on this series.
However, RQSC actually needs PPTT revision 3, because it adds cache IDs to the PPTT. The RQSC table references a capacity controller's cache by the PPTT cache ID. In Linux, find_acpi_cache_level_from_id() and acpi_pptt_get_cpumask_from_cache_id() return -ENOENT if PPTT rev < 3.
There is a new MPAM series by Jinjie Ruan which contains the patch "[PATCH 04/37] hw/acpi: Build PPTT rev 3 with cache IDs for MPAM cross-references" [2]. It bumps build_pptt() to revision 3 and gives every cache node an ID.
I could just base the RQSC series on this PPTT series and that patch 03/37. But maybe there is a better way to coordinate adding PPTT v3?
Thanks,
Drew
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Hi Drew!
Quoted 16 lines · Drew Fustini
Quoted 6 lines · Sunil V L
Hi all,
This series adds ACPI Processor Properties Topology Table (PPTT) support to the RISC-V virt machine. PPTT allows the guest to discover the processor and cache topology exposed by the machine, which is useful for making better scheduling and cache-management decisions.
Thanks for picking up PPTT support. I can now rebase the RQSC support
[1] on this series.However, RQSC actually needs PPTT revision 3, because it adds cache IDs to the PPTT. The RQSC table references a capacity controller's cache by the PPTT cache ID. In Linux,
find_acpi_cache_level_from_id()andacpi_pptt_get_cpumask_from_cache_id()return-ENOENTif PPTT rev < 3.
Quoted 7 lines
There is a new MPAM series by Jinjie Ruan which contains the patch "[PATCH 04/37] hw/acpi: Build PPTT rev 3 with cache IDs for MPAM cross-references" [2]. It bumps
build_pptt()to revision 3 and gives every cache node an ID.I could just base the RQSC series on this PPTT series and that patch 03/37. But maybe there is a better way to coordinate adding PPTT v3?
This PPTT support is acked and I believe we'll queue it in riscv-to-apply.next shortly.
As for the PPTT rev3 patch in the "Add Arm MPAM emulation", my suggestion is to put that on top of your series (i.e. your series will contain that patch). That ARM series has 37 patches and might take awhile to go through, and your work relies only on patch 04 ... which happens to be an arch agnostic patch. I believe it's fine for us to push it via the riscv queue.
I see that the author from the ARM series is CCed here. Jinjie Ruan, are you okay with us pushing your patch via the RISC-V tree? It'll unblock Drew's work and you'll have one less patch to worry about in your ARM MPAM work.
Thanks,
Daniel
Quoted 6 lines
Thanks,
Drew[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Quoted 43 lines · Daniel Henrique Barboza
Hi Drew!
Quoted 18 lines · Drew Fustini
Quoted 8 lines · Sunil V L
Hi all,
This series adds ACPI Processor Properties Topology Table (PPTT) support to
the RISC-V virt machine. PPTT allows the guest to discover the processor and
cache topology exposed by the machine, which is useful for making better scheduling and cache-management decisions.Thanks for picking up PPTT support. I can now rebase the RQSC support
[1] on this series.However, RQSC actually needs PPTT revision 3, because it adds cache IDs to the PPTT. The RQSC table references a capacity controller's cache by the PPTT cache ID. In Linux,
find_acpi_cache_level_from_id()andacpi_pptt_get_cpumask_from_cache_id()return-ENOENTif PPTT rev < 3.Quoted 7 lines
There is a new MPAM series by Jinjie Ruan which contains the patch "[PATCH 04/37] hw/acpi: Build PPTT rev 3 with cache IDs for MPAM cross-references" [2]. It bumps
build_pptt()to revision 3 and gives every cache node an ID.I could just base the RQSC series on this PPTT series and that patch 03/37. But maybe there is a better way to coordinate adding PPTT v3?
This PPTT support is acked and I believe we'll queue it in riscv-to- apply.next
shortly.As for the PPTT rev3 patch in the "Add Arm MPAM emulation", my suggestion is
to put that on top of your series (i.e. your series will contain that patch).
That ARM series has 37 patches and might take awhile to go through, and your
work relies only on patch 04 ... which happens to be an arch agnostic patch.
I believe it's fine for us to push it via the riscv queue.
Quoted 5 lines
I see that the author from the ARM series is CCed here. Jinjie Ruan, are you
okay with us pushing your patch via the RISC-V tree? It'll unblock Drew's work
and you'll have one less patch to worry about in your ARM MPAM work.
Hi Daniel,
I'm fine to do so.
Quoted 18 lines
Thanks,
DanielQuoted 8 lines
Thanks,
Drew[1] https://lore.kernel.org/all/20260202-riscv-rqsc-v1-0-
[email protected]/
[2] https://lore.kernel.org/all/
[email protected]/
Signature · 2 lines
Best regards, Jinjie
Quoted 19 lines · Sunil V L
Hi all,
This series adds ACPI Processor Properties Topology Table (PPTT) support to
the RISC-V virt machine. PPTT allows the guest to discover the processor and
cache topology exposed by the machine, which is useful for making better
scheduling and cache-management decisions.The implementation describes the RISC-V virt cache hierarchy with separate
L1 instruction and data caches, followed by unified L2 and L3 caches. It also
enables the corresponding cache and cluster properties in the machine SMP
description and wires the generated PPTT into the existing ACPI table build.
Quoted 9 lines
Unlike ARM, RISC-V doesn't have a way to discover the Cache topology from registers. Hence, I am hardcoding default values for the
cache topology structures. These cache topology structures are added invirt.citself so that a future series can add support for DT as well. In
future, it can be enhanced to support vendor cpu/soc specific cache information to override this default hardcoded cache details.
Why not add a vendor cpu/soc specific one to a vendor board? That way it actually model hardware instead of just providing the guest some made up information.
I feel like you should describe why we want this somewhere in the series
Quoted 14 lines
The series also updates the bios-tables-test data and removes the temporary
PPTT entry from the allowed-diff list. The generated table is 96 bytes and
describes the package, cluster, and processor hierarchy for the virt machine.This work follows the discussion and earlier work shared here:
https://lists.gnu.org/archive/html/qemu-riscv/2024-01/msg00928.htmlI have retained the contribution from Sia Jee Heng and added his Signed-off-by tag to the relevant patch.
Quoted 8 lines
To enable cache structures in the PPTT, one should use similar to below
command line option.-M virt,smp-cache.0.cache=l1d,smp-cache.0.topology=core,smp- cache.1.cache=l1i,smp-cache.1.topology=core,smp-cache.2.cache=l2,smp- cache.2.topology=cluster,smp-cache.3.cache=l3,smp- cache.3.topology=socket
Obviously :P
Let's at least add this to the virt machine docs so it's useful for someone.
Alistair
Quoted 25 lines
lscpu -C in linux can be used to display these cache structures.
Changes from v1:
1) Replaced loop with memcpy
2) Madevirt_cachesstatic invirt.c
3) Added Daniel's RB tagsSunil V L (4):
Sunil V L (4):
tests/qtest/bios-tables-test: Allow PPTT for RISC-V hw/riscv/virt: Add ACPI PPTT table tests/qtest/bios-tables-test: Update riscv64 virt PPTT golden reference
MAINTAINERS: Update Sunil's email idMAINTAINERS | 2 +- hw/riscv/virt-acpi-build.c | 7 ++++ hw/riscv/virt.c | 51
++++++++++++++++++++++++++++++
include/hw/riscv/virt.h | 4 +++ tests/data/acpi/riscv64/virt/PPTT | Bin 0 -> 96 bytes5 files changed, 63 insertions(+), 1 deletion(-)create mode 100644 tests/data/acpi/riscv64/virt/PPTT
Quoted 31 lines · Alistair Francis
Quoted 19 lines · Sunil V L
Hi all,
This series adds ACPI Processor Properties Topology Table (PPTT) support to
the RISC-V virt machine. PPTT allows the guest to discover the processor and
cache topology exposed by the machine, which is useful for making better
scheduling and cache-management decisions.The implementation describes the RISC-V virt cache hierarchy with separate
L1 instruction and data caches, followed by unified L2 and L3 caches. It also
enables the corresponding cache and cluster properties in the machine SMP
description and wires the generated PPTT into the existing ACPI table build.Quoted 9 lines
Unlike ARM, RISC-V doesn't have a way to discover the Cache topology from registers. Hence, I am hardcoding default values for the
cache topology structures. These cache topology structures are added invirt.citself so that a future series can add support for DT as well. In
future, it can be enhanced to support vendor cpu/soc specific cache information to override this default hardcoded cache details.
Quoted 4 lines
Why not add a vendor cpu/soc specific one to a vendor board? That way it actually model hardware instead of just providing the guest some made up information.
Thanks for the feedback!
Just to make sure I understand your suggestion correctly: should we avoid defining a hardcoded cache topology for the generic CPU on virt, and generate PPTT cache information only for CPU models that provide an appropriate cache hierarchy?
I can certainly omit the cache information for the generic CPU. The consequence is that Drew's CBQRI series, which requires cache information, would need a suitable CPU model before it can be used with virt. Drew, please share your thoughts.
Quoted 3 lines
I feel like you should describe why we want this somewhere in the series
Sure. Let me update the cover letter why PPTT support is required.
Quoted 23 lines
Quoted 14 lines
The series also updates the bios-tables-test data and removes the temporary
PPTT entry from the allowed-diff list. The generated table is 96 bytes and
describes the package, cluster, and processor hierarchy for the virt machine.This work follows the discussion and earlier work shared here:
https://lists.gnu.org/archive/html/qemu-riscv/2024-01/msg00928.htmlI have retained the contribution from Sia Jee Heng and added his Signed-off-by tag to the relevant patch.
Quoted 8 lines
To enable cache structures in the PPTT, one should use similar to below
command line option.-M virt,smp-cache.0.cache=l1d,smp-cache.0.topology=core,smp- cache.1.cache=l1i,smp-cache.1.topology=core,smp-cache.2.cache=l2,smp- cache.2.topology=cluster,smp-cache.3.cache=l3,smp- cache.3.topology=socket
Quoted 5 lines
Obviously :P
Let's at least add this to the virt machine docs so it's useful for someone.
Sure.
Thanks,
Sunil
Quoted 7 lines · Sunil V L
Quoted 5 lines · Alistair Francis
Quoted 3 lines · Sunil V L
Hi alil,
This series adds ACPI Processor Properties Topology Table (PPTT)
[..]
Quoted 14 lines
Quoted 7 lines
Quoted 2 lines
future, it can be enhanced to support vendor cpu/soc specific cache information to override this default hardcoded cache details.
Why not add a vendor cpu/soc specific one to a vendor board? That way it actually model hardware instead of just providing the guest some made up information.
Thanks for the feedback!
Just to make sure I understand your suggestion correctly: should we avoid defining a hardcoded cache topology for the generic CPU on virt, and generate PPTT cache information only for CPU models that provide an appropriate cache hierarchy?
Quoted 4 lines
I can certainly omit the cache information for the generic CPU. The consequence is that Drew's CBQRI series, which requires cache information, would need a suitable CPU model before it can be used with virt. Drew, please share your thoughts.
RQSC is a RISC-V standard so I think it would be nice for the generic cpu to have a set of caches defined. This would allow the ACPI virt machine to produce a PPTT with cache IDs that RQSC can reference, and it would simplify testing for the RISC-V QoS support that I am trying to upstream into Linux.
Thanks,
Drew
Quoted 38 lines · Drew Fustini
Quoted 8 lines · Sunil V L
Quoted 6 lines · Alistair Francis
Quoted 4 lines · Sunil V L
Hi alil,
This series adds ACPI Processor Properties Topology Table (PPTT)
[..]
Quoted 20 lines
Quoted 10 lines
Quoted 3 lines
future, it can be enhanced to support vendor cpu/soc specific cache
information to override this default hardcoded cache details.Why not add a vendor cpu/soc specific one to a vendor board? That way
it actually model hardware instead of just providing the guest some
made up information.Thanks for the feedback!
Just to make sure I understand your suggestion correctly: should we avoid
defining a hardcoded cache topology for the generic CPU on virt, and generate
PPTT cache information only for CPU models that provide an appropriate cache
hierarchy?Quoted 7 lines
I can certainly omit the cache information for the generic CPU. The consequence
is that Drew's CBQRI series, which requires cache information, would need a
suitable CPU model before it can be used with virt. Drew, please share
your thoughts.
Quoted 2 lines
RQSC is a RISC-V standard so I think it would be nice for the generic cpu to have a set of caches defined. This would allow the ACPI virt
Lots of things are RISC-V standards, it doesn't mean it necessarily makes sense for every board.
But there are no actual caches here, which is why it seems a bit strange
Alistair
Quoted 7 lines
machine to produce a PPTT with cache IDs that RQSC can reference, and it
would simplify testing for the RISC-V QoS support that I am trying to upstream into Linux.Thanks,
Drew
Quoted 47 lines · Sunil V L
Quoted 38 lines · Alistair Francis
Quoted 22 lines · Sunil V L
Hi all,
This series adds ACPI Processor Properties Topology Table (PPTT) support to
the RISC-V virt machine. PPTT allows the guest to discover the processor and
cache topology exposed by the machine, which is useful for making better
scheduling and cache-management decisions.The implementation describes the RISC-V virt cache hierarchy with separate
L1 instruction and data caches, followed by unified L2 and L3 caches.
It also
enables the corresponding cache and cluster properties in the machine
SMP
description and wires the generated PPTT into the existing ACPI table
build.Quoted 13 lines
Unlike ARM, RISC-V doesn't have a way to discover the Cache topology from registers. Hence, I am hardcoding default values for
the
cache topology structures. These cache topology structures are added
invirt.citself so that a future series can add support for DT as well.
In
future, it can be enhanced to support vendor cpu/soc specific cache
information to override this default hardcoded cache details.Quoted 5 lines
Why not add a vendor cpu/soc specific one to a vendor board? That way
it actually model hardware instead of just providing the guest some made up information.Thanks for the feedback!
Quoted 7 lines
Just to make sure I understand your suggestion correctly: should we avoid
defining a hardcoded cache topology for the generic CPU on virt, and generate
PPTT cache information only for CPU models that provide an appropriate cache
hierarchy?
It was a question
Something to keep in mind is that I (and others on the list) don't know all of the context that you know about this extension. So the cover letter and commit messages should describe **why** we want this.
Remember, I'm (and other on the list) are not part of RVI. We don't have the insight that you have. I also don't know what Drew is working on (I see some patches today, but before then I didn't know).
So, when sending patches please try to explain why we want them.
The question was, what use/value is there in faking some cache layout that doesn't exist? There might be a good reason, but that should be justified and explained.
Quoted 8 lines
I can certainly omit the cache information for the generic CPU. The consequence
is that Drew's CBQRI series, which requires cache information, would need a
suitable CPU model before it can be used with virt. Drew, please share
your thoughts.
Drew works at a company making it's own CPU, I would argue he can just use that :)
Alistair
Quoted 40 lines
Quoted 4 lines
I feel like you should describe why we want this somewhere in the series
Sure. Let me update the cover letter why PPTT support is required.
Quoted 25 lines
Quoted 19 lines
The series also updates the bios-tables-test data and removes the temporary
PPTT entry from the allowed-diff list. The generated table is 96 bytes and
describes the package, cluster, and processor hierarchy for the virt
machine.This work follows the discussion and earlier work shared here:
https://lists.gnu.org/archive/html/qemu-riscv/2024-01/msg00928.htmlI have retained the contribution from Sia Jee Heng and added his Signed-off-by tag to the relevant patch.
To enable cache structures in the PPTT, one should use similar to below
command line option.Quoted 5 lines
-M virt,smp-cache.0.cache=l1d,smp-cache.0.topology=core,smp- cache.1.cache=l1i,smp-cache.1.topology=core,smp- cache.2.cache=l2,smp- cache.2.topology=cluster,smp-cache.3.cache=l3,smp- cache.3.topology=socket
Quoted 5 lines
Obviously :P
Let's at least add this to the virt machine docs so it's useful for someone.
Sure.
Thanks,
Sunil
Quoted 3 lines · Alistair Francis
Quoted 2 lines · Sunil V L
On Thu, Oct 22, 2026 at 10:23 AM Alistair Francis
<[email protected]> wrote:
[..]
Quoted 40 lines
Quoted 7 lines
Quoted 5 lines
Why not add a vendor cpu/soc specific one to a vendor board? That way
it actually model hardware instead of just providing the guest some made up information.Thanks for the feedback!
Quoted 7 lines
Just to make sure I understand your suggestion correctly: should we avoid
defining a hardcoded cache topology for the generic CPU on virt, and generate
PPTT cache information only for CPU models that provide an appropriate cache
hierarchy?It was a question
Something to keep in mind is that I (and others on the list) don't know all of the context that you know about this extension. So the cover letter and commit messages should describe **why** we want this.
Remember, I'm (and other on the list) are not part of RVI. We don't have the insight that you have. I also don't know what Drew is working on (I see some patches today, but before then I didn't know).
So, when sending patches please try to explain why we want them.
The question was, what use/value is there in faking some cache layout that doesn't exist? There might be a good reason, but that should be justified and explained.
Quoted 8 lines
I can certainly omit the cache information for the generic CPU. The consequence
is that Drew's CBQRI series, which requires cache information, would need a
suitable CPU model before it can be used with virt. Drew, please share
your thoughts.
Quoted 2 lines
Drew works at a company making it's own CPU, I would argue he can just use that :)
I could add caches for the Ascalon core complex in Atlantis but the topology is pretty simple with just private L1 and shared L2. The tt-atlantis machine is also device tree only, so it would not produce a PPTT or RQSC table. A generic cpu with L1, L2 and L3 caches like Sunil defined is ideal for testing my Qemu RQSC series [1], since RQSC needs to reference cache IDs from PPTT. My plan is to rebase my RQSC series once PPTT support lands and send the new revision as a non-RFC series since RQSC has been ratified.
Qemu is important for testing the RISC-V QoS support in Linux [2], because I'm not aware of any hardware yet that supports all 4 features of CBQRI: capacity allocation, capacity monitoring, bandwidth allocation, and bandwidth monitoring. Ascalon only supports capacity allocation, and I have not seen public details from other vendors about which CBQRI features have been implemented.
Thanks,
Drew
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/