From nobody Mon Feb 9 20:59:16 2026 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=1680640697; cv=none; d=zohomail.com; s=zohoarc; b=bffXx/Z2l7+ZOv6VxEBG/G3ZqGqBE6iagqNAFnSUDUqMf5dGXkqMd28d2UNhGxolavWpdDTr97O9WLpOjfsoMPlkTHOgtTHTxQDLIsZ+wk/4bHz2SExAj8jYGW5908fMDhXVkzaCT/kKsTOIemLhu16llK3i5IOpv1piknFH/zQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680640697; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ZvINh2lTlsVDYlNcpGVFYZYIKuIcNzr8nmm2/+dwIpc=; b=J8qlMSA2XJTKEVLHXIiaKwZARIwwasuSX2KSfT7gUrtmqhuIAi9ezL7zbzny4H4v+7c4l3bhBMYVlZdxhrUEnlloGGuCY3LEDTVXoPoU6r9vL+FzTggRQaT1DDV9Bi/c8rjV5Jw6C4GePBKjT9MPDgPZKgPELsEc8pXjjW1hJsE= 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 1680640697639116.24667462869525; Tue, 4 Apr 2023 13:38:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pjnPV-0007P5-8g; Tue, 04 Apr 2023 16:37:45 -0400 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 1pjnPT-0007Os-BK for qemu-devel@nongnu.org; Tue, 04 Apr 2023 16:37:43 -0400 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 1pjnPR-0006sv-OY for qemu-devel@nongnu.org; Tue, 04 Apr 2023 16:37:43 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-q6Jq1ZthMsWD4YK-Q6dWPA-1; Tue, 04 Apr 2023 16:37:38 -0400 Received: by mail-ed1-f69.google.com with SMTP id s30-20020a508d1e000000b005005cf48a93so47345055eds.8 for ; Tue, 04 Apr 2023 13:37:38 -0700 (PDT) Received: from redhat.com ([2.52.139.22]) by smtp.gmail.com with ESMTPSA id y13-20020a170906524d00b00932ed432475sm6370955ejm.124.2023.04.04.13.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 13:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680640659; 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; bh=ZvINh2lTlsVDYlNcpGVFYZYIKuIcNzr8nmm2/+dwIpc=; b=RMYKhwaEjQybbU4s/FA3DE9Wh12zZji36IDDdQ/oDeh4bPWNzxG02qtLd98SI/jUV/Dt3V zFovxfeUTrlCjPD8llLn1PfYCK9b7tGqmlShAYJSVendlLKo3uMRKcVmQmrA1uBUpi0vN1 OtbYTAG4zVUd0SlXeDDV8BAufLUWHjs= X-MC-Unique: q6Jq1ZthMsWD4YK-Q6dWPA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680640655; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZvINh2lTlsVDYlNcpGVFYZYIKuIcNzr8nmm2/+dwIpc=; b=yM+9FqmLyVKwpZUGSKimAm8qmOK01hcEhvPI0BSRUrq9xYR0fkCP3dgZivNbDwnuQZ 2GPZjFAOm1bVYxjHoZV0ENmtdX19SSV8GJDlXCmi6VPNANDnSa4bu09gLbJCu7r/gMgT proKS2cl4uBz+jk6W2ZU8zxLAnZl2teViqi5mLm2Wut1dGbYr6DispDZ92tmtQ+lzZ/O D4KhAA9VAmxZV1QZ9C21Vo4nNfRstWrJarzvbfRr6K3iNoiKJrk9LBj0DQTwl/8dzI+2 mTzwaYtK6C2Mdm9K5lDZL4qrkvS0TVngGt+x3o5zWHBZeOGJbXoM//Bv9B174zE9HB1U FU+w== X-Gm-Message-State: AAQBX9czABtY1k/vIDvXyzS9oe0CV6Cg10eTXc+4JigPeWWoVLY9jsgv 4X9139etcNUX9y+OAu0Sd+mQxb9tStMRdPsp0mNVeMMjOi946toJPSBxlHYs4yrQlfOkFmKzIO/ gFJPhGod8pYZ6XZHjxaSXGtu1UMi/NksLk1fVZds1WTHYXL1qHLWdCEkUTxX9uevVA03/Hec= X-Received: by 2002:a17:906:1252:b0:86a:316:d107 with SMTP id u18-20020a170906125200b0086a0316d107mr677168eja.72.1680640655758; Tue, 04 Apr 2023 13:37:35 -0700 (PDT) X-Google-Smtp-Source: AKy350Z/FuaVSnRnch8tuDLZtmd9Oqfg2gUQP1zsXVf+nUGchjBMOLZpCDQ5Cs1Nd3hUHvMNQJKeNw== X-Received: by 2002:a17:906:1252:b0:86a:316:d107 with SMTP id u18-20020a170906125200b0086a0316d107mr677149eja.72.1680640655435; Tue, 04 Apr 2023 13:37:35 -0700 (PDT) Date: Tue, 4 Apr 2023 16:37:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Peter Xu , Jason Wang , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , David Hildenbrand , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: [PATCH] Revert "memory: Optimize replay of guest mapping" Message-ID: <917c1c552b2d1b732f9a86c6a90684c3a5e4cada.1680640587.git.mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-0.001, 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.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: 1680640698797100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Peter Maydell This reverts commit 6da24341866fa940fd7d575788a2319514941c77 ("memory: Optimize replay of guest mapping"). This change breaks the mps3-an547 board under TCG (and probably other TCG boards using an IOMMU), which now assert: $ ./build/x86/qemu-system-arm --machine mps3-an547 -serial stdio -kernel /tmp/an547-mwe/build/test.elf qemu-system-arm: ../../softmmu/memory.c:1903: memory_region_register_iommu_notifier: Assertion `n->end <=3D memory_region_size(mr)' failed. This is because tcg_register_iommu_notifier() registers an IOMMU notifier which covers the entire address space, so the assertion added in this commit is not correct. For the 8.0 release, just revert this commit as it is only an optimization. Fixes: 6da24341866f ("memory: Optimize replay of guest mapping") Signed-off-by: Peter Maydell Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- completely untested but Pater asked help in sending this. hw/i386/intel_iommu.c | 2 +- softmmu/memory.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index faade7def8..a62896759c 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3850,7 +3850,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu= _mr, IOMMUNotifier *n) .domain_id =3D vtd_get_domain_id(s, &ce, vtd_as->pasid), }; =20 - vtd_page_walk(s, &ce, n->start, n->end, &info, vtd_as->pasid); + vtd_page_walk(s, &ce, 0, ~0ULL, &info, vtd_as->pasid); } } else { trace_vtd_replay_ce_invalid(bus_n, PCI_SLOT(vtd_as->devfn), diff --git a/softmmu/memory.c b/softmmu/memory.c index 5305aca7ca..b1a6cae6f5 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1900,7 +1900,6 @@ int memory_region_register_iommu_notifier(MemoryRegio= n *mr, iommu_mr =3D IOMMU_MEMORY_REGION(mr); assert(n->notifier_flags !=3D IOMMU_NOTIFIER_NONE); assert(n->start <=3D n->end); - assert(n->end <=3D memory_region_size(mr)); assert(n->iommu_idx >=3D 0 && n->iommu_idx < memory_region_iommu_num_indexes(iommu_mr)); =20 @@ -1924,6 +1923,7 @@ uint64_t memory_region_iommu_get_min_page_size(IOMMUM= emoryRegion *iommu_mr) =20 void memory_region_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier= *n) { + MemoryRegion *mr =3D MEMORY_REGION(iommu_mr); IOMMUMemoryRegionClass *imrc =3D IOMMU_MEMORY_REGION_GET_CLASS(iommu_m= r); hwaddr addr, granularity; IOMMUTLBEntry iotlb; @@ -1936,7 +1936,7 @@ void memory_region_iommu_replay(IOMMUMemoryRegion *io= mmu_mr, IOMMUNotifier *n) =20 granularity =3D memory_region_iommu_get_min_page_size(iommu_mr); =20 - for (addr =3D n->start; addr < n->end; addr +=3D granularity) { + for (addr =3D 0; addr < memory_region_size(mr); addr +=3D granularity)= { iotlb =3D imrc->translate(iommu_mr, addr, IOMMU_NONE, n->iommu_idx= ); if (iotlb.perm !=3D IOMMU_NONE) { n->notify(n, &iotlb); --=20 MST