From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62F7CC7618B for ; Thu, 25 Jul 2019 12:04:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4358122C7B for ; Thu, 25 Jul 2019 12:04:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404468AbfGYMEr (ORCPT ); Thu, 25 Jul 2019 08:04:47 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34858 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403965AbfGYMEn (ORCPT ); Thu, 25 Jul 2019 08:04:43 -0400 Received: by mail-wm1-f68.google.com with SMTP id l2so44496018wmg.0 for ; Thu, 25 Jul 2019 05:04:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/bIhamhaCP8Od8nQqlaPQjE7bAnGgUhjKuEYaWcyOWQ=; b=kUVopFyiehUokAPGq0foiTxZKcI2j8PsKC0u4LBzFpIcHKQRKFJfTxqmFmJtZoft5b zS7sxPGz2LhEDC8Mm0lomQukkaqCTaADhi2aGO+04WHOHO4T3Btr6/hRboye8LfawlMD L1vHwYs77XbUDqA0/sB2pGoFnJqVG4t7+DdEG+7/3MptHBaeoO9e0L2PuLCkK6obMOnZ zP8dm0UVpXKHqoUuSvzMc2ANc8x63Se/a9u3PrcMpOlpPBcsGYze/BFXCHardgoD1GMv 4Y0U7CvL4nEAodqiw/NAs6lTnfKj0gixjn8y1dkeptefACofQxk9D1VD6BFV8Nodgkj1 Jmjg== X-Gm-Message-State: APjAAAUiOSnT8uCBgat/UGfAGRejAipj15JMbfYRdyvVUKT+0uzL9v7p AZpb6Tt5QfjaB61NUAmIuUno2g== X-Google-Smtp-Source: APXvYqww1uMiX4zlMkgdMe0dz50mX1hWd4r7Qep+978QB21ye1nFecSBufvr9akC9iei6QIfTX/wig== X-Received: by 2002:a1c:b707:: with SMTP id h7mr78305590wmf.45.1564056281416; Thu, 25 Jul 2019 05:04:41 -0700 (PDT) Received: from vitty.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id j6sm73793424wrx.46.2019.07.25.05.04.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 25 Jul 2019 05:04:40 -0700 (PDT) From: Vitaly Kuznetsov To: stable@vger.kernel.org Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PATCH stable-5.2 3/3] Revert "kvm: x86: Use task structs fpu field for user" Date: Thu, 25 Jul 2019 14:04:36 +0200 Message-Id: <20190725120436.5432-4-vkuznets@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190725120436.5432-1-vkuznets@redhat.com> References: <20190725120436.5432-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Bonzini [ Upstream commit ec269475cba7bcdd1eb8fdf8e87f4c6c81a376fe ] This reverts commit 240c35a3783ab9b3a0afaba0dde7291295680a6b ("kvm: x86: Use task structs fpu field for user", 2018-11-06). The commit is broken and causes QEMU's FPU state to be destroyed when KVM_RUN is preempted. Fixes: 240c35a3783a ("kvm: x86: Use task structs fpu field for user") Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/kvm_host.h | 7 ++++--- arch/x86/kvm/x86.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 26d1eb83f72a..08f46951c430 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -607,15 +607,16 @@ struct kvm_vcpu_arch { /* * QEMU userspace and the guest each have their own FPU state. - * In vcpu_run, we switch between the user, maintained in the - * task_struct struct, and guest FPU contexts. While running a VCPU, - * the VCPU thread will have the guest FPU context. + * In vcpu_run, we switch between the user and guest FPU contexts. + * While running a VCPU, the VCPU thread will have the guest FPU + * context. * * Note that while the PKRU state lives inside the fpu registers, * it is switched out separately at VMENTER and VMEXIT time. The * "guest_fpu" state here contains the guest FPU context, with the * host PRKU bits. */ + struct fpu user_fpu; struct fpu *guest_fpu; u64 xcr0; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index fafd81d2c9ea..a4eceb0b5dde 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8219,7 +8219,7 @@ static void kvm_load_guest_fpu(struct kvm_vcpu *vcpu) { fpregs_lock(); - copy_fpregs_to_fpstate(¤t->thread.fpu); + copy_fpregs_to_fpstate(&vcpu->arch.user_fpu); /* PKRU is separately restored in kvm_x86_ops->run. */ __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu->state, ~XFEATURE_MASK_PKRU); @@ -8236,7 +8236,7 @@ static void kvm_put_guest_fpu(struct kvm_vcpu *vcpu) fpregs_lock(); copy_fpregs_to_fpstate(vcpu->arch.guest_fpu); - copy_kernel_to_fpregs(¤t->thread.fpu.state); + copy_kernel_to_fpregs(&vcpu->arch.user_fpu.state); fpregs_mark_activate(); fpregs_unlock(); -- 2.20.1