qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [4710] Prevent guest reusing host memory allocations.


From: Laurent Desnogues
Subject: Re: [Qemu-devel] [4710] Prevent guest reusing host memory allocations.
Date: Tue, 10 Jun 2008 15:40:55 +0200

On Mon, Jun 9, 2008 at 7:19 PM, Laurent Desnogues
<address@hidden> wrote:
> On Mon, Jun 9, 2008 at 3:47 PM, Paul Brook <address@hidden> wrote:
>> Modified: trunk/exec.c
>> ===================================================================
>> --- trunk/exec.c        2008-06-09 12:10:22 UTC (rev 4709)
>> +++ trunk/exec.c        2008-06-09 13:47:45 UTC (rev 4710)
>> @@ -263,13 +263,33 @@
> [...]
>> +#if defined(CONFIG_USER_ONLY)
>> +        unsigned long addr;
>> +        size_t len = sizeof(PageDesc) * L2_SIZE;
>> +        /* Don't use qemu_malloc because it may recurse.  */
>> +        p = mmap(0, len, PROT_READ | PROT_WRITE,
>> +                 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>>         *lp = p;
>> +        addr = h2g(p);
>> +        if (addr == (target_ulong)addr) {
>> +            page_set_flags(addr & TARGET_PAGE_MASK,
>> +                           TARGET_PAGE_ALIGN(addr + len),
>> +                           PAGE_RESERVED);
>> +        }
>
> I don't understand what the test is supposed to do, to me it looks
> like it can't fail since we have:
>
> #define h2g(x) ((target_ulong)(x - GUEST_BASE))
>
> Did I miss something?

I guess addr = h2g(p); should be replaced with

    addr = (unsigned long)p;

BTW this makes me think that perhaps GUEST_BASE should
be used here and if that's true in some other places as well
(qemu_vmalloc for instance).

These are all *wild guesses* from someone who doesn't fully
understand qemu...


Laurent




reply via email to

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