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=-3.0 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 CE033C43219 for ; Tue, 30 Apr 2019 17:36:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A98D321670 for ; Tue, 30 Apr 2019 17:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbfD3RgY (ORCPT ); Tue, 30 Apr 2019 13:36:24 -0400 Received: from mga06.intel.com ([134.134.136.31]:32357 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbfD3RgY (ORCPT ); Tue, 30 Apr 2019 13:36:24 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Apr 2019 10:36:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,414,1549958400"; d="scan'208";a="166341319" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.181]) by fmsmga002.fm.intel.com with ESMTP; 30 Apr 2019 10:36:22 -0700 From: Sean Christopherson To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel Cc: kvm@vger.kernel.org Subject: [PATCH 0/3] KVM: x86: Drop "caching" of always-available GPRs Date: Tue, 30 Apr 2019 10:36:16 -0700 Message-Id: <20190430173619.15774-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's GPR caching logic is unconditionally emitted for all GPR accesses (that go through the accessors), even when the register being accessed is fixed and always available. This bloats KVM due to the instructions needed to test and set the available/dirty bitmaps, and to conditionally invoke the .cache_reg() callback. The latter is especially painful when compiling with retpolines. Eliminate the unnecessary overhead by: - Adding dedicated accessors for every GPR - Omitting the caching logic for GPRs that are always available - Preventing use of the unoptimized versions for fixed accesses The last patch is an opportunistic clean up of VMX, which has gradually acquired a bad habit of sprinkling in direct access to GPRs. Sean Christopherson (3): KVM: x86: Omit caching logic for always-available GPRs KVM: x86: Prevent use of kvm_register_{read,write}() with known GPRs KVM: VMX: Use accessors for GPRs outside of dedicated caching logic arch/x86/kvm/cpuid.c | 12 ++--- arch/x86/kvm/hyperv.c | 24 ++++----- arch/x86/kvm/kvm_cache_regs.h | 73 +++++++++++++++++++++++---- arch/x86/kvm/svm.c | 34 ++++++------- arch/x86/kvm/vmx/nested.c | 18 +++---- arch/x86/kvm/vmx/vmx.c | 14 +++--- arch/x86/kvm/x86.c | 93 +++++++++++++++++------------------ 7 files changed, 159 insertions(+), 109 deletions(-) -- 2.21.0