|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] xen/riscv: add support for riscv,isa-extensions devicetree property
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@xxxxxxxx wrote: On Thu, Nov 19, 2026 at 05:48:07PM +0200, cristian.andrei1423@xxxxxxxxx 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@xxxxxxxx>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@xxxxxxxx>Signed-off-by: Cristian Andrei <cristian.andrei1423@xxxxxxxxx> Nit: the author of the patch is set to just the e-mail address("cristian.andrei1423@xxxxxxxxx <cristian.andrei1423@xxxxxxxxx>"). 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(-) [...]
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.
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?
Is there a reason to change this message? If not, I would keep it as is to reduce churn.
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) ) [...]
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;
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.
> --- 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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |