From: Eduardo Habkost <ehabkost@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Greg Kurz" <groug@kaod.org>,
qemu-devel@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Richard Henderson" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v2] accel: forbid early use of kvm_enabled() and friends
Date: Fri, 29 Jun 2018 17:03:18 -0300 [thread overview]
Message-ID: <20180629200318.GY7451@localhost.localdomain> (raw)
In-Reply-To: <20180629103910.GE27016@redhat.com>
On Fri, Jun 29, 2018 at 11:39:10AM +0100, Daniel P. Berrangé wrote:
> On Fri, Jun 29, 2018 at 12:35:09PM +0200, Paolo Bonzini wrote:
> > On 29/06/2018 12:29, Greg Kurz wrote:
> > > It is unsafe to rely on *_enabled() helpers before the accelerator has
> > > been initialized, ie, accel_init_machine() has succeeded, because they
> > > always return false. But it is still possible to end up calling them
> > > indirectly by inadvertance, and cause QEMU to misbehave.
> > >
> > > This patch causes QEMU to abort if we try to check for an accelerator
> > > before it has been set up. This will help to catch bugs earlier.
> > >
> > > Signed-off-by: Greg Kurz <groug@kaod.org>
> > > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> > > ---
> > >
> > > This patch was motivated by an regression we're currently fixing in
> > > spapr because of an early use of kvm_enabled(). David suggested to
> > > post this patch separately:
> > >
> > > https://lists.nongnu.org/archive/html/qemu-ppc/2018-06/msg01136.html
> > >
> > > v2: - dropped change in qom/cpu.c (useless header inclusion)
> > > - only #include "sysemu/kvm.h" if we actually need it
> > > - added David's R-b from v1 because changes in v2 are minor
> >
> > This adds a function call on possibly hot paths. Can you make it inline?
> >
> > Also asserting current_machine != NULL is not necessary, since you're
> > immediately dereferencing it.
>
> Is there a practical way to simply initialize the accelerators earlier
> in startup sequence, so we just remove or at least reduce, the liklihood
> of accessing it too early ?
We can reduce it, but not eliminate it: it would still be
possible to use the *_enabled() macros too early, before we parse
all command-line options (on QOM class_init, for example).
--
Eduardo
next prev parent reply other threads:[~2018-06-29 20:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-29 10:29 [Qemu-devel] [PATCH v2] accel: forbid early use of kvm_enabled() and friends Greg Kurz
2018-06-29 10:35 ` Paolo Bonzini
2018-06-29 10:39 ` Daniel P. Berrangé
2018-06-29 10:40 ` Paolo Bonzini
2018-06-29 11:07 ` Greg Kurz
2018-06-29 11:08 ` Paolo Bonzini
2018-06-29 11:14 ` Daniel P. Berrangé
2018-06-29 11:42 ` Cédric Le Goater
2018-06-29 11:47 ` Paolo Bonzini
2018-06-29 20:09 ` Eduardo Habkost
2018-06-29 15:18 ` Igor Mammedov
2018-06-29 15:19 ` Daniel P. Berrangé
2018-06-29 20:16 ` Eduardo Habkost
2018-06-29 20:34 ` Eduardo Habkost
2018-07-02 13:44 ` Greg Kurz
2018-06-29 20:03 ` Eduardo Habkost [this message]
2018-06-29 10:48 ` Greg Kurz
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=20180629200318.GY7451@localhost.localdomain \
--to=ehabkost@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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;
as well as URLs for NNTP newsgroup(s).