Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3529928pxf; Mon, 15 Mar 2021 11:36:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdYK7t58Xkst69bD88ZG8Emz3fw3KUkHc7J4UDdN6N3k9DkTwrEjE9eHXVPqRni/hvZM5K X-Received: by 2002:a17:906:1d4e:: with SMTP id o14mr24278706ejh.549.1615833364967; Mon, 15 Mar 2021 11:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833364; cv=none; d=google.com; s=arc-20160816; b=XYfQV8HBiQ6Y1tfM1Q/iQPJxYmDEdSdNVN5XtZlfc6GOLoWDkseWV7ikJp4PGGXCAV 4B07MemLawT+LnTNkxp1GJe+9VH5ISXt42gasgUcRZl0mdCX7WNnEA6xfPOQVjX7rj2e JRvBkNeEaBg9iSZeDy344O8eBJ5bSsGJ/383Riy4o0Af37Q9eWanjIF4KcT1HTUUvFeN anPjlsgxE7f5J+S+tOLwLEE8OU7WxdkQqMvsXOEHn5+/neKQyATUHXX32gR+3u5XRQqd fJrswlB0FzzcwPhmKXteDEQCyVnpkrBlDTgpkyGn0MiirG/nI3rXKKyiLbJKDaB20jTn jH/g== 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=FS5d4LNtU3tIyVTBUzSUXnfCs8GdInSLiQbhU+L3tMA=; b=bGKAtu2XLdbrn12z82IG35mHGUUn23CuyuyHr3LFzcZ0AzOh8M3mIhvkWXP62mLHPw TuxVN1xfY/tFx6HldAlxeD4lMAndfRme7qzreJfFubHdclKqDc7KgGKRm3QC8beg4zbN sm/dFyecqnXYqPb+LdoM1osJoWnsJ7VMDRZ/oqZgYe7l+wlW/7YbeT023hcdcZ9cwKqB Yarmh15XIQDNZ4N1LI8JCll+CQMPYYXa5SBL4qzz7ya176N3kTuN3mMjSCeSof+3eDXB 7E/4pRA8DOxx0yMZI+b4h/24g1BMn3ucubqmxW58/nNOzVBWkeKp3PbrozxDDitU7P1M AU9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B8DHOYj3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n22si11449520eju.124.2021.03.15.11.35.42; Mon, 15 Mar 2021 11:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B8DHOYj3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239348AbhCOOqb (ORCPT + 99 others); Mon, 15 Mar 2021 10:46:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:53046 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231207AbhCOOEk (ORCPT ); Mon, 15 Mar 2021 10:04:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CA1EC64EF1; Mon, 15 Mar 2021 14:04:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817079; bh=0CceF+b+LmF5KHpXmBA8tZP9h2CE5iqe//MjyHGSF9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B8DHOYj3OVOmmouKlVU9+OCtBMqjCrGAxbhgUSsM86w+66ADLGLboWdLgBZTOuYnI /Iyc98kRAdQA+k5PkM0OG798xvw05vd+vo8OtecOd3P9Re15j5fGBpEanc6DKmK1Ju blG98wg0Vl4ToiIlHgRyX2I97jqlA6Cu5S92DEkk= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Lutomirski , Joerg Roedel , Borislav Petkov Subject: [PATCH 5.11 289/306] x86/sev-es: Correctly track IRQ states in runtime #VC handler Date: Mon, 15 Mar 2021 14:55:52 +0100 Message-Id: <20210315135517.456626134@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Joerg Roedel commit 62441a1fb53263bda349b6e5997c3cc5c120d89e upstream. Call irqentry_nmi_enter()/irqentry_nmi_exit() in the #VC handler to correctly track the IRQ state during its execution. Fixes: 0786138c78e79 ("x86/sev-es: Add a Runtime #VC Exception Handler") Reported-by: Andy Lutomirski Signed-off-by: Joerg Roedel Signed-off-by: Borislav Petkov Cc: stable@vger.kernel.org # v5.10+ Link: https://lkml.kernel.org/r/20210303141716.29223-5-joro@8bytes.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/sev-es.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/sev-es.c +++ b/arch/x86/kernel/sev-es.c @@ -1258,13 +1258,12 @@ static __always_inline bool on_vc_fallba DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication) { struct sev_es_runtime_data *data = this_cpu_read(runtime_data); + irqentry_state_t irq_state; struct ghcb_state state; struct es_em_ctxt ctxt; enum es_result result; struct ghcb *ghcb; - lockdep_assert_irqs_disabled(); - /* * Handle #DB before calling into !noinstr code to avoid recursive #DB. */ @@ -1273,6 +1272,8 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_co return; } + irq_state = irqentry_nmi_enter(regs); + lockdep_assert_irqs_disabled(); instrumentation_begin(); /* @@ -1335,6 +1336,7 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_co out: instrumentation_end(); + irqentry_nmi_exit(regs, irq_state); return;