Some execution fixes

This commit is contained in:
2019-12-14 20:06:56 -05:00
parent 3caa14603f
commit cc87e78cb2
14 changed files with 189 additions and 150 deletions

View File

@@ -7,11 +7,14 @@ set(CMAKE_ASM_COMPILER /usr/bin/aarch64-linux-gnu-as)
set(CMAKE_OBJCOPY /usr/bin/aarch64-linux-gnu-objcopy)
set(CMAKE_C_FLAGS "-nostdlib -O")
set(PAYLOADS payload_aes payload_sysreg)
set(PAYLOADS payload_sync payload_aes payload_sysreg)
add_executable(payload_sync src/sync.c)
add_executable(payload_aes src/aes.c)
add_executable(payload_sysreg src/sysreg.c)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/)
set_directory_properties(PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/bin/")
foreach(BINARY ${PAYLOADS})
add_custom_command(TARGET ${BINARY} POST_BUILD
BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BINARY}.bin

View File

@@ -0,0 +1,7 @@
#ifndef IPWNDFU_REWRITE_C_UTIL_H
#define IPWNDFU_REWRITE_C_UTIL_H
#define PAYLOAD_SECTION __attribute__ ((section (".payload_text")))
#define TEXT_SECTION __attribute__((section (".text")))
#endif //IPWNDFU_REWRITE_C_UTIL_H

View File

@@ -2,7 +2,9 @@
#include "brfunc_timing.h"
#include "brfunc_sep.h"
__attribute__ ((section (".payload_text")))
#include "util.h"
PAYLOAD_SECTION
int aes_hw_crypto_command(unsigned int cmd,
void *src,
void *dst,
@@ -45,6 +47,7 @@ int aes_hw_crypto_command(unsigned int cmd,
return 0;
}
TEXT_SECTION
int _start(unsigned int cmd,
void *src,
void *dst,

View File

@@ -0,0 +1,10 @@
#include "util.h"
TEXT_SECTION
void _start()
{
__asm__("dmb sy");
__asm__("ic iallu");
__asm__("dsb sy");
__asm__("isb");
}

View File

@@ -1,13 +1,16 @@
#include "util.h"
struct sysregs
{
long pt_base;
long evt_base;
};
TEXT_SECTION
struct sysregs _start()
{
struct sysregs res;
__asm__("mrs %0, ttbr1_el1" : "=r" (res.pt_base));
__asm__("mrs %0, ttbr0_el1" : "=r" (res.pt_base));
__asm__("mrs %0, vbar_el1" : "=r" (res.evt_base));
return res;

View File

@@ -1,5 +0,0 @@
int _start(int b)
{
return b * 5;
}