From: Sean Christopherson <seanjc@google.com>
To: Atish Kumar Patra <atishp@rivosinc.com>
Cc: Anup Patel <anup@brainfault.org>,
Atish Patra <atishp@atishpatra.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alexandre Ghiti <alex@ghiti.fr>,
Andrew Jones <ajones@ventanamicro.com>,
Anup Patel <apatel@ventanamicro.com>,
kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RISC-V: KVM: Teardown riscv specific bits after kvm_exit
Date: Wed, 26 Mar 2025 18:55:55 -0700 [thread overview]
Message-ID: <Z-SwK1xO_S4phG2o@google.com> (raw)
In-Reply-To: <CAHBxVyFLeZFwEnJYa-oUbAKVimdVsr=Ct76Jf=TyWeoAkHe8yQ@mail.gmail.com>
On Thu, Mar 20, 2025, Atish Kumar Patra wrote:
> On Mon, Mar 17, 2025 at 9:08 AM Sean Christopherson <seanjc@google.com> wrote:
> > On Mon, Mar 17, 2025, Atish Patra wrote:
> > > arch/riscv/kvm/main.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c
> > > index 1fa8be5ee509..4b24705dc63a 100644
> > > --- a/arch/riscv/kvm/main.c
> > > +++ b/arch/riscv/kvm/main.c
> > > @@ -172,8 +172,8 @@ module_init(riscv_kvm_init);
> > >
> > > static void __exit riscv_kvm_exit(void)
> > > {
> > > - kvm_riscv_teardown();
> > > -
> > > kvm_exit();
> > > +
> > > + kvm_riscv_teardown();
> >
> > I wonder if there's a way we can guard against kvm_init()/kvm_exit() being called
> > too early/late. x86 had similar bugs for a very long time, e.g. see commit
> > e32b120071ea ("KVM: VMX: Do _all_ initialization before exposing /dev/kvm to userspace").
> >
> > E.g. maybe we do something like create+destroy a VM at the end of kvm_init() and
> > the beginning of kvm_exit()? Not sure if that would work for kvm_exit(), but it
> > should definitely be fine for kvm_init().
> >
> Yes. That would be super useful. I am not sure about the exact
> mechanism to achieve that though.
Me either :-)
> Do you just test code guarded within a new config that just
> creates/destroys a dummy VM ?
That's only idea I could come up with too, but I don't particulary like it.
> May be kunit test for KVM fits here in some way ?
I don't think a kunit test would be a good fit, there are likely too many
dependencies, and I'm pretty sure we'd still need to hack KVM.
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Sean Christopherson <seanjc@google.com>
To: Atish Kumar Patra <atishp@rivosinc.com>
Cc: Anup Patel <anup@brainfault.org>,
Atish Patra <atishp@atishpatra.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alexandre Ghiti <alex@ghiti.fr>,
Andrew Jones <ajones@ventanamicro.com>,
Anup Patel <apatel@ventanamicro.com>,
kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RISC-V: KVM: Teardown riscv specific bits after kvm_exit
Date: Wed, 26 Mar 2025 18:55:55 -0700 [thread overview]
Message-ID: <Z-SwK1xO_S4phG2o@google.com> (raw)
In-Reply-To: <CAHBxVyFLeZFwEnJYa-oUbAKVimdVsr=Ct76Jf=TyWeoAkHe8yQ@mail.gmail.com>
On Thu, Mar 20, 2025, Atish Kumar Patra wrote:
> On Mon, Mar 17, 2025 at 9:08 AM Sean Christopherson <seanjc@google.com> wrote:
> > On Mon, Mar 17, 2025, Atish Patra wrote:
> > > arch/riscv/kvm/main.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c
> > > index 1fa8be5ee509..4b24705dc63a 100644
> > > --- a/arch/riscv/kvm/main.c
> > > +++ b/arch/riscv/kvm/main.c
> > > @@ -172,8 +172,8 @@ module_init(riscv_kvm_init);
> > >
> > > static void __exit riscv_kvm_exit(void)
> > > {
> > > - kvm_riscv_teardown();
> > > -
> > > kvm_exit();
> > > +
> > > + kvm_riscv_teardown();
> >
> > I wonder if there's a way we can guard against kvm_init()/kvm_exit() being called
> > too early/late. x86 had similar bugs for a very long time, e.g. see commit
> > e32b120071ea ("KVM: VMX: Do _all_ initialization before exposing /dev/kvm to userspace").
> >
> > E.g. maybe we do something like create+destroy a VM at the end of kvm_init() and
> > the beginning of kvm_exit()? Not sure if that would work for kvm_exit(), but it
> > should definitely be fine for kvm_init().
> >
> Yes. That would be super useful. I am not sure about the exact
> mechanism to achieve that though.
Me either :-)
> Do you just test code guarded within a new config that just
> creates/destroys a dummy VM ?
That's only idea I could come up with too, but I don't particulary like it.
> May be kunit test for KVM fits here in some way ?
I don't think a kunit test would be a good fit, there are likely too many
dependencies, and I'm pretty sure we'd still need to hack KVM.
WARNING: multiple messages have this Message-ID (diff)
From: Sean Christopherson <seanjc@google.com>
To: Atish Kumar Patra <atishp@rivosinc.com>
Cc: Anup Patel <anup@brainfault.org>,
Atish Patra <atishp@atishpatra.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alexandre Ghiti <alex@ghiti.fr>,
Andrew Jones <ajones@ventanamicro.com>,
Anup Patel <apatel@ventanamicro.com>,
kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RISC-V: KVM: Teardown riscv specific bits after kvm_exit
Date: Wed, 26 Mar 2025 18:55:55 -0700 [thread overview]
Message-ID: <Z-SwK1xO_S4phG2o@google.com> (raw)
In-Reply-To: <CAHBxVyFLeZFwEnJYa-oUbAKVimdVsr=Ct76Jf=TyWeoAkHe8yQ@mail.gmail.com>
On Thu, Mar 20, 2025, Atish Kumar Patra wrote:
> On Mon, Mar 17, 2025 at 9:08 AM Sean Christopherson <seanjc@google.com> wrote:
> > On Mon, Mar 17, 2025, Atish Patra wrote:
> > > arch/riscv/kvm/main.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c
> > > index 1fa8be5ee509..4b24705dc63a 100644
> > > --- a/arch/riscv/kvm/main.c
> > > +++ b/arch/riscv/kvm/main.c
> > > @@ -172,8 +172,8 @@ module_init(riscv_kvm_init);
> > >
> > > static void __exit riscv_kvm_exit(void)
> > > {
> > > - kvm_riscv_teardown();
> > > -
> > > kvm_exit();
> > > +
> > > + kvm_riscv_teardown();
> >
> > I wonder if there's a way we can guard against kvm_init()/kvm_exit() being called
> > too early/late. x86 had similar bugs for a very long time, e.g. see commit
> > e32b120071ea ("KVM: VMX: Do _all_ initialization before exposing /dev/kvm to userspace").
> >
> > E.g. maybe we do something like create+destroy a VM at the end of kvm_init() and
> > the beginning of kvm_exit()? Not sure if that would work for kvm_exit(), but it
> > should definitely be fine for kvm_init().
> >
> Yes. That would be super useful. I am not sure about the exact
> mechanism to achieve that though.
Me either :-)
> Do you just test code guarded within a new config that just
> creates/destroys a dummy VM ?
That's only idea I could come up with too, but I don't particulary like it.
> May be kunit test for KVM fits here in some way ?
I don't think a kunit test would be a good fit, there are likely too many
dependencies, and I'm pretty sure we'd still need to hack KVM.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-03-27 1:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 7:41 [PATCH] RISC-V: KVM: Teardown riscv specific bits after kvm_exit Atish Patra
2025-03-17 7:41 ` Atish Patra
2025-03-17 7:41 ` Atish Patra
2025-03-17 16:08 ` Sean Christopherson
2025-03-17 16:08 ` Sean Christopherson
2025-03-17 16:08 ` Sean Christopherson
2025-03-20 23:44 ` Atish Kumar Patra
2025-03-20 23:44 ` Atish Kumar Patra
2025-03-20 23:44 ` Atish Kumar Patra
2025-03-27 1:55 ` Sean Christopherson [this message]
2025-03-27 1:55 ` Sean Christopherson
2025-03-27 1:55 ` Sean Christopherson
2025-03-19 6:34 ` Anup Patel
2025-03-19 6:34 ` Anup Patel
2025-03-19 6:34 ` Anup Patel
2025-03-19 15:37 ` Anup Patel
2025-03-19 15:37 ` Anup Patel
2025-03-19 15:37 ` 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=Z-SwK1xO_S4phG2o@google.com \
--to=seanjc@google.com \
--cc=ajones@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=apatel@ventanamicro.com \
--cc=atishp@atishpatra.org \
--cc=atishp@rivosinc.com \
--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 \
/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.