All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@ventanamicro.com>
To: "Anup Patel" <apatel@ventanamicro.com>
Cc: <ventana-sw-patches@ventanamicro.com>,
	"Daniel Henrique Barboza" <dbarboza@ventanamicro.com>,
	"Andrew Jones" <ajones@ventanamicro.com>,
	<stable@vger.kernel.org>
Subject: Re: [PATCH] KVM: RISC-V: reset smstateen CSRs
Date: Tue, 25 Mar 2025 18:08:37 +0100	[thread overview]
Message-ID: <D8PIGUPV6622.4Z9G0C5FRLRK@ventanamicro.com> (raw)
In-Reply-To: <CAK9=C2V90_GX6u_M2hOh62J1xxVx-ioenSqz316BNWPt3Lr0dw@mail.gmail.com>

2025-03-25T22:27:41+05:30, Anup Patel <apatel@ventanamicro.com>:
> On Tue, Mar 25, 2025 at 8:58 PM Anup Patel <apatel@ventanamicro.com> wrote:
>>
>> On Tue, Mar 25, 2025 at 12:01 AM Radim Krčmář <rkrcmar@ventanamicro.com> wrote:
>> >
>> > Hi, I'm sending this early to ventana-sw as we hit the issue in today's
>> > slack discussion.  I only compile-tested it so far and it will take me a
>> > while to trigger a bug and verify the solution.
>> >
>> > ---8<--
>> > The smstateen CSRs control which stateful features are enabled in
>> > VU-mode.  SU-mode must properly context switch the state of all enabled
>> > features.
>> >
>> > Reset the smstateen CSRs, because SU-mode might not know that it must
>> > context switch the state.  Reset unconditionally as it is shorter and
>> > safer, and not that much slower.
>> >
>> > Fixes: 81f0f314fec9 ("RISCV: KVM: Add sstateen0 context save/restore")
>> > Cc: stable@vger.kernel.org
>> > Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com>
>>
>> How about moving "struct kvm_vcpu_smstateen_csr smstateen" from
>> "struct kvm_vcpu_arch" to "struct kvm_vcpu_csr". This way we will not
>> need an extra "struct kvm_vcpu_smstateen_csr reset_smstateen_csr"
>> in "struct kvm_vcpu_csr".

It is tricky, because kvm_riscv_vcpu_general_set_csr calculates the
amount of registers accessible to userspace based the on size of
kvm_vcpu_csr.

We'd have to make changes to logic before expanding kvm_vcpu_csr with
kvm_vcpu_smstateen_csr.  At that point, I think it be much easier to
just put all csrs to kvm_vcpu_csr directly, which would also simplify
future extensions.

> Other than my comment, this looks good for upstreaming.

I think the current version is more appropriate for stable, and we can
implement your suggestion afterwards.

Thanks.

  reply	other threads:[~2025-03-25 17:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-24 18:26 [PATCH] KVM: RISC-V: reset smstateen CSRs Radim Krčmář
2025-03-25 15:28 ` Anup Patel
2025-03-25 16:57   ` Anup Patel
2025-03-25 17:08     ` Radim Krčmář [this message]
2025-03-26  6:14       ` 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=D8PIGUPV6622.4Z9G0C5FRLRK@ventanamicro.com \
    --to=rkrcmar@ventanamicro.com \
    --cc=ajones@ventanamicro.com \
    --cc=apatel@ventanamicro.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=stable@vger.kernel.org \
    --cc=ventana-sw-patches@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 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.