Skip to content

Commit cb1ad3e

Browse files
joergroedelsuryasaimadhu
authored andcommitted
x86/sev-es: Handle #DB Events
Handle #VC exceptions caused by #DB exceptions in the guest. Those must be handled outside of instrumentation_begin()/end() so that the handler will not be raised recursively. Handle them by calling the kernel's debug exception handler. Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20200907131613.12703-62-joro@8bytes.org
1 parent a2d0171 commit cb1ad3e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

arch/x86/kernel/sev-es.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,14 @@ static enum es_result vc_handle_trap_ac(struct ghcb *ghcb,
922922
return ES_EXCEPTION;
923923
}
924924

925+
static __always_inline void vc_handle_trap_db(struct pt_regs *regs)
926+
{
927+
if (user_mode(regs))
928+
noist_exc_debug(regs);
929+
else
930+
exc_debug(regs);
931+
}
932+
925933
static enum es_result vc_handle_exitcode(struct es_em_ctxt *ctxt,
926934
struct ghcb *ghcb,
927935
unsigned long exit_code)
@@ -1033,6 +1041,15 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication)
10331041
struct ghcb *ghcb;
10341042

10351043
lockdep_assert_irqs_disabled();
1044+
1045+
/*
1046+
* Handle #DB before calling into !noinstr code to avoid recursive #DB.
1047+
*/
1048+
if (error_code == SVM_EXIT_EXCP_BASE + X86_TRAP_DB) {
1049+
vc_handle_trap_db(regs);
1050+
return;
1051+
}
1052+
10361053
instrumentation_begin();
10371054

10381055
/*

0 commit comments

Comments
 (0)