Re: [patch 06/13] KVM: MMU: global page keeping

Avi Kivity
2008-09-07T09:16:09Z

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