From patchwork Thu Feb 27 22:01:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 3736391 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 125C39F35F for ; Thu, 27 Feb 2014 22:01:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41451201EF for ; Thu, 27 Feb 2014 22:01:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A32D2008F for ; Thu, 27 Feb 2014 22:01:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752426AbaB0WBP (ORCPT ); Thu, 27 Feb 2014 17:01:15 -0500 Received: from mail-ea0-f179.google.com ([209.85.215.179]:52274 "EHLO mail-ea0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751393AbaB0WBO (ORCPT ); Thu, 27 Feb 2014 17:01:14 -0500 Received: by mail-ea0-f179.google.com with SMTP id q10so2180978ead.38 for ; Thu, 27 Feb 2014 14:01:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=yglzHoB0YaHxZuuCflYjY0IdCX4t5rRcb/SPZsphMKM=; b=ThG2jkRTIJ3Rbv76RxwbBWpotFfLohdA7hCxUeZ2vx8sOZuWtv1xvu7K46/ea3RcAk fXUslaMsIeAbYn1A1JsTGV7NTx1PrXBARZmfnP50aG04e331t02eke9xPmh8fM1XcwCD jT/ZvLh1FaRFF+1So9mZAUPzBi9IIQpu506gLTFJWH6xWMLcJJYNhVtOYInCp9FLoFBD iFnz5vByoxW/8LMQ8XZDAZZQckuPU74JG5KMY3zzPAbXhfRmOy1fsFztymC3CG7NeR2F upX4lBoJCkvanZtoSXWIYW3NLfb/d/+9IcSz6HPv7RMllETsDDgt6Sn+KN+jwxt9JI+c hPTw== X-Received: by 10.14.10.73 with SMTP id 49mr16269515eeu.52.1393538472720; Thu, 27 Feb 2014 14:01:12 -0800 (PST) Received: from playground.lan (net-37-117-154-249.cust.vodafonedsl.it. [37.117.154.249]) by mx.google.com with ESMTPSA id j41sm2518206eey.15.2014.02.27.14.01.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Feb 2014 14:01:11 -0800 (PST) From: Paolo Bonzini To: linux-kernel@vger.kernel.org Cc: kchamart@redhat.com, stefan.bader@canonical.com, bourgeois@bertin.fr, kvm@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] kvm, vmx: Really fix lazy FPU on nested guest Date: Thu, 27 Feb 2014 23:01:06 +0100 Message-Id: <1393538466-7523-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit e504c9098ed6 (kvm, vmx: Fix lazy FPU on nested guest, 2013-11-13) highlighted a real problem, but the fix was subtly wrong. nested_read_cr0 is the CR0 as read by L2, but here we want to look at the CR0 value reflecting L1's setup. In other words, L2 might think that TS=0 (so nested_read_cr0 has the bit clear); but if L1 is actually running it with TS=1, we should inject the fault into L1. The effective value of CR0 in L2 is contained in vmcs12->guest_cr0, use it. Fixes: e504c9098ed6acd9e1079c5e10e4910724ad429f Reported-by: Kashyap Chamarty Reported-by: Stefan Bader Tested-by: Kashyap Chamarty Tested-by: Anthoine Bourgeois Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini --- arch/x86/kvm/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index a06f101ef64b..392752834751 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -6688,7 +6688,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu) else if (is_page_fault(intr_info)) return enable_ept; else if (is_no_device(intr_info) && - !(nested_read_cr0(vmcs12) & X86_CR0_TS)) + !(vmcs12->guest_cr0 & X86_CR0_TS)) return 0; return vmcs12->exception_bitmap & (1u << (intr_info & INTR_INFO_VECTOR_MASK));