[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 06/23] xen/riscv: introduce guest riscv,isa string





On 6/22/26 4:09 PM, Jan Beulich wrote:
On 17.06.2026 13:17, Oleksii Kurochko wrote:
Introduce generation of the riscv,isa string passed to the guest via the
Device Tree riscv,isa property.

Introduce the per-domain isa string and guest isa bitmap, populated
during domain creation by calling init_guest_isa().

Introduce guest_unsupp to filter out ISA extensions that should not be
exposed to guests:

- f/d/q/v: FPU and vector context save/restore are not yet implemented
   for guests.

I may have asked before - what about Zfinx, Zdinx (and the supposed Zqinx)?
They aren't in riscv_isa_ext[], yes, but perhaps wrongly so? And hence they
may want at least mentioning?

They are not supported by Xen so they aren't in riscv_isa_ext so it looks fine for me.

They are not in guest_unsupp as they aren't present in riscv_isa_ext and so it won't be propagated to guest anyway because of:
  +    bitmap_andnot(d->arch.isa, riscv_isa, guest_unsupp,
  +                  RISCV_ISA_EXT_MAX);

While it isn't in riscv_isa_ext[] I think it is fine not to add them to guest_unsupp, so I will add to the commit message that:
```
- Zfinx, Zdinx and Zqinx are not implemented for guests either; as they are not present in the riscv_isa_ext[] array, they can never be set in riscv_isa and thus are never exposed to a guest, so there is no need to list them explicitly in guest_unsupp.
```

I think it is fine for now but probably it will need to be reworked in future.



@@ -480,6 +489,78 @@ bool riscv_isa_extension_available(const unsigned long 
*isa_bitmap,
      return test_bit(id, isa_bitmap);
  }
+static int build_guest_isa_str(char *buf, size_t size,
+                               const unsigned long *isa_bitmap)
+{
+    int total;
+
+#if defined(CONFIG_RISCV_32)
+    total = snprintf(buf, size, "rv32");
+#elif defined(CONFIG_RISCV_64)
+    total = snprintf(buf, size, "rv64");
+#else
+#   error "Unsupported RISC-V bitness"
+#endif
+
+    if ( total < 0 )
+        return total;
+
+    for ( unsigned int i = 0; i < ARRAY_SIZE(riscv_isa_ext); i++ )
+    {
+        const struct riscv_isa_ext_data *ext = &riscv_isa_ext[i];
+        int ret;
+
+        if ( !riscv_isa_extension_available(isa_bitmap, ext->id) )
+            continue;
+
+        ret = snprintf(buf ? buf + total : NULL,
+                       buf ? size - total : 0, "%s%s",

If total > size this subtraction will underflow and a huge value will be
passed to snprintf().

I will add the check before for():

if ( buf && ((size_t)total >= size) )
    return -ENOSPC;

Thanks.

~ Oleksii



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.