All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: mst@redhat.com, qemu-devel@nongnu.org, eric.auger@redhat.com,
	viktor@daynix.com
Subject: Re: [PATCH 3/3] intel-iommu: build iova tree during IOMMU translation
Date: Mon, 5 Dec 2022 18:18:56 -0500	[thread overview]
Message-ID: <Y458YMavxao9XSwL@x1n> (raw)
In-Reply-To: <CACGkMEszjH02RPRy5ps7JBqkELCqLSdcCCLyPLoxY155zh8BgQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 562 bytes --]

Jason,

On Mon, Dec 05, 2022 at 12:12:04PM +0800, Jason Wang wrote:
> I'm fine to go without iova-tree. Would you mind to post patches for
> fix? I can test and include it in this series then.

One sample patch attached, only compile tested.

I can also work on this but I'll be slow in making progress, so I'll add it
into my todo.  If you can help to fix this issue it'll be more than great.
No worry on the ownership or authorship of the patch if you agree on the
change and moving forward with this when modifying - just take it over!

Thanks!

-- 
Peter Xu

[-- Attachment #2: 0001-memory-sanity-check-flatview-deref-on-mr-transaction.patch --]
[-- Type: text/plain, Size: 1572 bytes --]

From 57e5cab805c94d56f801a7e21098389a77584e34 Mon Sep 17 00:00:00 2001
From: Peter Xu <peterx@redhat.com>
Date: Mon, 5 Dec 2022 11:14:02 -0500
Subject: [PATCH] memory: sanity check flatview deref on mr transactions
Content-type: text/plain

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 include/exec/memory.h | 9 +++++++++
 softmmu/memory.c      | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 91f8a2395a..e136ab9558 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1069,8 +1069,17 @@ struct FlatView {
     MemoryRegion *root;
 };
 
+extern unsigned memory_region_transaction_depth;
+
 static inline FlatView *address_space_to_flatview(AddressSpace *as)
 {
+    /*
+     * Before using any flatview, sanity check we're not during a memory
+     * region transaction or the map can be invalid.  Note that this can
+     * also be called during commit phase of memory transaction, but that
+     * should also only happen when the depth decreases to 0 first.
+     */
+    assert(memory_region_transaction_depth == 0);
     return qatomic_rcu_read(&as->current_map);
 }
 
diff --git a/softmmu/memory.c b/softmmu/memory.c
index bc0be3f62c..7cfcf5dffe 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -37,7 +37,7 @@
 
 //#define DEBUG_UNASSIGNED
 
-static unsigned memory_region_transaction_depth;
+unsigned memory_region_transaction_depth;
 static bool memory_region_update_pending;
 static bool ioeventfd_update_pending;
 unsigned int global_dirty_tracking;
-- 
2.37.3


  reply	other threads:[~2022-12-05 23:19 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29  8:10 [PATCH 0/3] Fix UNMAP notifier for intel-iommu Jason Wang
2022-11-29  8:10 ` [PATCH 1/3] intel-iommu: fail MAP notifier without caching mode Jason Wang
2022-11-29 15:35   ` Peter Xu
2022-11-30  6:23     ` Jason Wang
2022-11-30 15:06       ` Peter Xu
2022-12-01  8:46         ` Jason Wang
2022-12-06 13:23   ` Eric Auger
2022-11-29  8:10 ` [PATCH 2/3] intel-iommu: fail DEVIOTLB_UNMAP without dt mode Jason Wang
2022-11-29 15:38   ` Peter Xu
2022-12-01 16:03   ` Peter Xu
2023-02-23  3:19     ` Jason Wang
2022-12-06 13:33   ` Eric Auger
2023-02-03  9:08   ` Laurent Vivier
2023-02-07 16:17     ` Laurent Vivier
2023-02-07 16:35       ` Peter Xu
2022-11-29  8:10 ` [PATCH 3/3] intel-iommu: build iova tree during IOMMU translation Jason Wang
2022-11-29 15:57   ` Peter Xu
2022-11-30  6:33     ` Jason Wang
2022-11-30 15:17       ` Peter Xu
2022-12-01  8:35         ` Jason Wang
2022-12-01 14:58           ` Peter Xu
2022-12-05  4:12             ` Jason Wang
2022-12-05 23:18               ` Peter Xu [this message]
2022-12-06  3:18                 ` Jason Wang
2022-12-06 13:58                   ` Peter Xu
2022-12-23  8:02                     ` Jason Wang
2022-12-23 16:22                       ` Peter Xu
2022-11-30 16:37 ` [PATCH 0/3] Fix UNMAP notifier for intel-iommu Michael S. Tsirkin
2022-12-01  8:29   ` Jason Wang
2022-12-20 13:53 ` Michael S. Tsirkin
2022-12-21  3:17   ` Jason Wang
2023-01-15 23:30 ` Viktor Prutyanov
2023-01-16  7:06   ` Jason Wang
2023-01-27 13:17     ` Michael S. Tsirkin
2023-01-29  5:43       ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y458YMavxao9XSwL@x1n \
    --to=peterx@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=viktor@daynix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.