Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp577146img; Fri, 22 Mar 2019 04:24:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlO6IC0jcIPbCxTP8snx8XELD7HPL0AlJypPddIPuYuVoew3HUfMhN8ZVDpKGoWjkRAL3s X-Received: by 2002:a17:902:584:: with SMTP id f4mr9181326plf.330.1553253851486; Fri, 22 Mar 2019 04:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253851; cv=none; d=google.com; s=arc-20160816; b=zweN7Fq48/RWAmtGexZTvPRrgubCQqWc8f1eWofxRgjfCzBty+xTXAOodRKRagLwcV UvTDZl5faT98hQEHPnx9mr+mA+XYLnLlubDLE7pXfQ50N/4Sr6P+DkisEvFdIvnjPy+e AdHKEgKzVdIesb70iAi0ixYbokUHj7oIjXA8iyuY/lQY6EKgluyqlQs7+qmuNwyVnXWH 27m9zpkiAz42dUNF7B95uEap/Nf2z9YYxR93mjL5YIHynrDYwku2cieA8EV8/9ZOXvyy mdYFUFoBizkcnZI+I8Anc6mI12rJeYFnDOjWNBq92Ga8VMGiyisKmel8MJp4O9TBC8hq 0QCQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mVCvTyq+ySuBeYAMuyCDt9uN5D2CwY8xC9kGNPtmNsk=; b=yqOXns1te1UFN69rqWUJBY1x/SYUPfBvajxX0ut+i/Jjkhh0Gc3It3bGIMhVdEX0ec vFn97ecp/EEIXZ3kcNYPYhISY5v5Z3NMjxU5EyU1wCG0wYuT/lw+9KMBhTVQG4ZJVeec aqZm2bBjuaMhWa6PvM42YecRHirqivy4E4VqLgF73j9SVQ4TI+FlVcGvaJ8hsvlwTiJg R0wA1PnAuwkIuuSoDyCVMkYAUBq9f7tYlzm2hiU0nLkLDENo/rOTMoLoDpaZMm11EFp/ GFeuH43/PdmRefu423RQUH4kUdjBaE8bfG90+bPe6WduiJuBjwvCg4GqvoBSmICRj1lQ fm/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZlYMh7Un; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e127si6443166pgc.360.2019.03.22.04.23.53; Fri, 22 Mar 2019 04:24:11 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ZlYMh7Un; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728339AbfCVLWX (ORCPT + 99 others); Fri, 22 Mar 2019 07:22:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:49042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728750AbfCVLWU (ORCPT ); Fri, 22 Mar 2019 07:22:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0EDE6218D4; Fri, 22 Mar 2019 11:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253739; bh=RRGU1OKsRaCuLlfGrNq9hYcraCQuRu4681MFZ9onvH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZlYMh7UnBJtSb0Ove02qjXyKZFTVKcEkyGnolpy6a5WhCm/cwqEpD6qNWj5JuXygP eNqpwAa7lek0jOpSEsOXHJHD8c4tfp5eyG9RkZ8FO7r0vLmPBnPsyq2DVlHArKhYXm hmB0ivvhvrxo+OAn5VaZ3t36zD1giQp39IMbgvRs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , Paolo Bonzini , Sasha Levin Subject: [PATCH 3.18 040/134] KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1 Date: Fri, 22 Mar 2019 12:14:13 +0100 Message-Id: <20190322111212.769955206@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 619ad846fc3452adaf71ca246c5aa711e2055398 ] kvm-unit-tests' eventinj "NMI failing on IDT" test results in NMI being delivered to the host (L1) when it's running nested. The problem seems to be: svm_complete_interrupts() raises 'nmi_injected' flag but later we decide to reflect EXIT_NPF to L1. The flag remains pending and we do NMI injection upon entry so it got delivered to L1 instead of L2. It seems that VMX code solves the same issue in prepare_vmcs12(), this was introduced with code refactoring in commit 5f3d5799974b ("KVM: nVMX: Rework event injection and recovery"). Signed-off-by: Vitaly Kuznetsov Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/svm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 2e0c64a08549c..a29d59e205d39 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2431,6 +2431,14 @@ static int nested_svm_vmexit(struct vcpu_svm *svm) kvm_mmu_reset_context(&svm->vcpu); kvm_mmu_load(&svm->vcpu); + /* + * Drop what we picked up for L2 via svm_complete_interrupts() so it + * doesn't end up in L1. + */ + svm->vcpu.arch.nmi_injected = false; + kvm_clear_exception_queue(&svm->vcpu); + kvm_clear_interrupt_queue(&svm->vcpu); + return 0; } -- 2.19.1