From nobody Mon Nov 17 01:27:16 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1602177504; cv=none; d=zohomail.com; s=zohoarc; b=PYDSazFSt8NOhr0W4R7y/m4bcna3k082iRw1XU37AtxXX0HJF14+YnivnY1nR93h7j05Sm1OvjHqEYiH6ZlBWl5dG3WR0JE+KzK/daaKeKu2sROjVaoj2FpmsSTGHhAcKMURwnRUKhWn+HfSSiBy1nt5MmPD1LBNKoZIjUlVmco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602177504; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gIAtQOZ+zrlWQfjLRgAdZMIze9gG8ZgbjrmwZekQ+1A=; b=P0YEXWTpZiVFQDslH77a3G56TUiyRz8AyyFro2LMp0PegdMdj83/4GLFKYbXSAg7ljJ3DaR2p6wTfgjVOm3FcrH/evMTYexZqarwteVVKKwIJ9JbQsiWIOdZfmbaxqCk4xfwYaHPpd3qb86bSHjkr8S3B3sSZgps8EglnYgic48= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1602177504048292.43389772249884; Thu, 8 Oct 2020 10:18:24 -0700 (PDT) Received: from localhost ([::1]:49956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQZYc-0006Im-Qm for importer@patchew.org; Thu, 08 Oct 2020 13:18:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQZXB-0004h6-Jr for qemu-devel@nongnu.org; Thu, 08 Oct 2020 13:16:53 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:33630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kQZX9-0006eB-U8 for qemu-devel@nongnu.org; Thu, 08 Oct 2020 13:16:53 -0400 Received: by mail-wr1-x441.google.com with SMTP id m6so7473181wrn.0 for ; Thu, 08 Oct 2020 10:16:51 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id x1sm719413wrl.41.2020.10.08.10.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 10:16:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gIAtQOZ+zrlWQfjLRgAdZMIze9gG8ZgbjrmwZekQ+1A=; b=mj6EG3yT0yJc/G6ZQvoBaj4avhGX07sIpd+W4SBW+osrHKGbtvS47H/hVgf8QyfUHe A0auhOk72VcwzoVaK00/aISFnJryUfozXWqiWS7B/5m5Zjgf3i/PhZcT9HyhB2f+vDQy XgoRYwtXVuE+6G8TKL7KbxrBauOpsVJFOqvC0wD+RllsoWfeb+Jd8syWJhIfKEVQ3cNC LFkKzwpLCqRSyp8A8UNzjXlbnJExQ+eSTYRoTa1RFPuYaPHFumI7h6hBfvi+ldhWo3wX opZoiY+DINBx/YqI/6S6l5uutKSUWpgKurJYu/YIG4J7VdbfNNLBZ4TTbb3j+mc5AMXm BvUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gIAtQOZ+zrlWQfjLRgAdZMIze9gG8ZgbjrmwZekQ+1A=; b=cgHChoJVAnP63htJE6jXWvofaZxunEIi6Ogn8t7Hg1fbd+l6pZFWFADqlhJVswSB2Y 2WofPacnHwTrtlV821gPIxUDcWm9Lc3vinuxdfHU5fzihp/BjWEPDOKvfZXNIGJEwFG3 OiftpqB+VAJWZNOcHna58sVI6VKrBBg8qwbA4cvG2Zw0fPULg1gdWS4VLdSPZH78krb1 gVThSYVk1xidOnguwsQxRChney3ptDEQjF0UYm14jgDzmZ+K+PJKpjORvlojfbReIwSO RxforAA5ZP3PXW4Xz0/MbSZkIf7M74tsPnEfeGaCvGhVaJgywTbVl0mOVhv41o/tTpo3 v9cg== X-Gm-Message-State: AOAM533nOk85rgTgSqL4Jj6npmsbjLG8izUYqKs41EKKlUky/hLb+A03 CynYhf4JAoeS2FeSvzNlkjT94Q== X-Google-Smtp-Source: ABdhPJyF/1ViTi2qRMbTXgKqpTpGV0nnp1HpSKSEeLboXZzCr42byYjowas4ASKTAXN5tJjxEFJ+8A== X-Received: by 2002:adf:f3c4:: with SMTP id g4mr11146586wrp.207.1602177410647; Thu, 08 Oct 2020 10:16:50 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com, alex.williamson@redhat.com Subject: [PATCH v10 02/10] virtio-iommu: Store memory region in endpoint struct Date: Thu, 8 Oct 2020 19:15:50 +0200 Message-Id: <20201008171558.410886-3-jean-philippe@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201008171558.410886-1-jean-philippe@linaro.org> References: <20201008171558.410886-1-jean-philippe@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=jean-philippe@linaro.org; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jean-Philippe Brucker , mst@redhat.com, qemu-devel@nongnu.org, peterx@redhat.com, pbonzini@redhat.com, bbhushan2@marvell.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Store the memory region associated to each endpoint into the endpoint structure, to allow efficient memory notification on map/unmap. Signed-off-by: Jean-Philippe Brucker Acked-by: Eric Auger --- Not super confident about the reconstruct_endpoint() change since I haven't tested migration yet. Does it make sense? --- hw/virtio/virtio-iommu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 543fbbb24fb..33115e82186 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -49,6 +49,7 @@ typedef struct VirtIOIOMMUDomain { typedef struct VirtIOIOMMUEndpoint { uint32_t id; VirtIOIOMMUDomain *domain; + IOMMUMemoryRegion *iommu_mr; QLIST_ENTRY(VirtIOIOMMUEndpoint) next; } VirtIOIOMMUEndpoint; =20 @@ -137,16 +138,19 @@ static VirtIOIOMMUEndpoint *virtio_iommu_get_endpoint= (VirtIOIOMMU *s, uint32_t ep_id) { VirtIOIOMMUEndpoint *ep; + IOMMUMemoryRegion *mr; =20 ep =3D g_tree_lookup(s->endpoints, GUINT_TO_POINTER(ep_id)); if (ep) { return ep; } - if (!virtio_iommu_mr(s, ep_id)) { + mr =3D virtio_iommu_mr(s, ep_id); + if (!mr) { return NULL; } ep =3D g_malloc0(sizeof(*ep)); ep->id =3D ep_id; + ep->iommu_mr =3D mr; trace_virtio_iommu_get_endpoint(ep_id); g_tree_insert(s->endpoints, GUINT_TO_POINTER(ep_id), ep); return ep; @@ -927,9 +931,14 @@ static gboolean reconstruct_endpoints(gpointer key, gp= ointer value, VirtIOIOMMU *s =3D (VirtIOIOMMU *)data; VirtIOIOMMUDomain *d =3D (VirtIOIOMMUDomain *)value; VirtIOIOMMUEndpoint *iter; + IOMMUMemoryRegion *mr; =20 QLIST_FOREACH(iter, &d->endpoint_list, next) { + mr =3D virtio_iommu_mr(s, iter->id); + assert(mr); + iter->domain =3D d; + iter->iommu_mr =3D mr; g_tree_insert(s->endpoints, GUINT_TO_POINTER(iter->id), iter); } return false; /* continue the domain traversal */ --=20 2.28.0