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=-7.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED 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 14E8AC282C7 for ; Tue, 29 Jan 2019 10:32:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8F6C20869 for ; Tue, 29 Jan 2019 10:32:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D0Oa8YOt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728460AbfA2KcM (ORCPT ); Tue, 29 Jan 2019 05:32:12 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:42095 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728366AbfA2KcL (ORCPT ); Tue, 29 Jan 2019 05:32:11 -0500 Received: by mail-lf1-f66.google.com with SMTP id l10so14200740lfh.9; Tue, 29 Jan 2019 02:32:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=lT72oyG2+xq5VAX1R43zKurpwtleD5Eog1xx9oB0mP0=; b=D0Oa8YOtgmwuZC0TvAaqVfkLA8liv/L7f9YcA20VoBVpMYjnB2p1n/5eFV77K3UEKP qeZcToWNSNUiQeIVlFdUxpz2Kku84Ai3XEk0oyyWqw9SsOE3C0txk6eTJHtm7b+JioRm UtmsxQ9ti5GhYkWrVLmoe505mT3IWiJuy49MVe6abyLy4iKV5N4HRmHbSPxj7j4lPn2V BC0eaXrZJXGNnFVXucJhbvsW+33aLeUMTWAiAaJcmHDlde9KNBBb8wXVehQ/X2htmRYf XalF3hQn0U1gfkbkCQsO23vcZk5rR1Q/TpE8GnDtOaE7puelTOqIDQKR4HOy9dbBH5dO 8BRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lT72oyG2+xq5VAX1R43zKurpwtleD5Eog1xx9oB0mP0=; b=JRsNvTnH/K2aTYOj6wlFYrUYZdg5HKhAU+mPIVQo03FO9cVR1t/xr8qqIzZ8PSRu73 txRDdc1LgfzBGkWB8qX0wo+sboRK42YJutIJKH41OXzjgNkD341E3G8LcfaLUftdkb1m eqlQFKv8lTNqyAn89pFErJEpkwDJas9cvnS/aMfa3YJvs2BxRzVW+i37jLvSoY+01TTp 7yPUtwc20yLmX/PVBabc4p2NUf/2zxHUVYXQQ7/i+4ogCxoIkGV+MjW7DVageBnaXc0s pwMigKcWxKdDDuIsA5whRpdfIwBJMSsSigzELu17m0SIOdkx7WIAJcHcKPX6bzblzXeX Torw== X-Gm-Message-State: AJcUukfzT2LsyCmn59DZuVsmACrxZPTsf++byh+lH2D4d9wqxOSx7jxM wGFmRpR0LSawSxRIHQA53msc6pLf/lE= X-Google-Smtp-Source: ALg8bN6e5cx+MW/sEByGPAY0IvQEzsWCiwl/Ty8INhqc46iMZiAT6hpqznMzAqrlRsrTT88EzGdzHQ== X-Received: by 2002:a19:3b45:: with SMTP id i66mr20647069lfa.28.1548757928888; Tue, 29 Jan 2019 02:32:08 -0800 (PST) Received: from [84.217.171.221] (c-ddabd954.501502050104-0-757473696b74.bbcust.telenor.se. [84.217.171.221]) by smtp.gmail.com with ESMTPSA id q21-v6sm3510086ljc.5.2019.01.29.02.32.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 02:32:08 -0800 (PST) Subject: Re: [PATCH] KVM: x86: Fix a 4.14 backport regression related to userspace/guest FPU To: Sean Christopherson , Sasha Levin Cc: kvm@vger.kernel.org, stable@vger.kernel.org, Greg Kroah-Hartman , Peter Xu , Rik van Riel , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <20190128205102.29393-1-sean.j.christopherson@intel.com> From: Thomas Lindroth Message-ID: <7cedf2fd-ef08-44c8-8db5-a34187d035b8@gmail.com> Date: Tue, 29 Jan 2019 11:32:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190128205102.29393-1-sean.j.christopherson@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On 1/28/19 9:51 PM, 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 > --- > arch/x86/kvm/x86.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 130be2efafbe..af7ab2c71786 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -7423,14 +7423,12 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) > } > } > > - kvm_load_guest_fpu(vcpu); > - > if (unlikely(vcpu->arch.complete_userspace_io)) { > int (*cui)(struct kvm_vcpu *) = vcpu->arch.complete_userspace_io; > vcpu->arch.complete_userspace_io = NULL; > r = cui(vcpu); > if (r <= 0) > - goto out_fpu; > + goto out; > } else > WARN_ON(vcpu->arch.pio.count || vcpu->mmio_needed); > > @@ -7439,8 +7437,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) > else > r = vcpu_run(vcpu); > > -out_fpu: > - kvm_put_guest_fpu(vcpu); > out: > kvm_put_guest_fpu(vcpu); > post_kvm_run_save(vcpu); > I applied this patch on top of a standard 4.14.96 kernel and ran the stress-ng test for a few hours. No errors or other problems to report.