From patchwork Mon Dec 19 20:48:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 9480751 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 BFBFE601C2 for ; Mon, 19 Dec 2016 20:49:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A588A2849D for ; Mon, 19 Dec 2016 20:49:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 989D2284CA; Mon, 19 Dec 2016 20:49:49 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 3AD0728487 for ; Mon, 19 Dec 2016 20:49:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753002AbcLSUsr (ORCPT ); Mon, 19 Dec 2016 15:48:47 -0500 Received: from mail-it0-f54.google.com ([209.85.214.54]:36156 "EHLO mail-it0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751499AbcLSUsq (ORCPT ); Mon, 19 Dec 2016 15:48:46 -0500 Received: by mail-it0-f54.google.com with SMTP id 75so44483607ite.1 for ; Mon, 19 Dec 2016 12:48:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=FSP08uPSGXT10HvNrtafAaKJUvTIu8TDeYRmus+yb9Y=; b=cRqmgwhAAluRi9z+cgseRD5qQQ1CUxF+PWuguIS25V4Pk1jWGFbaPL0hLedJfyx89f 4IAbi8FGq5x6LkX/ZMHQxcE86EsT0Lj1BaFkR9F+cmocekt533XjcxlZM9QM/tC63LPG ECg25110nrf1LjDwASFawIWxTuR1dEA+zegztK0UhVFnObwe60uPSDoQ1lWdIf0eI31K qlhwI7MrxGdVz/v20F6kD6OqsF75v9ayqNPj31Opg50ak/TKwSO7slrz4Uf/Ii4PJxTW DqtaQYJKK5JsirrKaW3eWKL86vfz59MsfICJ2vXxF/kP1ysj3FymufbUjnjBuRbWzAcn 1K5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FSP08uPSGXT10HvNrtafAaKJUvTIu8TDeYRmus+yb9Y=; b=khMYXJiFL3kxxoI7hlfS1T3bo4dfWxpUSh8UjxxOLv8VpwRmKLAqTfk3GWwkSteaLb IZ3P4MmH3w8ahUeCSVd6pa8Yh2Y9Qg6ybSWIU9Wv8FKn6OAOMWDTjDirqCFjm3IMHSIP Sj1S1P1a7GHYbKexJPmPq0x1q4P6NNeL+xYvSly919aSx55E72oGkvAaUA1xsuXlXQek cqeqd9/wbTeiz/jZbi2xH7zqbStZTRI64u6/bR2e4GfuWjVl5wdckUXIyHw0VEknhQMD ZGe248zu5V6mPUJTuupOfTww7GTgHIF/9Aa20IMDwPsxrFkrP7RFOR4HBaY6BCCarphM 06oQ== X-Gm-Message-State: AKaTC00lI00mHhSm3y66wi+LaOHQ5UaQFWLFvQvn1SLJ2k8cH/5iIdARTTLdxGuxpkbErI1f X-Received: by 10.36.98.206 with SMTP id d197mr19039629itc.52.1482180525685; Mon, 19 Dec 2016 12:48:45 -0800 (PST) Received: from dmatlack.sea.corp.google.com ([100.100.206.82]) by smtp.gmail.com with ESMTPSA id f4sm8870191ioe.40.2016.12.19.12.48.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Dec 2016 12:48:45 -0800 (PST) From: David Matlack To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, me@kylehuey.com, David Matlack Subject: [PATCH] KVM: nVMX: fix instruction skipping during emulated vm-entry Date: Mon, 19 Dec 2016 12:48:41 -0800 Message-Id: <1482180521-71290-1-git-send-email-dmatlack@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 kvm_skip_emulated_instruction() should not be called after emulating a VM-entry failure during or after loading guest state (nested_vmx_entry_failure()). Otherwise the L1 hypervisor is resumed some number of bytes past vmcs->host_rip. Fixes: eb2775621701e6ee3ea2a474437d04e93ccdcb2f Signed-off-by: David Matlack Reviewed-by: Radim Krčmář --- arch/x86/kvm/vmx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index c41d7ff..0e7ad72 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10474,12 +10474,12 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) !nested_guest_cr4_valid(vcpu, vmcs12->guest_cr4)) { nested_vmx_entry_failure(vcpu, vmcs12, EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT); - goto out; + return 1; } if (vmcs12->vmcs_link_pointer != -1ull) { nested_vmx_entry_failure(vcpu, vmcs12, EXIT_REASON_INVALID_STATE, ENTRY_FAIL_VMCS_LINK_PTR); - goto out; + return 1; } /* @@ -10499,7 +10499,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) ia32e != !!(vmcs12->guest_ia32_efer & EFER_LME))) { nested_vmx_entry_failure(vcpu, vmcs12, EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT); - goto out; + return 1; } } @@ -10517,7 +10517,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) ia32e != !!(vmcs12->host_ia32_efer & EFER_LME)) { nested_vmx_entry_failure(vcpu, vmcs12, EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT); - goto out; + return 1; } }