|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 05/26] xen/riscv: introduce guest riscv,isa string
On 5/19/26 2:12 PM, Jan Beulich wrote: On 19.05.2026 13:59, Oleksii Kurochko wrote:On 5/18/26 5:51 PM, Jan Beulich wrote:On 08.05.2026 16:43, Oleksii Kurochko wrote: Oh, I missed to turned off "full match" during search... Or it would be fine just to take something bigger as a const (lets say 2048) and use it for dynamic allocation?I'd rather not. Can't you determine how much space the string is going to occupy? I thought about two options as alternatives:1. Take as a length host RISC-V ISA string but theoretically we can emulate some extensions which aren't mentioned in host RISC-V ISA string so it could be longer. So not a good option.
2. Having two walks in init_guest_isa():
Introduce the following function:
static size_t guest_isa_str_len(const unsigned long *isa_bitmap)
{
size_t len = 4; /* rvX prefix */
for ( unsigned int i = 0; i < ARRAY_SIZE(riscv_isa_ext); i++ )
{
const struct riscv_isa_ext_data *ext = &riscv_isa_ext[i];
if ( !riscv_isa_extension_available(isa_bitmap, ext->id) )
continue;
if ( ext->id >= RISCV_ISA_EXT_BASE )
len++; /* '_' separator */
len += strlen(ext->name);
}
return len + 1; /* NUL terminator */
}
and then:
int init_guest_isa(struct domain *d)
{
bitmap_andnot(d->arch.guest_isa, riscv_isa, guest_unsupp,
RISCV_ISA_EXT_MAX);
size_t len = guest_isa_str_len(d->arch.guest_isa);
d->arch.guest_isa_str = xzalloc_array(char, len);
if ( !d->arch.guest_isa_str )
return -ENOMEM;
/* ... existing snprintf + strlcat loop unchanged ... */
}
If approach 2 is a good one I can follow it.
~ Oleksii
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |