[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qcow2: Fix L1 table memory allocation
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH] qcow2: Fix L1 table memory allocation |
Date: |
Wed, 08 Jul 2009 09:29:22 +0200 |
User-agent: |
Thunderbird 2.0.0.21 (X11/20090320) |
malc schrieb:
> On Tue, 7 Jul 2009, Avi Kivity wrote:
>
>> On 07/07/2009 07:09 PM, Kevin Wolf wrote:
>>> Contrary to what one could expect, the size of L1 tables is not cluster
>>> aligned. So as we're writing whole sectors now instead of single entries,
>>> we need to ensure that the L1 table in memory is large enough; otherwise
>>> write would access memory after the end of the L1 table.
>>>
>>>
>>> new_l1_size2 = sizeof(uint64_t) * new_l1_size;
>>> - new_l1_table = qemu_mallocz(new_l1_size2);
>>> + new_l1_table = qemu_mallocz(align_offset(new_l1_size2, 512));
>>> memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));
>>>
>> Unrelated note: using qemu_memalign() here would reduce the copying for
>> cache=none.
>>
>
> Another unrelated note, qemu_memalign(and by extension qemu_vmalloc)
> is NULL happy. And FWIW 487414f1cbd638beb0227c7da71fe7b8a821e155
> removed NULL checks for qemu_memalgn and after that new code was added
> that doesn't check for NULLs either (for instance e3f4e2a4 which has
> bitten me).
Good to know that there still is an alternative that isn't broken.
Another good reason to switch to qemu_memalign.
Kevin