All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: David Kiarie <davidkiarie4@gmail.com>, qemu-devel@nongnu.org
Cc: marcel@redhat.com, valentine.sinitsyn@gmail.com,
	crosthwaitepeter@gmail.com, mst@redhat.com
Subject: Re: [Qemu-devel] [V4 3/4] hw/i386: ACPI table for AMD IO MMU
Date: Sun, 21 Feb 2016 09:21:12 +0100	[thread overview]
Message-ID: <56C97378.9020208@web.de> (raw)
In-Reply-To: <1455736149-21869-4-git-send-email-davidkiarie4@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3702 bytes --]

On 2016-02-17 20:09, David Kiarie wrote:
> Add IVRS table for AMD IO MMU. Also reverve MMIO
> region for IO MMU via ACPI
> 
> Signed-off-by: David Kiarie <davidkiarie4@gmail.com>
> ---
>  hw/i386/acpi-build.c        | 98 ++++++++++++++++++++++++++++++++++++++++-----
>  include/hw/acpi/acpi-defs.h | 55 +++++++++++++++++++++++++
>  2 files changed, 142 insertions(+), 11 deletions(-)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 739cfa3..b8cd091 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -51,6 +51,7 @@
>  #include "hw/pci/pci_bus.h"
>  #include "hw/pci-host/q35.h"
>  #include "hw/i386/intel_iommu.h"
> +#include "hw/i386/amd_iommu.h"
>  #include "hw/timer/hpet.h"
>  
>  #include "hw/acpi/aml-build.h"
> @@ -121,6 +122,12 @@ typedef struct AcpiBuildPciBusHotplugState {
>      bool pcihp_bridge_en;
>  } AcpiBuildPciBusHotplugState;
>  
> +typedef enum iommu_type {
> +    TYPE_AMD,
> +    TYPE_INTEL,
> +    TYPE_NONE
> +} iommu_type;
> +
>  static
>  int acpi_add_cpu_info(Object *o, void *opaque)
>  {
> @@ -2423,6 +2430,78 @@ build_dmar_q35(GArray *table_data, GArray *linker)
>  }
>  
>  static void
> +build_amd_iommu(GArray *table_data, GArray *linker)
> +{
> +    int iommu_start = table_data->len;
> +    bool iommu_ambig;
> +
> +    AcpiAMDIOMMUIVRS *ivrs;
> +    AcpiAMDIOMMUHardwareUnit *iommu;
> +
> +    /* IVRS definition */
> +    ivrs = acpi_data_push(table_data, sizeof(*ivrs));
> +    ivrs->revision = cpu_to_le16(ACPI_IOMMU_IVRS_TYPE);
> +    ivrs->length = cpu_to_le16((sizeof(*ivrs) + sizeof(*iommu)));
> +    ivrs->v_common_info = cpu_to_le64(AMD_IOMMU_HOST_ADDRESS_WIDTH << 8);
> +
> +    AMDIOMMUState *s = (AMDIOMMUState *)object_resolve_path_type("",
> +                        TYPE_AMD_IOMMU_DEVICE, &iommu_ambig);
> +
> +    /* IVDB definition - type 10h */
> +    iommu = acpi_data_push(table_data, sizeof(*iommu));
> +    if (!iommu_ambig) {
> +        iommu->type = cpu_to_le16(0x10);
> +        /* IVHD flags */
> +        iommu->flags = cpu_to_le16(iommu->flags);
> +        iommu->flags = cpu_to_le16(IVHD_HT_TUNEN | IVHD_PPRSUP | IVHD_IOTLBSUP
> +                       | IVHD_PREFSUP);
> +        iommu->length = cpu_to_le16(sizeof(*iommu));
> +        iommu->device_id = cpu_to_le16(PCI_DEVICE_ID_RD890_IOMMU);
> +        iommu->capability_offset = cpu_to_le16(s->capab_offset);
> +        iommu->mmio_base = cpu_to_le64(s->mmio.addr);
> +        iommu->pci_segment = 0;
> +        iommu->interrupt_info = 0;
> +        /* EFR features */
> +        iommu->efr_register = cpu_to_le64(IVHD_EFR_GTSUP | IVHD_EFR_HATS
> +                              | IVHD_EFR_GATS);
> +        iommu->efr_register = cpu_to_le64(iommu->efr_register);
> +        /* device entries */
> +        memset(iommu->dev_entries, 0, 20);
> +        /* Add device flags here
> +         *  This is are 4-byte device entries currently reporting the range of
> +         *  devices 00h - ffffh; all devices
> +         *
> +         *  Device setting affecting all devices should be made here
> +         *
> +         *  Refer to
> +         *  (http://developer.amd.com/wordpress/media/2012/10/488821.pdf)
> +         *  5.2.2.1
> +         */
> +        iommu->dev_entries[12] = 3;
> +        iommu->dev_entries[16] = 4;
> +        iommu->dev_entries[17] = 0xff;
> +        iommu->dev_entries[18] = 0xff;
> +    }
> +
> +    build_header(linker, table_data, (void *)(table_data->data + iommu_start),
> +                 "IVRS", table_data->len - iommu_start, 1, NULL);

Requires rebasing over master (to append another NULL here).

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2016-02-21  8:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17 19:09 [Qemu-devel] [V4 0/4] AMD IOMMU David Kiarie
2016-02-17 19:09 ` [Qemu-devel] [V4 1/4] hw/i386: Introduce AMD IO MMU David Kiarie
2016-02-21  8:16   ` Jan Kiszka
2016-02-21  8:18     ` Jan Kiszka
2016-02-17 19:09 ` [Qemu-devel] [V4 2/4] hw/core: Add AMD IO MMU to machine properties David Kiarie
2016-02-21  8:23   ` Jan Kiszka
2016-02-17 19:09 ` [Qemu-devel] [V4 3/4] hw/i386: ACPI table for AMD IO MMU David Kiarie
2016-02-21  8:21   ` Jan Kiszka [this message]
2016-02-17 19:09 ` [Qemu-devel] [V4 4/4] hw/pci-host: Emulate " David Kiarie
2016-02-21  8:29 ` [Qemu-devel] [V4 0/4] AMD IOMMU Jan Kiszka
  -- strict thread matches above, loose matches on Subject: below --
2016-01-18 15:25 [Qemu-devel] [V4 0/4] AMD IO MMU David Kiarie
2016-01-18 15:25 ` [Qemu-devel] [V4 3/4] hw/i386: ACPI table for " David Kiarie
2016-02-14 12:54   ` Marcel Apfelbaum
2016-02-14 13:07     ` Michael S. Tsirkin
2016-02-14 18:11       ` David kiarie

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=56C97378.9020208@web.de \
    --to=jan.kiszka@web.de \
    --cc=crosthwaitepeter@gmail.com \
    --cc=davidkiarie4@gmail.com \
    --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 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.