Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528869pxf; Mon, 15 Mar 2021 11:34:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCSlhcxf/D1oviOR1Vt6OmBp8no9jt35NlF1/c6mrWXICydns+TYaAWiTuNXs1g49I7VsT X-Received: by 2002:a17:906:2551:: with SMTP id j17mr25227719ejb.441.1615833280727; Mon, 15 Mar 2021 11:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833280; cv=none; d=google.com; s=arc-20160816; b=gKgiUWTVN8/ggibHSICVJcRKIJc/8zZ2XyV7NGVLTtpbWWvOgru6+f1JJBs3RaYR9K gdxLX8HfLEPUPoF/WogrJ0aSp8lFtUsNqK3UQPYv8ezbBwCxIvsjoHYUluICNahxmqAP rB0wNClh/NVKJz0zV6ZYFacLH6E4EcmLcV3q7AF8BRT/Ilj+Aod0mA8Hb5+95gpZWZgC R1SNxpWHUdJwrvG8DoHQfGGjGaMX7g8M8GpWZXB2/icBLEuQggHBEjE9aW8/TS5gie/t tj4t0iCJ/29Sxu1eThS192FRJzVgTWoEkWXxzSm5pA2ufY/+JAftvI6BmO2upzwcGNBE IA+w== 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=ONt+Din0IPLllD1T/utCT5LGLfyjUMyJvmMt0GF6r4ppnk4GBm44kMgRFcnWoKkyAa 53ggpYkSsCJ0dva98KiM1aAmdViQ9/iy3IyIbg88b7ZcA3cgK6jNYm1AZTzSeNUR3Hqd VdFBYutX9wP771uie5NPMOC+UTYgDoQ2MiUrXzVZrBpTQcs9xaBP3KYGv9XSSnMBwYce hAbVFy0O647SmCcKbECeJFt0itT+PPm30WYEicSr2zbld68BDSx2JuMlciiaaI6ir09r pvYRFSD9l8KXiYBEin06Z5Tf4I6VfrgN8nXFwDGUk2IUtEzlKJPHh4RxwWr6/1w0LXiJ fUlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VV+hnPO4; 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 jo5si12391962ejb.644.2021.03.15.11.34.18; Mon, 15 Mar 2021 11:34:40 -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=VV+hnPO4; 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 S234590AbhCOOqQ (ORCPT + 99 others); Mon, 15 Mar 2021 10:46:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:52254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231916AbhCOOEa (ORCPT ); Mon, 15 Mar 2021 10:04:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA87564E89; Mon, 15 Mar 2021 14:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817069; bh=0CceF+b+LmF5KHpXmBA8tZP9h2CE5iqe//MjyHGSF9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VV+hnPO4YPkPav3yhjAhiLL42JEDeuJj2X598qvccyYt08ENVyLVa0bqx+ENGddy/ W7pdEBNllaAgCxZ+W+zhw2mXO3LbegmjI8Po0bjHbGLCf1K6eMJmtl9HdMVEjnUcvz DYjig+XYQiekxnDEh+bSQhqkezCT1bJnJLNPLmXA= 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.10 273/290] x86/sev-es: Correctly track IRQ states in runtime #VC handler Date: Mon, 15 Mar 2021 14:56:06 +0100 Message-Id: <20210315135551.250398104@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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;