From: Thomas Huth <thuth@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Anthony Green <green@moxielogic.com>,
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
Blue Swirl <blauwirbel@gmail.com>,
Max Filippov <jcmvbkbc@gmail.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
Guan Xuetao <gxt@mprc.pku.edu.cn>, Jia Liu <proljc@gmail.com>,
Alexander Graf <agraf@suse.de>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Leon Alrae <leon.alrae@imgtec.com>,
ehabkost@redhat.com, qemu-stable@nongnu.org, stefanha@redhat.com,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Richard Henderson <rth@twiddle.net>,
Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
Michael Walle <michael@walle.cc>,
qemu-ppc@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
afaerber@suse.de, Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH v4 6/7] qdev: Protect device-list-properties against broken devices
Date: Tue, 29 Sep 2015 09:01:42 +0200 [thread overview]
Message-ID: <560A3756.3020401@redhat.com> (raw)
In-Reply-To: <1443470907-32335-7-git-send-email-armbru@redhat.com>
On 28/09/15 22:08, Markus Armbruster wrote:
> Several devices don't survive object_unref(object_new(T)): they crash
> or hang during cleanup, or they leave dangling pointers behind.
>
> This breaks at least device-list-properties, because
> qmp_device_list_properties() needs to create a device to find its
> properties. Broken in commit f4eb32b "qmp: show QOM properties in
> device-list-properties", v2.1. Example reproducer:
>
> $ qemu-system-aarch64 -nodefaults -display none -machine none -S -qmp stdio
> {"QMP": {"version": {"qemu": {"micro": 50, "minor": 4, "major": 2}, "package": ""}, "capabilities": []}}
> { "execute": "qmp_capabilities" }
> {"return": {}}
> { "execute": "device-list-properties", "arguments": { "typename": "pxa2xx-pcmcia" } }
> qemu-system-aarch64: /home/armbru/work/qemu/memory.c:1307: memory_region_finalize: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
> Aborted (core dumped)
> [Exit 134 (SIGABRT)]
>
> Unfortunately, I can't fix the problems in these devices right now.
> Instead, add DeviceClass member cannot_even_create_with_object_new_yet
> to mark them:
>
> * Hang during cleanup (didn't debug, so I can't say why):
> "realview_pci", "versatile_pci", "s390-sclp-event-facility", "sclp"
>
> * Dangling pointer in cpus: most CPUs, plus "allwinner-a10", "digic",
> "fsl,imx25", "fsl,imx31", "xlnx,zynqmp", because they create such
> CPUs
>
> * Dangling pointers in QOM: "cgthree", "cuda", "integrator_debug",
> "macio-oldworld", "macio-newworld", "pxa2xx-fir", "pxa2xx-pcmcia",
> "SUNW,tcx"
>
> * Assert kvm_enabled(): "host-x86_64-cpu", host-i386-cpu",
> "host-powerpc64-cpu", "host-embedded-powerpc-cpu",
> "host-powerpc-cpu" (the powerpc ones can't currently reach the
> assertion, because the CPUs are only registered when KVM is enabled,
> but the assertion is arguably in the wrong place all the same)
>
> Make qmp_device_list_properties() fail cleanly when the device is so
> marked. This improves device-list-properties from "crashes, hangs or
> leaves dangling pointers behind" to "fails". Not a complete fix, just
> a better-than-nothing work-around. In the above reproducer,
> device-list-properties now fails with "Can't list properties of device
> 'pxa2xx-pcmcia'".
>
> This also protects -device FOO,help, which uses the same machinery
> since commit ef52358 "qdev-monitor: include QOM properties in -device
> FOO, help output", v2.2. Example reproducer:
>
> $ qemu-system-aarch64 -machine none -device pxa2xx-pcmcia,help
>
> Before:
>
> qemu-system-aarch64: .../memory.c:1307: memory_region_finalize: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
>
> After:
>
> Can't list properties of device 'pxa2xx-pcmcia'
...
> static const TypeInfo xtensa_cpu_type_info = {
> diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c
> index a8950a1..11d5fea 100644
> --- a/tests/device-introspect-test.c
> +++ b/tests/device-introspect-test.c
> @@ -91,34 +91,6 @@ static void test_device_intro_abstract(void)
> qtest_end();
> }
>
> -static bool blacklisted(const char *type)
> -{
> - static const char *blacklist[] = {
> - /* create memory region without owner -> dangling pointer */
> - "cgthree", "cuda", "integrator_debug", "macio-oldworld",
> - "macio-newworld", "pxa2xx-fir", "pxa2xx-pcmcia",
> - "SUNW,tcx",
> - /* hang in object_unref(): */
> - "realview_pci", "versatile_pci", "s390-sclp-event-facility", "sclp",
> - /* create a CPU, thus use after free (see below): */
> - "allwinner-a10", "digic", "fsl,imx25", "fsl,imx31", "xlnx,zynqmp",
> - };
> - size_t len = strlen(type);
> - int i;
> -
> - if (len >= 4 && !strcmp(type + len - 4, "-cpu")) {
> - /* use after free: cpu_exec_init() saves CPUState in cpus */
> - return true;
> - }
> -
> - for (i = 0; i < ARRAY_SIZE(blacklist); i++) {
> - if (!strcmp(blacklist[i], type)) {
> - return true;
> - }
> - }
> - return false;
> -}
> -
> static void test_device_intro_concrete(void)
> {
> QList *types;
> @@ -132,9 +104,6 @@ static void test_device_intro_concrete(void)
> type = qdict_get_try_str(qobject_to_qdict(qlist_entry_obj(entry)),
> "name");
> g_assert(type);
> - if (blacklisted(type)) {
> - continue; /* FIXME broken device, skip */
> - }
> test_one_device(type);
> }
I'd also rather move this patch before patch 4/7 so you can get rid of
the temporary workaround.
Thomas
next prev parent reply other threads:[~2015-09-29 7:01 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 20:08 [Qemu-devel] [PATCH v4 0/7] Fix device introspection regressions Markus Armbruster
2015-09-28 20:08 ` [Qemu-devel] [PATCH v4 1/7] tests: Fix how qom-test is run Markus Armbruster
2015-09-29 16:06 ` Andreas Färber
2015-10-01 5:41 ` Markus Armbruster
2015-09-28 20:08 ` [Qemu-devel] [PATCH v4 2/7] libqtest: Clean up unused QTestState member sigact_old Markus Armbruster
2015-09-28 20:08 ` [Qemu-devel] [PATCH v4 3/7] libqtest: New hmp() & friends Markus Armbruster
2015-09-29 6:38 ` Thomas Huth
2015-09-29 12:41 ` Markus Armbruster
2015-09-28 20:08 ` [Qemu-devel] [PATCH v4 4/7] device-introspect-test: New, covering device introspection Markus Armbruster
2015-09-28 20:08 ` [Qemu-devel] [PATCH v4 5/7] qmp: Fix device-list-properties not to crash for abstract device Markus Armbruster
2015-09-29 6:50 ` Thomas Huth
2015-09-29 12:44 ` Markus Armbruster
2015-09-29 16:07 ` Andreas Färber
2015-09-28 20:08 ` [Qemu-devel] [PATCH v4 6/7] qdev: Protect device-list-properties against broken devices Markus Armbruster
2015-09-28 20:15 ` Eduardo Habkost
2015-09-29 7:01 ` Thomas Huth [this message]
2015-09-29 16:22 ` Andreas Färber
2015-10-01 5:45 ` Markus Armbruster
2015-09-28 20:08 ` [Qemu-devel] [PATCH v4 7/7] Revert "qdev: Use qdev_get_device_class() for -device <type>, help" Markus Armbruster
2015-09-29 15:33 ` [Qemu-devel] [PATCH v4 0/7] Fix device introspection regressions Markus Armbruster
2015-10-01 13:42 ` Stefan Hajnoczi
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=560A3756.3020401@redhat.com \
--to=thuth@redhat.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=armbru@redhat.com \
--cc=aurelien@aurel32.net \
--cc=blauwirbel@gmail.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=edgar.iglesias@gmail.com \
--cc=ehabkost@redhat.com \
--cc=green@moxielogic.com \
--cc=gxt@mprc.pku.edu.cn \
--cc=jcmvbkbc@gmail.com \
--cc=kbastian@mail.uni-paderborn.de \
--cc=leon.alrae@imgtec.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=michael@walle.cc \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=proljc@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=rth@twiddle.net \
--cc=stefanha@redhat.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.