From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: David Kiarie <davidkiarie4@gmail.com>,
qemu-devel@nongnu.org, jan.kiszka@web.de,
valentine.sinitsyn@gmail.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/4] hw/pci-host: Add AMD IOMMU to PIIX and Q35 pcs
Date: Thu, 8 Oct 2015 17:40:48 +0300 [thread overview]
Message-ID: <56168070.30306@gmail.com> (raw)
In-Reply-To: <1444359237-27224-3-git-send-email-davidkiarie4@gmail.com>
On 10/09/2015 05:53 AM, David Kiarie wrote:
> From: David <davidkiarie4@gmail.com>
>
> Emulate AMD IOMMU on PIIX and Q35 controlled by a command line
> switch
>
> Signed-off-by: David Kiarie <davidkiarie4@gmail.com>
> ---
> hw/pci-host/piix.c | 10 ++++++++++
> hw/pci-host/q35.c | 10 ++++++++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> index 1fb71c8..a4b07d2 100644
> --- a/hw/pci-host/piix.c
> +++ b/hw/pci-host/piix.c
> @@ -31,6 +31,7 @@
> #include "qemu/range.h"
> #include "hw/xen/xen.h"
> #include "hw/pci-host/pam.h"
> +#include "hw/i386/amd_iommu.h"
> #include "sysemu/sysemu.h"
> #include "hw/i386/ioapic.h"
> #include "qapi/visitor.h"
> @@ -290,12 +291,21 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)
> {
> PCIHostState *s = PCI_HOST_BRIDGE(dev);
> SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> + AMDIOMMUState *iommu_state;
> + PCIDevice *iommu;
Hi,
Maybe you can move the above declarations inside the if statement.
>
> sysbus_add_io(sbd, 0xcf8, &s->conf_mem);
> sysbus_init_ioports(sbd, 0xcf8, 4);
>
> sysbus_add_io(sbd, 0xcfc, &s->data_mem);
> sysbus_init_ioports(sbd, 0xcfc, 4);
> +
> + /* AMD IOMMU (AMD-Vi) */
> + if(machine_amd_iommu(current_machine)){
> + iommu = pci_create_simple(s->bus, 0x20, TYPE_AMD_IOMMU_DEVICE);
TYPE_AMD_IOMMU_DEVICE is defined in patch 3/4, I suppose you would
want to switch them.
> + iommu_state = AMD_IOMMU_DEVICE(iommu);
> + pci_setup_iommu(s->bus, bridge_host_amd_iommu, iommu_state);
> + }
> }
>
> static void i440fx_realize(PCIDevice *dev, Error **errp)
> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
> index bd74094..cef84ff 100644
> --- a/hw/pci-host/q35.c
> +++ b/hw/pci-host/q35.c
> @@ -30,6 +30,7 @@
> #include "hw/hw.h"
> #include "hw/pci-host/q35.h"
> #include "qapi/visitor.h"
> +#include "hw/i386/amd_iommu.h"
>
> /****************************************************************************
> * Q35 host
> @@ -470,6 +471,8 @@ static void mch_realize(PCIDevice *d, Error **errp)
> {
> int i;
> MCHPCIState *mch = MCH_PCI_DEVICE(d);
> + AMDIOMMUState *iommu_state;
> + PCIDevice *iommu;
Same here.
Thanks,
Marcel
>
> /* setup pci memory mapping */
> pc_pci_as_mapping_init(OBJECT(mch), mch->system_memory,
> @@ -528,6 +531,13 @@ static void mch_realize(PCIDevice *d, Error **errp)
> if (machine_iommu(current_machine)) {
> mch_init_dmar(mch);
> }
> + /* AMD IOMMU (AMD-Vi) */
> + if (machine_amd_iommu(current_machine)){
> + PCIBus *bus = PCI_BUS(qdev_get_parent_bus(DEVICE(mch)));
> + iommu = pci_create_simple(bus, 0x20, TYPE_AMD_IOMMU_DEVICE);
> + iommu_state = AMD_IOMMU_DEVICE(iommu);
> + pci_setup_iommu(bus, bridge_host_amd_iommu, iommu_state);
> + }
> }
>
> uint64_t mch_mcfg_base(void)
>
next prev parent reply other threads:[~2015-10-08 14:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-09 2:53 [Qemu-devel] [PATCH 0/4] AMD IOMMU v1 David Kiarie
2015-10-09 2:53 ` [Qemu-devel] [PATCH 1/4] hw/core: Add iommu to machine properties David Kiarie
2015-10-08 18:10 ` Marcel Apfelbaum
2015-10-09 12:17 ` David kiarie
2015-10-09 17:16 ` Peter Crosthwaite
2015-10-09 2:53 ` [Qemu-devel] [PATCH 2/4] hw/pci-host: Add AMD IOMMU to PIIX and Q35 pcs David Kiarie
2015-10-08 12:11 ` Michael S. Tsirkin
2015-10-08 14:40 ` Marcel Apfelbaum [this message]
2015-10-09 2:53 ` [Qemu-devel] [PATCH 3/4] hw/i386: Introduce AMD IOMMU David Kiarie
2015-10-08 18:24 ` Marcel Apfelbaum
2015-10-09 12:20 ` David kiarie
2015-10-09 2:53 ` [Qemu-devel] [PATCH 4/4] hw/acpi: ACPI table for " David Kiarie
2015-10-09 7:17 ` [Qemu-devel] [PATCH 0/4] AMD IOMMU v1 Valentine Sinitsyn
2015-10-09 12:22 ` David kiarie
2015-10-09 12:24 ` Valentine Sinitsyn
2015-10-09 12:27 ` David kiarie
2015-10-09 12:30 ` Valentine Sinitsyn
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=56168070.30306@gmail.com \
--to=marcel.apfelbaum@gmail.com \
--cc=davidkiarie4@gmail.com \
--cc=jan.kiszka@web.de \
--cc=marcel@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=valentine.sinitsyn@gmail.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).