qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] exec: Fix section_covers_addr() for sections wi


From: BALATON Zoltan
Subject: Re: [Qemu-devel] [PATCH] exec: Fix section_covers_addr() for sections with non-zero offset
Date: Wed, 15 Nov 2017 00:03:12 +0100 (CET)
User-agent: Alpine 2.21 (BSF 202 2017-01-01)

On Tue, 14 Nov 2017, Paolo Bonzini wrote:
On 21/10/2017 13:24, BALATON Zoltan wrote:
diff --git a/exec.c b/exec.c
index db5ae23..a915817 100644
--- a/exec.c
+++ b/exec.c
@@ -370,7 +370,8 @@ static inline bool section_covers_addr(const 
MemoryRegionSection *section,
      * the section must cover the entire address space.
      */
     return int128_gethi(section->size) ||
-           range_covers_byte(section->offset_within_address_space,
+           range_covers_byte(section->offset_within_address_space +
+                             section->offset_within_region,
                              int128_getlo(section->size), addr);
 }

Sorry, this is incorrect.  addr is an address in the address space, and
range_covers_byte checks if it is between
section->offset_within_address_space and
section->offset_within_address_space + section->size.  I am not sure how
things don't explode completely by adding section->offset_within_region
(probably it's just because section->offset_within_region is usually 0).

I had a feeling this might not be correct but appeared to work, very likely because in most cases the offset is 0 (which is why the bug wasn't happening very often either). How about the alternative I've just sent according to your suggestion? That also appears to fix the problem and hopefully more correct.

Thank you,
BALATON Zoltan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]