[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 1/1] xen/riscv: add RISC-V virtual SBI base extension support for guests


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 6 Jan 2026 10:55:31 +0100
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 06 Jan 2026 09:55:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06.01.2026 10:30, Oleksii Kurochko wrote:
> On 1/5/26 5:26 PM, Jan Beulich wrote:
>> On 30.12.2025 16:50, Oleksii Kurochko wrote:
>>> Add support of virtual SBI base extension calls for RISC-V guests, 
>>> delegating
>>> hardware-specific queries to the underlying SBI and handling version and
>>> firmware ID queries directly.
>>>
>>> The changes include:
>>> 1. Define new SBI base extension function IDs (SBI_EXT_BASE_GET_MVENDORID,
>>>     SBI_EXT_BASE_GET_MARCHID, SBI_EXT_BASE_GET_MIMPID).
>>> 2. Introduce XEN_SBI_VER_MAJOR, XEN_SBI_VER_MINOR for imeplenataion of
>>>     SBI_EXT_BASE_GET_SPEC_VERSION.
>>> 4. Introduce SBI_XEN_IMPID to implement SBI_EXT_BASE_GET_IMP_ID.
>>> 5. Implement handling of SBI base extension functions, including version,
>>>     firmware ID, and machine-specific queries.
>>>
>>> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
>> Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> Thanks.
> 
>> Albeit with a question:
>>
>>> --- /dev/null
>>> +++ b/xen/arch/riscv/vsbi/base-extension.c
>>> @@ -0,0 +1,82 @@
>>> +
>>> +/* SPDX-License-Identifier: GPL-2.0-only */
>>> +
>>> +#include <xen/lib.h>
>>> +#include <xen/sched.h>
>>> +#include <xen/version.h>
>>> +
>>> +#include <asm/processor.h>
>>> +#include <asm/sbi.h>
>>> +#include <asm/vsbi.h>
>>> +
>>> +/* Xen-controlled SBI version reported to guests */
>>> +#define XEN_SBI_VER_MAJOR 0
>>> +#define XEN_SBI_VER_MINOR 2
>> Is it clear from whatever spec it is that is ...
>>
>>> +static int vsbi_base_ecall_handler(unsigned long eid, unsigned long fid,
>>> +                                   struct cpu_user_regs *regs)
>>> +{
>>> +    int ret = 0;
>>> +    struct sbiret sbi_ret;
>>> +
>>> +    ASSERT(eid == SBI_EXT_BASE);
>>> +
>>> +    switch ( fid )
>>> +    {
>>> +    case SBI_EXT_BASE_GET_SPEC_VERSION:
>>> +        regs->a1 = MASK_INSR(XEN_SBI_VER_MAJOR, 
>>> SBI_SPEC_VERSION_MAJOR_MASK) |
>>> +                   XEN_SBI_VER_MINOR;
>>> +        break;
>> ... implied here (it's ..._SPEC_VERSION after all) under what conditions the
>> version would need bumping and what effects this would have on existing (e.g.
>> migrating-in) guests? Recall that ...
> 
> For example, sooner or later we will want to use the SBI DBCN (Debug Console
> Extension) for early debug output for guests, as it provides an API to work 
> with
> strings instead of single characters. This will require bumping the SBI 
> version
> to 2.0.

I fear there's a misunderstanding here, likely on my side: Why would it be 2.0?
Didn't you say the version is Xen controlled? If so, why not 0.3 or 1.0?

Contrary to what you said previously, it now looks to me as if the version
wasn't "Xen-controlled", but instead what we pick reflects functionality
required by a particular spec version of a spec we do not control. That's
"SBI version implemented by Xen" to me though, not really a "Xen-controlled"
version.

Jan

> I don’t think this should cause any migration issues. If a guest was fully 
> booted
> and running with Xen SBI version 0.2, it would continue to use the legacy 
> extension
> for early console output (or for hvc console which is using SBI calls in 
> Linux for
> the moment). If the guest was still in the initialization stage (before SBI
> extensions were probed), it would simply use the newer SBI DBCN extension 
> instead
> of the Legacy one.
> 
> ~ Oleksii
> 
>>
>>> +    case SBI_EXT_BASE_GET_IMP_ID:
>>> +        regs->a1 = SBI_XEN_IMPID;
>>> +        break;
>>> +
>>> +    case SBI_EXT_BASE_GET_IMP_VERSION:
>>> +        regs->a1 = (xen_major_version() << 16) | xen_minor_version();
>>> +        break;
>>> +
>>> +    case SBI_EXT_BASE_GET_MVENDORID:
>>> +    case SBI_EXT_BASE_GET_MARCHID:
>>> +    case SBI_EXT_BASE_GET_MIMPID:
>>> +        if ( is_hardware_domain(current->domain) )
>>> +        {
>>> +            sbi_ret = sbi_ecall(SBI_EXT_BASE, fid, 0, 0, 0, 0, 0, 0);
>>> +            ret = sbi_ret.error;
>>> +            regs->a1 = sbi_ret.value;
>>> +        }
>>> +        else
>>> +            /*
>>> +             * vSBI should present a consistent, virtualized view to 
>>> guests.
>>> +             * In particular, DomU-visible data must remain stable across
>>> +             * migration and must not expose hardware-specific details.
>> ... what is being said here applies to other sub-functions as well. IOW it
>> looks to me as if the version reported needs to be a per-guest property.
>>
>> Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.