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=-9.0 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 927C8C10F13 for ; Thu, 11 Apr 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 67E462083E for ; Thu, 11 Apr 2019 19:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726739AbfDKTSM (ORCPT ); Thu, 11 Apr 2019 15:18:12 -0400 Received: from mga07.intel.com ([134.134.136.100]:15349 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726690AbfDKTSM (ORCPT ); Thu, 11 Apr 2019 15:18:12 -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 orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2019 12:18:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,338,1549958400"; d="scan'208";a="222699522" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.181]) by orsmga001.jf.intel.com with ESMTP; 11 Apr 2019 12:18:10 -0700 From: Sean Christopherson To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: kvm@vger.kernel.org, Krish Sadhukhan , Karl Heubaum , Sean Christopherson , Jim Mattson Subject: [PATCH v6 6/7] KVM: nVMX: Collapse nested_check_host_control_regs() into its caller Date: Thu, 11 Apr 2019 12:18:08 -0700 Message-Id: <20190411191809.8131-7-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190411191809.8131-1-sean.j.christopherson@intel.com> References: <20190411191809.8131-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 ...now that nested_vmx_check_host_state() returns -EINVAL to indicate failure, i.e. moving the checks doesn't require changing their return values to be 'VMXERR_ENTRY_INVALID_HOST_STATE_FIELD'. This eliminates a misleading function name since nested_check_host_control_regs() was checking MSRs as well as control registers. Alternatively, nested_check_host_control_regs() could be split up, e.g. into _control_regs(), _debug_regs() and _msrs(), but that's a bit gratutitous at this time given that the entire function is 30 LoC. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/nested.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 16cff40456ee..98afbe7c15a1 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -2590,13 +2590,11 @@ static int nested_vmx_check_controls(struct kvm_vcpu *vcpu, return 0; } -/* - * Checks related to Host Control Registers and MSRs - */ -static int nested_check_host_control_regs(struct kvm_vcpu *vcpu, - struct vmcs12 *vmcs12) +static int nested_vmx_check_host_state(struct kvm_vcpu *vcpu, + struct vmcs12 *vmcs12, + u32 *vm_instruction_error) { - bool ia32e; + *vm_instruction_error = VMXERR_ENTRY_INVALID_HOST_STATE_FIELD; if (!nested_host_cr0_valid(vcpu, vmcs12->host_cr0) || !nested_host_cr4_valid(vcpu, vmcs12->host_cr4) || @@ -2618,8 +2616,8 @@ static int nested_check_host_control_regs(struct kvm_vcpu *vcpu, * the host address-space size VM-exit control. */ if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_EFER) { - ia32e = (vmcs12->vm_exit_controls & - VM_EXIT_HOST_ADDR_SPACE_SIZE) != 0; + bool ia32e = (vmcs12->vm_exit_controls & + VM_EXIT_HOST_ADDR_SPACE_SIZE) != 0; if (!kvm_valid_efer(vcpu, vmcs12->host_ia32_efer) || ia32e != !!(vmcs12->host_ia32_efer & EFER_LMA) || ia32e != !!(vmcs12->host_ia32_efer & EFER_LME)) @@ -2629,18 +2627,6 @@ static int nested_check_host_control_regs(struct kvm_vcpu *vcpu, return 0; } -static int nested_vmx_check_host_state(struct kvm_vcpu *vcpu, - struct vmcs12 *vmcs12, - u32 *vm_instruction_error) -{ - *vm_instruction_error = VMXERR_ENTRY_INVALID_HOST_STATE_FIELD; - - if (nested_check_host_control_regs(vcpu, vmcs12)) - return -EINVAL; - - return 0; -} - static int nested_vmx_check_vmcs_link_ptr(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) { -- 2.21.0