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.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no 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 8D8D5C7618F for ; Fri, 19 Jul 2019 17:25:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67C702186A for ; Fri, 19 Jul 2019 17:25:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729812AbfGSRZm (ORCPT ); Fri, 19 Jul 2019 13:25:42 -0400 Received: from mga14.intel.com ([192.55.52.115]:21962 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729425AbfGSRZm (ORCPT ); Fri, 19 Jul 2019 13:25:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2019 10:25:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,283,1559545200"; d="scan'208";a="252213001" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.165]) by orsmga001.jf.intel.com with ESMTP; 19 Jul 2019 10:25:41 -0700 From: Sean Christopherson To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Josh Poimboeuf , Peter Zijlstra Cc: kvm@vger.kernel.org Subject: [PATCH 0/4] KVM: VMX: Preemptivly optimize VMX instrs Date: Fri, 19 Jul 2019 10:25:36 -0700 Message-Id: <20190719172540.7697-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.22.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 An in-flight patch[1] to make __kvm_handle_fault_on_reboot() play nice with objtool will add a JMP after most VMX instructions so that the reboot macro can use an actual CALL to kvm_spurious_fault() instead of a funky PUSH+JMP facsimile. Rework the low level VMX instruction helpers to handle unexpected faults manually instead of relying on the "fault on reboot" macro. By using asm-goto, most helpers can branch directly to an in-function call to kvm_spurious_fault(), which can then be optimized by compilers to reside out-of-line at the end of the function instead of inline as done by "fault on reboot". The net impact relative to the current code base is more or less a nop when building with a compiler that supports __GCC_ASM_FLAG_OUTPUTS__. A bunch of code that was previously in .fixup gets moved into the slow paths of functions, but the fast paths are more basically unchanged. Without __GCC_ASM_FLAG_OUTPUTS__, manually coding the Jcc is a net positive as CC_SET() without compiler support almost always generates a SETcc+CMP+Jcc sequence, which is now replaced with a single Jcc. A small bonus is that the Jcc instrs are hinted to predict that the VMX instr will be successful. [1] https://lkml.kernel.org/r/64a9b64d127e87b6920a97afde8e96ea76f6524e.1563413318.git.jpoimboe@redhat.com Sean Christopherson (4): objtool: KVM: x86: Check kvm_rebooting in kvm_spurious_fault() KVM: VMX: Optimize VMX instruction error and fault handling KVM: VMX: Add error handling to VMREAD helper KVM: x86: Drop ____kvm_handle_fault_on_reboot() arch/x86/include/asm/kvm_host.h | 6 +-- arch/x86/kvm/vmx/ops.h | 93 ++++++++++++++++++++------------- arch/x86/kvm/vmx/vmx.c | 42 +++++++++++++++ arch/x86/kvm/x86.c | 3 +- tools/objtool/check.c | 1 - 5 files changed, 102 insertions(+), 43 deletions(-) -- 2.22.0