From nobody Wed Nov 27 00:31:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1703582862; cv=none; d=zohomail.com; s=zohoarc; b=Cs69NrYYPSKYX1aE1xwdTkWc+7WyKm6Oo7YG8ulhyP1hdcH934NZq1DODDQ9fPsLfRTeOYYiuHOPiZNLW/WvnGn95V9PRLvTJdV80GUI28+GHCw6MMgew2wjBfhG+hTDBFw+EXZ8LeK9DPP3rC1VGTTlS15Bhr8LquZtJXfVBHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703582862; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=o0S1EGWalT9mc5fSDPitMMFcpDcP6GvPJwnq9hG5/c8=; b=ncOD61NdL/kliMzmsJQbDHUWMG3cQ8hfkLUk69WJQTqXnzPu+5kEgoRkYgMdYRLPht6mjQXIbrdVRhXEhfmnzwevOS0GSjjONmSn7RTopaKprMdbu1yIVaCuWGZRyJdBK5rNjCP7oRJhEde/kjC++CTDMdzp7MWHvklcIGH15T4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1703582862649415.12300749528686; Tue, 26 Dec 2023 01:27:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rI3gp-00051B-N5; Tue, 26 Dec 2023 04:25:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rI3gn-0004sO-MS for qemu-devel@nongnu.org; Tue, 26 Dec 2023 04:25:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rI3gl-0000HP-Gw for qemu-devel@nongnu.org; Tue, 26 Dec 2023 04:25:29 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-UTP067Z0OkCrCqtG7tF1pA-1; Tue, 26 Dec 2023 04:25:24 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40d54db2ab5so20914875e9.2 for ; Tue, 26 Dec 2023 01:25:24 -0800 (PST) Received: from redhat.com ([2.55.177.189]) by smtp.gmail.com with ESMTPSA id j16-20020a05600c191000b0040c11fbe581sm20159153wmq.27.2023.12.26.01.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 01:25:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703582726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o0S1EGWalT9mc5fSDPitMMFcpDcP6GvPJwnq9hG5/c8=; b=iB5B6yVMC908Hx7/toOvo22cShvU4F7U41HkQvvK1Ls+xMvIepUvspzM20TECxgPozx6kx LJXOL+byy7KKXaZRfXyAadEXIrWv7HMXUl/F9VeOu0nblDpdSNmJBR3/LrCn+4AZP9G5E+ SdtXTg6NSY/AoS13cp30AyR24wl7j98= X-MC-Unique: UTP067Z0OkCrCqtG7tF1pA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703582723; x=1704187523; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=o0S1EGWalT9mc5fSDPitMMFcpDcP6GvPJwnq9hG5/c8=; b=gAiU4o3iQuazncZaFcnIifWUot9qmREwaHYJeeAyJEBcVXwy4DZRd0P+Q95RTBDCQt Dv8V9Cb/w7bOEQmQOQx2Aq2d6FyOQVimmqqSxWsG2lYZYqd5WJHDbCwZxDT7yrUW2keJ mmlOC1Pg5JtMMJhxxrs9PmJjpKHfjcPbU7fqyvgzTNNIym6pILmtI6HN/k9dQZO/WJxu i44i8EeZBva2VTvZsbji8gZCIzkm8x+SFsrwRb4r2dzWsQtq6cREhMI3xTSt2sjn3Klz oJnghEOPrf6C9w+SM2h/gBdMRf59qd8KHmcj6Vola7IR5/MMYTf/oQjcMZ1waJpqGKDt 0flw== X-Gm-Message-State: AOJu0Yxr+1AuGrAcb06Q+xoW92LUYbEIyLLkRaKaJJ+qXEdHrJpTYh4U kxDrGDOKU43OHSBd0KcKXoen6uiMU+dzQapDMHvLuogqiFJ9K3V+WsxxWnMXHyunojSNP929efQ s9+svn44sKYK/VV5Ux7vyezcmKGlfAnXeSLBEMe+zdXhmLLSLGQVPRmfcNirypu+WbwwDVH//29 Ln X-Received: by 2002:a05:600c:22ca:b0:40d:4a5e:e4f2 with SMTP id 10-20020a05600c22ca00b0040d4a5ee4f2mr2898476wmg.125.1703582722893; Tue, 26 Dec 2023 01:25:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IElSf2jtupM7KpRYjpndKIPxpuwRtqQJBuXFGVq4b9PosqqLTpUYXIFI1fYwmVQixouZRhJHQ== X-Received: by 2002:a05:600c:22ca:b0:40d:4a5e:e4f2 with SMTP id 10-20020a05600c22ca00b0040d4a5ee4f2mr2898466wmg.125.1703582722562; Tue, 26 Dec 2023 01:25:22 -0800 (PST) Date: Tue, 26 Dec 2023 04:25:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Eugenio =?utf-8?B?UMOpcmV6?= , Jason Wang , Lei Yang Subject: [PULL 20/21] vdpa: use dev_shared in vdpa_iommu Message-ID: <878f1e7dd9acc736e7a0f5a205c278c8ae769d39.1703582625.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.977, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1703582863209100001 From: Eugenio P=C3=A9rez The memory listener functions can call these too. Make vdpa_iommu work with VhostVDPAShared. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Message-Id: <20231221174322.3130442-13-eperezma@redhat.com> Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-vdpa.h | 2 +- hw/virtio/vhost-vdpa.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 705c754776..2abee2164a 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -75,7 +75,7 @@ int vhost_vdpa_dma_unmap(VhostVDPAShared *s, uint32_t asi= d, hwaddr iova, hwaddr size); =20 typedef struct vdpa_iommu { - struct vhost_vdpa *dev; + VhostVDPAShared *dev_shared; IOMMUMemoryRegion *iommu_mr; hwaddr iommu_offset; IOMMUNotifier n; diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index ada3cc5d7c..e6276fb1e4 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -199,7 +199,7 @@ static void vhost_vdpa_iommu_map_notify(IOMMUNotifier *= n, IOMMUTLBEntry *iotlb) struct vdpa_iommu *iommu =3D container_of(n, struct vdpa_iommu, n); =20 hwaddr iova =3D iotlb->iova + iommu->iommu_offset; - struct vhost_vdpa *v =3D iommu->dev; + VhostVDPAShared *s =3D iommu->dev_shared; void *vaddr; int ret; Int128 llend; @@ -212,10 +212,10 @@ static void vhost_vdpa_iommu_map_notify(IOMMUNotifier= *n, IOMMUTLBEntry *iotlb) RCU_READ_LOCK_GUARD(); /* check if RAM section out of device range */ llend =3D int128_add(int128_makes64(iotlb->addr_mask), int128_makes64(= iova)); - if (int128_gt(llend, int128_make64(v->shared->iova_range.last))) { + if (int128_gt(llend, int128_make64(s->iova_range.last))) { error_report("RAM section out of device range (max=3D0x%" PRIx64 ", end addr=3D0x%" PRIx64 ")", - v->shared->iova_range.last, int128_get64(llend)); + s->iova_range.last, int128_get64(llend)); return; } =20 @@ -225,20 +225,20 @@ static void vhost_vdpa_iommu_map_notify(IOMMUNotifier= *n, IOMMUTLBEntry *iotlb) if (!memory_get_xlat_addr(iotlb, &vaddr, NULL, &read_only, NULL)) { return; } - ret =3D vhost_vdpa_dma_map(v->shared, VHOST_VDPA_GUEST_PA_ASID, io= va, + ret =3D vhost_vdpa_dma_map(s, VHOST_VDPA_GUEST_PA_ASID, iova, iotlb->addr_mask + 1, vaddr, read_only); if (ret) { error_report("vhost_vdpa_dma_map(%p, 0x%" HWADDR_PRIx ", " "0x%" HWADDR_PRIx ", %p) =3D %d (%m)", - v, iova, iotlb->addr_mask + 1, vaddr, ret); + s, iova, iotlb->addr_mask + 1, vaddr, ret); } } else { - ret =3D vhost_vdpa_dma_unmap(v->shared, VHOST_VDPA_GUEST_PA_ASID, = iova, + ret =3D vhost_vdpa_dma_unmap(s, VHOST_VDPA_GUEST_PA_ASID, iova, iotlb->addr_mask + 1); if (ret) { error_report("vhost_vdpa_dma_unmap(%p, 0x%" HWADDR_PRIx ", " "0x%" HWADDR_PRIx ") =3D %d (%m)", - v, iova, iotlb->addr_mask + 1, ret); + s, iova, iotlb->addr_mask + 1, ret); } } } @@ -270,7 +270,7 @@ static void vhost_vdpa_iommu_region_add(MemoryListener = *listener, iommu_idx); iommu->iommu_offset =3D section->offset_within_address_space - section->offset_within_region; - iommu->dev =3D v; + iommu->dev_shared =3D v->shared; =20 ret =3D memory_region_register_iommu_notifier(section->mr, &iommu->n, = NULL); if (ret) { --=20 MST