[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH 3/7] pci: call IOMMU hooks
From: |
Isaku Yamahata |
Subject: |
Re: [Qemu-devel] [RFC PATCH 3/7] pci: call IOMMU hooks |
Date: |
Wed, 14 Jul 2010 16:37:39 +0900 |
User-agent: |
Mutt/1.5.19 (2009-01-05) |
On Wed, Jul 14, 2010 at 08:45:03AM +0300, Eduard - Gabriel Munteanu wrote:
> Memory accesses must go through the IOMMU layer.
>
> Signed-off-by: Eduard - Gabriel Munteanu <address@hidden>
> ---
> hw/pci.c | 21 +++++++++++++++++++++
> 1 files changed, 21 insertions(+), 0 deletions(-)
>
> diff --git a/hw/pci.c b/hw/pci.c
> index 6871728..9c5d706 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -22,6 +22,7 @@
> * THE SOFTWARE.
> */
> #include "hw.h"
> +#include "iommu.h"
> #include "pci.h"
> #include "monitor.h"
> #include "net.h"
> @@ -733,12 +734,25 @@ static void do_pci_unregister_device(PCIDevice *pci_dev)
> pci_config_free(pci_dev);
> }
>
> +#ifdef CONFIG_IOMMU
> +static inline int pci_iommu_register_device(PCIBus *bus, PCIDevice *dev)
> +{
> + return iommu_register_device(bus->qbus.iommu, &dev->qdev);
> +}
> +#else
> +static inline int pci_iommu_register_device(PCIBus *bus, PCIDevice *dev)
> +{
> + return 0;
> +}
> +#endif
> +
> PCIDevice *pci_register_device(PCIBus *bus, const char *name,
> int instance_size, int devfn,
> PCIConfigReadFunc *config_read,
> PCIConfigWriteFunc *config_write)
> {
> PCIDevice *pci_dev;
> + int err;
>
> pci_dev = qemu_mallocz(instance_size);
> pci_dev = do_pci_register_device(pci_dev, bus, name, devfn,
> @@ -747,6 +761,13 @@ PCIDevice *pci_register_device(PCIBus *bus, const char
> *name,
> if (pci_dev == NULL) {
> hw_error("PCI: can't register device\n");
> }
> +
> + err = pci_iommu_register_device(bus, pci_dev);
> + if (err) {
> + hw_error("PCI: can't register device with IOMMU\n");
> + return NULL;
> + }
> +
> return pci_dev;
> }
pci_register_device() is pre-qdev api.
qdev'fied device doesn't call pci_register_device().
So please move the initialization hook into do_pci_register_device()
which are commonly used by pci_register_device() and pci_qdev_init().
--
yamahata
- [Qemu-devel] [RFC PATCH 0/7] AMD IOMMU emulation patchset, Eduard - Gabriel Munteanu, 2010/07/14
- [Qemu-devel] [RFC PATCH 3/7] pci: call IOMMU hooks, Eduard - Gabriel Munteanu, 2010/07/14
- Re: [Qemu-devel] [RFC PATCH 3/7] pci: call IOMMU hooks,
Isaku Yamahata <=
- [Qemu-devel] [RFC PATCH 4/7] ide: IOMMU support, Eduard - Gabriel Munteanu, 2010/07/14
- [Qemu-devel] Re: [RFC PATCH 4/7] ide: IOMMU support, Paul Brook, 2010/07/14
- [Qemu-devel] Re: [RFC PATCH 4/7] ide: IOMMU support, Joerg Roedel, 2010/07/14
- Re: [Qemu-devel] Re: [RFC PATCH 4/7] ide: IOMMU support, Paul Brook, 2010/07/14
- Re: [Qemu-devel] Re: [RFC PATCH 4/7] ide: IOMMU support, Anthony Liguori, 2010/07/14
- Re: [Qemu-devel] Re: [RFC PATCH 4/7] ide: IOMMU support, Chris Wright, 2010/07/14
- Re: [Qemu-devel] Re: [RFC PATCH 4/7] ide: IOMMU support, Paul Brook, 2010/07/15
- Re: [Qemu-devel] Re: [RFC PATCH 4/7] ide: IOMMU support, Chris Wright, 2010/07/15
- Re: [Qemu-devel] Re: [RFC PATCH 4/7] ide: IOMMU support, Avi Kivity, 2010/07/15