Received: by 10.223.164.202 with SMTP id h10csp1784669wrb; Thu, 16 Nov 2017 04:23:36 -0800 (PST) X-Google-Smtp-Source: AGs4zMbwqQP91QRjL0pvcxcBt767MO3XPGBU8DCB01RTQjn57r003nKZIu4VzaHOc00ybOhF7foR X-Received: by 10.159.254.12 with SMTP id r12mr1588385pls.218.1510835016099; Thu, 16 Nov 2017 04:23:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510835016; cv=none; d=google.com; s=arc-20160816; b=X40Zb4JGYnYPJTSlmutc/R5vLKuBvA4lzqnn3yp42vcjORvBfBDAsMib4TlDLLlQ7v /HVzJJfTAPEcoPLUg53Ixybm37qGmzfcormvZupJH3/Fk4Iqb0Gi5Chf1I3s9qfYJQs7 SuPpToKkf/GUQ8iWbCb6fwiLCev+BZWOQC9AOMCunwGVFMSJA9PR3BA8LA6Rqpsjwbhz jYXf/G1rb4dWJlARgQOpJuRTAuDhyf/gHSrgE3WMmVpxGdaSiy2Yluu5TsX/r0i7e51B 3TUZOmVPU2qlsWsIhIRPCfWCnIWE5afyZFAMXcrHlt6lxsKd1EchAJL+SwUgtLetF7R8 Z2lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=o9/0ZJ23fWNThcWkWGdMnZkhnIE3OFojjSzfVy3pzdc=; b=TKorMFMLGdIUaS/soRsv/NaoVezoAhr58MrsxR79raLr9kgmk7RZ8gt8PNdBylLLAI gExkq0jIoxy2tu9qbk2VWof1v5Kgkoy2900KoiEX2rtaCjcYHOaIK2KZeRLm7AYSXQuL SAlXvxfeaUrlhchWiBg2p104WyDFmovN55lY0BRfj0QwM2um08bPAChXT4y1+qpkQxxh cDmbnwI8gGX7rvcQIW6uZhn40R5ykNVUpXgO0t3aAZMY0J493e10zhIfo6Ht6jaXhGIZ LNPrJXnuID1jM4XK2cz8iAz67+wWZo3ED6RViOvYqTd+r1M1rWBQgJbBS1B179snFdiv YpsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5si759183pga.803.2017.11.16.04.23.23; Thu, 16 Nov 2017 04:23:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934712AbdKPMSr (ORCPT + 91 others); Thu, 16 Nov 2017 07:18:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47692 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934661AbdKPMSk (ORCPT ); Thu, 16 Nov 2017 07:18:40 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF89776537; Thu, 16 Nov 2017 12:18:40 +0000 (UTC) Received: from [10.36.117.65] (ovpn-117-65.ams2.redhat.com [10.36.117.65]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C48C5C1A3; Thu, 16 Nov 2017 12:18:35 +0000 (UTC) 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> <9ba2d4c1-0781-419e-ddeb-77e0494583d2@redhat.com> From: Paolo Bonzini Message-ID: <00231a24-f1a2-324e-1c32-0a5a7a3995f1@redhat.com> Date: Thu, 16 Nov 2017 13:18:34 +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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 16 Nov 2017 12:18:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/11/2017 13:12, Quan Xu wrote: > 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." By "guest FPU state" Rik means "guest FPU with host PKRU". Guest PKRU is always stored in vcpu->arch.pkru rather than in the guest FPU state, so guest PKRU will never be in current->thread.fpu.state either. KVM_GET_XSAVE will the guest FPU state with vcpu->arch.pkru and migration will work properly. Thanks, Paolo > 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.. >> > From 1584222569117491443@xxx Thu Nov 16 11:39:35 +0000 2017 X-GM-THRID: 1584017174910331026 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread