From patchwork Tue Mar 3 03:30:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wincy Van X-Patchwork-Id: 5919471 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CADC09F373 for ; Tue, 3 Mar 2015 03:31:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 198FB20142 for ; Tue, 3 Mar 2015 03:31:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5677B2013A for ; Tue, 3 Mar 2015 03:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756425AbbCCDbX (ORCPT ); Mon, 2 Mar 2015 22:31:23 -0500 Received: from smtpbg303.qq.com ([184.105.206.26]:60156 "EHLO smtpbg303.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756413AbbCCDbU (ORCPT ); Mon, 2 Mar 2015 22:31:20 -0500 X-QQ-mid: esmtp23t1425353458t703t17296 Received: from localhost (unknown [114.255.44.132]) by esmtp4.qq.com (ESMTP) with id ; Tue, 03 Mar 2015 11:30:57 +0800 (CST) X-QQ-SSF: 01000000000000F0FTF02F00002000Z X-QQ-FEAT: zPV9VjcbcTrr99OmikZHzqxZrrznhYVGSoP/5X9EKAEZ835Kam1uDenmYwlUX 8xngk9QbIGYP6oEUD6WM9LQf5d4znve5L76pujRZznw3sFfQ63Vth9LdaO5SjKF8JyAm/Gd jm3YKOOq34bl5x4C4deXmQXT3f+I23ZSsSNRHw+TckRC40HepeUnE0gkQRx0ugngXANVACb tpV5QVZrcSmwcc7wT9oV0GPaiYjRbImk= X-QQ-GoodBg: 0 X-QQ-CSender: fanwenyi0529@vip.qq.com From: Wincy Van To: mtosatti@redhat.com, pbonzini@redhat.com, gleb@kernel.org, yang.z.zhang@intel.com, fanwenyi0529@gmail.com Cc: wanpeng.li@linux.intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, jan.kiszka@web.de, yong.y.wang@linux.intel.com Subject: [PATCH] KVM: vmx: Set msr bitmap correctly if vcpu is in guest mode Date: Tue, 3 Mar 2015 11:30:17 +0800 Message-Id: <1425353417-2060-1-git-send-email-fanwenyi0529@gmail.com> X-Mailer: git-send-email 1.7.1 X-QQ-SENDSIZE: 520 X-QQ-FName: EB9434E2A64140FCA374B4F9A01A209B X-QQ-LocalIP: 163.177.66.155 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,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 In commit 3af18d9c5fe9 ("KVM: nVMX: Prepare for using hardware MSR bitmap"), we are setting MSR_BITMAP in prepare_vmcs02 if we should use hardware. This is not enough since the field will be modified by following vmx_set_efer. Fix this by setting vmx_msr_bitmap_nested in vmx_set_msr_bitmap if vcpu is in guest mode. Signed-off-by: Wincy Van --- arch/x86/kvm/vmx.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f7b20b4..f6e3457 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2168,7 +2168,10 @@ static void vmx_set_msr_bitmap(struct kvm_vcpu *vcpu) { unsigned long *msr_bitmap; - if (irqchip_in_kernel(vcpu->kvm) && apic_x2apic_mode(vcpu->arch.apic)) { + if (is_guest_mode(vcpu)) + msr_bitmap = vmx_msr_bitmap_nested; + else if (irqchip_in_kernel(vcpu->kvm) && + apic_x2apic_mode(vcpu->arch.apic)) { if (is_long_mode(vcpu)) msr_bitmap = vmx_msr_bitmap_longmode_x2apic; else