From patchwork Sun Feb 21 18:10:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Kiarie X-Patchwork-Id: 8368911 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 7A0EF9F372 for ; Sun, 21 Feb 2016 18:11:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2DBE20274 for ; Sun, 21 Feb 2016 18:11:46 +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 C35B420204 for ; Sun, 21 Feb 2016 18:11:45 +0000 (UTC) Received: from localhost ([::1]:43030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXYTw-0006x0-Su for patchwork-qemu-devel@patchwork.kernel.org; Sun, 21 Feb 2016 13:11:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXYTk-0006qa-TJ for qemu-devel@nongnu.org; Sun, 21 Feb 2016 13:11:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXYTj-0005aN-Qz for qemu-devel@nongnu.org; Sun, 21 Feb 2016 13:11:32 -0500 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:34112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXYTj-0005Zl-Hk for qemu-devel@nongnu.org; Sun, 21 Feb 2016 13:11:31 -0500 Received: by mail-wm0-x22d.google.com with SMTP id b205so128638837wmb.1 for ; Sun, 21 Feb 2016 10:11:31 -0800 (PST) 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=jXkT8BaO4H6lCytYq0G4TxD8mPBlIofsE2YgbT7rrww=; b=LtQVH5sjBy8sVbtYk2/BhA7PayknIc9mSw7oM+kITrjedesktNNVaExBNB5KA0XCEb FyGZFeD6kNieHmYBJfs20Xk04Xtaw6Z9AYzFNLt0Nb3Ss6s21OqVDa1AoQaF83kHMUC8 gVT4iSWDMhgJZpxeYf90XJK+aKd4y7qE+bmkgoiqaYNc+AGJmMn0+DHaVHjzjF7Zr3ed 0WNRbVgwdELVSx8ZG9z9F/z3i6sBWFVv0qRUbIeuz8noo4qoQSbajQxJuisB7T44wGk0 NQc5batZoHbUQuu/lMTBcucXPMmP3cCdkrq+U+1RTTnHqTzdOKcKbFFCCRx5JZnxJyaC eJVQ== 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=jXkT8BaO4H6lCytYq0G4TxD8mPBlIofsE2YgbT7rrww=; b=Z9azVKtMLtbYynkCb1I7c1blKhKULbcba/ojjW1i//DN4xqFAu6KcT7C4wBtdzWvZC Yyl9Eox7Yh7M7bfndMeT/rPIAWPp7lfQsNDzTrrfJO3PgUAPdi2M8htF3Qj6uuDvk3wR VU0m2vd+0PW1sJlX1ieALn6W6dbJwEi+RhpDzn8St3EzpDRNtT899ecjQ78/hMd8s3o4 fTeZPUt2/DpJHCPdN5q737O38mai8ISyUFAfQjtwmN2v6xBHyMzin+4bamowXeLszi6m 1ly2866gIv5yig1Frf1xhqAtnBUsSKokvByRt5j4QsWiI1/wOAO8xSwNMv7qsRPs34mn +bTQ== X-Gm-Message-State: AG10YOSyEPQbA78w5UVlWx4GK8lfhExmk8fTX7Ihoz319L0aF0lGCnHcKbhdXFXuH9ajCw== X-Received: by 10.194.84.66 with SMTP id w2mr11846267wjy.6.1456078291019; Sun, 21 Feb 2016 10:11:31 -0800 (PST) Received: from debian.flybox.orange ([154.122.76.124]) by smtp.googlemail.com with ESMTPSA id l132sm17411011wmf.7.2016.02.21.10.11.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 21 Feb 2016 10:11:30 -0800 (PST) From: David Kiarie To: qemu-devel@nongnu.org Date: Sun, 21 Feb 2016 21:10:58 +0300 Message-Id: <1456078260-6669-3-git-send-email-davidkiarie4@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456078260-6669-1-git-send-email-davidkiarie4@gmail.com> References: <1456078260-6669-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::22d Cc: marcel@redhat.com, valentine.sinitsyn@gmail.com, jan.kiszka@web.de, David Kiarie , mst@redhat.com Subject: [Qemu-devel] [V6 2/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 Add IOMMU as a string to machine properties which is used to control whether and the type of IOMMU to emulate Signed-off-by: David Kiarie --- hw/core/machine.c | 28 ++++++++++++++++++++-------- include/hw/boards.h | 3 ++- qemu-options.hx | 6 +++--- util/qemu-config.c | 4 ++-- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 6d1a0d8..001ace9 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -14,6 +14,8 @@ #include "hw/boards.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" @@ -284,18 +286,28 @@ static void machine_set_firmware(Object *obj, const char *value, Error **errp) ms->firmware = g_strdup(value); } -static bool machine_get_iommu(Object *obj, Error **errp) +static char *machine_get_iommu(Object *obj, Error **errp) { MachineState *ms = MACHINE(obj); - return ms->iommu; + return g_strdup(ms->iommu); } -static void machine_set_iommu(Object *obj, bool value, Error **errp) +static void machine_set_iommu(Object *obj, const char *value, Error **errp) { MachineState *ms = MACHINE(obj); + Error *err = NULL; + + g_free(ms->iommu); + + 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; + } - ms->iommu = value; + ms->iommu = g_strdup(value); } static void machine_set_suppress_vmdesc(Object *obj, bool value, Error **errp) @@ -455,11 +467,10 @@ static void machine_initfn(Object *obj) object_property_set_description(obj, "firmware", "Firmware image", NULL); - object_property_add_bool(obj, "iommu", - machine_get_iommu, - machine_set_iommu, NULL); + object_property_add_str(obj, "iommu", + machine_get_iommu, machine_set_iommu, NULL); object_property_set_description(obj, "iommu", - "Set on/off to enable/disable Intel IOMMU (VT-d)", + "IOMMU list", NULL); object_property_add_bool(obj, "suppress-vmdesc", machine_get_suppress_vmdesc, @@ -485,6 +496,7 @@ static void machine_finalize(Object *obj) g_free(ms->dumpdtb); g_free(ms->dt_compatible); g_free(ms->firmware); + g_free(ms->iommu); } bool machine_usb(MachineState *machine) diff --git a/include/hw/boards.h b/include/hw/boards.h index 0f30959..b119245 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -36,6 +36,7 @@ bool machine_usb(MachineState *machine); bool machine_kernel_irqchip_allowed(MachineState *machine); bool machine_kernel_irqchip_required(MachineState *machine); bool machine_kernel_irqchip_split(MachineState *machine); +bool machine_amd_iommu(MachineState *machine); int machine_kvm_shadow_mem(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); @@ -126,7 +127,7 @@ struct MachineState { bool usb_disabled; bool igd_gfx_passthru; char *firmware; - bool iommu; + char *iommu; bool suppress_vmdesc; ram_addr_t ram_size; diff --git a/qemu-options.hx b/qemu-options.hx index 2f0465e..dad160f 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -38,7 +38,7 @@ 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=amd|intel enables and selects the emulated IOMMU (default: off)\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" @@ -72,8 +72,8 @@ Include guest memory in a core dump. The default is on. 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. +@item iommu=intel|amd +Enables and selects the emulated IOMMU. The default is off. @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..f1b5a3b 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -213,8 +213,8 @@ 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_STRING, + .help = "Enables IOMMU and sets the emulated type", },{ .name = "suppress-vmdesc", .type = QEMU_OPT_BOOL,