[kvm-unit-tests PATCH v2 4/8] riscv: Add ACPI support for ISA string discovery
Andrew Jones
andrew.jones at linux.dev
Fri Nov 20 01:14:13 PST 2026
On Thu, Nov 05, 2026 at 04:20:31PM +0800, Xiang W wrote:
...
> +static int acpi_rhct_for_each_hart(void (*func)(struct acpi_table_rhct *,
> + struct acpi_rhct_node_hart_info *,
> + void *), void *data)
Check the alignment of these parameters. There's an extra space.
> +{
> + u32 offset;
> + struct acpi_table_rhct *rhct;
> + struct acpi_rhct_node *node;
> + struct acpi_rhct_node_hart_info *hart_info;
> +
> + rhct = find_acpi_table_addr(RHCT_SIGNATURE);
> + if (rhct == NULL)
> + return -1;
> +
> + offset = rhct->node_offset;
> + for (int i = 0; i < rhct->node_count; i++) {
> + if (offset >= rhct->length)
> + return -1;
> +
> + node = (void *)rhct + offset;
> + if (node->length < sizeof(*node))
> + return -1;
> +
> + if (node->type == ACPI_RHCT_NODE_TYPE_HART_INFO) {
> + hart_info = (void *)node;
> + func(rhct, hart_info, data);
> + }
> +
> + offset += node->length;
> + }
> +
> + return 0;
> }
> +#endif
>
> void isa_init(struct thread_info *ti)
> {
> struct isa_info info = {
> - .hartid = ti->hartid,
> .func = isa_bit,
> .data = ti,
> };
> int ret;
>
> if (dt_available()) {
> + info.id = ti->hartid;
> ret = dt_for_each_cpu_node(isa_parse_fdt, &info);
> assert(ret == 0);
> } else {
> - isa_init_acpi();
> +#ifdef CONFIG_EFI
> + info.id = ti->uid;
> + ret = acpi_rhct_for_each_hart(isa_parse_acpi, &info);
> + assert(ret == 0);
assert_msg(ret == 0, "ACPI: Failed to parse RHCT");
> +#else
> + assert_msg(false, "ACPI not available");
> +#endif
> }
> }
>
> bool cpu_has_extension_name(int cpu, const char *ext)
> {
> struct isa_info info = {
> - .hartid = cpus[cpu].hartid,
> .func = isa_name,
> .data = &(struct isa_check){ .ext = ext, },
> };
> @@ -116,10 +176,17 @@ bool cpu_has_extension_name(int cpu, const char *ext)
> int ret;
>
> if (dt_available()) {
> + info.id = cpus[cpu].hartid;
> ret = dt_for_each_cpu_node(isa_parse_fdt, &info);
> assert(ret == 0);
> } else {
> +#ifdef CONFIG_EFI
> + info.id = cpus[cpu].uid;
> + ret = acpi_rhct_for_each_hart(isa_parse_acpi, &info);
> + assert(ret == 0);
assert_msg(ret == 0, "ACPI: Failed to parse RHCT");
> +#else
> assert_msg(false, "ACPI not available");
> +#endif
> }
>
> return check->found;
> --
> 2.47.3
>
More information about the kvm-riscv
mailing list