mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-06 05:41:37 +00:00
[Pal/{Linux,Linux-SGX}] Implement pal_ucontext_get_ip()
This commit is contained in:
committed by
Dmitrii Kuvaiskii
parent
91e882c130
commit
7383da296a
@@ -152,6 +152,10 @@ static inline void pal_context_to_ucontext(ucontext_t* uc, PAL_CONTEXT* context)
|
||||
uc->uc_mcontext.fpregs = (struct _libc_fpstate*)context->fpregs;
|
||||
}
|
||||
|
||||
static inline uint64_t pal_ucontext_get_ip(ucontext_t* uc) {
|
||||
return uc->uc_mcontext.gregs[REG_RIP];
|
||||
}
|
||||
|
||||
#else /* __WORDSIZE == 32 */
|
||||
|
||||
/* Type for general register. */
|
||||
|
||||
@@ -127,7 +127,7 @@ static void handle_sync_signal(int signum, siginfo_t* info, struct ucontext* uc)
|
||||
for (size_t i = 0; i < g_rpc_queue->rpc_threads_cnt; i++)
|
||||
INLINE_SYSCALL(tkill, 2, g_rpc_queue->rpc_threads[i], SIGUSR2);
|
||||
|
||||
unsigned long rip = uc->uc_mcontext.gregs[REG_RIP];
|
||||
unsigned long rip = pal_ucontext_get_ip(uc);
|
||||
|
||||
if (rip != (unsigned long)async_exit_pointer) {
|
||||
/* exception happened in untrusted PAL code (during syscall handling): fatal in Graphene */
|
||||
@@ -162,7 +162,7 @@ static void handle_async_signal(int signum, siginfo_t* info, struct ucontext* uc
|
||||
for (size_t i = 0; i < g_rpc_queue->rpc_threads_cnt; i++)
|
||||
INLINE_SYSCALL(tkill, 2, g_rpc_queue->rpc_threads[i], SIGUSR2);
|
||||
|
||||
unsigned long rip = uc->uc_mcontext.gregs[REG_RIP];
|
||||
unsigned long rip = pal_ucontext_get_ip(uc);
|
||||
|
||||
if (rip != (unsigned long)async_exit_pointer) {
|
||||
/* signal arrived while in untrusted PAL code (during syscall handling), emulate as if
|
||||
|
||||
@@ -141,7 +141,7 @@ static void handle_sync_signal(int signum, siginfo_t* info, struct ucontext* uc)
|
||||
int event = get_pal_event(signum);
|
||||
assert(event > 0);
|
||||
|
||||
uintptr_t rip = uc->uc_mcontext.gregs[REG_RIP];
|
||||
uintptr_t rip = pal_ucontext_get_ip(uc);
|
||||
if (!ADDR_IN_PAL(rip)) {
|
||||
/* exception happened in application or LibOS code, normal benign case */
|
||||
perform_signal_handling(event, info, uc);
|
||||
@@ -174,8 +174,7 @@ static void handle_async_signal(int signum, siginfo_t* info, struct ucontext* uc
|
||||
int event = get_pal_event(signum);
|
||||
assert(event > 0);
|
||||
|
||||
uintptr_t rip = uc->uc_mcontext.gregs[REG_RIP];
|
||||
|
||||
uintptr_t rip = pal_ucontext_get_ip(uc);
|
||||
if (!ADDR_IN_PAL(rip)) {
|
||||
/* signal arrived while in application or LibOS code, normal benign case */
|
||||
perform_signal_handling(event, info, uc);
|
||||
|
||||
Reference in New Issue
Block a user