Received: by 10.223.164.202 with SMTP id h10csp719099wrb; Wed, 15 Nov 2017 06:52:53 -0800 (PST) X-Google-Smtp-Source: AGs4zMaqdgkQkHwfV22lIkr33LOxzots7h0TseIl+0VVDTghbVWTDZTih+7QLwpy5Dsf36T66v0G X-Received: by 10.99.181.67 with SMTP id u3mr16116443pgo.118.1510757573433; Wed, 15 Nov 2017 06:52:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510757573; cv=none; d=google.com; s=arc-20160816; b=UcVnxneS3BgFQG7mrjiBZMdO2pv4Nq0ue3vtO7mCGVclyrTGtkU5GZBZUeb25etFlG npD7GXuI14Ysb2LuJKFOH7jcsqYwgfxjRI1YnZLCG37IvPiZNMRtM2KE40WjJzRUyggs E3HIngUAfkRxCGfAuQdQmU+vmjKzL0MedTAVnSgEeWRsoA/vb1nYI5DzhiY0MRioFBLo e/ltcJHlRRKB+KWufPCVgU/hKs2IGkxnXZd9aPhhnJ4UzlVpY5tssEJRdrPeHmj7Cu8Q Nm3QTUpFA4JJXtZDqWFQ+8ia4/D3eNK75Xb6opQPcKnVtcjsWYbhnWLmCooIfBCUXYH8 FEAg== 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:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=ZGAeKWzyDlDjwvENP5cAh/oVQ1psOGSs6dRc1qFyJZg=; b=gCafCThitALXcrCKHslmTO/IeI6b4T3h/xy6v9Zryh4LqZHRJDVuij2dmEWpJ4jYl1 XD+4JB+xQa85vReUzAvKX173/kgbE/oDSbnHPodrXpLDdFspzRv2LLW1RLXMpZjgAy3L B+4ikas3q4Gh8Zsv5UdS1qvxzp1Z0OPX9p9Ql46Oqr6RhKyEKqGpMK1dbYFWhla2TWKx NVcB9vsQixLtxi+tkG8T9pzs7sha8arfdt6FUrsSmFiwh3okjWQeokHLEO/u1cf3yo3g hEeEOW+J2xCjY6lfIU2yp4RWMfdnZnw/2C7oFb/ZTmVvgSoRerDuaIym6Q93SDsx4mj3 Ymjw== 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 l30si18096934plg.532.2017.11.15.06.52.41; Wed, 15 Nov 2017 06:52:53 -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 S1758074AbdKOOum (ORCPT + 89 others); Wed, 15 Nov 2017 09:50:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33048 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756639AbdKOOuh (ORCPT ); Wed, 15 Nov 2017 09:50:37 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8413C624CD; Wed, 15 Nov 2017 14:50:37 +0000 (UTC) Received: from annuminas.surriel.com (ovpn-126-55.rdu2.redhat.com [10.10.126.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F31D7D146; Wed, 15 Nov 2017 14:50:32 +0000 (UTC) Message-ID: <1510757432.21121.294.camel@redhat.com> Subject: Re: [PATCH] x86,kvm: move qemu/guest FPU switching out to vcpu_run From: Rik van Riel To: Paolo Bonzini , David Hildenbrand Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, rkrcmar@redhat.com, borntraeger@de.ibm.com Date: Wed, 15 Nov 2017 09:50:32 -0500 In-Reply-To: References: <20171114001223.441ea2ca@annuminas.surriel.com> <1510682877.30057.1.camel@redhat.com> <6f73cff1-eddf-7dc6-a93c-31c20e8520d7@redhat.com> Organization: Red Hat, Inc Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 15 Nov 2017 14:50:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2017-11-15 at 09:34 +0100, Paolo Bonzini wrote: > On 14/11/2017 20:40, David Hildenbrand wrote: > > I think we should check all get/put_fpu callers if they need > > preempt_disable(). > > > > E.g. em_fxrstor() needs disabled preemption as we temporarily > > save + restore some host register (via fxsave + fxrstor) under some > > circumstances that are not saved/restored when switching to/back > > from > > another process. We should double check. > > Rik may correct me, but I believe that you don't need > preempt_disable/enable because preempt notifiers do this for you. We no longer even need the preempt notifiers to save and restore the guest FPU state. The context switch code itself will save the FPU state from the registers, into current->thread.fpu.state, when the VCPU thread gets scheduled out. When the VCPU thread gets scheduled in, the scheduler will restore the guest FPU state from current->thread.fpu.state. At this point, vcpu->arch.guest_fpu may be OUT OF DATE. However, this is just fine, because we will save the guest FPU state into vcpu->arch.guest_fpu in kvm_put_guest_fpu, before we leave the KVM_RUN ioctl, and before we release the vcpu->mutex. In other words, by the time anybody else can examine the VCPU FPU state (after they obtain the vcpu->mutex), the vcpu->arch.guest_fpu area will contain the correct FPU state. From 1584143680664312426@xxx Wed Nov 15 14:45:41 +0000 2017 X-GM-THRID: 1584017174910331026 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread