From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH] KVM: x86: Fix a 4.14 backport regression related to userspace/guest FPU Date: Mon, 28 Jan 2019 17:14:34 -0500 Message-ID: <20190128221434.GP3973@sasha-vm> References: <20190128205102.29393-1-sean.j.christopherson@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Cc: kvm@vger.kernel.org, stable@vger.kernel.org, Greg Kroah-Hartman , Peter Xu , Rik van Riel , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Thomas Lindroth To: Sean Christopherson Return-path: Content-Disposition: inline In-Reply-To: <20190128205102.29393-1-sean.j.christopherson@intel.com> Sender: stable-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Mon, Jan 28, 2019 at 12:51:02PM -0800, Sean Christopherson wrote: >Upstream commit: > > f775b13eedee ("x86,kvm: move qemu/guest FPU switching out to vcpu_run") > >introduced a bug, which was later fixed by upstream commit: > > 5663d8f9bbe4 ("kvm: x86: fix WARN due to uninitialized guest FPU state") > >For reasons unknown, both commits were initially passed-over for >inclusion in the 4.14 stable branch despite being tagged for stable. >Eventually, someone noticed that the fixup, commit 5663d8f9bbe4, was >missing from stable[1], and so it was queued up for 4.14 and included in >release v4.14.79. > >Even later, the original buggy patch, commit f775b13eedee, was also >applied to the 4.14 stable branch. Through an unlucky coincidence, the >incorrect ordering did not generate a conflict between the two patches, >and led to v4.14.94 and later releases containing a spurious call to >kvm_load_guest_fpu() in kvm_arch_vcpu_ioctl_run(). As a result, KVM may >reload stale guest FPU state, e.g. after accepting in INIT event. This >can manifest as crashes during boot, segfaults, failed checksums and so >on and so forth. > >Remove the unwanted kvm_{load,put}_guest_fpu() calls, i.e. make >kvm_arch_vcpu_ioctl_run() look like commit 5663d8f9bbe4 was backported >after commit f775b13eedee. > >[1] https://www.spinics.net/lists/stable/msg263931.html > >Fixes: 4124a4cff344 ("x86,kvm: move qemu/guest FPU switching out to vcpu_run") >Cc: stable@vger.kernel.org >Cc: Sasha Levin >Cc: Greg Kroah-Hartman >Cc: Peter Xu >Cc: Rik van Riel >Cc: Paolo Bonzini >Cc: Radim Krčmář >Reported-by: Roman Mamedov >Reported-by: Thomas Lindroth >Signed-off-by: Sean Christopherson I agree with your analysis and the patch makes sense. Hopefully one of the KVM folks can Ack. 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=-5.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham 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 AAE37C282CD for ; Mon, 28 Jan 2019 22:14:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78BA02177E for ; Mon, 28 Jan 2019 22:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548713677; bh=sUr4vvPvUOfoQ+LoTzHQWSqACmu5lCBGwnvlpkxBNd4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=rq/VrB0nHw4kDKkm64pOLahDxZ97kbMR8ywhUwH7d2S7/JOldJa5t2PZASRklVcRE UcWIsZAAQbla+eNJeAzHsT0AtZyPIPZnJgzWDRXssxUq2vs9aMx4/55EIpapmLIco9 MncbeiErr2kGKE7NHIvOCVz7mBDr6sqrwCJbP800= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726802AbfA1WOh (ORCPT ); Mon, 28 Jan 2019 17:14:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:50460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726790AbfA1WOg (ORCPT ); Mon, 28 Jan 2019 17:14:36 -0500 Received: from localhost (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 08FAD21738; Mon, 28 Jan 2019 22:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548713676; bh=sUr4vvPvUOfoQ+LoTzHQWSqACmu5lCBGwnvlpkxBNd4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dh2CQO9QWAUvU9yQ2ZnDXifXJs9uVfSKKwylKYiHTyFSMXTMO0pjRPoQX1w8DpwhQ p9EkXSxLzvEK6MPKqL9/cqDz6KXA6COLCT0EUdKF5c6MBQvnKTOTYlfGw97+E0J7bm CL84AF3Tv+LHndzgiCxElq6ejK8/r7JMpOmrkEKg= Date: Mon, 28 Jan 2019 17:14:34 -0500 From: Sasha Levin To: Sean Christopherson Cc: kvm@vger.kernel.org, stable@vger.kernel.org, Greg Kroah-Hartman , Peter Xu , Rik van Riel , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Thomas Lindroth Subject: Re: [PATCH] KVM: x86: Fix a 4.14 backport regression related to userspace/guest FPU Message-ID: <20190128221434.GP3973@sasha-vm> References: <20190128205102.29393-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190128205102.29393-1-sean.j.christopherson@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, Jan 28, 2019 at 12:51:02PM -0800, Sean Christopherson wrote: >Upstream commit: > > f775b13eedee ("x86,kvm: move qemu/guest FPU switching out to vcpu_run") > >introduced a bug, which was later fixed by upstream commit: > > 5663d8f9bbe4 ("kvm: x86: fix WARN due to uninitialized guest FPU state") > >For reasons unknown, both commits were initially passed-over for >inclusion in the 4.14 stable branch despite being tagged for stable. >Eventually, someone noticed that the fixup, commit 5663d8f9bbe4, was >missing from stable[1], and so it was queued up for 4.14 and included in >release v4.14.79. > >Even later, the original buggy patch, commit f775b13eedee, was also >applied to the 4.14 stable branch. Through an unlucky coincidence, the >incorrect ordering did not generate a conflict between the two patches, >and led to v4.14.94 and later releases containing a spurious call to >kvm_load_guest_fpu() in kvm_arch_vcpu_ioctl_run(). As a result, KVM may >reload stale guest FPU state, e.g. after accepting in INIT event. This >can manifest as crashes during boot, segfaults, failed checksums and so >on and so forth. > >Remove the unwanted kvm_{load,put}_guest_fpu() calls, i.e. make >kvm_arch_vcpu_ioctl_run() look like commit 5663d8f9bbe4 was backported >after commit f775b13eedee. > >[1] https://www.spinics.net/lists/stable/msg263931.html > >Fixes: 4124a4cff344 ("x86,kvm: move qemu/guest FPU switching out to vcpu_run") >Cc: stable@vger.kernel.org >Cc: Sasha Levin >Cc: Greg Kroah-Hartman >Cc: Peter Xu >Cc: Rik van Riel >Cc: Paolo Bonzini >Cc: Radim Krčmář >Reported-by: Roman Mamedov >Reported-by: Thomas Lindroth >Signed-off-by: Sean Christopherson I agree with your analysis and the patch makes sense. Hopefully one of the KVM folks can Ack. -- Thanks, Sasha