From patchwork Wed Oct 3 17:42:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 10625131 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 17ED8175A for ; Wed, 3 Oct 2018 17:42:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF85828DD6 for ; Wed, 3 Oct 2018 17:42:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3D0928E20; Wed, 3 Oct 2018 17:42:13 +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=-7.9 required=2.0 tests=BAYES_00,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 82E9B28DD6 for ; Wed, 3 Oct 2018 17:42:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726893AbeJDAbf (ORCPT ); Wed, 3 Oct 2018 20:31:35 -0400 Received: from mga12.intel.com ([192.55.52.136]:57200 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726851AbeJDAbf (ORCPT ); Wed, 3 Oct 2018 20:31:35 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Oct 2018 10:42:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,336,1534834800"; d="scan'208";a="262579097" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.193]) by orsmga005.jf.intel.com with ESMTP; 03 Oct 2018 10:42:13 -0700 From: Sean Christopherson To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: kvm@vger.kernel.org Subject: [PATCH] KVM: VMX: check flexpriority module param when setting virt apic mode Date: Wed, 3 Oct 2018 10:42:07 -0700 Message-Id: <20181003174207.26418-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.18.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Query the flexpriority module param instead of simply checking if flexpriority is supported by the cpu when checking whether or not VMCS fields need to be updated in response to the guest changing its APIC_BASE MSR control bits. This avoids multiple unnecessary VMREADs and a VMWRITE if flexpriority is disabled via its module param and the cpu doesn't support X2APIC virtualization. Signed-off-by: Sean Christopherson --- This is basically fixup for commit 76e97cc35522 ("KVM: VMX: check for existence of secondary exec controls before accessing") in kvm.git/queue. The aforementioned commit came from a series with a prior patch that removed the module param, but the prior patch was ultimately rejected resulting in this partially wrong code. 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 c7ae8ea87bc4..612fd17be635 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10223,7 +10223,7 @@ static void vmx_set_virtual_apic_mode(struct kvm_vcpu *vcpu) if (!lapic_in_kernel(vcpu)) return; - if (!cpu_has_vmx_flexpriority() && + if (!flexpriority_enabled && !cpu_has_vmx_virtualize_x2apic_mode()) return;