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

Commit 16dffc4

Browse files
committed
trusty: trigger vmcall to activate VT-d in eVMM
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]>
1 parent 9a84515 commit 16dffc4

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

include/trusty_common.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@
3636

3737
EFI_STATUS load_tos_image(OUT VOID **bootimage);
3838

39+
VOID trusty_late_init(VOID);
40+
3941
#endif /* _TRUSTY_COMMON_H_ */

libkernelflinger/android.c

+10
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
#ifdef USE_FIRSTSTAGE_MOUNT
5858
#include "firststage_mount.h"
5959
#endif
60+
#ifdef USE_TRUSTY
61+
#include "trusty_common.h"
62+
#endif
6063

6164
#include "uefi_utils.h"
6265

@@ -467,6 +470,13 @@ static inline EFI_STATUS handover_jump(EFI_HANDLE image,
467470

468471
boot:
469472

473+
#ifdef USE_TRUSTY
474+
/*
475+
* Called after ExitBootService.
476+
*/
477+
trusty_late_init();
478+
#endif
479+
470480
#if __LP64__
471481
/* The 64-bit kernel entry is 512 bytes after the start. */
472482
kernel_start += 512;

libkernelflinger/trusty_common.c

+14
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,17 @@ EFI_STATUS load_tos_image(OUT VOID **tosimage)
258258

259259
return EFI_SUCCESS;
260260
}
261+
262+
static VOID activate_vtd(VOID)
263+
{
264+
#define VMCALL_ACTIVATE_VTD 0x56544400ULL // "VTD"
265+
asm volatile ("vmcall" : : "a"(VMCALL_ACTIVATE_VTD));
266+
}
267+
268+
/*
269+
* This function is designed to run after bootloader triggered ExitBootService.
270+
*/
271+
VOID trusty_late_init(VOID)
272+
{
273+
activate_vtd();
274+
}

0 commit comments

Comments
 (0)