Skip to content

Commit

Permalink
Apply smurfd's patch (geohot/qira#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianRudolph committed Jul 23, 2022
1 parent ca1808b commit ff798e3
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
6 changes: 3 additions & 3 deletions linux-user/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3416,7 +3416,7 @@ struct target_signal_frame {

struct rt_signal_frame {
siginfo_t info;
struct ucontext uc;
struct ucontext_t uc;
uint32_t tramp[2];
};

Expand Down Expand Up @@ -3627,7 +3627,7 @@ struct rt_signal_frame {
siginfo_t *pinfo;
void *puc;
siginfo_t info;
struct ucontext uc;
struct ucontext_t uc;
uint16_t retcode[4]; /* Trampoline code. */
};

Expand Down Expand Up @@ -3924,7 +3924,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
tswap_siginfo(&frame->info, info);
}

/*err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));*/
/*err |= __clear_user(&frame->uc, offsetof(struct ucontext_t, uc_mcontext));*/
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, &frame->uc.tuc_link);
__put_user(target_sigaltstack_used.ss_sp,
Expand Down
1 change: 1 addition & 0 deletions linux-user/strace.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <sys/types.h>
#include <sys/mount.h>
#include <sys/mman.h>
#include <sys/sysmacros.h>
#include <unistd.h>
#include <sched.h>
#include "qemu.h"
Expand Down
6 changes: 3 additions & 3 deletions linux-user/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \
#endif

#ifdef __NR_gettid
_syscall0(int, gettid)
//_syscall0(int, gettid)
#else
/* This is a replacement for the host gettid() and must return a host
errno. */
static int gettid(void) {
int gettid(void) {
return -ENOSYS;
}
#endif
Expand Down Expand Up @@ -6074,7 +6074,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
time_t host_time;
if (get_user_sal(host_time, arg1))
goto efault;
ret = get_errno(stime(&host_time));
ret = get_errno(time(&host_time));
}
break;
#endif
Expand Down
1 change: 1 addition & 0 deletions qga/commands-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/sysmacros.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
Expand Down
2 changes: 1 addition & 1 deletion qga/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static void ga_log(const gchar *domain, GLogLevelFlags level,
#else
if (level & s->log_level) {
#endif
g_get_current_time(&time);
g_get_real_time();//g_get_current_time(&time);
fprintf(s->log_file,
"%lu.%lu: %s: %s\n", time.tv_sec, time.tv_usec, level_str, msg);
fflush(s->log_file);
Expand Down
4 changes: 2 additions & 2 deletions tests/tcg/test-i386.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ int tab[2];

void sig_handler(int sig, siginfo_t *info, void *puc)
{
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;

printf("si_signo=%d si_errno=%d si_code=%d",
info->si_signo, info->si_errno, info->si_code);
Expand Down Expand Up @@ -1912,7 +1912,7 @@ void test_exceptions(void)
/* specific precise single step test */
void sig_trap_handler(int sig, siginfo_t *info, void *puc)
{
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
printf("EIP=" FMTLX "\n", (long)uc->uc_mcontext.gregs[REG_EIP]);
}

Expand Down
27 changes: 14 additions & 13 deletions user-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "qemu/bitops.h"
#include "exec/cpu_ldst.h"
#include "translate-all.h"
#include <ucontext.h>

#undef EAX
#undef ECX
Expand Down Expand Up @@ -58,7 +59,7 @@ static void exception_action(CPUState *cpu)
void cpu_resume_from_signal(CPUState *cpu, void *puc)
{
#ifdef __linux__
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
#elif defined(__OpenBSD__)
struct sigcontext *uc = puc;
#endif
Expand Down Expand Up @@ -172,7 +173,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
#elif defined(__OpenBSD__)
struct sigcontext *uc = puc;
#else
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
#endif
unsigned long pc;
int trapno;
Expand Down Expand Up @@ -227,7 +228,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
#elif defined(__OpenBSD__)
struct sigcontext *uc = puc;
#else
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
#endif

pc = PC_sig(uc);
Expand Down Expand Up @@ -289,7 +290,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,

#ifdef __APPLE__
#include <sys/ucontext.h>
typedef struct ucontext SIGCONTEXT;
typedef struct ucontext_t SIGCONTEXT;
/* All Registers access - only for local access */
#define REG_sig(reg_name, context) \
((context)->uc_mcontext->ss.reg_name)
Expand Down Expand Up @@ -332,7 +333,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
ucontext_t *uc = puc;
#else
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
#endif
unsigned long pc;
int is_write;
Expand All @@ -359,7 +360,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
void *puc)
{
siginfo_t *info = pinfo;
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
uint32_t *pc = uc->uc_mcontext.sc_pc;
uint32_t insn = *pc;
int is_write = 0;
Expand Down Expand Up @@ -457,7 +458,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
#if defined(__NetBSD__)
ucontext_t *uc = puc;
#else
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
#endif
unsigned long pc;
int is_write;
Expand All @@ -484,7 +485,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
{
siginfo_t *info = pinfo;
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
uintptr_t pc = uc->uc_mcontext.pc;
uint32_t insn = *(uint32_t *)pc;
bool is_write;
Expand Down Expand Up @@ -513,7 +514,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
void *puc)
{
siginfo_t *info = pinfo;
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
unsigned long pc;
int is_write;

Expand All @@ -535,7 +536,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
int cpu_signal_handler(int host_signum, void *pinfo, void *puc)
{
siginfo_t *info = pinfo;
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
unsigned long ip;
int is_write = 0;

Expand Down Expand Up @@ -566,7 +567,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
void *puc)
{
siginfo_t *info = pinfo;
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
unsigned long pc;
uint16_t *pinsn;
int is_write = 0;
Expand Down Expand Up @@ -619,7 +620,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
void *puc)
{
siginfo_t *info = pinfo;
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
greg_t pc = uc->uc_mcontext.pc;
int is_write;

Expand All @@ -635,7 +636,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
void *puc)
{
siginfo_t *info = pinfo;
struct ucontext *uc = puc;
struct ucontext_t *uc = puc;
unsigned long pc = uc->uc_mcontext.sc_iaoq[0];
uint32_t insn = *(uint32_t *)pc;
int is_write = 0;
Expand Down
2 changes: 1 addition & 1 deletion util/memfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <sys/syscall.h>
#include <asm/unistd.h>

static int memfd_create(const char *name, unsigned int flags)
int memfd_create(const char *name, unsigned int flags)
{
#ifdef __NR_memfd_create
return syscall(__NR_memfd_create, name, flags);
Expand Down

0 comments on commit ff798e3

Please sign in to comment.