From patchwork Tue Nov 3 05:49:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Huang X-Patchwork-Id: 7539921 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 22335BEEA4 for ; Tue, 3 Nov 2015 05:55:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C68C320830 for ; Tue, 3 Nov 2015 05:55:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6D3520832 for ; Tue, 3 Nov 2015 05:55:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752884AbbKCFx5 (ORCPT ); Tue, 3 Nov 2015 00:53:57 -0500 Received: from mga03.intel.com ([134.134.136.65]:6649 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750774AbbKCFx4 (ORCPT ); Tue, 3 Nov 2015 00:53:56 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 02 Nov 2015 21:53:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,237,1444719600"; d="scan'208";a="825499910" Received: from kai-desktop.bj.intel.com ([10.238.135.54]) by fmsmga001.fm.intel.com with ESMTP; 02 Nov 2015 21:53:55 -0800 From: Kai Huang To: pbonzini@redhat.com, guangrong.xiao@linux.intel.com, kvm@vger.kernel.org Cc: Kai Huang Subject: [PATCH] KVM: VMX: Fix commit which broke PML Date: Tue, 3 Nov 2015 13:49:58 +0800 Message-Id: <1446529798-31895-1-git-send-email-kai.huang@linux.intel.com> X-Mailer: git-send-email 2.5.0 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, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 I found PML was broken since below commit: commit feda805fe7c4ed9cf78158e73b1218752e3b4314 Author: Xiao Guangrong Date: Wed Sep 9 14:05:55 2015 +0800 KVM: VMX: unify SECONDARY_VM_EXEC_CONTROL update Unify the update in vmx_cpuid_update() Signed-off-by: Xiao Guangrong [Rewrite to use vmcs_set_secondary_exec_control. - Paolo] Signed-off-by: Paolo Bonzini The reason is PML after above commit vmx_cpuid_update calls vmx_secondary_exec_control, in which PML is disabled unconditionally, as PML is enabled in creating vcpu. Therefore if vcpu_cpuid_update is called after vcpu is created, PML will be disabled unexpectedly while log-dirty code still think PML is used. Actually looks calling vmx_secondary_exec_control in vmx_cpuid_update is likely to break any VMX features that is enabled/disabled on demand by updating SECONDARY_VM_EXEC_CONTROL, if vmx_cpuid_update is called between the feature is enabled and disabled. Fix this by calling vmcs_read32 to read out SECONDARY_VM_EXEC_CONTROL directly. Signed-off-by: Kai Huang --- 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 4d0aa31..4525c0a7 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -8902,7 +8902,7 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu) { struct kvm_cpuid_entry2 *best; struct vcpu_vmx *vmx = to_vmx(vcpu); - u32 secondary_exec_ctl = vmx_secondary_exec_control(vmx); + u32 secondary_exec_ctl = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); if (vmx_rdtscp_supported()) { bool rdtscp_enabled = guest_cpuid_has_rdtscp(vcpu);