diff --git a/include/android.h b/include/android.h index 0ddade1f..8881feb0 100644 --- a/include/android.h +++ b/include/android.h @@ -32,6 +32,7 @@ #define BOOT_ARGS_SIZE 512 #define BOOT_EXTRA_ARGS_SIZE 1024 +extern UINT64 start_tsc; struct boot_img_hdr { diff --git a/include/timer.h b/include/timer.h index 194ccedf..81ac8523 100644 --- a/include/timer.h +++ b/include/timer.h @@ -45,6 +45,7 @@ enum TM_POINT { TM_POINT_LAST }; +uint64_t __attribute__((unused,always_inline)) __RDTSC (void); uint32_t get_cpu_freq(void); uint32_t boottime_in_msec(void); void set_boottime_stamp(int num); diff --git a/kernelflinger.c b/kernelflinger.c index 001ebede..bf26571c 100644 --- a/kernelflinger.c +++ b/kernelflinger.c @@ -1196,6 +1196,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) VBDATA *vb_data = NULL; set_boottime_stamp(TM_EFI_MAIN); + start_tsc = __RDTSC(); /* gnu-efi initialization */ InitializeLib(image, sys_table); diff --git a/libkernelflinger/android.c b/libkernelflinger/android.c index 6993d200..700001ee 100644 --- a/libkernelflinger/android.c +++ b/libkernelflinger/android.c @@ -240,6 +240,7 @@ typedef struct { } __attribute__((packed)) dt_addr_t; static dt_addr_t *gdt; +UINT64 start_tsc; typedef void(*kernel_func)(void *, struct boot_params *); @@ -1601,6 +1602,7 @@ static EFI_STATUS handover_kernel(CHAR8 *bootimage, EFI_HANDLE parent_image) UINT32 koffset; size_t setup_header_size; size_t setup_header_end; + UINT64 end_tsc; aosp_header = (struct boot_img_hdr *)bootimage; buf = get_boot_param_hdr(bootimage); @@ -1677,6 +1679,11 @@ static EFI_STATUS handover_kernel(CHAR8 *bootimage, EFI_HANDLE parent_image) goto out; boot_params->hdr.code32_start = (UINT32)((UINT64)kernel_start); + end_tsc = __RDTSC(); + log(L"start tsc = %llx\n", start_tsc); + log(L"end tsc = %llx\n", end_tsc); + log(L"total tsc consumed by kernelflinger = %llx\n", end_tsc - start_tsc); + ret = handover_jump(parent_image, boot_params, kernel_start); /* Shouldn't get here */ efi_perror(ret, L"handover to Linux kernel has failed"); diff --git a/libkernelflinger/timer.c b/libkernelflinger/timer.c index 580cd42a..d7e9efec 100644 --- a/libkernelflinger/timer.c +++ b/libkernelflinger/timer.c @@ -69,7 +69,7 @@ __RDMSR (unsigned idx) return msr.val; } -static uint64_t __attribute__((unused,always_inline)) +uint64_t __attribute__((unused,always_inline)) __RDTSC (void) { uint32_t lo, hi;