lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 16 Nov 2017 20:12:58 +0800
From:   Quan Xu <quan.xu0@...il.com>
To:     Paolo Bonzini <pbonzini@...hat.com>,
        Rik van Riel <riel@...hat.com>,
        "quan.xu04@...il.com" <quan.xu04@...il.com>
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        david@...hat.com, borntraeger@...ibm.com, tglx@...utronix.de,
        rkrcmar@...hat.com
Subject: Re: [PATCH 1/2] x86,kvm: move qemu/guest FPU switching out to
 vcpu_run



On 2017-11-16 18:21, Paolo Bonzini wrote:
> 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
> vmx_vcpu_run).

refer to the following code,

vcpu_enter_guest()
{
     ...
     preempt_disable()
        ...
        kvm_x86_ops->run(vcpu);  (actually it is vmx_vcpu_run())
        ...
     ...
     preempt_enable();
}



when preempt_disable before to run kvm_x86_ops->run..
in kvm_x86_ops->run, the pkru is restored with host_pkru (IF guest_pkru 
!= host_pkru).
all this happened under preempt_disable().

it's not true that preemtion is disable all the time while PKRU  = 
guest_pkru..



However it seems there is still some gap..

as Rik said, "at context switch time, the context switch code will save 
the guest
FPU state to current->thread.fpu when the VCPU thread is scheduled out."

after preempt_enable() in vcpu_enter_guest(), the vcpu thread is 
scheduled out,
in kvm_x86_ops->run, the PKRU has been restored with host_pkru (IF 
guest_pkru != host_pkru)..
instead of guest_pkru..

then the PKRU is host_pkru, how to save guest_pkru current->thread.fpu?

as mentioned, all this _assumes_ that the pkru is in 
current->thread.fpu.state as well.


thanks,

Quan
Alibaba Cloud

> 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.
>
> Thanks,
>
> Paolo
>
>> 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..
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ