Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp822987ybl; Fri, 23 Aug 2019 08:52:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvhqBdh9v5/6gDtLuBAhEWjqb7Oe1yltrwUTiMuGzbed5GHe8u6WzPBoX2Z2K/nhuAoDMt X-Received: by 2002:a65:5382:: with SMTP id x2mr4620888pgq.422.1566575529186; Fri, 23 Aug 2019 08:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566575529; cv=none; d=google.com; s=arc-20160816; b=WNFAodwtjImqWjcNaO5/F2XpIh1H4PMBIYVSEueIps4b9v8oH8n+LvB3v/0g+lgx8P +mpibiqTuYld6lwZAl/oXz6wwCQBBF4E30f4mfO2eg6hFjb7shDDC7jq0HDbqhNIuToZ HU1S68I44MXAs4NLE8Zcqjs4htIGMyhZqG+eDoDlbzNX1OHWCEuNKPZ/nYw8VBUECu02 cVo1RDTUmW8BeTCCKezUOmqjcyuEjwm7+qqRktwF4aagCzmgmSnOVNSRLYihSuLmAo38 bA1WMR4Guc5H0vX/MK4Yz3qGCdxJ7JP44k0BdJ1wD/ov5gg9CK15YcsrSuArCKL/hYjT Ejxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=EKJ4zzBBzgTf3dByORJDOFIxv4A54bElk5z1GS5NOIY=; b=J+SRclk03CJbcicNgkS8Wkd0c9k/cyoKZ4KIyR2PWp2BJhutFQXezqx/okVf/vO4QS c76pftjN7TzOtT9idseZjClhbCWKUXlFBIl7VSLBv6xt6GKh76p/eVhZ6iXi8jmHbuDX rG3enYB/RPAerS502Wu73EfyxhNA5RazFsw6fGB5kyib79fEj48istT+c1uoDbNIRBxo ROW+5MxdF7L+EEc9H8lXXNpDp0DO65FTP0uFrc2O0j195xrWZkCPAWGIoNpge7XCWZGB fCmIUDoQ73t9FBZ50M8M2gg6qBXL4zH7GjpWRk6ZYrZh4C2wY+5amty9gzFcNFMl9rlC eF7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si2532336pjq.98.2019.08.23.08.51.53; Fri, 23 Aug 2019 08:52:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733066AbfHWBH3 (ORCPT + 99 others); Thu, 22 Aug 2019 21:07:29 -0400 Received: from mga01.intel.com ([192.55.52.88]:38007 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732771AbfHWBHP (ORCPT ); Thu, 22 Aug 2019 21:07:15 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 18:07:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,419,1559545200"; d="scan'208";a="186733521" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.41]) by FMSMGA003.fm.intel.com with ESMTP; 22 Aug 2019 18:07:13 -0700 From: Sean Christopherson To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH 12/13] KVM: VMX: Remove EMULATE_FAIL handling in handle_invalid_guest_state() Date: Thu, 22 Aug 2019 18:07:08 -0700 Message-Id: <20190823010709.24879-13-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190823010709.24879-1-sean.j.christopherson@intel.com> References: <20190823010709.24879-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that EMULATE_FAIL is completely unused, remove the last remaning usage where KVM does something functional in response to EMULATE_FAIL. Leave the check in place as a WARN_ON_ONCE to provide a better paper trail when EMULATE_{DONE,FAIL,USER_EXIT} are completely removed. Opportunistically remove the gotos in handle_invalid_guest_state(). With the EMULATE_FAIL handling gone there is no need to have a common handler for emulation failure and the gotos only complicate things, e.g. the signal_pending() check always returns '1', but this is far from obvious when glancing through the code. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index efc2f913ca19..5b5f622cc092 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -5164,7 +5164,6 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); enum emulation_result err = EMULATE_DONE; - int ret = 1; bool intr_window_requested; unsigned count = 130; @@ -5187,38 +5186,38 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu) err = kvm_emulate_instruction(vcpu, 0); - if (err == EMULATE_USER_EXIT) { - ret = 0; - goto out; - } + if (err == EMULATE_USER_EXIT) + return 0; - if (err != EMULATE_DONE) - goto emulation_error; + if (WARN_ON_ONCE(err == EMULATE_FAIL)) + return 1; if (vmx->emulation_required && !vmx->rmode.vm86_active && - vcpu->arch.exception.pending) - goto emulation_error; + vcpu->arch.exception.pending) { + vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; + vcpu->run->internal.suberror = + KVM_INTERNAL_ERROR_EMULATION; + vcpu->run->internal.ndata = 0; + return 0; + } if (vcpu->arch.halt_request) { vcpu->arch.halt_request = 0; - ret = kvm_vcpu_halt(vcpu); - goto out; + return kvm_vcpu_halt(vcpu); } + /* + * Note, return 1 and not 0, vcpu_run() is responsible for + * morphing the pending signal into the proper return code. + */ if (signal_pending(current)) - goto out; + return 1; + if (need_resched()) schedule(); } -out: - return ret; - -emulation_error: - vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; - vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; - vcpu->run->internal.ndata = 0; - return 0; + return 1; } static void grow_ple_window(struct kvm_vcpu *vcpu) -- 2.22.0