Skip to content

Commit a2d0171

Browse files
joergroedelsuryasaimadhu
authored andcommitted
x86/sev-es: Handle #AC Events
Implement a handler for #VC exceptions caused by #AC exceptions. The #AC exception is just forwarded to do_alignment_check() and not pushed down to the hypervisor, as requested by the SEV-ES GHCB Standardization Specification. Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20200907131613.12703-61-joro@8bytes.org
1 parent 2eb7dcf commit a2d0171

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

arch/x86/kernel/sev-es.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,19 @@ static enum es_result vc_handle_vmmcall(struct ghcb *ghcb,
909909
return ES_OK;
910910
}
911911

912+
static enum es_result vc_handle_trap_ac(struct ghcb *ghcb,
913+
struct es_em_ctxt *ctxt)
914+
{
915+
/*
916+
* Calling ecx_alignment_check() directly does not work, because it
917+
* enables IRQs and the GHCB is active. Forward the exception and call
918+
* it later from vc_forward_exception().
919+
*/
920+
ctxt->fi.vector = X86_TRAP_AC;
921+
ctxt->fi.error_code = 0;
922+
return ES_EXCEPTION;
923+
}
924+
912925
static enum es_result vc_handle_exitcode(struct es_em_ctxt *ctxt,
913926
struct ghcb *ghcb,
914927
unsigned long exit_code)
@@ -922,6 +935,9 @@ static enum es_result vc_handle_exitcode(struct es_em_ctxt *ctxt,
922935
case SVM_EXIT_WRITE_DR7:
923936
result = vc_handle_dr7_write(ghcb, ctxt);
924937
break;
938+
case SVM_EXIT_EXCP_BASE + X86_TRAP_AC:
939+
result = vc_handle_trap_ac(ghcb, ctxt);
940+
break;
925941
case SVM_EXIT_RDTSC:
926942
case SVM_EXIT_RDTSCP:
927943
result = vc_handle_rdtsc(ghcb, ctxt, exit_code);
@@ -981,6 +997,9 @@ static __always_inline void vc_forward_exception(struct es_em_ctxt *ctxt)
981997
case X86_TRAP_UD:
982998
exc_invalid_op(ctxt->regs);
983999
break;
1000+
case X86_TRAP_AC:
1001+
exc_alignment_check(ctxt->regs, error_code);
1002+
break;
9841003
default:
9851004
pr_emerg("Unsupported exception in #VC instruction emulation - can't continue\n");
9861005
BUG();

0 commit comments

Comments
 (0)