All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Alistair Francis" <alistair.francis@wdc.com>,
	"Bob Eshleman" <bobbyeshleman@gmail.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 v1 3/3] xen/riscv: add RISC-V virtual SBI base extension support for guests
Date: Fri, 12 Dec 2025 17:31:22 +0100	[thread overview]
Message-ID: <23de700d-7ffc-44ac-a8fe-22e69aaaaebf@gmail.com> (raw)
In-Reply-To: <5154e129-675b-4027-b97f-257559c7ea50@gmail.com>


On 12/12/25 4:25 PM, Oleksii Kurochko wrote:
> On 12/8/25 4:15 PM, Jan Beulich wrote:
>> On 01.12.2025 11:24, Oleksii Kurochko wrote:
>>> --- /dev/null
>>> +++ b/xen/arch/riscv/vsbi/vsbi-base-extension.c
>>> @@ -0,0 +1,52 @@
>>> +
>>> +/* SPDX-License-Identifier: GPL-2.0-only */
>>> +
>>> +#include <xen/lib.h>
>>> +#include <xen/sched.h>
>>> +
>>> +#include <asm/processor.h>
>>> +#include <asm/sbi.h>
>>> +#include <asm/vsbi.h>
>>> +
>>> +extern unsigned long __ro_after_init sbi_spec_version;
>>> +extern long __ro_after_init sbi_fw_id;
>>> +extern long __ro_after_init sbi_fw_version;
>>> +
>>> +static int vsbi_base_ecall_handler(struct vcpu *vcpu, unsigned long 
>>> eid,
>>> +                                   unsigned long fid,
>>> +                                   struct cpu_user_regs *regs)
>>> +{
>>> +    int ret = 0;
>>> +    struct sbiret sbi_ret;
>>> +
>>> +    switch ( fid ) {
>>> +    case SBI_EXT_BASE_GET_SPEC_VERSION:
>>> +        regs->a1 = sbi_spec_version;
>> Wouldn't this need to be the minimum of what firmware supports and 
>> what Xen
>> supports / knows about? (Assuming backward compatibility among the spec
>> versions of course.)
>
> The base extension is mandatory (according to the spec), and based on 
> some Linux
> commits from contributors to the OpenSBI spec, it is also intended to 
> allow
> backward compatibility and probing of future extensions (although I 
> was not able
> to find this explicitly stated in the spec).
>
> However, none of this guarantees that everything else is backward 
> compatible.
> For example, the entire v0.1 SBI has been moved to the legacy 
> extension, which
> is now an optional extension. This is technically a 
> backwards-incompatible
> change because the legacy extension is optional, and v0.1 of the SBI 
> does not
> allow probing.
>
> Regarding what should be written to|regs->a1|, I think you are right: 
> it should
> be the minimum of what the firmware provides and what Xen supports. 
> Otherwise,
> if|sbi_spec_version| is set to 2.0 and we return 2.0 to the guest, the 
> guest might
> try to probe the DBGN (which Xen does not currently support) extension 
> and use
> it instead of the legacy extension for the early console.

I think we could still introduce the following in Xen:
   #define XEN_SBI_VERSION_MAJOR 0
   #define XEN_SBI_VERSION_MINOR 2
and pass it to the guest as:
   regs-> a1 = (XEN_SBI_VERSION_MAJOR << SBI_SPEC_VERSION_MAJOR_SHIFT) | XEN_SBI_VERSION_MINOR;

IMO, this should be sufficient because:
1. We can fully emulate the base extension in Xen without calling into OpenSBI.
    This covers the case where OpenSBI might return version 0.1,which is unlikely, as all
    boards with hypervisor extension support at least 0.2, and in practice even 2.0, while we
    report 0.2 to the guest.
2. Even if OpenSBI returns, for example, version 2.0 and we tell the guest that we support
    0.2, it should still be fine, as the base extension is at least backward compatible.

In other words, I think we should care only about what Xen supports and provide it to a
guest. Any concerns about that?

~ Oleksii



  reply	other threads:[~2025-12-12 16:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01 10:24 [PATCH v1 0/3] RISC-V: Introduce vSBI framework Oleksii Kurochko
2025-12-01 10:24 ` [PATCH v1 1/3] xen/riscv: introduce vSBI extension framework Oleksii Kurochko
2025-12-08 14:25   ` Jan Beulich
2025-12-10 17:03     ` Oleksii Kurochko
2025-12-11  9:23       ` Jan Beulich
2025-12-11 12:00         ` Oleksii Kurochko
2025-12-01 10:24 ` [PATCH v1 2/3] xen/riscv: add RISC-V legacy SBI extension support for guests Oleksii Kurochko
2025-12-08 15:05   ` Jan Beulich
2025-12-11 10:29     ` Oleksii Kurochko
2025-12-11 11:02       ` Jan Beulich
2025-12-11 12:52         ` Oleksii Kurochko
2025-12-11 13:36           ` Jan Beulich
2025-12-01 10:24 ` [PATCH v1 3/3] xen/riscv: add RISC-V virtual SBI base " Oleksii Kurochko
2025-12-08 15:15   ` Jan Beulich
2025-12-12 15:25     ` Oleksii Kurochko
2025-12-12 16:31       ` Oleksii Kurochko [this message]
2025-12-15  8:20       ` Jan Beulich
2025-12-15 10:39         ` 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=23de700d-7ffc-44ac-a8fe-22e69aaaaebf@gmail.com \
    --to=oleksii.kurochko@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=bobbyeshleman@gmail.com \
    --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.