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

From: Paolo Bonzini
Date: Thu Nov 16 2017 - 08:40:11 EST

On 16/11/2017 14:35, Quan Xu wrote:
> but we introduce another method:
> ÂÂÂÂÂ -- When the VCPU thread is scheduled back in, the context
> ÂÂÂÂÂÂÂÂ switch code will restore current->thread.fpu to the FPU
> ÂÂÂÂÂÂÂÂ registers.
> there is still a window to restore current->thread.fpu to the FPU
> registers before enter guest mode and
> preempt_disable().

That will always use the host PKRU. The guest PKRU is _never_ visible
to the context switch code, because it's only ever used in a section
that runs with preemption disabled.

It's actually much simpler than before.


> on target machine, after migration, the pkru value is source_host_pkru
> in current->thread.fpu.
> in case,
> ÂÂÂÂÂÂÂÂÂÂÂ source_host_pkru_value != guest_pkru_value,
> ÂÂÂÂÂÂÂÂÂÂÂ target_host_pkru_value == guest_pkru_value..
> source_host_pkru_value may be restored to PKRU.. make pkru status
> inconsistent..