Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1584062imm; Thu, 12 Jul 2018 04:35:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdlmSBNbtcj1Z1R1tSVhP4+csX1r+fJxNqBSQlpuYRw8opsDx6oObLYmlhkXOOqD99DUm7x X-Received: by 2002:a17:902:9345:: with SMTP id g5-v6mr1873256plp.10.1531395357098; Thu, 12 Jul 2018 04:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531395357; cv=none; d=google.com; s=arc-20160816; b=VFkHdAG6HJFVgEM6/RAgpIYt2Q27oEGUPO4r1r0+bOSbk9irMX0PsYx31Bg7eBr/2t Jmy1iwouXeqZrX8mwu247Q6vI7V3wgjokmibvGP6Pz1MckiPfGxIanglOFYREoshi9SX JSIR5MNNByjIE7U43N7Fuzeh0QHNWMZDB3DfqnDIYWlvtW36dO+yypPvEZlyyFOlfVbM 1Aj1VZnxrleQUbQmFHSMz8shnjKzp0d8lNjAPv7SFGX2V6WYcE9PRAq7o/XUxetJhvVP 7xZiqiL9wXhbifEA72KjxG2a1/wyi2p5ZFmRG121qQME6DkDVdWrrtBHF3CbOWm7X0B3 rZVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XB1lSHo5vQKbi+iv8U1Iq50q2ci6vjZhjwcaEBw8wXY=; b=wFKfJDNIMN9iZ6dNlsEvC8/Ja4IPeTCCwXTPd0u7HsShHkSSJq63jwSVYN4O2vwo2Z d9mjyYkE6FV+yrCHfrBBeOKpMOqNjDFxc5049Nxhgp+T+0FF9G2PyvQFh8Os6rr6vGSk 6W7cJdT/EZWWGvppiTAoNCNKKz7sw9CQNMEuXZ9PCU55qkBVroozjxs5M2eJ1usrvnqP HYGpyqr+Zk05bw+Dikw9VTTh9MO9xOBldSJtuEIN7D5sXePdhn1ts0TSbnkrxmN3oc0S ekssyUvOij54VihRUkZ2lfFVM9rn6KuYDRoWrYd9z/jEbQBkhfDhXwNW7JNCZ3+3U3qz hmFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i126-v6si22750609pfc.296.2018.07.12.04.35.41; Thu, 12 Jul 2018 04:35:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726713AbeGLLoS (ORCPT + 99 others); Thu, 12 Jul 2018 07:44:18 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42806 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726575AbeGLLoS (ORCPT ); Thu, 12 Jul 2018 07:44:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6B6940201BF; Thu, 12 Jul 2018 11:35:08 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 401842156889; Thu, 12 Jul 2018 11:35:07 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , x86@kernel.org, Wanpeng Li , KarimAllah Ahmed , linux-kernel@vger.kernel.org Subject: [PATCH] x86/kvm/nVMX: set exit_qualification correctly when nested_vmx_load_msr() fails Date: Thu, 12 Jul 2018 13:35:05 +0200 Message-Id: <20180712113505.23354-1-vkuznets@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 12 Jul 2018 11:35:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 12 Jul 2018 11:35:08 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit e79f245ddec1 ("X86/KVM: Properly update 'tsc_offset' to represent the running guest") introduced a regression in enter_vmx_non_root_mode(): when nested_vmx_load_msr() fails exit_qualification needs to point to the entry number we failed to validate. Intel's SDM states: "VM-entry failure due to MSR loading. The exit qualification is loaded to indicate which entry in the VM-entry MSR-load area caused the problem (1 for the first entry, 2 for the second, etc.)." Fixes: e79f245ddec1 ("X86/KVM: Properly update 'tsc_offset' to represent the running guest") Reported-by: Wanpeng Li Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/vmx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 65968649b365..be468c822892 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -11720,8 +11720,10 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu) msr_entry_idx = nested_vmx_load_msr(vcpu, vmcs12->vm_entry_msr_load_addr, vmcs12->vm_entry_msr_load_count); - if (msr_entry_idx) + if (msr_entry_idx) { + exit_qual = msr_entry_idx; goto fail; + } /* * Note no nested_vmx_succeed or nested_vmx_fail here. At this point -- 2.14.4