From mboxrd@z Thu Jan 1 00:00:00 1970 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=-2.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,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 EF30BC004C9 for ; Tue, 7 May 2019 15:36:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C81ED206BF for ; Tue, 7 May 2019 15:36:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726503AbfEGPgb (ORCPT ); Tue, 7 May 2019 11:36:31 -0400 Received: from mga11.intel.com ([192.55.52.93]:51035 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbfEGPgb (ORCPT ); Tue, 7 May 2019 11:36:31 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 May 2019 08:36:31 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com ([10.54.74.181]) by fmsmga006.fm.intel.com with ESMTP; 07 May 2019 08:36:30 -0700 From: Sean Christopherson To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: kvm@vger.kernel.org, Jim Mattson , Liran Alon Subject: [PATCH 0/7] KVM: nVMX: Optimize VMCS data copying Date: Tue, 7 May 2019 08:36:22 -0700 Message-Id: <20190507153629.3681-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.21.0 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 KVM spends a lot of time copying data between VMCSes, especially when utilizing a shadow VMCS as data needs to moved between vmcs12 and the shadow VMCS. This series is comprised of three mostly unrelated optimizations that happen to modify the same code and would cause non-trivial conflicts: - Expose read-frequently write-rarely fields to L1 for VMREAD only. Exposing fields to L1 for both VMWRITE and VMREAD means KVM needs to copy data from the shadow VMCS to vmcs12 on nested VM-Entry. For fields that are almost never written by L1, copying those fields on every nested VM-Entry is pure overhead. - Track the vmcs12 offsets for shadowed fields. All offsets are known at compile time (HIGH fields complicate this slightly), but KVM currently does a runtime lookup to get the offset, which adds measurable latency to copying to/from the shadow VMCS. - Sync rarely accessed guest fields from vmcs02 to vmcs12 only when necessary. A non-trivial number of guest fields are infrequently accessed by VMMs, e.g. most segment descriptor fields. Avoid copying the fields from vmcs02 (30+ VMREADs) on every nested VM-Exit to L1, and instead pull them from vmcs02 when read by L1, or when they may be consumed by KVM, e.g. for consistency checks. Sean Christopherson (7): KVM: nVMX: Intercept VMWRITEs to read-only shadow VMCS fields KVM: nVMX: Intercept VMWRITEs to GUEST_{CS,SS}_AR_BYTES KVM: nVMX: Track vmcs12 offsets for shadowed VMCS fields KVM: nVMX: Lift sync_vmcs12() out of prepare_vmcs12() KVM: nVMX: Use descriptive names for VMCS sync functions and flags KVM: nVMX: Add helpers to identify shadowed VMCS fields KVM: nVMX: Sync rarely accessed guest fields only when needed arch/x86/kvm/vmx/nested.c | 384 +++++++++++++++++--------- arch/x86/kvm/vmx/nested.h | 2 +- arch/x86/kvm/vmx/vmcs12.h | 57 ++-- arch/x86/kvm/vmx/vmcs_shadow_fields.h | 78 +++--- arch/x86/kvm/vmx/vmx.c | 4 +- arch/x86/kvm/vmx/vmx.h | 8 +- 6 files changed, 320 insertions(+), 213 deletions(-) -- 2.21.0