diff mbox

KVM: MMU: Segregate mmu pages created with different cr4.pge settings

Message ID 20090111091233.GB4040@amt.cnet (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Marcelo Tosatti Jan. 11, 2009, 9:12 a.m. UTC
On Wed, Jan 07, 2009 at 01:32:41PM +0200, Avi Kivity wrote:
> Marcelo Tosatti wrote:
>> Let me shoot at one direction: a shadow page with PGE bit in either
>> state is created. Later that shadow page is nuked (via mmu notifiers,
>> for example). 
>
> I doubt that mmu notifiers were invoked in this case (the bug would be  
> very rare); in any case we flush the tlb.

There are other events that zap shadow pages. Anyway, someone else
should figure why NPT dislikes duplicate shadow page tables for 
the same address space. How about this, untested:

KVM: MMU: zero base_role on TDP mmu context initialization

A recent change which propagates CR4.PGE to shadow page roles broke NPT,
perhaps due to the allocation of duplicate shadow trees for the same
address space (actual details unknown).

In the meantime, since guest CR4.PGE is controlled by HW with
NPT, and the relevant role information for TDP is passed directly to
kvm_mmu_get_page, zero base_role on TDP mmu context init.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Avi Kivity Jan. 11, 2009, 9:20 a.m. UTC | #1
Marcelo Tosatti wrote:
> On Wed, Jan 07, 2009 at 01:32:41PM +0200, Avi Kivity wrote:
>   
>> Marcelo Tosatti wrote:
>>     
>>> Let me shoot at one direction: a shadow page with PGE bit in either
>>> state is created. Later that shadow page is nuked (via mmu notifiers,
>>> for example). 
>>>       
>> I doubt that mmu notifiers were invoked in this case (the bug would be  
>> very rare); in any case we flush the tlb.
>>     
>
> There are other events that zap shadow pages. Anyway, someone else
> should figure why NPT dislikes duplicate shadow page tables for 
> the same address space. How about this, untested:
>
> KVM: MMU: zero base_role on TDP mmu context initialization
>
> A recent change which propagates CR4.PGE to shadow page roles broke NPT,
> perhaps due to the allocation of duplicate shadow trees for the same
> address space (actual details unknown).
>
> In the meantime, since guest CR4.PGE is controlled by HW with
> NPT, and the relevant role information for TDP is passed directly to
> kvm_mmu_get_page, zero base_role on TDP mmu context init.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 10bdb2a..44ffcf6 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -2231,6 +2231,8 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
>  		context->root_level = PT32_ROOT_LEVEL;
>  	}
>  
> +	vcpu->arch.mmu.base_role = 0;
> +
>  	return 0;
>  }
>  
>   

Won't even compile, will it?
diff mbox

Patch

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 10bdb2a..44ffcf6 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2231,6 +2231,8 @@  static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
 		context->root_level = PT32_ROOT_LEVEL;
 	}
 
+	vcpu->arch.mmu.base_role = 0;
+
 	return 0;
 }