qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: David Kiarie <davidkiarie4@gmail.com>, qemu-devel@nongnu.org
Cc: marcel@redhat.com, valentine.sinitsyn@gmail.com,
	jan.kizska@web.de, mst@redhat.com
Subject: Re: [Qemu-devel] [V8 3/4] hw/core: Add AMD IOMMU to machine properties
Date: Mon, 4 Apr 2016 14:17:27 +0300	[thread overview]
Message-ID: <57024D47.1090903@gmail.com> (raw)
In-Reply-To: <1459535994-18523-4-git-send-email-davidkiarie4@gmail.com>

On 04/01/2016 09:39 PM, David Kiarie wrote:
> Added a bool, subject to review to machine properties which
> it used to override iommu emulated from Intel to AMD.
>

Hi David,
The patch is looking good, thanks.
One minor comment below.

> Signed-off-by: David Kiarie <davidkiarie4@gmail.com>
> ---
>   hw/core/machine.c   | 32 +++++++++++++++++++++++++++++---
>   include/hw/boards.h |  1 +
>   qemu-options.hx     |  7 +++++--
>   util/qemu-config.c  |  8 ++++++--
>   4 files changed, 41 insertions(+), 7 deletions(-)
>
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 6dbbc85..792641b 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -15,6 +15,8 @@
>   #include "qapi/error.h"
>   #include "qapi-visit.h"
>   #include "qapi/visitor.h"
> +#include "hw/i386/amd_iommu.h"
> +#include "hw/i386/intel_iommu.h"
>   #include "hw/sysbus.h"
>   #include "sysemu/sysemu.h"
>   #include "qemu/error-report.h"
> @@ -300,6 +302,26 @@ static void machine_set_iommu(Object *obj, bool value, Error **errp)
>       ms->iommu = value;
>   }
>
> +static void machine_set_iommu_override(Object *obj, const char *value,
> +                                       Error **errp)
> +{
> +    MachineState *ms = MACHINE(obj);
> +    Error *err = NULL;
> +
> +    ms->x_iommu_type = false;
> +    /* ensure a valid iommu type */
> +    if (g_strcmp0(value, AMD_IOMMU_STR) &&
> +            g_strcmp0(value, INTEL_IOMMU_STR)) {
> +        error_setg(errp, "Invalid IOMMU type %s", value);
> +        error_propagate(errp, err);
> +        return;
> +    }
> +
> +    if ((g_strcmp0(value, AMD_IOMMU_STR) == 0)) {
> +        ms->x_iommu_type = true;
> +    }
> +}
> +
>   static void machine_set_suppress_vmdesc(Object *obj, bool value, Error **errp)
>   {
>       MachineState *ms = MACHINE(obj);
> @@ -473,10 +495,14 @@ static void machine_initfn(Object *obj)
>                                       "Firmware image",
>                                       NULL);
>       object_property_add_bool(obj, "iommu",
> -                             machine_get_iommu,
> -                             machine_set_iommu, NULL);
> +                             machine_get_iommu, machine_set_iommu, NULL);
>       object_property_set_description(obj, "iommu",
> -                                    "Set on/off to enable/disable Intel IOMMU (VT-d)",
> +                                    "Set on to enable IOMMU emulation",
> +                                    NULL);
> +    object_property_add_str(obj, "x-iommu-type",
> +                            NULL, machine_set_iommu_override, NULL);
> +    object_property_set_description(obj, "x-iommu-type",
> +                                    "Set on to override emulated IOMMU to AMD IOMMU",
>                                       NULL);
>       object_property_add_bool(obj, "suppress-vmdesc",
>                                machine_get_suppress_vmdesc,
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index aad5f2a..07788fc 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -151,6 +151,7 @@ struct MachineState {
>       bool igd_gfx_passthru;
>       char *firmware;
>       bool iommu;
> +    bool x_iommu_type;

The name is a little weird for a boolean variable.
You can either change the name to iommu_amd (true when AMD, false when INTEL)
or make it an enum. 0 - Intel, 1 - AMD, ...

Other than that the patch is ready in my opinion.
Thanks,
Marcel


>       bool suppress_vmdesc;
>       bool enforce_config_section;
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index a770086..14d30b7 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -38,7 +38,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
>       "                kvm_shadow_mem=size of KVM shadow MMU\n"
>       "                dump-guest-core=on|off include guest memory in a core dump (default=on)\n"
>       "                mem-merge=on|off controls memory merge support (default: on)\n"
> -    "                iommu=on|off controls emulated Intel IOMMU (VT-d) support (default=off)\n"
> +    "                iommu=on|off controls emulated IOMMU support(default: off)\n"
> +    "                x-iommu-type=amd|intel overrides emulated IOMMU to AMD IOMMU (default: intel)\n"
>       "                igd-passthru=on|off controls IGD GFX passthrough support (default=off)\n"
>       "                aes-key-wrap=on|off controls support for AES key wrapping (default=on)\n"
>       "                dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n"
> @@ -74,7 +75,9 @@ Enables or disables memory merge support. This feature, when supported by
>   the host, de-duplicates identical memory pages among VMs instances
>   (enabled by default).
>   @item iommu=on|off
> -Enables or disables emulated Intel IOMMU (VT-d) support. The default is off.
> +Enables and disables IOMMU emulation. The default is off.
> +@item x-iommu-type=on|off
> +Overrides emulated IOMMU from AMD IOMMU. By default Intel IOMMU is emulated.
>   @item aes-key-wrap=on|off
>   Enables or disables AES key wrapping support on s390-ccw hosts. This feature
>   controls whether AES wrapping keys will be created to allow
> diff --git a/util/qemu-config.c b/util/qemu-config.c
> index fb97307..8886abf 100644
> --- a/util/qemu-config.c
> +++ b/util/qemu-config.c
> @@ -213,8 +213,12 @@ static QemuOptsList machine_opts = {
>               .help = "firmware image",
>           },{
>               .name = "iommu",
> -            .type = QEMU_OPT_BOOL,
> -            .help = "Set on/off to enable/disable Intel IOMMU (VT-d)",
> +            .type =  QEMU_OPT_BOOL,
> +            .help = "Set on/off to enable iommu",
> +        },{
> +            .name = "x-iommu-type",
> +            .type =  QEMU_OPT_STRING,
> +            .help = "Overrides emulated IOMMU from Intel to AMD",
>           },{
>               .name = "suppress-vmdesc",
>               .type = QEMU_OPT_BOOL,
>

  reply	other threads:[~2016-04-04 11:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-01 18:39 [Qemu-devel] [V8 0/4] AMD IOMMU David Kiarie
2016-04-01 18:39 ` [Qemu-devel] [V8 1/4] hw/i386: Introduce " David Kiarie
2016-04-01 18:39 ` [Qemu-devel] [V8 2/4] hw/i386: ACPI table for " David Kiarie
2016-04-04 15:34   ` Marcel Apfelbaum
2016-04-06 16:25   ` Igor Mammedov
2016-04-01 18:39 ` [Qemu-devel] [V8 3/4] hw/core: Add AMD IOMMU to machine properties David Kiarie
2016-04-04 11:17   ` Marcel Apfelbaum [this message]
2016-04-01 18:39 ` [Qemu-devel] [V8 4/4] hw/pci-host: Emulate AMD IOMMU David Kiarie
2016-04-04 11:26   ` Marcel Apfelbaum

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=57024D47.1090903@gmail.com \
    --to=marcel.apfelbaum@gmail.com \
    --cc=davidkiarie4@gmail.com \
    --cc=jan.kizska@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).