From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [patch 06/13] KVM: MMU: global page keeping Date: Sun, 07 Sep 2008 12:16:07 +0300 Message-ID: <48C39BD7.9010803@qumranet.com> References: <20080906184822.560099087@localhost.localdomain> <20080906192430.958862856@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from il.qumranet.com ([212.179.150.194]:10518 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752305AbYIGJQJ (ORCPT ); Sun, 7 Sep 2008 05:16:09 -0400 In-Reply-To: <20080906192430.958862856@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: Marcelo Tosatti wrote: > Account pages that only have global entries. Such pages need to be > synced on cr4 writes, but not cr3 writes. > > @@ -1147,18 +1148,22 @@ struct page *gva_to_page(struct kvm_vcpu > static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte, > unsigned pt_access, unsigned pte_access, > int user_fault, int write_fault, int dirty, > - int *ptwrite, int largepage, gfn_t gfn, > - pfn_t pfn, bool speculative) > + int global, int *ptwrite, int largepage, > + gfn_t gfn, pfn_t pfn, bool speculative) > bool global One option to stop the ever-increasing m_s_s() parameter list is to put it into pte_access. Not sure if it's a good idea. > =================================================================== > --- kvm.orig/include/asm-x86/kvm_host.h > +++ kvm/include/asm-x86/kvm_host.h > @@ -199,6 +199,7 @@ struct kvm_mmu_page { > u64 *parent_pte; /* !multimapped */ > struct hlist_head parent_ptes; /* multimapped, kvm_pte_chain */ > }; > + unsigned long flags; > }; > bool global; (or: bool global : 1; if we run out of space) > int kvm_unmap_hva(struct kvm *kvm, unsigned long hva); > int kvm_age_hva(struct kvm *kvm, unsigned long hva); > > +enum kvm_page_flags { > + KVM_PG_global, > +}; > + > +#define KVMPGFLAG(name) \ > +static inline int kvm_page_##name(struct kvm_mmu_page *sp) \ > + { return test_bit(KVM_PG_##name, &sp->flags); } \ > +static inline void kvm_set_pg_##name(struct kvm_mmu_page *sp) \ > + { set_bit(KVM_PG_##name, &sp->flags); } \ > +static inline void kvm_clear_pg_##name(struct kvm_mmu_page *sp) \ > + { clear_bit(KVM_PG_##name, &sp->flags); } \ > +static inline int kvm_test_clear_pg_##name(struct kvm_mmu_page *sp) \ > + { return test_and_clear_bit(KVM_PG_##name, &sp->flags); } > + > +KVMPGFLAG(global); > + > Ugh. Note you're using locked operations even though the structure is protected by the mmu lock. -- error compiling committee.c: too many arguments to function