diff mbox

memory: check address space when a listener is registered

Message ID 6645adb9b3662c620ef26b444feec1b02ca06ecc.1333548055.git.julien.grall@citrix.com
State New
Headers show

Commit Message

Julien Grall April 4, 2012, 2:15 p.m. UTC
This patch resolves a bug in memory listener registration.
"range_add" callback  was called on each section of the both
address space (IO and memory space) even if it doesn't match
the address space filter.

Signed-off-by: Julien Grall <julien.grall@citrix.com>
---
 memory.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Comments

Avi Kivity April 5, 2012, 10:10 a.m. UTC | #1
On 04/04/2012 05:15 PM, Julien Grall wrote:
> This patch resolves a bug in memory listener registration.
> "range_add" callback  was called on each section of the both
> address space (IO and memory space) even if it doesn't match
> the address space filter.
>

Thanks, applied.

Did you find this bug by inspection, or did it bite you?  I thought all
listeners were registered before address spaces were materialized.
Julien Grall April 5, 2012, 11:05 a.m. UTC | #2
On 04/05/2012 11:10 AM, Avi Kivity wrote:
> On 04/04/2012 05:15 PM, Julien Grall wrote:
>    
>> This patch resolves a bug in memory listener registration.
>> "range_add" callback  was called on each section of the both
>> address space (IO and memory space) even if it doesn't match
>> the address space filter.
>>
>>      
> Thanks, applied.
>
> Did you find this bug by inspection, or did it bite you?  I thought all
> listeners were registered before address spaces were materialized.
>
>    
I added a listener on IO address space for Xen.
The listener is registered after Xen allocates ram.
Without this patch, the listener was called on Xen ram.
diff mbox

Patch

diff --git a/memory.c b/memory.c
index 22b0352..a9d237d 100644
--- a/memory.c
+++ b/memory.c
@@ -1444,6 +1444,11 @@  static void listener_add_address_space(MemoryListener *listener,
 {
     FlatRange *fr;
 
+    if (listener->address_space_filter
+        && listener->address_space_filter != as->root) {
+        return;
+    }
+
     if (global_dirty_log) {
         listener->log_global_start(listener);
     }