Re: [patch 2/3] KVM: MMU: skip global pgtables on sync due to cr3 switch

Marcelo Tosatti
2008-10-31T19:37:23Z

On Sun, Oct 26, 2008 at 01:27:34PM +0200, Avi Kivity wrote:
> Marcelo Tosatti wrote:
>> Skip syncing global pages on cr3 switch (but not on cr4/cr0). This is
>> important for Linux 32-bit guests with PAE, where the kmap page is
>> marked as global.
>>
>>
>
> Patch is good, but won't apply without the first.
>
>> {
>> u64 spte;
>> int ret = 0;
>> u64 mt_mask = shadow_mt_mask;
>> + struct kvm_mmu_page *sp = page_header(__pa(shadow_pte));
>> +
>> + if (!global && sp->global) {
>> + sp->global = 0;
>>
>
> A slight deficiency in this approach is that a page can't transition
> from !global to global. I don't think this is frequent, so we don't
> need to deal with it.

Yep.

> But a more accurate approach is to keep a count
> of non-global present mappings, and to activate the global logic when
> this count is nonzero.

I don't think the overhead it adds is significant for the added
complexity?