All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Romain Caritey" <Romain.Caritey@microchip.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Connor Davis" <connojdavis@gmail.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Julien Grall" <julien@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v2 05/26] xen/riscv: introduce guest riscv,isa string
Date: Tue, 19 May 2026 13:59:56 +0200	[thread overview]
Message-ID: <f032149e-aa99-4976-8012-39bd01d4a653@gmail.com> (raw)
In-Reply-To: <364abd6e-4fff-437a-90c8-bb4489f0c51d@suse.com>



On 5/18/26 5:51 PM, Jan Beulich wrote:
> On 08.05.2026 16:43, Oleksii Kurochko wrote:
>> @@ -480,6 +488,53 @@ bool riscv_isa_extension_available(const unsigned long *isa_bitmap,
>>       return test_bit(id, isa_bitmap);
>>   }
>>   
>> +int init_guest_isa(struct domain *d)
>> +{
>> +    char *buf = d->arch.guest_isa_str;
>> +    size_t len = sizeof(d->arch.guest_isa_str);
> 
> Seeing these uses: Is the "guest" prefix really of much use here?
> 
>> +    bitmap_andnot(d->arch.guest_isa, riscv_isa, guest_unsupp,
>> +                  RISCV_ISA_EXT_MAX);
> 
> Same question here, clearly.

I will drop "guest" prefix for "d->arch.guest_isa_str".


> 
>> +#if defined(CONFIG_RISCV_32)
>> +    if ( snprintf(buf, len, "rv32") >= len )
>> +        return -ENOBUFS;
>> +#elif defined(CONFIG_RISCV_64)
>> +    if ( snprintf(buf, len, "rv64") >= len )
>> +        return -ENOBUFS;
>> +#else
>> +#   error "Unsupported RISC-V bitness"
>> +#endif
>> +
>> +    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(d->arch.guest_isa, ext->id) )
>> +            continue;
>> +
>> +        if ( ext->id >= RISCV_ISA_EXT_BASE && strlcat(buf, "_", len) >= len )
>> +            return -ENOBUFS;
>> +
>> +        if ( strlcat(buf, ext->name, len) >= len )
>> +            return -ENOBUFS;
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>> +static void __init init_guest_unsupp(void)
>> +{
>> +    set_bit(RISCV_ISA_EXT_f, guest_unsupp);
>> +    set_bit(RISCV_ISA_EXT_d, guest_unsupp);
>> +    set_bit(RISCV_ISA_EXT_q, guest_unsupp);
>> +    set_bit(RISCV_ISA_EXT_v, guest_unsupp);
>> +    set_bit(RISCV_ISA_EXT_h, guest_unsupp);
>> +    set_bit(RISCV_ISA_EXT_sstc, guest_unsupp);
>> +    set_bit(RISCV_ISA_EXT_svade, guest_unsupp);
>> +    set_bit(RISCV_ISA_EXT_svpbmt, guest_unsupp);
>> +}
> 
> These don't need to be atomic, do they? I.e. __set_bit() would suffice.

Agree, __set_bit() would be enough.


> 
>> --- a/xen/arch/riscv/include/asm/cpufeature.h
>> +++ b/xen/arch/riscv/include/asm/cpufeature.h
>> @@ -17,6 +17,8 @@
>>    */
>>   #define RISCV_ISA_EXT_BASE  26
>>   
>> +#define RISCV_GUEST_ISA_STR_MAX 256
> 
> This looks like it won't be good for very long, seeing how long ISA strings can
> get. I wonder anyway whether ...
> 
>> @@ -94,6 +95,9 @@ struct arch_domain {
>>       struct p2m_domain p2m;
>>   
>>       struct paging_domain paging;
>> +
>> +    DECLARE_BITMAP(guest_isa, RISCV_ISA_EXT_MAX);
>> +    char guest_isa_str[RISCV_GUEST_ISA_STR_MAX];
> 
> ... a compile-time sized buffer is suitable here. Can't you allocate a buffer
> just large enough to hold the string?

It could be allocated dynamically.

Does it make sense to evaluate in run-time what should be a buffer size? 
For this case I can't find analogue of realloc() in Xen. Or it would be 
fine just to take something bigger as a const (lets say 2048) and use it 
for dynamic allocation?

Thanks.

~ Oleksii


  reply	other threads:[~2026-05-19 12:00 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 14:43 [PATCH v2 00/26] Introduce enablemenant of dom0less Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 01/26] xen: arm: update p2m_set_allocation() prototype Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 02/26] xen/riscv: Implement ARCH_PAGING_MEMPOOL Oleksii Kurochko
2026-05-18 15:13   ` Jan Beulich
2026-05-19  9:27     ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 03/26] xen/riscv: Implement construct_domain() Oleksii Kurochko
2026-05-18 15:33   ` Jan Beulich
2026-05-19  9:28     ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 04/26] xen/riscv: implement prerequisites for domain_create() Oleksii Kurochko
2026-05-18 15:43   ` Jan Beulich
2026-05-19 11:33     ` Oleksii Kurochko
2026-05-19 11:47       ` Jan Beulich
2026-05-08 14:43 ` [PATCH v2 05/26] xen/riscv: introduce guest riscv,isa string Oleksii Kurochko
2026-05-18 15:51   ` Jan Beulich
2026-05-19 11:59     ` Oleksii Kurochko [this message]
2026-05-19 12:12       ` Jan Beulich
2026-05-19 13:24         ` Oleksii Kurochko
2026-05-19 13:40           ` Jan Beulich
2026-05-19 14:49             ` Oleksii Kurochko
2026-05-19 14:53               ` Jan Beulich
2026-05-19 15:17                 ` Oleksii Kurochko
2026-05-19 15:56                   ` Jan Beulich
2026-05-19 16:21                     ` Oleksii Kurochko
2026-05-20  6:13                       ` Jan Beulich
2026-05-20  7:28                         ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 06/26] xen/riscv: implement make_cpus_node() Oleksii Kurochko
2026-05-18 16:00   ` Jan Beulich
2026-05-19 13:33     ` Oleksii Kurochko
2026-05-19 13:42       ` Jan Beulich
2026-05-08 14:43 ` [PATCH v2 07/26] xen/riscv: implement make_timer_node() Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 08/26] xen/riscv: implement make_arch_nodes() Oleksii Kurochko
2026-05-21 13:20   ` Jan Beulich
2026-05-08 14:43 ` [PATCH v2 09/26] xen/riscv: introduce init interrupt controller operations Oleksii Kurochko
2026-05-21 13:25   ` Jan Beulich
2026-05-22 14:38     ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 10/26] xen/riscv: implement make_intc_domU_node() Oleksii Kurochko
2026-05-21 13:30   ` Jan Beulich
2026-05-22 14:45     ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 11/26] xen/riscv: introduce aia_init() and aia_usable() Oleksii Kurochko
2026-05-21 14:57   ` Jan Beulich
2026-05-22 14:55     ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 12/26] xen/riscv: add basic VGEIN management for AIA guests Oleksii Kurochko
2026-05-21 15:11   ` Jan Beulich
2026-05-22 15:43     ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 13/26] xen/riscv: introduce per-vCPU IMSIC state Oleksii Kurochko
2026-05-21 15:24   ` Jan Beulich
2026-05-22 15:50     ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 14/26] xen/riscv: add very early virtual APLIC (vAPLIC) initialization support Oleksii Kurochko
2026-06-03 14:54   ` Jan Beulich
2026-06-04 11:29     ` Oleksii Kurochko
2026-06-05  7:22       ` Jan Beulich
2026-06-05 11:59       ` Oleksii Kurochko
2026-06-05 12:05         ` Jan Beulich
2026-05-08 14:43 ` [PATCH v2 15/26] xen/riscv: introduce (de)initialization helpers for vINTC Oleksii Kurochko
2026-06-03 15:00   ` Jan Beulich
2026-06-04 11:33     ` Oleksii Kurochko
2026-06-05  7:26       ` Jan Beulich
2026-06-05  9:25         ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 16/26] xen/riscv: create APLIC DT node for guest domains Oleksii Kurochko
2026-06-03 15:10   ` Jan Beulich
2026-06-04 11:54     ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 17/26] xen/riscv: generate IMSIC " Oleksii Kurochko
2026-06-03 15:21   ` Jan Beulich
2026-06-04 14:21     ` Oleksii Kurochko
2026-06-05  7:31       ` Jan Beulich
2026-06-05  9:29         ` Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 18/26] xen: move declaration of map_device_irqs_to_domain() to common header Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 19/26] xen/riscv: implement IRQ routing for device passthrough Oleksii Kurochko
2026-06-03 16:01   ` Jan Beulich
2026-06-04 15:35     ` Oleksii Kurochko
2026-06-05  7:38       ` Jan Beulich
2026-05-08 14:43 ` [PATCH v2 20/26] xen/riscv: add missing APLIC register offsets, masks to asm/aplic.h Oleksii Kurochko
2026-06-03 15:36   ` Jan Beulich
2026-06-05  8:48     ` Oleksii Kurochko
2026-06-05  9:07       ` Jan Beulich
2026-05-08 14:43 ` [PATCH v2 21/26] xen/riscv: implement virtual APLIC MMIO emulation Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 22/26] xen/riscv: implement init_intc_phandle() Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 23/26] xen/riscv: initialize RCU, scheduler, and system domains in start_xen() Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 24/26] xen/riscv: provide init_vuart() Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 25/26] xen/riscv: add initial dom0less infrastructure support Oleksii Kurochko
2026-05-08 14:43 ` [PATCH v2 26/26] xen/riscv: manage IRQ_DISABLED flag in APLIC irq enable/disable callbacks Oleksii Kurochko
2026-05-18 15:38 ` [PATCH v2 00/26] Introduce enablemenant of dom0less Jan Beulich
2026-05-19  9:26   ` Oleksii Kurochko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f032149e-aa99-4976-8012-39bd01d4a653@gmail.com \
    --to=oleksii.kurochko@gmail.com \
    --cc=Romain.Caritey@microchip.com \
    --cc=alistair.francis@wdc.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=connojdavis@gmail.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.