Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Suzuki Poulose <suzuki.lkml@gmail.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Will Deacon <Will.Deacon@arm.com>,
	Marc Zyngier <Marc.Zyngier@arm.com>,
	Suzuki Poulose <Suzuki.Poulose@arm.com>
Subject: Re: [KVMTOOL][PATCH] Handle KVM_EXIT_SYSTEM_EVENT on any VCPU
Date: Thu, 3 Sep 2015 11:48:17 +0100	[thread overview]
Message-ID: <20150903104817.GB10583@leverpostej> (raw)
In-Reply-To: <CABDioYJgtVJ2DTA_4SvzrteCdOhFCzarJYJFuYwa2PaSs_KFWA@mail.gmail.com>

On Thu, Sep 03, 2015 at 11:24:29AM +0100, Suzuki Poulose wrote:
> On Wed, Sep 2, 2015 at 11:50 AM, Mark Rutland <mark.rutland@arm.com> wrote:
> >
> > When VCPU #0 exits (e.g. due to KVM_EXIT_SYSTEM_EVENT), it sends
> > SIGKVMEXIT to all other VCPUs, waits for them to exit, then tears down
> > any remaining context. The signalling of SIGKVMEXIT is critical to
> > forcing VCPUs to shut down in response to a system event (e.g. PSCI
> > SYSTEM_OFF).
> >
> > VCPUs other that VCPU #0 simply exit in kvm_cpu_thread without forcing
> > other CPUs to shut down. Thus if a system event is taken on a VCPU other
> > than VCPU #0, the remaining CPUs are left online. This results in KVM
> > tool not exiting as expected when a system event is taken on a VCPU
> > other than VCPU #0 (as may happen if the guest panics).
> >
> > Fix this by signalling SIGKVMEXIT to VCPU #0 when a system event is
> > taken on other CPUs, so that it may tear things down as usual.
> >
> > Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> > Cc: Will Deacon <will.deacon@arm.com>
> > Cc: Marc Zyngier <marc.zyngier@arm.com>
> > ---
> >  kvm-cpu.c | 15 +++++++++++----
> >  1 file changed, 11 insertions(+), 4 deletions(-)
> >
> > diff --git a/kvm-cpu.c b/kvm-cpu.c
> > index 5d90664..f47e3db 100644
> > --- a/kvm-cpu.c
> > +++ b/kvm-cpu.c
> > @@ -166,13 +166,20 @@ int kvm_cpu__start(struct kvm_cpu *cpu)
> >                          * treat all system events as shutdown request.
> >                          */
> >                         switch (cpu->kvm_run->system_event.type) {
> > -                       case KVM_SYSTEM_EVENT_RESET:
> > -                               /* Fall through for now */
> > -                       case KVM_SYSTEM_EVENT_SHUTDOWN:
> > -                               goto exit_kvm;
> >                         default:
> >                                 pr_warning("unknown system event type %d",
> >                                            cpu->kvm_run->system_event.type);
> > +                               /* fall through for now */
> > +                       case KVM_SYSTEM_EVENT_RESET:
> > +                               /* Fall through for now */
> > +                       case KVM_SYSTEM_EVENT_SHUTDOWN:
> > +                               /*
> > +                                * Ensure that VCPU #0 tears everything down if
> > +                                * the event was taken on a different VCPU.
> > +                                */
> > +                               if (cpu->cpu_id != 0)
> > +                                       pthread_kill(cpu->kvm->cpus[0]->thread,
> > +                                                    SIGKVMEXIT);
> 
> Could we use kvm_cpu__reboot() instead ?
> 
> That sends SIGKVMEXIT to all the VCPUs, and is used by the other
> paths which trigger a reboot/shutdown.

Sure; I'll spin a v2 with that and an updated comment.

Thanks,
Mark.

      reply	other threads:[~2015-09-03 10:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02 10:50 [KVMTOOL][PATCH] Handle KVM_EXIT_SYSTEM_EVENT on any VCPU Mark Rutland
2015-09-03 10:24 ` Suzuki Poulose
2015-09-03 10:48   ` Mark Rutland [this message]

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=20150903104817.GB10583@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=Marc.Zyngier@arm.com \
    --cc=Suzuki.Poulose@arm.com \
    --cc=Will.Deacon@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=suzuki.lkml@gmail.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