From patchwork Tue Sep 6 16:33:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 9317465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2ADDE607D3 for ; Tue, 6 Sep 2016 16:34:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 180D928D66 for ; Tue, 6 Sep 2016 16:34:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A7F528DDB; Tue, 6 Sep 2016 16:34:12 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 A9B1628D66 for ; Tue, 6 Sep 2016 16:34:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936133AbcIFQeJ (ORCPT ); Tue, 6 Sep 2016 12:34:09 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:33344 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935027AbcIFQeH (ORCPT ); Tue, 6 Sep 2016 12:34:07 -0400 Received: by mail-pf0-f182.google.com with SMTP id g202so52979607pfb.0 for ; Tue, 06 Sep 2016 09:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id; bh=8lU5dQAwiqhhfSkZTtJVPVens/SPkuFi1foPHrY3yPk=; b=nGZVHzNQvmwy9FDL8ZXktJEP1G+yMSYRk5rdKflWqdroFTWUzL0AcBKkGMFoVIYffO tEZHFtt7wCIViYiABp4z0+w2N8hUkqLtiMey/uwxhwRyXre0QHcDvSPO0tdHiV2EJWCm 61FlAFiaYQpHGQm5EHn0R/+V37O3DPh95RVei/v99Kf8XhUxmE5G82CCSKV8AHf/i6t0 xqAFbCmzFkxL8kAIcRmdhZuRUOwza1RgGH4cxAvJE3zSNkKgCzHGW/TrCC35SvlsRbBx y0AOT7IRcHhApdkfwEzKlvFa7dP35T65Pf0iKV1J2uT/VU0Xh8PkN6U2lF5wkz30iHk7 DL/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=8lU5dQAwiqhhfSkZTtJVPVens/SPkuFi1foPHrY3yPk=; b=Vj9xsgCXFLPb7FBBAeB0YnP+BzGNG8KOUACF6HhS2xvwxHcSYkCMe+w5YhoJUj2plZ ZuwjbyjnLoFeXWABbCDPkKR5/hDelSXLAHNw3jUc9RiryMw6mCcNsCK/DYZuUs6b2aZm Z7t2mqVX7tN0OBP53OQdy2NtmTgVuzDeQo5XC0frJm1CFRJCaPvYw0RCSTwmQFJj3BMv ulPpD//0eFTcFbdU4XSi2wTb8iAPpsdKlHb1faLqrU9cgkGFGZIFRUXNQP983psor2vX kfAQaLTixrMy21XP27wKDxuJONVsrdRpbD8dNgF35DMKm+a+q4NHglToo7dJWCeAc13J E+8A== X-Gm-Message-State: AE9vXwN8WBdFSN7jj5eY9Fqg2tJ7aKJzHEcAX2DBusBwHLHekhpaQzpyFtB3rVAvB0ChKWWq X-Received: by 10.98.135.194 with SMTP id i185mr602130pfe.144.1473179647026; Tue, 06 Sep 2016 09:34:07 -0700 (PDT) Received: from jmattson.sea.corp.google.com ([100.100.206.154]) by smtp.gmail.com with ESMTPSA id o80sm42227077pfa.67.2016.09.06.09.34.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Sep 2016 09:34:06 -0700 (PDT) From: Jim Mattson To: kvm@vger.kernel.org, pfeiner@google.com, jmattson@google.com Subject: [PATCH] kvm: nVMX: Fetch VM_INSTRUCTION_ERROR from vmcs02 on vmx->fail Date: Tue, 6 Sep 2016 09:33:21 -0700 Message-Id: <1473179601-19546-1-git-send-email-jmattson@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When forwarding a hardware VM-entry failure to L1, fetch the VM_INSTRUCTION_ERROR field from vmcs02 before loading vmcs01. (Note that there is an implicit assumption that the VM-entry failure was on the first VM-entry to vmcs02 after nested_vmx_run; otherwise, L1 is going to be very confused.) Signed-off-by: Jim Mattson Reviewed-by: Peter Feiner --- arch/x86/kvm/vmx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 5cede40..2ce8585 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10714,6 +10714,7 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, { struct vcpu_vmx *vmx = to_vmx(vcpu); struct vmcs12 *vmcs12 = get_vmcs12(vcpu); + u32 vm_inst_error = 0; /* trying to cancel vmlaunch/vmresume is a bug */ WARN_ON_ONCE(vmx->nested.nested_run_pending); @@ -10726,6 +10727,9 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, vmcs12->vm_exit_msr_store_count)) nested_vmx_abort(vcpu, VMX_ABORT_SAVE_GUEST_MSR_FAIL); + if (unlikely(vmx->fail)) + vm_inst_error = vmcs_read32(VM_INSTRUCTION_ERROR); + vmx_load_vmcs01(vcpu); if ((exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT) @@ -10802,7 +10806,7 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason, */ if (unlikely(vmx->fail)) { vmx->fail = 0; - nested_vmx_failValid(vcpu, vmcs_read32(VM_INSTRUCTION_ERROR)); + nested_vmx_failValid(vcpu, vm_inst_error); } else nested_vmx_succeed(vcpu); if (enable_shadow_vmcs)