From patchwork Fri Apr 1 18:39:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Kiarie X-Patchwork-Id: 8727051 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 734659F38C for ; Fri, 1 Apr 2016 18:43:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A333D2039D for ; Fri, 1 Apr 2016 18:43:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C3DF720390 for ; Fri, 1 Apr 2016 18:43:24 +0000 (UTC) Received: from localhost ([::1]:45898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1am42W-0001yV-8k for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Apr 2016 14:43:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1am40S-0007Bv-5m for qemu-devel@nongnu.org; Fri, 01 Apr 2016 14:41:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1am40R-0007jI-2w for qemu-devel@nongnu.org; Fri, 01 Apr 2016 14:41:16 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34305) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1am40Q-0007jD-On for qemu-devel@nongnu.org; Fri, 01 Apr 2016 14:41:15 -0400 Received: by mail-wm0-x242.google.com with SMTP id p65so350299wmp.1 for ; Fri, 01 Apr 2016 11:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Mmq4uFsju8YnSl0cTOxap66SbFbjapIHYbEI1NX6SNc=; b=qJsfEdVWBsPT3JZiRCQ2IacK+EKhkS/vOnkKO6+gMBY5Y0acKCbPBxpAWJR0tRiIXn euyh1cBi3621QEvTigs3jg/Ph3JER+kxEAsDJjMI2ZqIkyWocO66UgTsP7ToZ39y4Nuk NUKfEXvt1Il9/R7qK9/nhrnqj9Pj4oCbKhjZQrHbDQ6nU25RlpUAA8xrZwqQh9/6Pk0R XQSEsaVrK+WnouAPBqLuoqburl6SDzC4h6jFUxCsL7hvdjBSGeeg5hEcTPP+jF7cS9lf v1qn+I5fWg6yqMCGVkqKUeiPm+/2p3s4Y4IcVhubpyw2BApHKDOV2iAGStBO2Ck6sVMt DG5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Mmq4uFsju8YnSl0cTOxap66SbFbjapIHYbEI1NX6SNc=; b=A1gHFlOGi4Lsu2TGhkuoZKKmvvzOXJmWtXqcvBNcXDcbt2v7KJWJtak1w6xDW5KNk2 4/iebaluXEOe8NQHucbVGYN2RXvgPjnDZ7vzB8sy3N1sjyvRvkxGHWuPEmHUb1+6iJPv WcHEkgdgpE+P4Jp7EOon/ViAPy705u65iclMjYVu2wuzz4p49Z7B6mZMpXX60ia+XpCU tZk8eo0H5BaGsW/uJbvzbX/fK2CbOKf1CtETuanApa7puyRBL9XTiRG3zmRmXCqoD/vI 2UdQx/jBhko/6rvqXJM+YNtTwXhUHu4m1iQcZttGzDqvOOJHc9qzngIk4malNuj21jZw N5Tg== X-Gm-Message-State: AD7BkJJaG5/92VB3OTLasV+Wn0EsTq1XxonomdcfAdtcOW+RxsmvmuRferGCyh+/DzMRZw== X-Received: by 10.28.211.130 with SMTP id k124mr204089wmg.7.1459536074155; Fri, 01 Apr 2016 11:41:14 -0700 (PDT) Received: from debian.flybox.orange ([154.122.176.211]) by smtp.googlemail.com with ESMTPSA id w184sm233275wmb.1.2016.04.01.11.41.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 11:41:13 -0700 (PDT) From: David Kiarie To: qemu-devel@nongnu.org Date: Fri, 1 Apr 2016 21:39:53 +0300 Message-Id: <1459535994-18523-4-git-send-email-davidkiarie4@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459535994-18523-1-git-send-email-davidkiarie4@gmail.com> References: <1459535994-18523-1-git-send-email-davidkiarie4@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Cc: marcel@redhat.com, valentine.sinitsyn@gmail.com, David Kiarie , jan.kizska@web.de, mst@redhat.com Subject: [Qemu-devel] [V8 3/4] hw/core: Add AMD IOMMU to machine properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added a bool, subject to review to machine properties which it used to override iommu emulated from Intel to AMD. Signed-off-by: David Kiarie --- 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; 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,