Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp79829iof; Sun, 5 Jun 2022 21:43:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx35M3aLbbB/XjUQatoJn+NTcCcHSOZPFrDPaNP4RMjbfhNwnTjcFM27Ksooq/exnHM6XO1 X-Received: by 2002:a17:90b:314a:b0:1e8:5362:5620 with SMTP id ip10-20020a17090b314a00b001e853625620mr11717786pjb.9.1654490639198; Sun, 05 Jun 2022 21:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654490639; cv=none; d=google.com; s=arc-20160816; b=FMjOPuT2spSZdK6xeXhgGcsxu939+1Ups9Q0ct/byrdYdHbyiXseZSstStss/AXu2z hUfaj2A4V/QfbsGVNGCVxExZspygYsofeZOSEYmxbYM134v6cmmpeAL+6gZ9YKuZA1pt GNtaAZEW7P1cUzV8yVobLLYxdNh3j8+6rEDGyWa1Vka7Yp5r2GaFTLEKALn1rVps3j6z D4hamQWXm6TjfVcYOTsJJ3S1tvhesONRvJrlSJyIy1AIyBPOHUIXBfDFP3P/FUyBUREh HI4peAf6QcNkZye+qnSfjd/OOTa0sp9HAPcIvUxREQBbwRIAiDnKRAAK/mSzeeKd3quT 9NlQ== 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=Q6hQRArLKn0BWn0LJH+bws3aMGGZKZ0LkY6c1lw/+q8=; b=rJTxOPXhZu7Iw+2SCDC4Za9ZE5d5calmK38RdL5l6tPRj5J8g+VD3Pmwf28+okWfbL AwWAvWVcEUzvBpEl37s3+mmpK3nNaxttKy7mnakTia8Iwf29U8mZEztFBC0dLdhWHF+H Q3ibr6Kw6jw70fpgIqXowb8AewKfVYrePleABxyIqUcqJJOOGOEFP83RZcojHwOEyM/I KOyiDc0Ej2R7XHue4rEnz7Yil1Avv78wfZ6PeeYbMVtrj/+we90eZzspR7k4wEg/XwNg YsyOiPxZ8gAHbgDdZiX11EeeVIVqbfyY6yjt4vyPR/xXLbqhemRYdZ2zbJSPvcSn/bCh Cpog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wp3Wju6q; 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 b19-20020a056a0002d300b0050e136de8absi16054805pft.283.2022.06.05.21.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:43:59 -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=wp3Wju6q; 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 CF5CC1182D; Sun, 5 Jun 2022 21:02:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245080AbiFCR6t (ORCPT + 99 others); Fri, 3 Jun 2022 13:58:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347162AbiFCRwE (ORCPT ); Fri, 3 Jun 2022 13:52:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F6C0580C7; Fri, 3 Jun 2022 10:50:08 -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 ams.source.kernel.org (Postfix) with ESMTPS id 1F946B8241E; Fri, 3 Jun 2022 17:50:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A35FC385B8; Fri, 3 Jun 2022 17:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278605; bh=L9NL8cfQm4uBAI+EBhlVPB/EEPK4z9XyUAwqdOPAGPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wp3Wju6qe6pxG3XXramIEwdjjFD1VxRz3zVTVNlEM+MRsgt4Pe5iiAZuMDrOmWGJc nC3dK6+dF4+NmQh21Y2Utjs3HbzYTx661GEnu5btIv0T50kDxqPdHk7sK1q/U3/f+L x0P+S2I9W5F0/hntf/nGzynGWsl4GCcu5cVwtPyI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chenyi Qiang , Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.15 32/66] KVM: x86: Drop WARNs that assert a triple fault never "escapes" from L2 Date: Fri, 3 Jun 2022 19:43:12 +0200 Message-Id: <20220603173821.581325065@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173820.663747061@linuxfoundation.org> References: <20220603173820.663747061@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 commit 45846661d10422ce9e22da21f8277540b29eca22 upstream. Remove WARNs that sanity check that KVM never lets a triple fault for L2 escape and incorrectly end up in L1. In normal operation, the sanity check is perfectly valid, but it incorrectly assumes that it's impossible for userspace to induce KVM_REQ_TRIPLE_FAULT without bouncing through KVM_RUN (which guarantees kvm_check_nested_state() will see and handle the triple fault). The WARN can currently be triggered if userspace injects a machine check while L2 is active and CR4.MCE=0. And a future fix to allow save/restore of KVM_REQ_TRIPLE_FAULT, e.g. so that a synthesized triple fault isn't lost on migration, will make it trivially easy for userspace to trigger the WARN. Clearing KVM_REQ_TRIPLE_FAULT when forcibly leaving guest mode is tempting, but wrong, especially if/when the request is saved/restored, e.g. if userspace restores events (including a triple fault) and then restores nested state (which may forcibly leave guest mode). Ignoring the fact that KVM doesn't currently provide the necessary APIs, it's userspace's responsibility to manage pending events during save/restore. ------------[ cut here ]------------ WARNING: CPU: 7 PID: 1399 at arch/x86/kvm/vmx/nested.c:4522 nested_vmx_vmexit+0x7fe/0xd90 [kvm_intel] Modules linked in: kvm_intel kvm irqbypass CPU: 7 PID: 1399 Comm: state_test Not tainted 5.17.0-rc3+ #808 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:nested_vmx_vmexit+0x7fe/0xd90 [kvm_intel] Call Trace: vmx_leave_nested+0x30/0x40 [kvm_intel] vmx_set_nested_state+0xca/0x3e0 [kvm_intel] kvm_arch_vcpu_ioctl+0xf49/0x13e0 [kvm] kvm_vcpu_ioctl+0x4b9/0x660 [kvm] __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae ---[ end trace 0000000000000000 ]--- Fixes: cb6a32c2b877 ("KVM: x86: Handle triple fault in L2 without killing L1") Cc: stable@vger.kernel.org Cc: Chenyi Qiang Signed-off-by: Sean Christopherson Message-Id: <20220407002315.78092-2-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/nested.c | 3 --- arch/x86/kvm/vmx/nested.c | 3 --- 2 files changed, 6 deletions(-) --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -750,9 +750,6 @@ int nested_svm_vmexit(struct vcpu_svm *s struct kvm_host_map map; int rc; - /* Triple faults in L2 should never escape. */ - WARN_ON_ONCE(kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu)); - rc = kvm_vcpu_map(vcpu, gpa_to_gfn(svm->nested.vmcb12_gpa), &map); if (rc) { if (rc == -EINVAL) --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -4501,9 +4501,6 @@ void nested_vmx_vmexit(struct kvm_vcpu * /* trying to cancel vmlaunch/vmresume is a bug */ WARN_ON_ONCE(vmx->nested.nested_run_pending); - /* Similarly, triple faults in L2 should never escape. */ - WARN_ON_ONCE(kvm_check_request(KVM_REQ_TRIPLE_FAULT, vcpu)); - if (kvm_check_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu)) { /* * KVM_REQ_GET_NESTED_STATE_PAGES is also used to map