Re: [patch 12/13] KVM: x86: trap invlpg

Avi Kivity
2008-09-07T11:14:06Z

Marcelo Tosatti wrote:
> With pages out of sync invlpg needs to be trapped. For now simply nuke
> the entry.
>
>

We could kvm_mmu_pte_write() it, with some modifications. Probably
worth it for the guest breaking cow.

> [EXIT_REASON_MSR_WRITE] = handle_wrmsr,
> [EXIT_REASON_PENDING_INTERRUPT] = handle_interrupt_window,
> [EXIT_REASON_HLT] = handle_halt,
> + [EXIT_REASON_INVLPG] = handle_invlpg,
> [EXIT_REASON_VMCALL] = handle_vmcall,
> [EXIT_REASON_TPR_BELOW_THRESHOLD] = handle_tpr_below_threshold,
> [EXIT_REASON_APIC_ACCESS] = handle_apic_access,

We shouldn't do that if ept or npt is enabled.

> Index: kvm/arch/x86/kvm/mmu.c
> ===================================================================
> --- kvm.orig/arch/x86/kvm/mmu.c
> +++ kvm/arch/x86/kvm/mmu.c
> @@ -889,6 +889,12 @@ static int nonpaging_sync_page(struct kv
> return 1;
> }
>
> +static void nonpaging_invlpg(struct kvm_vcpu *vcpu, gva_t gva)
> +{
> + /* should never happen */
> + WARN_ON(1);
> +}
>

Nevertheless, invlpg is legal in real mode.

--
error compiling committee.c: too many arguments to function