Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2195773iof; Tue, 7 Jun 2022 22:52:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx66jpeNcZeBG4SPGWcK7buP9F98GOLZbiRPLmhF2+DsOk6wq3yocGpmBo1VXLaHQCG0wzx X-Received: by 2002:a17:90a:4e82:b0:1ea:3f61:51b with SMTP id o2-20020a17090a4e8200b001ea3f61051bmr1587551pjh.16.1654667551091; Tue, 07 Jun 2022 22:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667551; cv=none; d=google.com; s=arc-20160816; b=pOfvZv/y/L0J0TpJB2HvJ+jN4jwmOm2IPRGz2JZSP4NCjS7QB6M+T7Cvi6zJDumQst Houo4WCMgxYFl8WZz2x8VNQUidJCbk7Q6Hyy7uXv5smKrfLNWPE3wMRddAad2GEAAKgC idqKoaZale5mVosI9sjFvo2Bo0FuNarCqiZsaVZGZaAuEIH7E6p2MTtNvufG6yZvdlO9 Ty2fp0OUv9FtDqW1UhejEzL/n1bPiTB3muu4MUOqCzsRg++PWFrdnvDg+C79ZfbiriDF +itnLRBEQqqbxgtMlOBqCSmyWz+pRXi5RE275+/n2sLg9n81bJTmhCo4qN1bhCDxXlFZ Gh7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lLgzZD+AiP+txTzl7r34ejda+e8LxAepRARo8dsZOas=; b=VTYTHGJuigzCKu+BjVDlN0Sb6tt2eoHXSzg06p+SpfG3/Ulc1tUgMBEqdB8rhmWydR +c5SNYaeVLPA1diSSQ894xRXKyGlp0xjvyjfce1vJUd7JNJYjQ4WzMRMvBmbJmxXQNU8 at8z7F/9LSeBNJwmowp58Mpqn72fGx0WvIsz/TFBIchiqKqkkSW0O1BOFBEUQ6rCiawX 0/cisFIfcAO4QLdwH3Dl5J/oOS19Rle3UZtkxl/Sn03nujhXnkIc5D6L87RK/DJjGlYK 6jdd57+Iz/I0MCxh1kV/C/2IHADZhLgZJKFUdTGU/MZanJBvWK1zReOyq2laT+l0CjSJ 7AnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sCT2uiL4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g11-20020a056a001a0b00b0050e12e5d0c8si27828777pfv.54.2022.06.07.22.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:52:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sCT2uiL4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 484424B1761; Tue, 7 Jun 2022 22:22:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442935AbiFHA5Z (ORCPT + 99 others); Tue, 7 Jun 2022 20:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384249AbiFGVyX (ORCPT ); Tue, 7 Jun 2022 17:54:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE9D6AE66; Tue, 7 Jun 2022 12:13:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 547CA618DF; Tue, 7 Jun 2022 19:12:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61CD4C385A5; Tue, 7 Jun 2022 19:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629163; bh=jVvs9w7K39JhmF1xVqZrSta5rt7NcM8+MKaMntkkGo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sCT2uiL4J5DcJ9MQUPceiyB8/7UvyNvN4BrwBW3b1QZZJr9PR+JfR0kFNLGVra3Rb HVSmmxmfln9waBHsbVKJ7FE4yfTsQI8sPYnFVcNj9akUxLWRR3PXdymK40fx/hIDIB EbkoVDXC0eD0uUFzKSK1eXIm2dNPZf7sya0JItFE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.18 552/879] KVM: nVMX: Leave most VM-Exit info fields unmodified on failed VM-Entry Date: Tue, 7 Jun 2022 19:01:10 +0200 Message-Id: <20220607165018.888621803@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson [ Upstream commit c3634d25fbee88e2368a8e0903ae0d0670eb9e71 ] Don't modify vmcs12 exit fields except EXIT_REASON and EXIT_QUALIFICATION when performing a nested VM-Exit due to failed VM-Entry. Per the SDM, only the two aformentioned fields are filled and "All other VM-exit information fields are unmodified". Fixes: 4704d0befb07 ("KVM: nVMX: Exiting from L2 to L1") Signed-off-by: Sean Christopherson Message-Id: <20220407002315.78092-3-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx/nested.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 880d0b0c9315..afaddd43a6c0 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -4202,12 +4202,12 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, if (to_vmx(vcpu)->exit_reason.enclave_mode) vmcs12->vm_exit_reason |= VMX_EXIT_REASONS_SGX_ENCLAVE_MODE; vmcs12->exit_qualification = exit_qualification; - vmcs12->vm_exit_intr_info = exit_intr_info; - - vmcs12->idt_vectoring_info_field = 0; - vmcs12->vm_exit_instruction_len = vmcs_read32(VM_EXIT_INSTRUCTION_LEN); - vmcs12->vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO); + /* + * On VM-Exit due to a failed VM-Entry, the VMCS isn't marked launched + * and only EXIT_REASON and EXIT_QUALIFICATION are updated, all other + * exit info fields are unmodified. + */ if (!(vmcs12->vm_exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY)) { vmcs12->launch_state = 1; @@ -4219,8 +4219,13 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, * Transfer the event that L0 or L1 may wanted to inject into * L2 to IDT_VECTORING_INFO_FIELD. */ + vmcs12->idt_vectoring_info_field = 0; vmcs12_save_pending_event(vcpu, vmcs12); + vmcs12->vm_exit_intr_info = exit_intr_info; + vmcs12->vm_exit_instruction_len = vmcs_read32(VM_EXIT_INSTRUCTION_LEN); + vmcs12->vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO); + /* * According to spec, there's no need to store the guest's * MSRs if the exit is due to a VM-entry failure that occurs -- 2.35.1