Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EAA61D41C31 for ; Thu, 11 Dec 2025 12:52:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1184037.1506579 (Exim 4.92) (envelope-from ) id 1vTg9O-00043i-Jl; Thu, 11 Dec 2025 12:52:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1184037.1506579; Thu, 11 Dec 2025 12:52:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vTg9O-00043b-H9; Thu, 11 Dec 2025 12:52:06 +0000 Received: by outflank-mailman (input) for mailman id 1184037; Thu, 11 Dec 2025 12:52:05 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vTg9N-00043T-1r for xen-devel@lists.xenproject.org; Thu, 11 Dec 2025 12:52:05 +0000 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [2a00:1450:4864:20::536]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3084ef9a-d690-11f0-9cce-f158ae23cfc8; Thu, 11 Dec 2025 13:52:03 +0100 (CET) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-64951939e1eso87643a12.1 for ; Thu, 11 Dec 2025 04:52:02 -0800 (PST) Received: from [192.168.1.6] (user-109-243-71-38.play-internet.pl. [109.243.71.38]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b7cfa2e6dc1sm261121066b.17.2025.12.11.04.52.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Dec 2025 04:52:01 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3084ef9a-d690-11f0-9cce-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765457522; x=1766062322; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=gjHKG9zHoHi2T4haNYd1lNI7CXkznaRBQj6DUEU14rQ=; b=SiR60E7m3EIdK0ibBl95mscqPeSmeU2giQ34N/sIcNI/RnMw9BpXSe17qREe1DXxQj LGRG2+TcVyOzBRZrkRvbzZvU+UkKTqzjYd/unWSmxcWaZHOWXbV++93cl8ySwc3MYr1X melgHdfkqNI7HPPeg+DA4YIc7RtjRC04zqXWZoelZDLyvdfPtk3SDt2aZSYVIP0/+LOq 5ayI1Cat/c/AZbM5WjQHPro7eKs8LZHb0glbcaB+9hPpUVrpNXJPW1ewA+FTmwDxcetC V4WcWmyYtfqj+8ltHozHmxCP17EvzRDfo3P2X6SMjEdMfV56Wt/69O5lJHq6daqY/Xj7 A8uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765457522; x=1766062322; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gjHKG9zHoHi2T4haNYd1lNI7CXkznaRBQj6DUEU14rQ=; b=B/sKamnN2DEoETENg4ix4sb0rRieA6oSk6Cyzvzb8TynvM03qlvdJ6LL4MIReU6zsS PvkH9uoK5XiLmovMXVUvrzCcVnvfXQ0PiQr4wnDfA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cVTzXzPMiRM2Q== X-Received: by 2002:a17:907:75e1:b0:b7d:11ae:4006 with SMTP id a640c23a62f3a-b7d11ae4373mr20001966b.52.1765457521866; Thu, 11 Dec 2025 04:52:01 -0800 (PST) Message-ID: <60e200ad-96d3-4384-b9a6-458256f87256@gmail.com> Date: Thu, 11 Dec 2025 13:52:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 2/3] xen/riscv: add RISC-V legacy SBI extension support for guests To: Jan Beulich Cc: Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , xen-devel@lists.xenproject.org References: <2c84660b-4333-42f9-b178-aab72be9a40d@suse.com> Content-Language: en-US From: Oleksii Kurochko In-Reply-To: <2c84660b-4333-42f9-b178-aab72be9a40d@suse.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 >>>> +#include >>>> + >>>> +#include >>>> +#include >>>> + >>>> +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? > >>>> + default: >>>> + panic("%s: Unsupported ecall: FID: #%lx, EID: #%lx\n", >>>> + __func__, fid, eid); >>> Please don't. domain_crash() may be okay to use here, but crashing the hypervisor >>> because of unexpected guest input isn't okay. >> |domain_crash()| is better. I also considered just returning|SBI_ERR_NOT_SUPPORTED|, >> but it wasn’t too convenient for debugging which FID/EID the guest was called, >> so I started using|panic()| instead. > FTAOD - domain_crash() is acceptable here while things are still under development. > It shouldn't stay like this in the end though: Guests should not be punished like > this for something Xen hasn't implemented. Agree, I will create a task in my Xen's repo to not forget to drop panic()/domain_crash(). ~ Oleksii