On 11.12.2025 13:52, Oleksii Kurochko wrote:
> On 12/11/25 12:02 PM, Jan Beulich wrote:
>> On 11.12.2025 11:29, Oleksii Kurochko wrote:
>>> On 12/8/25 4:05 PM, Jan Beulich wrote:
>>>> On 01.12.2025 11:24, Oleksii Kurochko wrote:
>>>>> --- /dev/null
>>>>> +++ b/xen/arch/riscv/vsbi/vsbi-legacy-extension.c
>>>>> @@ -0,0 +1,37 @@
>>>>> +
>>>>> +/* SPDX-License-Identifier: GPL-2.0-only */
>>>>> +
>>>>> +#include <xen/lib.h>
>>>>> +#include <xen/sched.h>
>>>>> +
>>>>> +#include <asm/processor.h>
>>>>> +#include <asm/vsbi.h>
>>>>> +
>>>>> +static int vsbi_legacy_ecall_handler(struct vcpu *vcpu, unsigned long
>>>>> eid,
>>>>> + unsigned long fid,
>>>>> + struct cpu_user_regs *regs)
>>>>> +{
>>>>> + int ret = 0;
>>>>> +
>>>>> + switch ( eid )
>>>>> + {
>>>>> + case SBI_EXT_0_1_CONSOLE_PUTCHAR:
>>>>> + printk("%c", (char)regs->a0);
>>>> This is guest output, so shouldn't use plain printk().
>>> I think that I don't know what should be used instead. Could you suggest me
>>> something
>>> or point to the code in other arch-s?
>>>
>>> Or do you mean that guest_printk() should be used?
>> No direct replacement will do what you want, as they all prefix something to
>> the
>> string passed (which isn't what you want). You may need to buffer characters
>> and
>> emit them in batches (full lines unless overly long). For x86 see
>> hvm_print_line(),
>> but I think Arm also has something like this.
>
> I don’t recall anything like that for ARM. The only thing related to character
> buffering that I remember is in vpl011_write_data_xen()
> (https://elixir.bootlin.com/xen/v4.21.0/source/xen/arch/arm/vpl011.c#L76),
> but it
> does not use the buf declared in struct domain_console. Instead, it provides a
> separate structure for vpl011:
> struct vpl011_xen_backend {
> char in[SBSA_UART_FIFO_SIZE];
> char out[SBSA_UART_OUT_BUF_SIZE];
> XENCONS_RING_IDX in_cons, in_prod;
> XENCONS_RING_IDX out_prod;
> };
>
> I don’t see that ARM uses struct domain_console.
>
> By the way, I can’t find a counterpart of hvm_print_line() for reading a
> character(s).
> Is domain_console->buf intended to be used only for writing characters?
I don't think there's any particular intention, but of course you can use it
only for one of the two.
Jan