From patchwork Sat Oct 15 10:12:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aviv B.D." X-Patchwork-Id: 9377757 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 486B1600CA for ; Sat, 15 Oct 2016 10:13:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2408F2934C for ; Sat, 15 Oct 2016 10:13:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04AA82933E; Sat, 15 Oct 2016 10:13:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 84F402933E for ; Sat, 15 Oct 2016 10:13:06 +0000 (UTC) Received: from localhost ([::1]:51191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvLxg-0003bo-Qf for patchwork-qemu-devel@patchwork.kernel.org; Sat, 15 Oct 2016 06:13:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvLxG-0003bd-Ey for qemu-devel@nongnu.org; Sat, 15 Oct 2016 06:12:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bvLxD-0002hP-IV for qemu-devel@nongnu.org; Sat, 15 Oct 2016 06:12:37 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:33828) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bvLxD-0002gs-Bl for qemu-devel@nongnu.org; Sat, 15 Oct 2016 06:12:35 -0400 Received: by mail-wm0-x244.google.com with SMTP id z189so1964933wmb.1 for ; Sat, 15 Oct 2016 03:12:35 -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=U7dJkEcNEUslYjecCZfsiY86RHKQ6xqStT1g0Y44bVo=; b=zn+BMnTxrbt5+4amxwkaqkIVciWBNgpIhnlxrFPcDGUcMJXxlDlXl03vXlsD/KHASF sec01yyOoXgkWCL2QkaskhJLIgyBht7L4r1vh/AyoyrGfLN4f2Or8D9entNF+UAEJQZR ieMGfa7r2OdzbYVJQZwH9s/ii8zhsX1FVi8q0K+Q7cbsZw4a+507au5ETHlIhCSzkIt0 xM5b0XkcayKlVzw8J2BTIWN4Tz17Sg7j7Sg/1RElDyLyzeHz95EaEz+9zWnUf+d/feaM hJNL2c5gnAK08xMtnemzrYsolifa1a0OqPB83kFzzhZfqGAXucY536lgN49XhkxFmzhy eP7A== 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=U7dJkEcNEUslYjecCZfsiY86RHKQ6xqStT1g0Y44bVo=; b=W1rMXzhNb/eyMCGEHJao3yQid1+3uVg2OWQvZXDTtc63Uz9QF+u95HNg9b/TQwfbl9 OFqoWTDqT6B7XBuWncd00jZ7ni1hti3P+2KXx6oJLcS/fkejJ/hYTuhYnhhBS+IDTVJS CIikactAaHrwN2bzU4+GU1i+BcMUS94zMDA+knoaEQnLeDBv45YbQuaMwdFyihDW/Kmy BwBbKfkygTMWdMNQnvKQmZYuHVS/vGyA6QdQ1LRdPx3oO9J/FJc9UcB+GUjZF2eqyo5e VfbOKtFQyPsz8oU3sS0sCWEbKTp7VDnpfiZFYJHjahrl1Dsdd+qPauZN6gyeCezAlIQq Vl1g== X-Gm-Message-State: AA6/9RnBvYXD39YH9tf/iw97j7sC39CyKI/NBoKbVpgB0cHgLzhZJE/fycCRbaGrTNweTQ== X-Received: by 10.194.206.68 with SMTP id lm4mr4960420wjc.106.1476526354235; Sat, 15 Oct 2016 03:12:34 -0700 (PDT) Received: from tapuz2.cslcs.technion.ac.il (tapuz2.cslcs.technion.ac.il. [132.68.206.212]) by smtp.gmail.com with ESMTPSA id i15sm2757136wmf.8.2016.10.15.03.12.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 15 Oct 2016 03:12:33 -0700 (PDT) From: "Aviv B.D" To: qemu-devel@nongnu.org Date: Sat, 15 Oct 2016 13:12:04 +0300 Message-Id: <1476526326-32363-2-git-send-email-bd.aviv@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476526326-32363-1-git-send-email-bd.aviv@gmail.com> References: <1476526326-32363-1-git-send-email-bd.aviv@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::244 Subject: [Qemu-devel] [PATCH v4 1/3] IOMMU: add option to enable VTD_CAP_CM to vIOMMU capility exposoed to guest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Kiszka , Alex Williamson , Aviv Ben-David , Peter Xu , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Aviv Ben-David" This capability asks the guest to invalidate cache before each map operation. We can use this invalidation to trap map operations in the hypervisor. This capability only enabled when cache-mode property of the device is true. Signed-off-by: Aviv Ben-David --- hw/i386/intel_iommu.c | 5 +++++ hw/i386/intel_iommu_internal.h | 1 + include/hw/i386/intel_iommu.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 2efd69b..6e5ad7b 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2012,6 +2012,7 @@ static const MemoryRegionOps vtd_mem_ops = { static Property vtd_properties[] = { DEFINE_PROP_UINT32("version", IntelIOMMUState, version, 0), + DEFINE_PROP_BOOL("cache-mode", IntelIOMMUState, cache_mode_enabled, FALSE), DEFINE_PROP_END_OF_LIST(), }; @@ -2385,6 +2386,10 @@ static void vtd_init(IntelIOMMUState *s) s->ecap |= VTD_ECAP_IR | VTD_ECAP_EIM | VTD_ECAP_MHMV; } + if (s->cache_mode_enabled){ + s->cap |= VTD_CAP_CM; + } + vtd_reset_context_cache(s); vtd_reset_iotlb(s); diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 0829a50..35d9f3a 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -201,6 +201,7 @@ #define VTD_CAP_MAMV (VTD_MAMV << 48) #define VTD_CAP_PSI (1ULL << 39) #define VTD_CAP_SLLPS ((1ULL << 34) | (1ULL << 35)) +#define VTD_CAP_CM (1ULL << 7) /* Supported Adjusted Guest Address Widths */ #define VTD_CAP_SAGAW_SHIFT 8 diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index a42dbd7..7a94f16 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -258,6 +258,8 @@ struct IntelIOMMUState { uint8_t womask[DMAR_REG_SIZE]; /* WO (write only - read returns 0) */ uint32_t version; + bool cache_mode_enabled; /* RO - is cap CM enabled? */ + dma_addr_t root; /* Current root table pointer */ bool root_extended; /* Type of root table (extended or not) */ bool dmar_enabled; /* Set if DMA remapping is enabled */