From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
"Cédric Le Goater" <clg@kaod.org>
Subject: Re: [Qemu-devel] [PATCH 3/5] spapr_cpu_core: add missing rollback on realization path
Date: Fri, 15 Jun 2018 16:29:15 +1000 [thread overview]
Message-ID: <20180615062915.GU4129@umbus.fritz.box> (raw)
In-Reply-To: <20180615075805.1213ed06@bahia.lan>
[-- Attachment #1: Type: text/plain, Size: 3230 bytes --]
On Fri, Jun 15, 2018 at 07:58:05AM +0200, Greg Kurz wrote:
> On Fri, 15 Jun 2018 10:14:31 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > On Fri, Jun 15, 2018 at 10:02:25AM +1000, David Gibson wrote:
> > > On Thu, Jun 14, 2018 at 11:50:42PM +0200, Greg Kurz wrote:
> > > > The spapr_realize_vcpu() function doesn't rollback in case of error.
> > > > This isn't a problem with coldplugged CPUs because the machine won't
> > > > start and QEMU will exit. Hotplug is a different story though: the
> > > > CPU thread is started under object_property_set_bool() and it assumes
> > > > it can access the CPU object.
> > > >
> > > > If icp_create() fails, we return an error without unregistering the
> > > > reset handler for this CPU, and we let the underlying QEMU thread for
> > > > this CPU alive. Since spapr_cpu_core_realize() doesn't care to unrealize
> > > > already realized CPUs either, but happily frees all of them anyway, the
> > > > CPU thread crashes instantly:
> > > >
> > > > (qemu) device_add host-spapr-cpu-core,core-id=1,id=gku
> > > > GKU: failing icp_create (cpu 0x11497fd0)
> > > > ^^^^^^^^^^
> > > > Program received signal SIGSEGV, Segmentation fault.
> > > > [Switching to Thread 0x7fffee3feaa0 (LWP 24725)]
> > > > 0x00000000104c8374 in object_dynamic_cast_assert (obj=0x11497fd0,
> > > > ^^^^^^^^^^^^^^
> > > > pointer to the CPU object
> > > > 623 trace_object_dynamic_cast_assert(obj ? obj->class->type->name
> > > > (gdb) p obj->class->type
> > > > $1 = (Type) 0x0
> > > > (gdb) p * obj
> > > > $2 = {class = 0x10ea9c10, free = 0x11244620,
> > > > ^^^^^^^^^^
> > > > should be g_free
> > > > (gdb) p g_free
> > > > $3 = {<text variable, no debug info>} 0x7ffff282bef0 <g_free>
> > > >
> > > > obj is a dangling pointer to the CPU that was just destroyed in
> > > > spapr_cpu_core_realize().
> > > >
> > > > This patch adds proper rollback to both spapr_realize_vcpu() and
> > > > spapr_cpu_core_realize().
> > > >
> > > > Signed-off-by: Greg Kurz <groug@kaod.org>
> > >
> > > Applied to ppc-for-3.0, since it definitely looks to fix some
> > > problems.
> >
> > Uh.. actually it has a definite bug - the first exit point will call
> > g_free() on an uninitialized spapr_cpu. I fixed it up with a NULL
> > initialization in my tree.
>
> Ah... as said in the cover letter, all the series is based on machine_data
> being set before the call to object_property_set_bool()... Maybe I should
> have made that explicit with a preparatory patch... Sorry.
Ah, that makes sense.
So, I ended up having to rework a little differently, after I yanked
by intc -> machine_data patch because it broke things for clg. I
think I've fixed it up correctly now - if you can check the latest
ppc-for-3.0 I pushed out, that would be great.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-06-15 6:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-14 21:49 [Qemu-devel] [PATCH 0/5] spapr_cpu_core: fixes and cleanups Greg Kurz
2018-06-14 21:50 ` [Qemu-devel] [PATCH 1/5] spapr_cpu_core: convert last snprintf() to g_strdup_printf() Greg Kurz
2018-06-14 23:59 ` David Gibson
2018-06-14 21:50 ` [Qemu-devel] [PATCH 2/5] spapr_cpu_core: fix potential leak in spapr_cpu_core_realize() Greg Kurz
2018-06-14 23:59 ` David Gibson
2018-06-14 21:50 ` [Qemu-devel] [PATCH 3/5] spapr_cpu_core: add missing rollback on realization path Greg Kurz
2018-06-15 0:02 ` David Gibson
2018-06-15 0:14 ` David Gibson
2018-06-15 5:58 ` Greg Kurz
2018-06-15 6:29 ` David Gibson [this message]
2018-06-15 7:07 ` Greg Kurz
2018-06-15 8:01 ` Greg Kurz
2018-06-15 12:32 ` David Gibson
2018-06-15 13:24 ` Greg Kurz
2018-06-16 6:26 ` David Gibson
2018-06-15 5:53 ` Greg Kurz
2018-06-15 6:27 ` David Gibson
2018-06-14 21:50 ` [Qemu-devel] [PATCH 4/5] spapr_cpu_core: introduce spapr_create_vcpu() Greg Kurz
2018-06-15 0:05 ` David Gibson
2018-06-14 21:51 ` [Qemu-devel] [PATCH 5/5] spapr_cpu_core: simplify spapr_cpu_core_realize() Greg Kurz
2018-06-15 0:08 ` David Gibson
2018-06-15 6:57 ` 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=20180615062915.GU4129@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=clg@kaod.org \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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).