qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Alexander Graf <agraf@suse.de>, Eduardo Habkost <ehabkost@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Laszlo Ersek <lersek@redhat.com>,
	Marcel Apfelbaum <marcel@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	John Snow <jsnow@redhat.com>, Kevin Wolf <kwolf@redhat.com>,
	Max Reitz <mreitz@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Scott Wood <scottwood@freescale.com>,
	Jason Wang <jasowang@redhat.com>,
	David Gibson <david@gibson.dropbear.id.au>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Qemu-block <qemu-block@nongnu.org>,
	"qemu-ppc@nongnu.org" <qemu-ppc@nongnu.org>,
	Alistair Francis <alistair.francis@xilinx.com>,
	Beniamino Galvani <b.galvani@gmail.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Gabriel L . Somlo" <somlo@cmu.edu>,
	Igor Mammedov <imammedo@redhat.com>,
	Prasad J Pandit <pjp@fedoraproject.org>,
	qemu-arm <qemu-arm@nongnu.org>,
	Shannon Zhao <zhaoshenglong@huawei.com>
Subject: Re: [Qemu-devel] [RFC 03/19] sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE
Date: Tue, 4 Apr 2017 08:58:12 +0200	[thread overview]
Message-ID: <40848cee-6a6b-75fa-c395-2ba4705d5bf0@redhat.com> (raw)
In-Reply-To: <522a3489-2e8c-b31a-c592-391fe5cf3b5f@suse.de>

On 04.04.2017 08:53, Alexander Graf wrote:
> 
> 
> On 03.04.17 23:00, Eduardo Habkost wrote:
>> On Mon, Apr 03, 2017 at 10:15:44PM +0200, Alexander Graf wrote:
>>>
>>>
>>> On 03.04.17 22:10, Eduardo Habkost wrote:
>>>> On Mon, Apr 03, 2017 at 08:49:16PM +0100, Peter Maydell wrote:
>>>>> On 1 April 2017 at 01:46, Eduardo Habkost <ehabkost@redhat.com> wrote:
>>>>>> commit 33cd52b5d7b9adfd009e95f07e6c64dd88ae2a31 unset
>>>>>> cannot_instantiate_with_device_add_yet in TYPE_SYSBUS, making
>>>>>> all kinds of untested devices available to -device and
>>>>>> device_add.
>>>>>>
>>>>>> The problem with that is: setting has_dynamic_sysbus on a
>>>>>> machine-type lets it accept all the 288 sysbus device types we
>>>>>> have in QEMU, and most of them were never meant to be used with
>>>>>> -device. That's a lot of untested code.
>>>>>>
>>>>>> Fortunately today we have just a few has_dynamic_sysbus=1
>>>>>> machines: virt, pc-q35-*, ppce500, and spapr.
>>>>>>
>>>>>> virt, ppce500, and spapr have extra checks to ensure just a few
>>>>>> device types can be instantiated:
>>>>>>
>>>>>> * virt supports only TYPE_VFIO_CALXEDA_XGMAC, TYPE_VFIO_AMD_XGBE.
>>>>>> * ppce500 supports only TYPE_ETSEC_COMMON.
>>>>>> * spapr supports only TYPE_SPAPR_PCI_HOST_BRIDGE.
>>>>>>
>>>>>> q35 has no code to block unsupported sysbus devices, however, and
>>>>>> accepts all device types. Fortunately, only the following 20
>>>>>> device types are compiled into the qemu-system-x86_64 and
>>>>>> qemu-system-i386 binaries:
>>>>>>
>>>>>> * allwinner-ahci
>>>>>> * amd-iommu
>>>>>> * cfi.pflash01
>>>>>> * esp
>>>>>> * fw_cfg_io
>>>>>> * fw_cfg_mem
>>>>>> * generic-sdhci
>>>>>> * hpet
>>>>>> * intel-iommu
>>>>>> * ioapic
>>>>>> * isabus-bridge
>>>>>> * kvmclock
>>>>>> * kvm-ioapic
>>>>>> * kvmvapic
>>>>>> * SUNW,fdtwo
>>>>>> * sysbus-ahci
>>>>>> * sysbus-fdc
>>>>>> * sysbus-ohci
>>>>>> * unimplemented-device
>>>>>> * virtio-mmio
>>>>>>
>>>>>> Instead of requiring each machine-type with has_dynamic_sysbus=1
>>>>>> to implement its own mechanism to block unsupported devices, we
>>>>>> can use the user_creatable flag to ensure we won't let the user
>>>>>> plug anything that will never work.
>>>>>
>>>>> How does this work? Which devices can be dynamically
>>>>> plugged is machine dependent. You can't dynamically-plug
>>>>> an intel-iommu on the ARM virt board, and you can't
>>>>> dynamically-plug the vfio-calxeda-xgmac on the spapr
>>>>> board, and so on. So I don't see how we can just have
>>>>> a flag on the device itself that controls whether
>>>>> it can be dynamically plugged.
>>>>>
>>>>> So I'm definitely coming around to the opinion that
>>>>> it's just a bug in the q35 board that it doesn't have
>>>>> any device whitelisting, and we should fix that.
>>>>
>>>> OK, let's assume q35 must implement a whitelist:
>>>>
>>>> To build that whitelist, we need to be able to know what should
>>>> be in the whitelist, or not. And nobody knew for sure what was
>>>> user-creatable in q35 by accident, and what was really supposed
>>>> to be user-creatable in q35. See the "q35 and sysbus devices"
>>>> thread I started ~2 weeks ago.
>>>>
>>>> Building a q35 whitelist will be much easier if make
>>>> sys-bus-devices non-user-creatable by default.
>>>
>>> So why are they user creatable in the first place?
>>>
>>> We used to have boards that were dynamic sysbus aware (ppce500, virt)
>>> that
>>> allowed dynamic creation and every other board did not. I don't
>>> remember the
>>> exact mechanism behind it though.
>>>
>>> When did that behavior change? It sounds like a regression somewhere.
>>
>> See patch description:
>>
>>>>>> commit 33cd52b5d7b9adfd009e95f07e6c64dd88ae2a31 unset
>>>>>> cannot_instantiate_with_device_add_yet in TYPE_SYSBUS,
>>
>> Note that the commit above is not a regression[1] (because q35
>> didn't have has_dynamic_sysbus=1 yet), but having sysbus devices
>> have cannot_instantiate_with_device_add_yet=false/user_creatable=true
>> by default makes it harder to build the whitelist for q35 (or
>> other machines that will have has_dynamic_sysbus=1 in the
>> future).
> 
> I seem to miss the bigger picture.
> 
> Why would anyone set has_dynamic_sysbus=1 in a board file without an
> explicit whitelist? The whitelist is *not* device specific. It's board
> specific, because your board needs to know how to wire up a device and
> how to expose the fact that it exists to the OS.
> 
> So the real bug is that someone set has_dynamic_sysbus=1 in q35 without
> implementing all of the dynamic sysbus logic, no?

According to commit bf8d492405feaee2c1685b3b9d5e03228ed3e47f this was
just introduced for allowing the "intel-iommu" device, so I guess this
is the device that we want to have in a whitelist there?

 Thomas

  reply	other threads:[~2017-04-04  6:58 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-01  0:46 [Qemu-devel] [RFC 00/19] sysbus: Don't allow -device/device_add by default Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 01/19] qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable Eduardo Habkost
2017-04-03 17:16   ` Alistair Francis
2017-04-01  0:46 ` [Qemu-devel] [RFC 02/19] s390: Add FIXME for unexplained user_creatable=false line Eduardo Habkost
2017-04-03  8:55   ` Cornelia Huck
2017-04-03 19:20     ` Eduardo Habkost
2017-04-04  6:46       ` Cornelia Huck
2017-04-01  0:46 ` [Qemu-devel] [RFC 03/19] sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE Eduardo Habkost
2017-04-03 19:49   ` Peter Maydell
2017-04-03 20:10     ` Eduardo Habkost
2017-04-03 20:15       ` Alexander Graf
2017-04-03 21:00         ` Eduardo Habkost
2017-04-04  6:53           ` Alexander Graf
2017-04-04  6:58             ` Thomas Huth [this message]
2017-04-04  7:02               ` Alexander Graf
2017-04-04 12:59                 ` Eduardo Habkost
2017-04-04 13:06                   ` Alexander Graf
2017-04-04 14:44                     ` Eduardo Habkost
2017-04-04 13:05             ` Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 04/19] fdc: Remove user_creatable flag from sysbus-fdc & SUNW, fdtwo Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 05/19] pflash_cfi01: Remove user_creatable flag Eduardo Habkost
2017-04-03 12:43   ` Philippe Mathieu-Daudé
2017-04-03 15:45   ` Laszlo Ersek
2017-04-01  0:46 ` [Qemu-devel] [RFC 06/19] iommu: Remove FIXME comment about user_creatable=true Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 07/19] kvmclock: Remove user_creatable flag Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 08/19] ioapic: " Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 09/19] kvmvapic: " Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 10/19] sysbus-ahci: " Eduardo Habkost
2017-04-03 17:19   ` Alistair Francis
2017-04-01  0:46 ` [Qemu-devel] [RFC 11/19] allwinner-ahci: " Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 12/19] isabus-bridge: " Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 13/19] unimplemented-device: " Eduardo Habkost
2017-04-03 12:44   ` Philippe Mathieu-Daudé
2017-04-03 12:57   ` Peter Maydell
2017-04-03 13:34     ` Eduardo Habkost
2017-04-03 13:38       ` Peter Maydell
2017-04-03 13:54         ` Eduardo Habkost
2017-04-03 14:08           ` Peter Maydell
2017-04-03 18:30             ` Eduardo Habkost
2017-04-03 19:42               ` Peter Maydell
2017-04-03 20:05                 ` Eduardo Habkost
2017-04-04  7:05                   ` Thomas Huth
2017-04-04  7:12                     ` Alexander Graf
2017-04-04 13:12                       ` Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 14/19] fw_cfg: " Eduardo Habkost
2017-04-03 15:46   ` Laszlo Ersek
2017-04-01  0:46 ` [Qemu-devel] [RFC 15/19] esp: " Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 16/19] generic-sdhci: " Eduardo Habkost
2017-04-03 17:20   ` Alistair Francis
2017-04-01  0:46 ` [Qemu-devel] [RFC 17/19] hpet: " Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 18/19] sysbus-ohci: " Eduardo Habkost
2017-04-01  0:46 ` [Qemu-devel] [RFC 19/19] virtio-mmio: " Eduardo Habkost
2017-04-03 15:50   ` Laszlo Ersek
2017-04-04 19:35     ` Eduardo Habkost
2017-04-05  8:30       ` Laszlo Ersek

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=40848cee-6a6b-75fa-c395-2ba4705d5bf0@redhat.com \
    --to=thuth@redhat.com \
    --cc=agraf@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=alistair.francis@xilinx.com \
    --cc=armbru@redhat.com \
    --cc=b.galvani@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=edgar.iglesias@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lersek@redhat.com \
    --cc=marcel@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=scottwood@freescale.com \
    --cc=somlo@cmu.edu \
    --cc=zhaoshenglong@huawei.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;
as well as URLs for NNTP newsgroup(s).