[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] exec-obsolete: fix length handling
From: |
Blue Swirl |
Subject: |
Re: [Qemu-devel] [PATCH] exec-obsolete: fix length handling |
Date: |
Sun, 29 Jan 2012 13:39:26 +0000 |
On Sun, Jan 29, 2012 at 13:20, Avi Kivity <address@hidden> wrote:
> On 01/29/2012 03:16 PM, Blue Swirl wrote:
>> On Sun, Jan 29, 2012 at 12:08, Avi Kivity <address@hidden> wrote:
>> > On 01/28/2012 08:13 PM, Blue Swirl wrote:
>> >> Fix suspend/resume broken by off-by-one error in
>> >> 59abb06198ee9471e29c970f294eae80c0b39be1.
>> >>
>> >> Adjust the loop so that it handles correctly the case
>> >> start = (ram_addr_t)-TARGET_PAGE_SIZE, length = TARGET_PAGE_SIZE.
>> >>
>> >> Reported-by: Stefan Berger <address@hidden>
>> >> Signed-off-by: Blue Swirl <address@hidden>
>> >> ---
>> >> exec-obsolete.h | 10 ++++------
>> >> 1 files changed, 4 insertions(+), 6 deletions(-)
>> >>
>> >> diff --git a/exec-obsolete.h b/exec-obsolete.h
>> >> index 03cf35e..1bba970 100644
>> >> --- a/exec-obsolete.h
>> >> +++ b/exec-obsolete.h
>> >> @@ -81,11 +81,10 @@ static inline void
>> >> cpu_physical_memory_set_dirty_range(ram_addr_t start,
>> >> int dirty_flags)
>> >> {
>> >> uint8_t *p;
>> >> - ram_addr_t addr, end;
>> >> + ram_addr_t cur;
>> >>
>> >> - end = start + length;
>> >> p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
>> >> - for (addr = start; addr <= end; addr += TARGET_PAGE_SIZE) {
>> >> + for (cur = 0; cur < length; cur += TARGET_PAGE_SIZE) {
>> >> *p++ |= dirty_flags;
>> >> }
>> >
>> > I think this is still wrong - if length == 2 it will iterate once, but
>> > we need two iterations if start == 0xfff.
>>
>> Yes, tricky. We could do something like
>> for (cur = start & TARGET_PAGE_MASK; cur < length; cur += TARGET_PAGE_SIZE) {
>> but I'll send a new patch with just s/<=/</.
>
> That's broken too.
Because length should be adjusted by -1?
> I have:
>
> uint8_t *p;
> ram_addr_t addr, end;
>
> - end = start + length;
> + end = (start + length - 1) | (TARGET_PAGE_SIZE - 1);
Why | (TARGET_PAGE_SIZE - 1), for length == 1? TARGET_PAGE_ALIGN()
could be useful here.
> + start &= TARGET_PAGE_MASK;
> p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
> for (addr = start; addr <= end; addr += TARGET_PAGE_SIZE) {
> *p++ |= dirty_flags;
> @@ -98,7 +99,8 @@ static inline void
> cpu_physical_memory_mask_dirty_range(ram_addr_t start,
> uint8_t *p;
> ram_addr_t addr, end;
>
> - end = start + length;
> + end = (start + length - 1) | (TARGET_PAGE_SIZE - 1);
> + start &= TARGET_PAGE_MASK;
> mask = ~dirty_flags;
> p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
> for (addr = start; addr <= end; addr += TARGET_PAGE_SIZE) {
>
>
> And a non-terminating migration - not sure if this is the cause.
>
> --
> error compiling committee.c: too many arguments to function
>