From patchwork Thu Dec 20 20:25:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 10739549 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 E0D1F13BF for ; Thu, 20 Dec 2018 20:25:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1F7B28D05 for ; Thu, 20 Dec 2018 20:25:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C639428D11; Thu, 20 Dec 2018 20:25:42 +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 75F8028D05 for ; Thu, 20 Dec 2018 20:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732766AbeLTUZl (ORCPT ); Thu, 20 Dec 2018 15:25:41 -0500 Received: from mga14.intel.com ([192.55.52.115]:65141 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728835AbeLTUZk (ORCPT ); Thu, 20 Dec 2018 15:25:40 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Dec 2018 12:25:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,378,1539673200"; d="scan'208";a="112203701" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.154]) by orsmga003.jf.intel.com with ESMTP; 20 Dec 2018 12:25:39 -0800 From: Sean Christopherson To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Miguel Ojeda Cc: kvm@vger.kernel.org, Andi Kleen , Martin Jambor , Nadav Amit , Josh Poimboeuf , Arnd Bergmann , Steven Rostedt , Miroslav Benes Subject: [PATCH 00/11] KVM: VMX: Clean up VM-Enter/VM-Exit asm code Date: Thu, 20 Dec 2018 12:25:15 -0800 Message-Id: <20181220202518.21442-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Despite all but one patch being KVM cleanup, that one outlier is the true catalyst for this series. The outlier, patch 3/11, removes an optimization tweak from the __noclone macro that was added by commit 95272c29378e ("compiler-gcc: disable -ftracer for __noclone functions") to workaround a compiler error in KVM's esoteric VMX assembly code. Unbeknownst at the time, using the __optimize__ attribute causes GCC to reset to -O2 optimization defaults, which has several unintended side effects including dropping -fno-omit-frame-pointer and preventing GCC from properly inlining function calls due to the functions having incompatible optimization attributes. Patches 1/11 and 2/11 fix the offending KVM code and eliminate its usage of __noclone, allowing patch 3/11 to remove "no-tracer" from the __noclone macro. Patches 4/11 and beyond are a mix of cleanup, fixes and optimizations for a variety of low hanging fruit that were (unsurprisingly) revealed when revisiting KVM's inline assembly blob. FYI, I cc'd everyone involved for all patches up until the -ftracer revert, after that I limited the cc/to list to KVM folks. Sean Christopherson (11): KVM: VMX: Explicitly reference RCX as the vmx_vcpu pointer in asm blobs KVM: VMX: Move VM-Enter + VM-Exit handling to non-inline sub-routines Revert "compiler-gcc: disable -ftracer for __noclone functions" KVM: VMX: Modify only RSP when creating a placeholder for guest's RCX KVM: VMX: Save RSI to an unused output in vmx_vcpu_run() asm blob KVM: VMX: Manually load RDX in vmx_vcpu_run() asm blob KVM: VMX: Let the compiler save/load RDX around VM-Enter KVM: nVMX: Cache host_rsp on a per-VMCS basis KVM: nVMX: Add eVMCS support to nested_vmx_check_vmentry_hw() KVM: VMX: Add macros to handle HOST_RSP updates at VM-Enter KVM: nVMX: Remove a rogue "rax" clobber from nested_vmx_check_vmentry_hw() arch/x86/kvm/Makefile | 2 +- arch/x86/kvm/vmx/nested.c | 57 ++++--------- arch/x86/kvm/vmx/vmcs.h | 1 + arch/x86/kvm/vmx/vmenter.S | 57 +++++++++++++ arch/x86/kvm/vmx/vmx.c | 127 +++++++++++++--------------- arch/x86/kvm/vmx/vmx.h | 30 ++++++- include/linux/compiler_attributes.h | 8 +- 7 files changed, 164 insertions(+), 118 deletions(-) create mode 100644 arch/x86/kvm/vmx/vmenter.S Reviewed-by: Andi Kleen