Re: [RFC PATCH V3 13/16] x86/sev: Add Check of #HV event in path

From: Tianyu Lan
Date: Fri Mar 10 2023 - 11:04:11 EST


On 3/9/2023 12:18 AM, Gupta, Pankaj wrote:
On 3/1/2023 12:11 PM, Gupta, Pankaj wrote:
On 1/22/2023 3:46 AM, Tianyu Lan wrote:

diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c
index a8862a2eff67..fe5e5e41433d 100644
--- a/arch/x86/kernel/sev.c
+++ b/arch/x86/kernel/sev.c
@@ -179,6 +179,45 @@ void noinstr __sev_es_ist_enter(struct pt_regs *regs)
      this_cpu_write(cpu_tss_rw.x86_tss.ist[IST_INDEX_VC], new_ist);
  }
+static void do_exc_hv(struct pt_regs *regs)
+{
+    /* Handle #HV exception. */
+}
+
+void check_hv_pending(struct pt_regs *regs)
+{
+    if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
+        return;
+
+    if ((regs->flags & X86_EFLAGS_IF) == 0)
+        return;

Will this return and prevent guest from executing NMI's
while irqs are disabled?

I think we need to handle NMI's even when irqs are disabled.


Yes, nice catch!

As we reset "no_further_signal" in hv_raw_handle_exception()
and return from check_hv_pending() when irqs are disabled, this
can result in loss/delay of NMI event?

Will fix this in the next version.

Thanks.