Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp767592ybl; Fri, 23 Aug 2019 08:05:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzn+QcE4z4fb2BzLQxNJCc1txq2KqbgkPnmxM3nMfEbyPoNxZsj/E67JWTH1/Wd46KMp6Xl X-Received: by 2002:a17:90a:d343:: with SMTP id i3mr6011501pjx.15.1566572736874; Fri, 23 Aug 2019 08:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566572736; cv=none; d=google.com; s=arc-20160816; b=dsEkVb83IslnrnufCdz+9JQWAxtEOfzP2Yg9npnuasyt3s3ruWKBHboqU43Wf/i/Ju m83+161RBk2NQfQbmo/Zp4T9Y33FUeSNV5yXZF1xEv/fQENy75EmP6fQ09k6p0tBQ/s5 a0ki54lTnpDsMIwfREu6GO1waNqhaoMXspdv3APPI5jXAZHSj/3tZZEOlf/S0+rTH2HO PSqie0hhDTe6LVKS+lZ6Wlz0A3G/uPne5V7GQzQMh4kTxNX9SISZxSpkK33sfGuSgT9G gDYDKaBZquwHP2WIjtMZaaAsf2PtbKWT6+MnsTeRJ1AywMjcpSQaga//Mop2mq9hU1vM jb+A== 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=xdQFwFsbN+xDw5tsNw1auutXjdsdlh1IndnZc41svMs=; b=Q8DNKK8UB4/OEcPChGoQOn9SyFDzsfM+aWT64Eo9CM5rfh3vIjWy9m4+HSIWuambeh UavkzlP96FwYgYblzZbgJT6aFyN+P3X1MfmgXaqlNdx0vxpO20YYgxWEwq70btQVHFyq HZ7gKmKEfTWQoQpgY5Bwloreoyut9Y/sF3ANKkGFQBNLhjDFw50rziQOC/WLpl50DBt1 /ntktGxLvT9543ZeFd9bID4rDjtU7ZkT5BisYzj/1BQQSXQkebjZEfP9rhBR9QuhUYhJ s8AOUN4JkQpjyZ5r9i9r7NwqATSLmyJ67AmpNQ8Iad8i6tQJy2YBbSz77oDLs+cPmVzX x5lg== 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 b190si2257058pga.212.2019.08.23.08.05.15; Fri, 23 Aug 2019 08:05:36 -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 S1733048AbfHWBHZ (ORCPT + 99 others); Thu, 22 Aug 2019 21:07:25 -0400 Received: from mga01.intel.com ([192.55.52.88]:38011 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732750AbfHWBHO (ORCPT ); Thu, 22 Aug 2019 21:07:14 -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="186733517" 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 11/13] KVM: x86: Move triple fault request into RM int injection Date: Thu, 22 Aug 2019 18:07:07 -0700 Message-Id: <20190823010709.24879-12-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 Request triple fault in kvm_inject_realmode_interrupt() instead of returning EMULATE_FAIL and deferring to the caller. All existing callers request triple fault and it's highly unlikely Real Mode is going to acquire new features. While this consolidates a small amount of code, the real goal is to remove the last reference to EMULATE_FAIL. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 9 +++------ arch/x86/kvm/x86.c | 17 ++++++++--------- arch/x86/kvm/x86.h | 2 +- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 52d5705ff7dc..efc2f913ca19 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1527,8 +1527,7 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu) int inc_eip = 0; if (kvm_exception_is_soft(nr)) inc_eip = vcpu->arch.event_exit_inst_len; - if (kvm_inject_realmode_interrupt(vcpu, nr, inc_eip) != EMULATE_DONE) - kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu); + kvm_inject_realmode_interrupt(vcpu, nr, inc_eip); return; } @@ -4276,8 +4275,7 @@ static void vmx_inject_irq(struct kvm_vcpu *vcpu) int inc_eip = 0; if (vcpu->arch.interrupt.soft) inc_eip = vcpu->arch.event_exit_inst_len; - if (kvm_inject_realmode_interrupt(vcpu, irq, inc_eip) != EMULATE_DONE) - kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu); + kvm_inject_realmode_interrupt(vcpu, irq, inc_eip); return; } intr = irq | INTR_INFO_VALID_MASK; @@ -4313,8 +4311,7 @@ static void vmx_inject_nmi(struct kvm_vcpu *vcpu) vmx->loaded_vmcs->nmi_known_unmasked = false; if (vmx->rmode.vm86_active) { - if (kvm_inject_realmode_interrupt(vcpu, NMI_VECTOR, 0) != EMULATE_DONE) - kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu); + kvm_inject_realmode_interrupt(vcpu, NMI_VECTOR, 0); return; } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 83b3c7e9fce7..e457363622e5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6176,7 +6176,7 @@ static void init_emulate_ctxt(struct kvm_vcpu *vcpu) vcpu->arch.emulate_regs_need_sync_from_vcpu = false; } -int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip) +void kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip) { struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; int ret; @@ -6188,14 +6188,13 @@ int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip) ctxt->_eip = ctxt->eip + inc_eip; ret = emulate_int_real(ctxt, irq); - if (ret != X86EMUL_CONTINUE) - return EMULATE_FAIL; - - ctxt->eip = ctxt->_eip; - kvm_rip_write(vcpu, ctxt->eip); - kvm_set_rflags(vcpu, ctxt->eflags); - - return EMULATE_DONE; + if (ret != X86EMUL_CONTINUE) { + kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu); + } else { + ctxt->eip = ctxt->_eip; + kvm_rip_write(vcpu, ctxt->eip); + kvm_set_rflags(vcpu, ctxt->eflags); + } } EXPORT_SYMBOL_GPL(kvm_inject_realmode_interrupt); diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index b5274e2a53cf..dbf7442a822b 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -261,7 +261,7 @@ static inline bool kvm_check_has_quirk(struct kvm *kvm, u64 quirk) } void kvm_set_pending_timer(struct kvm_vcpu *vcpu); -int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip); +void kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip); void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr); u64 get_kvmclock_ns(struct kvm *kvm); -- 2.22.0