qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	Stefan Berger <stefanb@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH] exec-obsolete: fix length handling
Date: Sun, 29 Jan 2012 16:21:25 +0200	[thread overview]
Message-ID: <4F2555E5.2060808@redhat.com> (raw)
In-Reply-To: <CAAu8pHtBOkWh5oZFCTxu10n7OJYoiV8bi=St36m94w-4qLCwDQ@mail.gmail.com>

On 01/29/2012 03:39 PM, Blue Swirl wrote:
> >> >> +++ 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?

0xfff/2 breaks.

More generally, you can't have a loop that just looks at length, since
0/2 wants one iteration, and 0xfff/2 wants two.

>
> > 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? 

Yes.  More generally, I wanted something that is easily understood -
start/end addresses without trickery, given all the broken patches for
fixing this.

> TARGET_PAGE_ALIGN()
> could be useful here.

True, I'll respin.

-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2012-01-29 14:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-28 18:13 [Qemu-devel] [PATCH] exec-obsolete: fix length handling Blue Swirl
2012-01-29 10:22 ` Avi Kivity
2012-01-29 11:37   ` Blue Swirl
2012-01-29 11:53     ` Avi Kivity
2012-01-29 12:08 ` Avi Kivity
2012-01-29 13:16   ` Blue Swirl
2012-01-29 13:20     ` Avi Kivity
2012-01-29 13:39       ` Blue Swirl
2012-01-29 14:21         ` Avi Kivity [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-01-29 13:17 Blue Swirl

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=4F2555E5.2060808@redhat.com \
    --to=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).