Re: index-out-of-range ubsan warnings

Paolo Bonzini
2016-02-24T07:59:55Z

>>
>> This is meant to stop mmu_pages_clear_parents _after_ it has
>> processed sp, so the "-1" is correct. The right fix would be:
>>
>> if (parent->role.level < PT64_ROOT_LEVEL-1)
>> parents->parent[parent->role.level - 1] = NULL;
>>
>
> it is okay as mmu_pages_next() will refill the highest level.

That would only happen for 64-bit pages, not for 32-bit (both PAE AND
non-PAE, including the case of non-paged mode with !unrestricted_guest).

On 24/02/2016 07:23, Xiao Guangrong wrote:
>> + parents->parent[level-1] = NULL;
>
> Why?

The idea was to move the NULL down at every step (first at parent[1],
then at parent[2], then at parent[3], then at parent[4]) but as you note
it is wrong because pages are added starting from the parent rather than
the children. I think I can put together my patch and yours to build
something that works; I'll post it later today.

Thanks for your help!

Paolo