* [PATCH] xen/riscv: add support for riscv,isa-extensions devicetree property @ 2026-11-19 15:48 cristian.andrei1423 2026-11-19 17:12 ` dmukhin 2026-11-20 10:32 ` Baptiste Le Duc 0 siblings, 2 replies; 5+ messages in thread From: cristian.andrei1423 @ 2026-11-19 15:48 UTC (permalink / raw) To: xen-devel Cc: oleksii.kurochko, alistair.francis, connojdavis, baptiste.le-duc, community.manager, andrew.cooper3, anthony.perard, michal.orzel, jbeulich, julien, roger, sstabellini, Cristian Andrei, Denis Mukhin Xen panics when a CPU only has the riscv,isa-extensions property in the device tree. It only accepts the deprecated riscv,isa property, which forces users to use legacy devicetrees. Use riscv,isa-extensions if present, otherwise the legacy riscv,isa. If the new property is used, riscv,isa-extensions and riscv,isa-base must both be present and riscv,isa-base must exactly match the build string. Make a new shared helper riscv_isa_ext_check() which returns the exact state of the property: whether both are present or to use the legacy property. This helper makes both cpufeature.c and smpboot.c agree on which property a CPU uses. A CPU with neither property is skipped with a message. Make it now an error because a skipped CPU is left out of the intersection, so Xen could use extensions that CPU lacks. Add a per-CPU fallback so that any mix of new and legacy CPUs works. This deviates from Linux, which skips CPUs without riscv,isa-extensions and could assume extensions those CPUs lack. Add a first-CPU flag because with the new riscv,isa-extensions, a CPU's set can now be empty, which would make a later CPU appear as the first one. This couldn't happen with riscv,isa, where 'i' is always set. Use the new property in dt_processor_hartid(), with the legacy fallback, which also only used the legacy riscv,isa during interrupt-controller setup. Suggested-by: Denis Mukhin <dmukhin@ford.com> Signed-off-by: Cristian Andrei <cristian.andrei1423@gmail.com> --- Tested on QEMU (virt, aia=aplic-imsic, -cpu rv64,svpbmt=on), -smp 1/2: default DT, only-new, only-legacy, mixed (CPU 0 new, CPU 1 legacy, showing CPU 1 falling back) boot. CPU 1 base "rv32i" -> panic. CPU 1 with only one of the new pair (either one) -> panic. Neither property: untestable in QEMU as OpenSBI stops first. CHANGELOG.md | 3 + docs/misc/riscv/booting.txt | 3 +- xen/arch/riscv/cpufeature.c | 135 ++++++++++++++---------- xen/arch/riscv/include/asm/cpufeature.h | 2 + xen/arch/riscv/smpboot.c | 26 ++++- 5 files changed, 109 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 225397f128..6bacd64f49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) afterwards. ### Added + - On RISC-V: + - Support for riscv,isa-extensions devicetree cpu property, alongside + the legacy riscv,isa. ### Removed - On Arm: diff --git a/docs/misc/riscv/booting.txt b/docs/misc/riscv/booting.txt index 14212ed62f..1505ae8c87 100644 --- a/docs/misc/riscv/booting.txt +++ b/docs/misc/riscv/booting.txt @@ -2,7 +2,8 @@ System requirements =================== The following extensions are required by Xen. Xen panics at boot if any of -them is missing from the riscv,isa property of the CPU nodes: +them is missing from the riscv,isa or riscv,isa-extensions property of the +CPU nodes: - I, M, A, Zicsr, Zifencei: Base ISA Xen is compiled for. - C: diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c index b1c614867c..844269df70 100644 --- a/xen/arch/riscv/cpufeature.c +++ b/xen/arch/riscv/cpufeature.c @@ -42,10 +42,11 @@ struct riscv_isa_ext_data { * * These flags express Xen's policy, not the ISA's rules: extensions which * are architecturally tied to one XLEN (Zilsd on RV32, say) need no special - * treatment here, as they can only ever appear in the "riscv,isa" of a host - * of that XLEN, and guest_isa is masked against the host ISA bitmap anyway. - * They are only of use for extensions Xen chooses not to expose to guests of - * a given width despite the hardware implementing them. + * treatment here, as they can only ever appear in the "riscv,isa" or + * "riscv,isa-extensions" of a host of that XLEN, and guest_isa is masked + * against the host ISA bitmap anyway. They are only of use for extensions + * Xen chooses not to expose to guests of a given width despite the hardware + * implementing them. */ #define RISCV_ISA_EXT_GUEST_NONE 0 #define RISCV_ISA_EXT_GUEST_RV32 (1U << 0) @@ -455,10 +456,41 @@ static int __init riscv_isa_parse_string(const char *isa, return -EINVAL; } -static void __init riscv_fill_hwcap_from_isa_string(void) +int riscv_isa_ext_check(const struct dt_device_node *cpu) +{ + const char *base; + const char *expected_base = IS_ENABLED(CONFIG_RISCV_64) ? "rv64i" : "rv32i"; + const char *node_name = dt_node_full_name(cpu); + bool isa_ext_exists = dt_property_read_bool(cpu, "riscv,isa-extensions"); + bool isa_base_exists = !dt_property_read_string(cpu, "riscv,isa-base", + &base); + + if ( isa_ext_exists && isa_base_exists ) + { + if ( !strcmp(base, expected_base) ) + return 0; + else + { + printk("%s: riscv,isa-base \"%s\" doesn't match %s\n", + node_name, base, expected_base); + return -EINVAL; + } + } + else if ( isa_ext_exists || isa_base_exists ) + { + printk("%s: need both riscv,isa-extensions and riscv,isa-base\n", + node_name); + return -EINVAL; + } + else + return -ENOENT; +} + +static void __init riscv_fill_hwcap_from_dt(void) { const struct dt_device_node *cpus = dt_find_node_by_path("/cpus"); const struct dt_device_node *cpu; + bool first_cpu = true; if ( !cpus ) { @@ -471,6 +503,7 @@ static void __init riscv_fill_hwcap_from_isa_string(void) DECLARE_BITMAP(this_isa, RISCV_ISA_EXT_MAX); const char *isa; unsigned long cpuid; + int ret; bitmap_zero(this_isa, RISCV_ISA_EXT_MAX); @@ -483,57 +516,48 @@ static void __init riscv_fill_hwcap_from_isa_string(void) if ( dt_get_cpuid_from_node(cpu, &cpuid) < 0 ) continue; - if ( dt_property_read_string(cpu, "riscv,isa", &isa) ) + ret = riscv_isa_ext_check(cpu); + + /* Try riscv,isa-extensions, fall back to the deprecated riscv,isa */ + if ( !ret ) { - printk("Unable to find \"riscv,isa\" devicetree entry " - "for DT's cpu%ld node\n", cpuid); - continue; + for ( unsigned int i = 0; i < ARRAY_SIZE(riscv_isa_ext); i++ ) + if ( dt_property_match_string(cpu, "riscv,isa-extensions", + riscv_isa_ext[i].name) >= 0 ) + __set_bit(riscv_isa_ext[i].id, this_isa); } + else if ( ret == -ENOENT && + !dt_property_read_string(cpu, "riscv,isa", &isa) ) + { + for ( unsigned int i = 0; (isa[i] != '\0'); i++ ) + if ( !isdigit(isa[i]) && (isa[i] != '_') && !islower(isa[i]) ) + panic("DT binding: riscv,isa must be lowercase\n"); - for ( unsigned int i = 0; (isa[i] != '\0'); i++ ) - if ( !isdigit(isa[i]) && (isa[i] != '_') && !islower(isa[i]) ) - panic("According to DT binding riscv,isa must be lowercase\n"); - - if ( riscv_isa_parse_string(isa, this_isa) ) - panic("Check riscv,isa in dts file\n"); + if ( riscv_isa_parse_string(isa, this_isa) ) + panic("cpu%lu: riscv,isa failed to parse \"%s\"\n", + cpuid, isa); + } + else if ( ret == -EINVAL ) + panic("cpu%lu: invalid riscv,isa-base/riscv,isa-extensions\n", + cpuid); + else + panic("Unable to find \"riscv,isa\" or \"riscv,isa-extensions\" " + "devicetree entry for DT's cpu%lu node\n", cpuid); - if ( bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX) ) + /* + * The intersection may legitimately become empty, so don't use + * bitmap_empty(riscv_isa) to detect the first CPU. + */ + if ( first_cpu ) + { bitmap_copy(riscv_isa, this_isa, RISCV_ISA_EXT_MAX); + first_cpu = false; + } else bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX); } } -static bool __init has_isa_extensions_property(void) -{ - const struct dt_device_node *cpus = dt_find_node_by_path("/cpus"); - const struct dt_device_node *cpu; - - if ( !cpus ) - { - printk("Missing /cpus node in the device tree?\n"); - return false; - } - - dt_for_each_child_node(cpus, cpu) - { - const char *isa; - - if ( !dt_device_type_is_equal(cpu, "cpu") ) - continue; - - if ( !dt_device_is_available(cpu) ) - continue; - - if ( dt_property_read_string(cpu, "riscv,isa-extensions", &isa) ) - continue; - - return true; - } - - return false; -} - bool riscv_isa_extension_available(const unsigned long *isa_bitmap, enum riscv_isa_ext_id id) { @@ -690,16 +714,10 @@ void __init riscv_fill_hwcap(void) bool all_extns_available = true; unsigned long tmp; - riscv_fill_hwcap_from_isa_string(); + riscv_fill_hwcap_from_dt(); if ( bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX) ) - { - const char *failure_msg = has_isa_extensions_property() ? - "\"riscv,isa-extension\" isn't supported" : - "\"riscv,isa\" parsing failed"; - - panic("HW capabilities parsing failed: %s\n", failure_msg); - } + panic("HW cap: no usable CPU node or extension found\n"); if ( csr_read_safe(CSR_STIMECMP, &tmp) ) { @@ -707,9 +725,10 @@ void __init riscv_fill_hwcap(void) "SSTC detected; supported for Xen use, but not for guests\n"); /* - * As there is no any guarantee that SSTC will be added to riscv,isa - * property by OpenSBI(it doesn't add it now) or whatever ran before - * Xen, it is needed to set this bit manually. + * As there is no any guarantee that SSTC will be added to + * riscv,isa or riscv,isa-extensions property by OpenSBI + * (it doesn't add it now) or whatever ran before Xen, + * it is needed to set this bit manually. * * Guest isolation is maintained by not setting ENVCFG_STCE in henvcfg. */ @@ -745,7 +764,7 @@ void __init riscv_fill_hwcap(void) __set_bit(hw_update ? RISCV_ISA_EXT_svadu : RISCV_ISA_EXT_svade, riscv_isa); printk(XENLOG_WARNING - "Svade/Svadu missing from \"riscv,isa\" - probed as %s\n", + "Svade/Svadu missing from \"riscv,isa\" or \"riscv,isa-extensions\" - probed as %s\n", hw_update ? "svadu" : "svade"); } diff --git a/xen/arch/riscv/include/asm/cpufeature.h b/xen/arch/riscv/include/asm/cpufeature.h index d42189e8eb..ef1d0e4889 100644 --- a/xen/arch/riscv/include/asm/cpufeature.h +++ b/xen/arch/riscv/include/asm/cpufeature.h @@ -47,6 +47,7 @@ enum riscv_isa_ext_id { }; struct domain; +struct dt_device_node; void riscv_fill_hwcap(void); void init_guest_isa(struct domain *d); @@ -54,6 +55,7 @@ const char *get_guest_isa_str(void); bool riscv_isa_extension_available(const unsigned long *isa_bitmap, enum riscv_isa_ext_id id); +int riscv_isa_ext_check(const struct dt_device_node *cpu); #endif /* __ASSEMBLER__ */ diff --git a/xen/arch/riscv/smpboot.c b/xen/arch/riscv/smpboot.c index 3b8bf98e20..95c4d650ac 100644 --- a/xen/arch/riscv/smpboot.c +++ b/xen/arch/riscv/smpboot.c @@ -7,6 +7,7 @@ #include <xen/types.h> #include <asm/current.h> +#include <asm/cpufeature.h> cpumask_t __read_mostly cpu_online_map; cpumask_t __ro_after_init cpu_possible_map; @@ -77,9 +78,32 @@ int dt_processor_hartid(const struct dt_device_node *node, return -ENODEV; } + if ( (ret = riscv_isa_ext_check(node)) == -ENOENT ) + { + printk(XENLOG_DEBUG "CPU with hartid=%#lx has no riscv,isa-base, " + "falling back to legacy riscv,isa\n", *hartid); + goto fallback_to_riscv_isa; + } + + if ( ret ) + return -ENODEV; + + if ( dt_property_match_string(node, "riscv,isa-extensions", "i") < 0 || + dt_property_match_string(node, "riscv,isa-extensions", "m") < 0 || + dt_property_match_string(node, "riscv,isa-extensions", "a") < 0 ) + { + printk("CPU with hartid=%#lx does not support ima\n", *hartid); + return -ENODEV; + } + + return 0; + + fallback_to_riscv_isa: + if ( (ret = dt_property_read_string(node, "riscv,isa", &isa)) ) { - printk("CPU with hartid=%#lx has no \"riscv,isa\" property\n", *hartid); + printk("CPU with hartid=%#lx has no \"riscv,isa-base\" or " + "\"riscv,isa\" property\n", *hartid); return ret; } -- 2.56.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] xen/riscv: add support for riscv,isa-extensions devicetree property 2026-11-19 15:48 [PATCH] xen/riscv: add support for riscv,isa-extensions devicetree property cristian.andrei1423 @ 2026-11-19 17:12 ` dmukhin 2026-11-19 19:33 ` Oleksii Kurochko 2026-11-20 10:32 ` Baptiste Le Duc 1 sibling, 1 reply; 5+ messages in thread From: dmukhin @ 2026-11-19 17:12 UTC (permalink / raw) To: cristian.andrei1423 Cc: xen-devel, oleksii.kurochko, alistair.francis, connojdavis, baptiste.le-duc, community.manager, andrew.cooper3, anthony.perard, michal.orzel, jbeulich, julien, roger, sstabellini, Denis Mukhin On Thu, Nov 19, 2026 at 05:48:07PM +0200, cristian.andrei1423@gmail.com wrote: > Xen panics when a CPU only has the riscv,isa-extensions property in > the device tree. It only accepts the deprecated riscv,isa property, > which forces users to use legacy devicetrees. > > Use riscv,isa-extensions if present, otherwise the legacy riscv,isa. > If the new property is used, riscv,isa-extensions and riscv,isa-base > must both be present and riscv,isa-base must exactly match the build > string. Make a new shared helper riscv_isa_ext_check() which returns > the exact state of the property: whether both are present or to use > the legacy property. This helper makes both cpufeature.c and smpboot.c > agree on which property a CPU uses. > > A CPU with neither property is skipped with a message. Make it now > an error because a skipped CPU is left out of the intersection, so > Xen could use extensions that CPU lacks. > > Add a per-CPU fallback so that any mix of new and legacy CPUs works. > This deviates from Linux, which skips CPUs without riscv,isa-extensions > and could assume extensions those CPUs lack. > > Add a first-CPU flag because with the new riscv,isa-extensions, a CPU's > set can now be empty, which would make a later CPU appear as the first > one. This couldn't happen with riscv,isa, where 'i' is always set. > > Use the new property in dt_processor_hartid(), with the legacy > fallback, which also only used the legacy riscv,isa during > interrupt-controller setup. > > Suggested-by: Denis Mukhin <dmukhin@ford.com> This should be Oleksii's credentials, as Oleksii suggested that task. With that updated, the code looks good to me: Reviewed-by: Denis Mukhin <dmukhin@ford.com> > Signed-off-by: Cristian Andrei <cristian.andrei1423@gmail.com> > --- > Tested on QEMU (virt, aia=aplic-imsic, -cpu rv64,svpbmt=on), > -smp 1/2: default DT, only-new, only-legacy, mixed (CPU 0 new, > CPU 1 legacy, showing CPU 1 falling back) boot. > CPU 1 base "rv32i" -> panic. > CPU 1 with only one of the new pair (either one) -> panic. > Neither property: untestable in QEMU as OpenSBI stops first. > > CHANGELOG.md | 3 + > docs/misc/riscv/booting.txt | 3 +- > xen/arch/riscv/cpufeature.c | 135 ++++++++++++++---------- > xen/arch/riscv/include/asm/cpufeature.h | 2 + > xen/arch/riscv/smpboot.c | 26 ++++- > 5 files changed, 109 insertions(+), 60 deletions(-) > > diff --git a/CHANGELOG.md b/CHANGELOG.md > index 225397f128..6bacd64f49 100644 > --- a/CHANGELOG.md > +++ b/CHANGELOG.md > @@ -16,6 +16,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) > afterwards. > > ### Added > + - On RISC-V: > + - Support for riscv,isa-extensions devicetree cpu property, alongside > + the legacy riscv,isa. > > ### Removed > - On Arm: > diff --git a/docs/misc/riscv/booting.txt b/docs/misc/riscv/booting.txt > index 14212ed62f..1505ae8c87 100644 > --- a/docs/misc/riscv/booting.txt > +++ b/docs/misc/riscv/booting.txt > @@ -2,7 +2,8 @@ System requirements > =================== > > The following extensions are required by Xen. Xen panics at boot if any of > -them is missing from the riscv,isa property of the CPU nodes: > +them is missing from the riscv,isa or riscv,isa-extensions property of the > +CPU nodes: > - I, M, A, Zicsr, Zifencei: > Base ISA Xen is compiled for. > - C: > diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c > index b1c614867c..844269df70 100644 > --- a/xen/arch/riscv/cpufeature.c > +++ b/xen/arch/riscv/cpufeature.c > @@ -42,10 +42,11 @@ struct riscv_isa_ext_data { > * > * These flags express Xen's policy, not the ISA's rules: extensions which > * are architecturally tied to one XLEN (Zilsd on RV32, say) need no special > - * treatment here, as they can only ever appear in the "riscv,isa" of a host > - * of that XLEN, and guest_isa is masked against the host ISA bitmap anyway. > - * They are only of use for extensions Xen chooses not to expose to guests of > - * a given width despite the hardware implementing them. > + * treatment here, as they can only ever appear in the "riscv,isa" or > + * "riscv,isa-extensions" of a host of that XLEN, and guest_isa is masked > + * against the host ISA bitmap anyway. They are only of use for extensions > + * Xen chooses not to expose to guests of a given width despite the hardware > + * implementing them. > */ > #define RISCV_ISA_EXT_GUEST_NONE 0 > #define RISCV_ISA_EXT_GUEST_RV32 (1U << 0) > @@ -455,10 +456,41 @@ static int __init riscv_isa_parse_string(const char *isa, > return -EINVAL; > } > > -static void __init riscv_fill_hwcap_from_isa_string(void) > +int riscv_isa_ext_check(const struct dt_device_node *cpu) > +{ > + const char *base; > + const char *expected_base = IS_ENABLED(CONFIG_RISCV_64) ? "rv64i" : "rv32i"; > + const char *node_name = dt_node_full_name(cpu); > + bool isa_ext_exists = dt_property_read_bool(cpu, "riscv,isa-extensions"); > + bool isa_base_exists = !dt_property_read_string(cpu, "riscv,isa-base", > + &base); > + > + if ( isa_ext_exists && isa_base_exists ) > + { > + if ( !strcmp(base, expected_base) ) > + return 0; > + else > + { > + printk("%s: riscv,isa-base \"%s\" doesn't match %s\n", > + node_name, base, expected_base); > + return -EINVAL; > + } > + } > + else if ( isa_ext_exists || isa_base_exists ) > + { > + printk("%s: need both riscv,isa-extensions and riscv,isa-base\n", > + node_name); > + return -EINVAL; > + } > + else > + return -ENOENT; > +} > + > +static void __init riscv_fill_hwcap_from_dt(void) > { > const struct dt_device_node *cpus = dt_find_node_by_path("/cpus"); > const struct dt_device_node *cpu; > + bool first_cpu = true; > > if ( !cpus ) > { > @@ -471,6 +503,7 @@ static void __init riscv_fill_hwcap_from_isa_string(void) > DECLARE_BITMAP(this_isa, RISCV_ISA_EXT_MAX); > const char *isa; > unsigned long cpuid; > + int ret; > > bitmap_zero(this_isa, RISCV_ISA_EXT_MAX); > > @@ -483,57 +516,48 @@ static void __init riscv_fill_hwcap_from_isa_string(void) > if ( dt_get_cpuid_from_node(cpu, &cpuid) < 0 ) > continue; > > - if ( dt_property_read_string(cpu, "riscv,isa", &isa) ) > + ret = riscv_isa_ext_check(cpu); > + > + /* Try riscv,isa-extensions, fall back to the deprecated riscv,isa */ > + if ( !ret ) > { > - printk("Unable to find \"riscv,isa\" devicetree entry " > - "for DT's cpu%ld node\n", cpuid); > - continue; > + for ( unsigned int i = 0; i < ARRAY_SIZE(riscv_isa_ext); i++ ) > + if ( dt_property_match_string(cpu, "riscv,isa-extensions", > + riscv_isa_ext[i].name) >= 0 ) > + __set_bit(riscv_isa_ext[i].id, this_isa); > } > + else if ( ret == -ENOENT && > + !dt_property_read_string(cpu, "riscv,isa", &isa) ) > + { > + for ( unsigned int i = 0; (isa[i] != '\0'); i++ ) > + if ( !isdigit(isa[i]) && (isa[i] != '_') && !islower(isa[i]) ) > + panic("DT binding: riscv,isa must be lowercase\n"); > > - for ( unsigned int i = 0; (isa[i] != '\0'); i++ ) > - if ( !isdigit(isa[i]) && (isa[i] != '_') && !islower(isa[i]) ) > - panic("According to DT binding riscv,isa must be lowercase\n"); > - > - if ( riscv_isa_parse_string(isa, this_isa) ) > - panic("Check riscv,isa in dts file\n"); > + if ( riscv_isa_parse_string(isa, this_isa) ) > + panic("cpu%lu: riscv,isa failed to parse \"%s\"\n", > + cpuid, isa); > + } > + else if ( ret == -EINVAL ) > + panic("cpu%lu: invalid riscv,isa-base/riscv,isa-extensions\n", > + cpuid); > + else > + panic("Unable to find \"riscv,isa\" or \"riscv,isa-extensions\" " > + "devicetree entry for DT's cpu%lu node\n", cpuid); > > - if ( bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX) ) > + /* > + * The intersection may legitimately become empty, so don't use > + * bitmap_empty(riscv_isa) to detect the first CPU. > + */ > + if ( first_cpu ) > + { > bitmap_copy(riscv_isa, this_isa, RISCV_ISA_EXT_MAX); > + first_cpu = false; > + } > else > bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX); > } > } > > -static bool __init has_isa_extensions_property(void) > -{ > - const struct dt_device_node *cpus = dt_find_node_by_path("/cpus"); > - const struct dt_device_node *cpu; > - > - if ( !cpus ) > - { > - printk("Missing /cpus node in the device tree?\n"); > - return false; > - } > - > - dt_for_each_child_node(cpus, cpu) > - { > - const char *isa; > - > - if ( !dt_device_type_is_equal(cpu, "cpu") ) > - continue; > - > - if ( !dt_device_is_available(cpu) ) > - continue; > - > - if ( dt_property_read_string(cpu, "riscv,isa-extensions", &isa) ) > - continue; > - > - return true; > - } > - > - return false; > -} > - > bool riscv_isa_extension_available(const unsigned long *isa_bitmap, > enum riscv_isa_ext_id id) > { > @@ -690,16 +714,10 @@ void __init riscv_fill_hwcap(void) > bool all_extns_available = true; > unsigned long tmp; > > - riscv_fill_hwcap_from_isa_string(); > + riscv_fill_hwcap_from_dt(); > > if ( bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX) ) > - { > - const char *failure_msg = has_isa_extensions_property() ? > - "\"riscv,isa-extension\" isn't supported" : > - "\"riscv,isa\" parsing failed"; > - > - panic("HW capabilities parsing failed: %s\n", failure_msg); > - } > + panic("HW cap: no usable CPU node or extension found\n"); > > if ( csr_read_safe(CSR_STIMECMP, &tmp) ) > { > @@ -707,9 +725,10 @@ void __init riscv_fill_hwcap(void) > "SSTC detected; supported for Xen use, but not for guests\n"); > > /* > - * As there is no any guarantee that SSTC will be added to riscv,isa > - * property by OpenSBI(it doesn't add it now) or whatever ran before > - * Xen, it is needed to set this bit manually. > + * As there is no any guarantee that SSTC will be added to > + * riscv,isa or riscv,isa-extensions property by OpenSBI > + * (it doesn't add it now) or whatever ran before Xen, > + * it is needed to set this bit manually. > * > * Guest isolation is maintained by not setting ENVCFG_STCE in henvcfg. > */ > @@ -745,7 +764,7 @@ void __init riscv_fill_hwcap(void) > __set_bit(hw_update ? RISCV_ISA_EXT_svadu : RISCV_ISA_EXT_svade, > riscv_isa); > printk(XENLOG_WARNING > - "Svade/Svadu missing from \"riscv,isa\" - probed as %s\n", > + "Svade/Svadu missing from \"riscv,isa\" or \"riscv,isa-extensions\" - probed as %s\n", > hw_update ? "svadu" : "svade"); > } > > diff --git a/xen/arch/riscv/include/asm/cpufeature.h b/xen/arch/riscv/include/asm/cpufeature.h > index d42189e8eb..ef1d0e4889 100644 > --- a/xen/arch/riscv/include/asm/cpufeature.h > +++ b/xen/arch/riscv/include/asm/cpufeature.h > @@ -47,6 +47,7 @@ enum riscv_isa_ext_id { > }; > > struct domain; > +struct dt_device_node; > > void riscv_fill_hwcap(void); > void init_guest_isa(struct domain *d); > @@ -54,6 +55,7 @@ const char *get_guest_isa_str(void); > > bool riscv_isa_extension_available(const unsigned long *isa_bitmap, > enum riscv_isa_ext_id id); > +int riscv_isa_ext_check(const struct dt_device_node *cpu); > > #endif /* __ASSEMBLER__ */ > > diff --git a/xen/arch/riscv/smpboot.c b/xen/arch/riscv/smpboot.c > index 3b8bf98e20..95c4d650ac 100644 > --- a/xen/arch/riscv/smpboot.c > +++ b/xen/arch/riscv/smpboot.c > @@ -7,6 +7,7 @@ > #include <xen/types.h> > > #include <asm/current.h> > +#include <asm/cpufeature.h> > > cpumask_t __read_mostly cpu_online_map; > cpumask_t __ro_after_init cpu_possible_map; > @@ -77,9 +78,32 @@ int dt_processor_hartid(const struct dt_device_node *node, > return -ENODEV; > } > > + if ( (ret = riscv_isa_ext_check(node)) == -ENOENT ) > + { > + printk(XENLOG_DEBUG "CPU with hartid=%#lx has no riscv,isa-base, " > + "falling back to legacy riscv,isa\n", *hartid); > + goto fallback_to_riscv_isa; > + } > + > + if ( ret ) > + return -ENODEV; > + > + if ( dt_property_match_string(node, "riscv,isa-extensions", "i") < 0 || > + dt_property_match_string(node, "riscv,isa-extensions", "m") < 0 || > + dt_property_match_string(node, "riscv,isa-extensions", "a") < 0 ) > + { > + printk("CPU with hartid=%#lx does not support ima\n", *hartid); > + return -ENODEV; > + } > + > + return 0; > + > + fallback_to_riscv_isa: > + > if ( (ret = dt_property_read_string(node, "riscv,isa", &isa)) ) > { > - printk("CPU with hartid=%#lx has no \"riscv,isa\" property\n", *hartid); > + printk("CPU with hartid=%#lx has no \"riscv,isa-base\" or " > + "\"riscv,isa\" property\n", *hartid); > return ret; > } > > -- > 2.56.0 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xen/riscv: add support for riscv,isa-extensions devicetree property 2026-11-19 17:12 ` dmukhin @ 2026-11-19 19:33 ` Oleksii Kurochko 2026-11-20 10:34 ` Baptiste Le Duc 0 siblings, 1 reply; 5+ messages in thread From: Oleksii Kurochko @ 2026-11-19 19:33 UTC (permalink / raw) To: cristian.andrei1423 Cc: xen-devel, alistair.francis, connojdavis, baptiste.le-duc, community.manager, andrew.cooper3, anthony.perard, michal.orzel, jbeulich, julien, roger, sstabellini, dmukhin Hi Cristian, For some reason, I can't find the original patch so I will respond as reply to Denis's reply. Thanks for the patch. The overall approach (prefer riscv,isa-extensions, fall back to riscv,isa per CPU) looks good to me. Some comments below. On 11/19/26 6:12 PM, dmukhin@ford.com wrote: > On Thu, Nov 19, 2026 at 05:48:07PM +0200, cristian.andrei1423@gmail.com wrote: >> Xen panics when a CPU only has the riscv,isa-extensions property in >> the device tree. It only accepts the deprecated riscv,isa property, >> which forces users to use legacy devicetrees. >> >> Use riscv,isa-extensions if present, otherwise the legacy riscv,isa. >> If the new property is used, riscv,isa-extensions and riscv,isa-base >> must both be present and riscv,isa-base must exactly match the build >> string. Make a new shared helper riscv_isa_ext_check() which returns >> the exact state of the property: whether both are present or to use >> the legacy property. This helper makes both cpufeature.c and smpboot.c >> agree on which property a CPU uses. >> >> A CPU with neither property is skipped with a message. Make it now >> an error because a skipped CPU is left out of the intersection, so >> Xen could use extensions that CPU lacks. This reads as if skipping were the new behaviour. Maybe something like: "Currently, a CPU with neither property is skipped with a message. Make this an error instead, as a skipped CPU is left out of the intersection and Xen could then use extensions that CPU lacks." Also, the same argument applies to CPU nodes for which dt_get_cpuid_from_node() fails: they are still silently skipped. Either handle them the same way or explain why that case is different. >> >> Add a per-CPU fallback so that any mix of new and legacy CPUs works. >> This deviates from Linux, which skips CPUs without riscv,isa-extensions >> and could assume extensions those CPUs lack. >> >> Add a first-CPU flag because with the new riscv,isa-extensions, a CPU's >> set can now be empty, which would make a later CPU appear as the first >> one. This couldn't happen with riscv,isa, where 'i' is always set. >> >> Use the new property in dt_processor_hartid(), with the legacy >> fallback, which also only used the legacy riscv,isa during >> interrupt-controller setup. >> >> Suggested-by: Denis Mukhin <dmukhin@ford.com> > > This should be Oleksii's credentials, as Oleksii suggested that task. > > With that updated, the code looks good to me: > > Reviewed-by: Denis Mukhin <dmukhin@ford.com> > > >> Signed-off-by: Cristian Andrei <cristian.andrei1423@gmail.com> Nit: the author of the patch is set to just the e-mail address ("cristian.andrei1423@gmail.com <cristian.andrei1423@gmail.com>"). Please set your name so that it matches the Signed-off-by tag. >> --- >> Tested on QEMU (virt, aia=aplic-imsic, -cpu rv64,svpbmt=on), >> -smp 1/2: default DT, only-new, only-legacy, mixed (CPU 0 new, >> CPU 1 legacy, showing CPU 1 falling back) boot. >> CPU 1 base "rv32i" -> panic. >> CPU 1 with only one of the new pair (either one) -> panic. >> Neither property: untestable in QEMU as OpenSBI stops first. >> >> CHANGELOG.md | 3 + >> docs/misc/riscv/booting.txt | 3 +- >> xen/arch/riscv/cpufeature.c | 135 ++++++++++++++---------- >> xen/arch/riscv/include/asm/cpufeature.h | 2 + >> xen/arch/riscv/smpboot.c | 26 ++++- >> 5 files changed, 109 insertions(+), 60 deletions(-) >> [...] >> diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c >> index b1c614867c..844269df70 100644 >> --- a/xen/arch/riscv/cpufeature.c >> +++ b/xen/arch/riscv/cpufeature.c >> @@ -42,10 +42,11 @@ struct riscv_isa_ext_data { >> * >> * These flags express Xen's policy, not the ISA's rules: extensions which >> * are architecturally tied to one XLEN (Zilsd on RV32, say) need no special >> - * treatment here, as they can only ever appear in the "riscv,isa" of a host >> - * of that XLEN, and guest_isa is masked against the host ISA bitmap anyway. >> - * They are only of use for extensions Xen chooses not to expose to guests of >> - * a given width despite the hardware implementing them. >> + * treatment here, as they can only ever appear in the "riscv,isa" or >> + * "riscv,isa-extensions" of a host of that XLEN, and guest_isa is masked >> + * against the host ISA bitmap anyway. They are only of use for extensions >> + * Xen chooses not to expose to guests of a given width despite the hardware >> + * implementing them. >> */ >> #define RISCV_ISA_EXT_GUEST_NONE 0 >> #define RISCV_ISA_EXT_GUEST_RV32 (1U << 0) >> @@ -455,10 +456,41 @@ static int __init riscv_isa_parse_string(const char *isa, >> return -EINVAL; >> } >> >> -static void __init riscv_fill_hwcap_from_isa_string(void) >> +int riscv_isa_ext_check(const struct dt_device_node *cpu) >> +{ Please add a comment above the function describing what the three return values mean (0: use riscv,isa-extensions, -EINVAL: broken riscv,isa-base/riscv,isa-extensions, -ENOENT: use legacy riscv,isa). Right now this has to be reverse-engineered from the callers. >> + const char *base; >> + const char *expected_base = IS_ENABLED(CONFIG_RISCV_64) ? "rv64i" : "rv32i"; >> + const char *node_name = dt_node_full_name(cpu); >> + bool isa_ext_exists = dt_property_read_bool(cpu, "riscv,isa-extensions"); >> + bool isa_base_exists = !dt_property_read_string(cpu, "riscv,isa-base", >> + &base); >> + >> + if ( isa_ext_exists && isa_base_exists ) >> + { >> + if ( !strcmp(base, expected_base) ) >> + return 0; >> + else >> + { >> + printk("%s: riscv,isa-base \"%s\" doesn't match %s\n", >> + node_name, base, expected_base); >> + return -EINVAL; >> + } >> + } >> + else if ( isa_ext_exists || isa_base_exists ) >> + { >> + printk("%s: need both riscv,isa-extensions and riscv,isa-base\n", >> + node_name); >> + return -EINVAL; >> + } >> + else >> + return -ENOENT; >> +} The "else" branches after "return" are not needed and only add indentation. Also, node_name is only used on the error paths, so it could be computed there (or dt_node_full_name() used directly). And the printk()s are missing a log level. Something like: if ( !isa_ext_exists && !isa_base_exists ) return -ENOENT; if ( !isa_ext_exists || !isa_base_exists ) { printk(XENLOG_ERR "%s: need both riscv,isa-extensions and riscv,isa-base\n", dt_node_full_name(cpu)); return -EINVAL; } if ( strcmp(base, expected_base) ) { printk(XENLOG_ERR "%s: riscv,isa-base \"%s\" doesn't match %s\n", dt_node_full_name(cpu), base, expected_base); return -EINVAL; } return 0; Do I miss something? >> + >> +static void __init riscv_fill_hwcap_from_dt(void) >> { >> const struct dt_device_node *cpus = dt_find_node_by_path("/cpus"); >> const struct dt_device_node *cpu; >> + bool first_cpu = true; >> >> if ( !cpus ) >> { >> @@ -471,6 +503,7 @@ static void __init riscv_fill_hwcap_from_isa_string(void) >> DECLARE_BITMAP(this_isa, RISCV_ISA_EXT_MAX); >> const char *isa; >> unsigned long cpuid; >> + int ret; >> >> bitmap_zero(this_isa, RISCV_ISA_EXT_MAX); >> >> @@ -483,57 +516,48 @@ static void __init riscv_fill_hwcap_from_isa_string(void) >> if ( dt_get_cpuid_from_node(cpu, &cpuid) < 0 ) >> continue; >> >> - if ( dt_property_read_string(cpu, "riscv,isa", &isa) ) >> + ret = riscv_isa_ext_check(cpu); >> + >> + /* Try riscv,isa-extensions, fall back to the deprecated riscv,isa */ >> + if ( !ret ) >> { >> - printk("Unable to find \"riscv,isa\" devicetree entry " >> - "for DT's cpu%ld node\n", cpuid); >> - continue; >> + for ( unsigned int i = 0; i < ARRAY_SIZE(riscv_isa_ext); i++ ) >> + if ( dt_property_match_string(cpu, "riscv,isa-extensions", >> + riscv_isa_ext[i].name) >= 0 ) >> + __set_bit(riscv_isa_ext[i].id, this_isa); >> } >> + else if ( ret == -ENOENT && >> + !dt_property_read_string(cpu, "riscv,isa", &isa) ) >> + { >> + for ( unsigned int i = 0; (isa[i] != '\0'); i++ ) >> + if ( !isdigit(isa[i]) && (isa[i] != '_') && !islower(isa[i]) ) >> + panic("DT binding: riscv,isa must be lowercase\n"); >> >> - for ( unsigned int i = 0; (isa[i] != '\0'); i++ ) >> - if ( !isdigit(isa[i]) && (isa[i] != '_') && !islower(isa[i]) ) >> - panic("According to DT binding riscv,isa must be lowercase\n"); Is there a reason to change this message? If not, I would keep it as is to reduce churn. >> - >> - if ( riscv_isa_parse_string(isa, this_isa) ) >> - panic("Check riscv,isa in dts file\n"); >> + if ( riscv_isa_parse_string(isa, this_isa) ) >> + panic("cpu%lu: riscv,isa failed to parse \"%s\"\n", >> + cpuid, isa); >> + } >> + else if ( ret == -EINVAL ) >> + panic("cpu%lu: invalid riscv,isa-base/riscv,isa-extensions\n", >> + cpuid); >> + else >> + panic("Unable to find \"riscv,isa\" or \"riscv,isa-extensions\" " >> + "devicetree entry for DT's cpu%lu node\n", cpuid); Mixing the return code check with reading the riscv,isa property in one condition makes the last "else" ("-ENOENT and no riscv,isa") not obvious. I think a switch ( ret ), or handling -EINVAL first and then -ENOENT (with the riscv,isa lookup inside that branch), would be easier to follow. >> >> - if ( bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX) ) >> + /* >> + * The intersection may legitimately become empty, so don't use >> + * bitmap_empty(riscv_isa) to detect the first CPU. >> + */ >> + if ( first_cpu ) >> + { >> bitmap_copy(riscv_isa, this_isa, RISCV_ISA_EXT_MAX); >> + first_cpu = false; >> + } >> else >> bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX); >> } >> } >> [...] >> bool riscv_isa_extension_available(const unsigned long *isa_bitmap, >> enum riscv_isa_ext_id id) >> { >> @@ -690,16 +714,10 @@ void __init riscv_fill_hwcap(void) >> bool all_extns_available = true; >> unsigned long tmp; >> >> - riscv_fill_hwcap_from_isa_string(); >> + riscv_fill_hwcap_from_dt(); >> >> if ( bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX) ) >> - { >> - const char *failure_msg = has_isa_extensions_property() ? >> - "\"riscv,isa-extension\" isn't supported" : >> - "\"riscv,isa\" parsing failed"; >> - >> - panic("HW capabilities parsing failed: %s\n", failure_msg); >> - } >> + panic("HW cap: no usable CPU node or extension found\n"); With the per-CPU panics above, this can now only be reached if there is no /cpus node, no usable CPU node, or the intersection is empty. Maybe say so more explicitly, e.g. "No usable CPU node found or ISA intersection is empty". [...] >> diff --git a/xen/arch/riscv/smpboot.c b/xen/arch/riscv/smpboot.c >> index 3b8bf98e20..95c4d650ac 100644 >> --- a/xen/arch/riscv/smpboot.c >> +++ b/xen/arch/riscv/smpboot.c >> @@ -7,6 +7,7 @@ >> #include <xen/types.h> >> >> #include <asm/current.h> >> +#include <asm/cpufeature.h> >> >> cpumask_t __read_mostly cpu_online_map; >> cpumask_t __ro_after_init cpu_possible_map; >> @@ -77,9 +78,32 @@ int dt_processor_hartid(const struct dt_device_node *node, >> return -ENODEV; >> } >> >> + if ( (ret = riscv_isa_ext_check(node)) == -ENOENT ) >> + { >> + printk(XENLOG_DEBUG "CPU with hartid=%#lx has no riscv,isa-base, " >> + "falling back to legacy riscv,isa\n", *hartid); >> + goto fallback_to_riscv_isa; >> + } >> + >> + if ( ret ) >> + return -ENODEV; >> + >> + if ( dt_property_match_string(node, "riscv,isa-extensions", "i") < 0 || >> + dt_property_match_string(node, "riscv,isa-extensions", "m") < 0 || >> + dt_property_match_string(node, "riscv,isa-extensions", "a") < 0 ) >> + { >> + printk("CPU with hartid=%#lx does not support ima\n", *hartid); >> + return -ENODEV; >> + } >> + >> + return 0; >> + >> + fallback_to_riscv_isa: >> + It could be written without the label: ret = riscv_isa_ext_check(node); if ( ret != -ENOENT ) { if ( ret ) return -ENODEV; if ( dt_property_match_string(node, "riscv,isa-extensions", "i") < 0 || dt_property_match_string(node, "riscv,isa-extensions", "m") < 0 || dt_property_match_string(node, "riscv,isa-extensions", "a") < 0 ) { printk("CPU with hartid=%#lx does not support ima\n", *hartid); return -ENODEV; } return 0; } Also, the XENLOG_DEBUG message will be printed for every hart referenced from interrupts-extended of every IMSIC node on a legacy DT, so I would drop it. >> if ( (ret = dt_property_read_string(node, "riscv,isa", &isa)) ) >> { >> - printk("CPU with hartid=%#lx has no \"riscv,isa\" property\n", *hartid); >> + printk("CPU with hartid=%#lx has no \"riscv,isa-base\" or " >> + "\"riscv,isa\" property\n", *hartid); >> return ret; >> } >> > --- a/docs/misc/riscv/booting.txt > +++ b/docs/misc/riscv/booting.txt [...] > -them is missing from the riscv,isa or riscv,isa-extensions property of the > +them is missing from the riscv,isa or riscv,isa-extensions property of the > +CPU nodes: It might be worth adding that riscv,isa-extensions (together with riscv,isa-base) takes precedence when both are present. ~ Oleksii ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xen/riscv: add support for riscv,isa-extensions devicetree property 2026-11-19 19:33 ` Oleksii Kurochko @ 2026-11-20 10:34 ` Baptiste Le Duc 0 siblings, 0 replies; 5+ messages in thread From: Baptiste Le Duc @ 2026-11-20 10:34 UTC (permalink / raw) To: Oleksii Kurochko Cc: cristian.andrei1423, xen-devel, alistair.francis, connojdavis, baptiste.le-duc, community.manager, andrew.cooper3, anthony.perard, michal.orzel, jbeulich, julien, roger, sstabellini, dmukhin On 2026-11-19 20:33:51+01:00, Oleksii Kurochko wrote: > [ ... 11 lines skipped ... ] > This reads as if skipping were the new behaviour. Maybe something like: > > "Currently, a CPU with neither property is skipped with a message. > Make this an error instead, as a skipped CPU is left out of the > intersection and Xen could then use extensions that CPU lacks." > > Also, the same argument applies to CPU nodes for which > dt_get_cpuid_from_node() fails: they are still silently skipped. Either > handle them the same way or explain why that case is different. If it is handled in the same way, then it could worth to do it in a dedicated patch in this patch series. > [ ... 60 lines skipped ... ] > Mixing the return code check with reading the riscv,isa property in one > condition makes the last "else" ("-ENOENT and no riscv,isa") not obvious. > I think a switch ( ret ), or handling -EINVAL first and then -ENOENT I agree the switch would be better -- Baptiste Le Duc <baptiste.le-duc@vates.tech> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xen/riscv: add support for riscv,isa-extensions devicetree property 2026-11-19 15:48 [PATCH] xen/riscv: add support for riscv,isa-extensions devicetree property cristian.andrei1423 2026-11-19 17:12 ` dmukhin @ 2026-11-20 10:32 ` Baptiste Le Duc 1 sibling, 0 replies; 5+ messages in thread From: Baptiste Le Duc @ 2026-11-20 10:32 UTC (permalink / raw) To: cristian.andrei1423 Cc: xen-devel, oleksii.kurochko, alistair.francis, connojdavis, baptiste.le-duc, community.manager, andrew.cooper3, anthony.perard, michal.orzel, jbeulich, julien, roger, sstabellini, Denis Mukhin Hi Cristian, Thanks for contributing to Xen on RISC-V! > Xen panics when a CPU only has the riscv,isa-extensions property in > the device tree. It only accepts the deprecated riscv,isa property, > which forces users to use legacy devicetrees. > > Use riscv,isa-extensions if present, otherwise the legacy riscv,isa. > If the new property is used, riscv,isa-extensions and riscv,isa-base > must both be present and riscv,isa-base must exactly match the build > string. Make a new shared helper riscv_isa_ext_check() which returns > the exact state of the property: whether both are present or to use > the legacy property. This helper makes both cpufeature.c and smpboot.c > agree on which property a CPU uses. > > A CPU with neither property is skipped with a message. Make it now > an error because a skipped CPU is left out of the intersection, so > Xen could use extensions that CPU lacks. > > Add a per-CPU fallback so that any mix of new and legacy CPUs works. > This deviates from Linux, which skips CPUs without riscv,isa-extensions > and could assume extensions those CPUs lack. > > Add a first-CPU flag because with the new riscv,isa-extensions, a CPU's > set can now be empty, which would make a later CPU appear as the first > one. This couldn't happen with riscv,isa, where 'i' is always set. > > Use the new property in dt_processor_hartid(), with the legacy > fallback, which also only used the legacy riscv,isa during > interrupt-controller setup. > > Suggested-by: Denis Mukhin <dmukhin@ford.com> > Signed-off-by: Cristian Andrei <cristian.andrei1423@gmail.com> I would first say explicitly what Xen currently does: it only parses riscv,isa, which is deprecated in the DT bindings, and silently skips CPU nodes that lack it. Something like (I also shortened the subject): xen/riscv: support riscv,isa-extensions devicetree property Xen only parses the riscv,isa devicetree property, which Linux has deprecated in favour of riscv,isa-base plus riscv,isa-extensions [1]. Xen panics if no CPU node has riscv,isa, so a devicetree using only the new properties cannot boot Xen. Use riscv,isa-extensions when present, falling back to the legacy riscv,isa otherwise. With the new binding, riscv,isa-extensions and riscv,isa-base must both be present, and riscv,isa-base must match the base ISA Xen is built for ("rv64i" or "rv32i"). Add a shared helper, riscv_isa_ext_check(), so that cpufeature.c and smpboot.c agree on which property a CPU uses. Currently, a CPU node with neither property is skipped with a message. Make this an error instead, as a skipped CPU is left out of the ISA intersection and Xen could then use extensions that CPU lacks. Add a per-CPU fallback so that any mix of new and legacy CPUs works. This deviates from Linux, which skips CPUs without riscv,isa-extensions and could assume extensions those CPUs lack. Track the first CPU with a flag instead of testing whether the intersection is empty: with riscv,isa-extensions a CPU's set can be empty, which would make a later CPU look like the first one. This can't happen with the legacy riscv,isa, where 'i' is always set. dt_processor_hartid(), used during interrupt-controller setup, also only reads riscv,isa. Make it use the new property too, with the same legacy fallback. [1] Linux commit aeb71e42caae ("dt-bindings: riscv: deprecate riscv,isa") > [ ... 66 lines skipped ... ] > -static void __init riscv_fill_hwcap_from_isa_string(void) > +int riscv_isa_ext_check(const struct dt_device_node *cpu) The name reads like a pass/fail check, but callers act on three outcomes: 0 (use riscv,isa-extensions), -ENOENT (new binding absent, fall back to riscv,isa) and -EINVAL (invalid). Could it be renamed to something like riscv_isa_ext_probe(), so that the -ENOENT test at the call sites reads naturally? Together with the comment Oleksii asked for, that should make it more clear. > [ ... 63 lines skipped ... ] > + else if ( ret == -ENOENT && > + !dt_property_read_string(cpu, "riscv,isa", &isa) ) > + { > + for ( unsigned int i = 0; (isa[i] != '\0'); i++ ) Nit: since the line is touched anyway, the parentheses around isa[i] != '\0' can go. > [ ... 16 lines skipped ... ] > + else > + panic("Unable to find \"riscv,isa\" or \"riscv,isa-extensions\" " > + "devicetree entry for DT's cpu%lu node\n", cpuid); Nit: maybe don't split the format string, it makes it harder to grep. Keep the literal on one line and move cpuid to the next one: panic("Unable to find \"riscv,isa\" or \"riscv,isa-extensions\" devicetree entry for DT's cpu%lu node\n", cpuid); > [ ... 71 lines skipped ... ] > /* > - * As there is no any guarantee that SSTC will be added to riscv,isa > - * property by OpenSBI(it doesn't add it now) or whatever ran before > - * Xen, it is needed to set this bit manually. > + * As there is no any guarantee that SSTC will be added to While rewrapping these lines: "there is no any guarantee" -> "there is no guarantee". > [ ... 35 lines skipped ... ] > diff --git a/xen/arch/riscv/smpboot.c b/xen/arch/riscv/smpboot.c > index 3b8bf98e20..95c4d650ac 100644 > --- a/xen/arch/riscv/smpboot.c > +++ b/xen/arch/riscv/smpboot.c > @@ -7,6 +7,7 @@ > #include <xen/types.h> > > #include <asm/current.h> > +#include <asm/cpufeature.h> Please keep the <asm/...> group sorted alphabetically: cpufeature.h goes before current.h. > [ ... 17 lines skipped ... ] > + if ( dt_property_match_string(node, "riscv,isa-extensions", "i") < 0 || > + dt_property_match_string(node, "riscv,isa-extensions", "m") < 0 || > + dt_property_match_string(node, "riscv,isa-extensions", "a") < 0 ) > + { > + printk("CPU with hartid=%#lx does not support ima\n", *hartid); Missing log level: printk(XENLOG_ERR ...). -- Baptiste Le Duc <baptiste.le-duc@vates.tech> ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-20 10:35 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-19 15:48 [PATCH] xen/riscv: add support for riscv,isa-extensions devicetree property cristian.andrei1423 2026-11-19 17:12 ` dmukhin 2026-11-19 19:33 ` Oleksii Kurochko 2026-11-20 10:34 ` Baptiste Le Duc 2026-11-20 10:32 ` Baptiste Le Duc
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.