From: Atish Patra <atish.patra@linux.dev>
To: "Radim Krčmář" <rkrcmar@ventanamicro.com>,
"Anup Patel" <apatel@ventanamicro.com>
Cc: kvm-riscv@lists.infradead.org, kvm@vger.kernel.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Anup Patel <anup@brainfault.org>,
Atish Patra <atishp@atishpatra.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
Andrew Jones <ajones@ventanamicro.com>
Subject: Re: [PATCH v3 0/2] RISC-V: KVM: VCPU reset fixes
Date: Fri, 23 May 2025 10:44:37 -0700 [thread overview]
Message-ID: <7ad8cfad-745f-4626-a2ce-eab33998a711@linux.dev> (raw)
In-Reply-To: <DA3FGGI5PEZG.3T26KJXT2QO8M@ventanamicro.com>
On 5/23/25 2:20 AM, Radim Krčmář wrote:
> 2025-05-23T13:38:26+05:30, Anup Patel <apatel@ventanamicro.com>:
>> On Fri, May 23, 2025 at 12:47 PM Radim Krčmář <rkrcmar@ventanamicro.com> wrote:
>>> 2025-05-22T14:43:40-07:00, Atish Patra <atish.patra@linux.dev>:
>>>> On 5/15/25 7:37 AM, Radim KrÄmáŠwrote:
>>>>> Hello,
>>>>>
>>>>> the design still requires a discussion.
>>>>>
>>>>> [v3 1/2] removes most of the additional changes that the KVM capability
>>>>> was doing in v2. [v3 2/2] is new and previews a general solution to the
>>>>> lack of userspace control over KVM SBI.
>>>>>
>>>> I am still missing the motivation behind it. If the motivation is SBI
>>>> HSM suspend, the PATCH2 doesn't achieve that as it forwards every call
>>>> to the user space. Why do you want to control hsm start/stop from the
>>>> user space ?
>>> HSM needs fixing, because KVM doesn't know what the state after
>>> sbi_hart_start should be.
>>> For example, we had a discussion about scounteren and regardless of what
>>> default we choose in KVM, the userspace might want a different value.
>>> I don't think that HSM start/stop is a hot path, so trapping to
>>> userspace seems better than adding more kernel code.
>> There are no implementation specific S-mode CSR reset values
>> required at the moment.
> Jessica mentioned that BSD requires scounteren to be non-zero, so
> userspace should be able to provide that value.
Jessica admitted that it was a bug which should be fixed.
> I would prefer if KVM could avoid getting into those discussions.
> We can just just let userspace be as crazy as it wants.
The scounteren state you mentioned is already fixed now.
I would prefer to do this if there are more of these issues. Otherwise,
we may gain little by just delegating more work to the userspace for no
reason.
>> Whenever the need arises, we will extend
>> the ONE_REG interface so that user space can specify custom
>> CSR reset values at Guest/VM creation time. We don't need to
>> forward SBI HSM calls to user space for custom S-mode CSR
>> reset values.
> The benefits of adding a new ONE_REG interface seem very small compared
> to the drawbacks of having extra kernel code.
How ? The extra kernel code is just few lines where it just registers a
SBI extension and forwards
it to the userspace. That's for the entire extension.
For extensions like HSM, only selective functions that should be
forwarded to the userspace which
defeats the purpose.
Let's not try to fix something that is not broken yet.
> If userspace would want to reset or setup new multi-VCPUs VMs often, we
> could add an interface that loads the whole register state from
> userspace in a single IOCTL, because ONE_REG is not the best interface
> for bulk data transfer either.
>
>>> Forwarding all the unimplemented SBI ecalls shouldn't be a performance
>>> issue, because S-mode software would hopefully learn after the first
>>> error and stop trying again.
>>>
>>> Allowing userspace to fully implement the ecall instruction one of the
>>> motivations as well -- SBI is not a part of RISC-V ISA, so someone might
>>> be interested in accelerating a different M-mode software with KVM.
>>>
>>> I'll send v4 later today -- there is a missing part in [2/2], because
>>> userspace also needs to be able to emulate the base SBI extension.
>>>
>> [...] The best approach is to selectively forward SBI
>> calls to user space where needed (e.g. SBI system reset,
>> SBI system suspend, SBI debug console, etc.).
> That is exactly what my proposal does, it's just that the userspace says
> what is "needed".
>
> If we started with this mechanism, KVM would not have needed to add
> SRST/SUSP/DBCN SBI emulation at all -- they would be forwarded as any
> other unhandled ecall.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-05-23 17:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 14:37 [PATCH v3 0/2] RISC-V: KVM: VCPU reset fixes Radim Krčmář
2025-05-15 14:37 ` [PATCH v3 1/2] RISC-V: KVM: add KVM_CAP_RISCV_MP_STATE_RESET Radim Krčmář
2025-05-16 12:25 ` Anup Patel
2025-05-19 12:25 ` Radim Krčmář
2025-05-20 15:43 ` Anup Patel
2025-05-15 14:37 ` [PATCH v3 2/2] RISC-V: KVM: add KVM_CAP_RISCV_USERSPACE_SBI Radim Krčmář
2025-05-22 21:43 ` [PATCH v3 0/2] RISC-V: KVM: VCPU reset fixes Atish Patra
2025-05-23 7:17 ` Radim Krčmář
2025-05-23 8:08 ` Anup Patel
2025-05-23 9:20 ` Radim Krčmář
2025-05-23 17:44 ` Atish Patra [this message]
2025-05-24 9:59 ` Anup Patel
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=7ad8cfad-745f-4626-a2ce-eab33998a711@linux.dev \
--to=atish.patra@linux.dev \
--cc=ajones@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=apatel@ventanamicro.com \
--cc=atishp@atishpatra.org \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=rkrcmar@ventanamicro.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox