From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758992AbdKPKVz (ORCPT ); Thu, 16 Nov 2017 05:21:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48820 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751449AbdKPKVu (ORCPT ); Thu, 16 Nov 2017 05:21:50 -0500 Subject: Re: [PATCH 1/2] x86,kvm: move qemu/guest FPU switching out to vcpu_run To: Quan Xu , Rik van Riel , "quan.xu04@gmail.com" Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, david@redhat.com, borntraeger@de.ibm.com, tglx@linutronix.de, rkrcmar@redhat.com References: <20171114215424.32214-1-riel@redhat.com> <20171114215424.32214-2-riel@redhat.com> <2e83dd3f-8f03-03ac-45e0-f2fae1d17013@gmail.com> <1510756981.21121.291.camel@redhat.com> <1510806094.21121.303.camel@redhat.com> <0fc15536-0b34-51b6-cc14-00989825b0bc@gmail.com> From: Paolo Bonzini Message-ID: <9ba2d4c1-0781-419e-ddeb-77e0494583d2@redhat.com> Date: Thu, 16 Nov 2017 11:21:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <0fc15536-0b34-51b6-cc14-00989825b0bc@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 16 Nov 2017 10:21:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). 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..