From patchwork Wed Jan 30 22:29:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Verkamp X-Patchwork-Id: 10789339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E33941390 for ; Wed, 30 Jan 2019 22:55:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 062152F88A for ; Wed, 30 Jan 2019 22:55:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE9B02F88F; Wed, 30 Jan 2019 22:55:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9329B2F88A for ; Wed, 30 Jan 2019 22:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728536AbfA3Wz3 (ORCPT ); Wed, 30 Jan 2019 17:55:29 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46791 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725798AbfA3Wz2 (ORCPT ); Wed, 30 Jan 2019 17:55:28 -0500 Received: by mail-pf1-f196.google.com with SMTP id c73so496379pfe.13 for ; Wed, 30 Jan 2019 14:55:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UfOBqBENUts5OeFLDZ1mQPPfaNT70R7ACJZw8NVpukE=; b=dqdjPDdsBaNsMWunphnc6/4R9k65JbGHcyac9huGF6gWhnCWsveu0hf29xhMJ7RE5c CNLsfWjTufn722UXkeWRowNKvBc3GJ5jmqWOD3z4HgUw8s6aQrDPh4d9DXtLxRME4o7c wPnksJ/MdiS5KrhcN3Rd0GrVECEcgWdcDfxUM= 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=UfOBqBENUts5OeFLDZ1mQPPfaNT70R7ACJZw8NVpukE=; b=MA2MylvW5cGBzlM/6LEfd3/MAdoeKtYf8f0TlgtKrSKTxW+Uvt15jf4NJjPu1LWkTO f04krW8rG8v4CN5/z7UTasdr6hLBkGCXRZfKilq+5pXypMawHYRp6vJFoB4c9niXcQzQ l9Q+2zh/S6QReJ+efHtxCSglDRYUi4GP+tAN/eOTYWzcS95ShsUA+sV9jBfw7Ji/tMYt YuBA46Fa4t5TLAIvy2ylsVQh7Du5f/r6xsn9SCn5Zs2WwoZq8Yzb8s684VgrH30GdUAG 8TwbesJF5QMOc/sLdrWuGPmD2oXzGT6gLNgq0dQGOD4ntJNeuN5HSHa4xWFothj79J84 U99A== X-Gm-Message-State: AJcUukcd6n/iWo52DzTp1ZfzTkYJGueAFZPS0A5CLL9cfFfGLZHW/aXB 7ylH6zaTjJJK7TuntdmhmCsofg== X-Google-Smtp-Source: ALg8bN6joYysgmzR1X1fAb6RxSgn4mukQYF1yhobGXdaI377/EYF4f+JA8rif8OUZCCCv6wN58AfdA== X-Received: by 2002:a65:520a:: with SMTP id o10mr30149477pgp.276.1548887377117; Wed, 30 Jan 2019 14:29:37 -0800 (PST) Received: from dverkamp.mtv.corp.google.com ([2620:15c:202:201:30e7:25d1:2132:3dcb]) by smtp.gmail.com with ESMTPSA id n186sm3418521pfn.137.2019.01.30.14.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 14:29:36 -0800 (PST) From: Daniel Verkamp To: stable@vger.kernel.org Cc: Rik van Riel , kvm@vger.kernel.org, Daniel Verkamp Subject: [PATCH v2 for-4.14-stable] x86,kvm: remove extra kvm_{get,put}_guest_fpu Date: Wed, 30 Jan 2019 14:29:26 -0800 Message-Id: <20190130222926.120454-1-dverkamp@chromium.org> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190130220731.92849-1-dverkamp@chromium.org> References: <20190130220731.92849-1-dverkamp@chromium.org> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 4124a4cff344 ("x86,kvm: move qemu/guest FPU switching out to vcpu_run") applied a patch from upstream, but it appears that it wasn't backported correctly to 4.14. The extra out_fpu label and kvm_put_guest_fpu() added in kvm_arch_vcpu_ioctl_run() result in calling kvm_put_guest_fpu() twice in a row, corrupting guest state. Additionally, a duplicate kvm_load_guest_fpu() is added in the middle of the function. Fixes: 4124a4cff344 ("x86,kvm: move qemu/guest FPU switching out to vcpu_run") Signed-off-by: Daniel Verkamp --- v2: removed additional redundant kvm_load_guest_fpu() I'm unsure if this is the right way to send this fix - there is no corresponding mainline commit to reference, since the code there is already correct, and the problem was introduced in the cherry-picked stable backport. Please let me know if there's a different process for fixes to stable-only issues. --- 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);