Re: [PATCH v2 08/12] Inject asynchronous page fault into a guest if page is swapped out.

Avi Kivity
2009-11-25T13:03:30Z

On 11/23/2009 04:06 PM, Gleb Natapov wrote:
> If guest access swapped out memory do not swap it in from vcpu thread
> context. Setup slow work to do swapping and send async page fault to
> a guest.
>
> Allow async page fault injection only when guest is in user mode since
> otherwise guest may be in non-sleepable context and will not be able to
> reschedule.
>
> +
> +void kvm_arch_inject_async_page_present(struct kvm_vcpu *vcpu,
> + struct kvm_async_pf *work)
> +{
> + put_user(KVM_PV_REASON_PAGE_READY, vcpu->arch.apf_data);
> + kvm_inject_page_fault(vcpu, work->arch.token, 0);
> + trace_kvm_send_async_pf(work->arch.token, work->gva,
> + KVM_PV_REASON_PAGE_READY);
> +}
>

What if the guest is now handling a previous asynv pf or ready
notification? We're clobbering the data structure.

> +
> +bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu)
> +{
> + return !kvm_event_needs_reinjection(vcpu)&&
> + kvm_x86_ops->interrupt_allowed(vcpu);
> +}
>

Okay, so this is only allowed with interrupts disabled. Need to make
sure the entire pf path up to async pf executes with interrupts disabled.

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