qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, gcosta@redhat.com
Subject: Re: [Qemu-devel] Re: [PATCH] Make page_find() return 0 for too-large addresses
Date: Mon, 15 Sep 2008 12:48:43 -0300	[thread overview]
Message-ID: <20080915154843.GC12539@blackpad> (raw)
In-Reply-To: <48CE7F4A.3060000@codemonkey.ws>

On Mon, Sep 15, 2008 at 10:29:14AM -0500, Anthony Liguori wrote:
> Eduardo Habkost wrote:
<snip>
>>
>> New patch, reusing the range check from page_find_alloc() on
>> page_find(). Untested.
>>   
>
> Have you tested this patch yet?  I like to avoid being the first one to  
> test something when it's not my code :-)

I've tested it now, both with KVM enabled and with KVM disabled. My
machine didn't explode yet, so it seems to be fine.  :)

>
> Regards,
>
> Anthony Liguori
>
>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>> ---
>> Index: qemu/exec.c
>> ===================================================================
>> --- qemu/exec.c	(revisão 5200)
>> +++ qemu/exec.c	(cópia de trabalho)
>> @@ -279,17 +279,24 @@ static void page_init(void)
>>  #endif
>>  }
>>  -static inline PageDesc *page_find_alloc(target_ulong index)
>> +static inline PageDesc **page_l1_map(target_ulong index)
>>  {
>> -    PageDesc **lp, *p;
>> -
>>  #if TARGET_LONG_BITS > 32
>>      /* Host memory outside guest VM.  For 32-bit targets we have already
>>         excluded high addresses.  */
>>      if (index > ((target_ulong)L2_SIZE * L1_SIZE))
>>          return NULL;
>>  #endif
>> -    lp = &l1_map[index >> L2_BITS];
>> +    return &l1_map[index >> L2_BITS];
>> +}
>> +
>> +static inline PageDesc *page_find_alloc(target_ulong index)
>> +{
>> +    PageDesc **lp, *p;
>> +    lp = page_l1_map(index);
>> +    if (!lp)
>> +        return NULL;
>> +
>>      p = *lp;
>>      if (!p) {
>>          /* allocate if not found */
>> @@ -316,9 +323,12 @@ static inline PageDesc *page_find_alloc(
>>   static inline PageDesc *page_find(target_ulong index)
>>  {
>> -    PageDesc *p;
>> +    PageDesc **lp, *p;
>> +    lp = page_l1_map(index);
>> +    if (!lp)
>> +        return NULL;
>>  -    p = l1_map[index >> L2_BITS];
>> +    p = *lp;
>>      if (!p)
>>          return 0;
>>      return p + (index & (L2_SIZE - 1));
>>
>>
>>   
>
>

-- 
Eduardo

  reply	other threads:[~2008-09-15 15:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12 18:58 [Qemu-devel] [PATCH] Make page_find() return 0 for too-large addresses Eduardo Habkost
2008-09-12 19:50 ` [Qemu-devel] " Anthony Liguori
2008-09-12 20:14   ` Eduardo Habkost
2008-09-12 20:44     ` Eduardo Habkost
2008-09-12 21:27       ` Anthony Liguori
2008-09-12 21:47         ` Eduardo Habkost
2008-09-15 13:08         ` Glauber Costa
2008-09-15 15:29       ` Anthony Liguori
2008-09-15 15:48         ` Eduardo Habkost [this message]
2008-09-15 15:57           ` Anthony Liguori

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=20080915154843.GC12539@blackpad \
    --to=ehabkost@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=gcosta@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /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).