Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
trusty: trigger vmcall to activate VT-d in eVMM
Browse files Browse the repository at this point in the history
Add new function trusty_late_init() which is called between
ExitBootService() and kernel jumping.
Currently, only activate_vtd_vmcall() is called in trusty_late_init().

Signed-off-by: Yadong Qi <[email protected]>
  • Loading branch information
YadongQi committed Dec 7, 2021
1 parent 9a84515 commit 16dffc4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/trusty_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@

EFI_STATUS load_tos_image(OUT VOID **bootimage);

VOID trusty_late_init(VOID);

#endif /* _TRUSTY_COMMON_H_ */
10 changes: 10 additions & 0 deletions libkernelflinger/android.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
#ifdef USE_FIRSTSTAGE_MOUNT
#include "firststage_mount.h"
#endif
#ifdef USE_TRUSTY
#include "trusty_common.h"
#endif

#include "uefi_utils.h"

Expand Down Expand Up @@ -467,6 +470,13 @@ static inline EFI_STATUS handover_jump(EFI_HANDLE image,

boot:

#ifdef USE_TRUSTY
/*
* Called after ExitBootService.
*/
trusty_late_init();
#endif

#if __LP64__
/* The 64-bit kernel entry is 512 bytes after the start. */
kernel_start += 512;
Expand Down
14 changes: 14 additions & 0 deletions libkernelflinger/trusty_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,17 @@ EFI_STATUS load_tos_image(OUT VOID **tosimage)

return EFI_SUCCESS;
}

static VOID activate_vtd(VOID)
{
#define VMCALL_ACTIVATE_VTD 0x56544400ULL // "VTD"
asm volatile ("vmcall" : : "a"(VMCALL_ACTIVATE_VTD));
}

/*
* This function is designed to run after bootloader triggered ExitBootService.
*/
VOID trusty_late_init(VOID)
{
activate_vtd();
}

0 comments on commit 16dffc4

Please sign in to comment.