Re: [patch 04/10] KVM: MMU: mode specific sync_page

Avi Kivity
2008-09-20T00:45:16Z

Marcelo Tosatti wrote:
> Examine guest pagetable and bring the shadow back in sync. Caller is responsible
> for local TLB flush before re-entering guest mode.
>
>

Neat! We had a gpte snapshot, and I forgot all about it.

> + for (i = 0; i < PT64_ENT_PER_PAGE; i++) {
> + if (is_shadow_present_pte(sp->spt[i])) {
>

if (!is_..())
continue;

to reduce indentation.

> + pte_gpa += (i+offset) * sizeof(pt_element_t);
> +
> + if (kvm_read_guest_atomic(vcpu->kvm, pte_gpa, &gpte,
> + sizeof(pt_element_t)))
> + return -EINVAL;
>

I guess we want a kvm_map_guest_page_atomic() to speed this up. Can be
done later as an optimization, of course.

> +
> + if (gpte_to_gfn(gpte) != gfn || !(gpte & PT_ACCESSED_MASK)) {
> + rmap_remove(vcpu->kvm, &sp->spt[i]);
> + if (is_present_pte(gpte))
> + sp->spt[i] = shadow_trap_nonpresent_pte;
> + else
> + sp->spt[i] = shadow_notrap_nonpresent_pte;
>

set_shadow_pte()

> + continue;
> + }
> +
> + if (!is_present_pte(gpte)) {
> + rmap_remove(vcpu->kvm, &sp->spt[i]);
> + sp->spt[i] = shadow_notrap_nonpresent_pte;
> + continue;
> + }
>

Merge with previous block?

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.