Re: [RFC PATCH 16/17] x86/sev: Add a #HV exception handler

From: Tianyu Lan
Date: Sun Nov 13 2022 - 20:28:49 EST


Thanks for your review.

On 11/11/2022 4:38 AM, Kalra, Ashish wrote:
+    UNWIND_HINT_REGS
+
+    /* Update pt_regs */
+    movq    ORIG_RAX(%rsp), %rsi    /* get error code into 2nd argument*/
+    movq    $-1, ORIG_RAX(%rsp)    /* no syscall to restart */
+
+    movq    %rsp, %rdi        /* pt_regs pointer */
+    call    kernel_\cfunc
+
+    jmp    paranoid_exit
+
+.Lfrom_usermode_switch_stack_\@:
+    idtentry_body user_\cfunc, has_error_code=1

#HV exception handler cannot/does not inject an error code, so shouldn't
has_error_code == 0?

Nice catch. Will update in the next version.

+    irqentry_state_t irq_state;
+
+    if (unlikely(on_hv_fallback_stack(regs))) {
+            instrumentation_begin();
+            panic("Can't handle #HV exception from unsupported context\n");
+            instrumentation_end();
+    }

HV fallback stack exists and is used if we couldn't switch to HV stack. If we have to issue a panic() here, why don't we simply issue the panic() in hv_switch_off_ist(), when we couldn't switch to HV stack ?


Yes, this is a good idea. Will update. Thanks.