From patchwork Mon Jul 23 20:16:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 10540929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2266C112E for ; Mon, 23 Jul 2018 20:42:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 134E32849D for ; Mon, 23 Jul 2018 20:42:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07905284A5; Mon, 23 Jul 2018 20:42:21 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 750772849D for ; Mon, 23 Jul 2018 20:42:20 +0000 (UTC) Received: from localhost ([::1]:36469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhet-0005Zd-BZ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 Jul 2018 16:42:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIu-00024v-Bn for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIt-0003WZ-7v for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:36 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:46052) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIt-0003V9-0c; Mon, 23 Jul 2018 16:19:35 -0400 Received: by mail-oi0-x243.google.com with SMTP id q11-v6so3445797oic.12; Mon, 23 Jul 2018 13:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WOZC3pqoGeotZ1mreXhAi+nVK6kqI0RZ7Qp3NXO0dn8=; b=h640N5GD63yTY/oc8poQ19SjC7VQX/1TtXL4sCPJHe5MwCmoDpuv80ecLqZGcHuzLT FP8Yc8+9mRHgaPMaPJrZ8TT0GOR0GZ6FDqrlZ28OMRlngSvOxA9oB57bP2IUBnot4T9F gSGLhWIvqtiTtWkYEaOIN7tarWKPTs5OMRog7ieHtfha8EmNtHaciJtwZf/GZeikbU/F wWCvbvgY7C4Y/RSk+gRzrScA0zqnv4eHsb8dwq3wu22ny+/zpnc8L24iNOmMKjGh5Uq+ PfjpWWve9cYIxFnpfk1+8oOxNUrwWE/+hAA8Pi8DCSfPc2vhigf7t0anpK3Z4awfvkaG qIGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=WOZC3pqoGeotZ1mreXhAi+nVK6kqI0RZ7Qp3NXO0dn8=; b=uCIu/G9EreN0zkbpwyU6LtZQGF8Ps6slhW+Dyfp+EfSYga8zyqovjcHUwJNmgULPIT HcjXaYjy/YFdHn3QU9cnbU4m+oKa4SaKO1brqSbgSSheV/cF1wN+ko/hjnK+8YKLP2Hk Y1KrbalLitmYtmxARmAqprRFhV/seRylnMCcbE4TtfWA+C5ZeZeoHWOghp8IJOJlexc+ LtQX3u8i+LMc9S7X2ykIzNu1WPPpsS1AY6ylt+IwhK/RD3TgSVcV/B/MvLcYi01G+ftD m5y2SDIlSx8FPDpA0HgRJ53+G1mAzh4uR63YyQpYo3ho9YO22QLkvcSyncjZOCUAOwFd wuwg== X-Gm-Message-State: AOUpUlHa5bHYZdW42RXPY6m5sITOrPIscSZddbhltWCXClk48N+YfdAL 2W1e9lGKseSzMABDqXIRtTmC2YRH9eE= X-Google-Smtp-Source: AAOMgpfG+951j0L1QDgnXTlAionbGzh37lwm6oA8zAXOSc+XBs69EcRu6tGg9bH+P62apwYuOSMYkQ== X-Received: by 2002:aca:b641:: with SMTP id g62-v6mr324391oif.71.1532377173857; Mon, 23 Jul 2018 13:19:33 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id f75-v6sm17893826oig.53.2018.07.23.13.19.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:32 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:40 -0500 Message-Id: <20180723201748.25573-32-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 31/99] intel-iommu: trace domain id during page walk 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: qemu-stable@nongnu.org, 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: Peter Xu This patch only modifies the trace points. Previously we were tracing page walk levels. They are redundant since we have page mask (size) already. Now we trace something much more useful which is the domain ID of the page walking. That can be very useful when we trace more than one devices on the same system, so that we can know which map is for which domain. CC: QEMU Stable Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit d118c06ebbee2d23ddf873cae4a809311aa61310) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 16 ++++++++++------ hw/i386/trace-events | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index a882894f49..61bb3d31e7 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -756,6 +756,7 @@ typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private); * @notify_unmap: whether we should notify invalid entries * @as: VT-d address space of the device * @aw: maximum address width + * @domain: domain ID of the page walk */ typedef struct { VTDAddressSpace *as; @@ -763,17 +764,18 @@ typedef struct { void *private; bool notify_unmap; uint8_t aw; + uint16_t domain_id; } vtd_page_walk_info; -static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level, - vtd_page_walk_info *info) +static int vtd_page_walk_one(IOMMUTLBEntry *entry, vtd_page_walk_info *info) { vtd_page_walk_hook hook_fn = info->hook_fn; void *private = info->private; assert(hook_fn); - trace_vtd_page_walk_one(level, entry->iova, entry->translated_addr, - entry->addr_mask, entry->perm); + trace_vtd_page_walk_one(info->domain_id, entry->iova, + entry->translated_addr, entry->addr_mask, + entry->perm); return hook_fn(entry, private); } @@ -844,7 +846,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, trace_vtd_page_walk_skip_perm(iova, iova_next); goto next; } - ret = vtd_page_walk_one(&entry, level, info); + ret = vtd_page_walk_one(&entry, info); if (ret < 0) { return ret; } @@ -856,7 +858,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, * Translated address is meaningless, zero it. */ entry.translated_addr = 0x0; - ret = vtd_page_walk_one(&entry, level, info); + ret = vtd_page_walk_one(&entry, info); if (ret < 0) { return ret; } @@ -1466,6 +1468,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, .notify_unmap = true, .aw = s->aw_bits, .as = vtd_as, + .domain_id = domain_id, }; /* @@ -2947,6 +2950,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) .notify_unmap = false, .aw = s->aw_bits, .as = vtd_as, + .domain_id = VTD_CONTEXT_ENTRY_DID(ce.hi), }; vtd_page_walk(&ce, 0, ~0ULL, &info); diff --git a/hw/i386/trace-events b/hw/i386/trace-events index 22d44648af..ca23ba9fad 100644 --- a/hw/i386/trace-events +++ b/hw/i386/trace-events @@ -39,7 +39,7 @@ vtd_fault_disabled(void) "Fault processing disabled for context entry" vtd_replay_ce_valid(uint8_t bus, uint8_t dev, uint8_t fn, uint16_t domain, uint64_t hi, uint64_t lo) "replay valid context device %02"PRIx8":%02"PRIx8".%02"PRIx8" domain 0x%"PRIx16" hi 0x%"PRIx64" lo 0x%"PRIx64 vtd_replay_ce_invalid(uint8_t bus, uint8_t dev, uint8_t fn) "replay invalid context device %02"PRIx8":%02"PRIx8".%02"PRIx8 vtd_page_walk_level(uint64_t addr, uint32_t level, uint64_t start, uint64_t end) "walk (base=0x%"PRIx64", level=%"PRIu32") iova range 0x%"PRIx64" - 0x%"PRIx64 -vtd_page_walk_one(uint32_t level, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "detected page level 0x%"PRIx32" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" +vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIu16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to unable to read" vtd_page_walk_skip_perm(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to perm empty" vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set"