Re: [PATCH 1/2] x86,kvm: move qemu/guest FPU switching out to vcpu_run

From: Paolo Bonzini
Date: Thu Nov 16 2017 - 05:22:00 EST

On 16/11/2017 06:06, Quan Xu wrote:
> when vcpu thread is scheduled out, the pkru value in
> current->thread.fpu.state may be the host pkru value, instead of
> guest pkru value (of course, this _assumes_ that the pkru is in
> current->thread.fpu.state as well). in this way, the pkru may be a
> coner case.

Rik may correct me, but I think this is not possible. Preemption is
disabled all the time while PKRU = guest_pkru (which is only during

Context switching will only happen in vcpu_enter_guest() after
preempt_enable() for a preemptible kernel, or in vcpu_run via
cond_resched() for a non-preemptible kernel.



> VM migration again, in case,
> ÂÂÂÂÂÂÂÂÂÂ source_host_pkru_value != guest_pkru_value,
> ÂÂÂÂÂÂÂÂÂÂ target_host_pkru_value == guest_pkru_value..
> the pkru status would be inconsistent..