Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C22BFC04AAD for ; Tue, 7 May 2019 19:18:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97BA0206A3 for ; Tue, 7 May 2019 19:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726544AbfEGTSL (ORCPT ); Tue, 7 May 2019 15:18:11 -0400 Received: from mga06.intel.com ([134.134.136.31]:55701 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbfEGTSK (ORCPT ); Tue, 7 May 2019 15:18:10 -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 orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 May 2019 12:18:06 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com ([10.54.74.36]) by orsmga005.jf.intel.com with ESMTP; 07 May 2019 12:18:06 -0700 From: Sean Christopherson To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: kvm@vger.kernel.org Subject: [PATCH 12/13] KVM: nVMX: Don't mark vmcs12 as dirty when L1 writes pin controls Date: Tue, 7 May 2019 12:18:04 -0700 Message-Id: <20190507191805.9932-13-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190507191805.9932-1-sean.j.christopherson@intel.com> References: <20190507191805.9932-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Pin controls doesn't affect dirty logic, e.g. the preemption timer value is loaded from vmcs12 even if vmcs12 is "clean", i.e. there is no need to mark vmcs12 dirty when L1 writes pin controls. KVM currently toggles the VMX_PREEMPTION_TIMER control flag when it disables or enables the timer. The VMWRITE to toggle the flag can be responsible for a large percentage of vmcs12 dirtying when running KVM as L1 (depending on the behavior of L2). Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/nested.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 6ecdcfc67245..652022a77b64 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -4508,8 +4508,12 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu) /* * The fields that can be updated by L1 without a vmexit are * always updated in the vmcs02, the others go down the slow - * path of prepare_vmcs02. + * path of prepare_vmcs02. Pin controls is an exception as + * writing pin controls doesn't affect KVM's dirty logic and + * the VMX_PREEMPTION_TIMER flag may be toggled frequently, + * but not frequently enough to justify shadowing. */ + case PIN_BASED_VM_EXEC_CONTROL: break; default: vmx->nested.dirty_vmcs12 = true; -- 2.21.0