[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: |
Tue, 07 Jul 2009 18:32:59 +0200 |
User-agent: |
Thunderbird 2.0.0.21 (X11/20090320) |
Avi Kivity schrieb:
> 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.
Good point. I guess there are more places where we could use
qemu_memalign, so I would prefer to change them all in another patch.
Kevin