Skip to content

Commit

Permalink
Merge branch 'linux-user-for-upstream' of git://git.linaro.org/people…
Browse files Browse the repository at this point in the history
…/rikuvoipio/qemu

* 'linux-user-for-upstream' of git://git.linaro.org/people/rikuvoipio/qemu:
  linux-user: Fix sa_flags byte swaps for mips
  linux-user: Define TARGET_QEMU_ESIGRETURN for mips64
  linux-user: Define TARGET_QEMU_ESIGRETURN for mipsn32
  linux-user: Add default configs for mips64[el]
  linux-user: Add default-configs for mipsn32[el]
  linux-user: Implement *listxattr syscalls
  linux-user/syscall.c: Implement f and l versions of set/get/removexattr
  linux-user: Allow NULL value pointer in setxattr and getxattr
  linux-user: fix wait* syscall status returns
  linux-user/strace.c: Correct errno printing for mmap etc
  linux-user: fix QEMU_STRACE=1 segfault
  linux-user: add SO_PEERCRED support for getsockopt
  linux-user/main.c: Add option to user-mode emulation so that user can specify log file name
  linux-user: fake /proc/self/auxv
  linux-user: fake /proc/self/stat
  linux-user: fake /proc/self/maps
  linux-user: add open() hijack infrastructure
  linux-user: save auxv length
  linux-user: stack_base is now mandatory on all targets
  • Loading branch information
blueswirl committed Feb 4, 2012
2 parents 2944e4e + f78b0f0 commit cb437e4
Show file tree
Hide file tree
Showing 13 changed files with 332 additions and 39 deletions.
1 change: 1 addition & 0 deletions default-configs/mips64-linux-user.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Default configuration for mips64-linux-user
1 change: 1 addition & 0 deletions default-configs/mips64el-linux-user.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Default configuration for mips64el-linux-user
1 change: 1 addition & 0 deletions default-configs/mipsn32-linux-user.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Default configuration for mipsn32-linux-user
1 change: 1 addition & 0 deletions default-configs/mipsn32el-linux-user.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Default configuration for mipsn32el-linux-user
15 changes: 4 additions & 11 deletions linux-user/elfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
struct image_info *interp_info)
{
abi_ulong sp;
abi_ulong sp_auxv;
int size;
int i;
abi_ulong u_rand_bytes;
Expand Down Expand Up @@ -1316,6 +1317,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
sp -= n; put_user_ual(id, sp); \
} while(0)

sp_auxv = sp;
NEW_AUX_ENT (AT_NULL, 0);

/* There must be exactly DLINFO_ITEMS entries here. */
Expand Down Expand Up @@ -1346,6 +1348,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
#undef NEW_AUX_ENT

info->saved_auxv = sp;
info->auxv_len = sp_auxv - sp;

sp = loader_build_argptr(envc, argc, sp, p, 0);
return sp;
Expand Down Expand Up @@ -2326,25 +2329,15 @@ static void fill_auxv_note(struct memelfnote *note, const TaskState *ts)
{
elf_addr_t auxv = (elf_addr_t)ts->info->saved_auxv;
elf_addr_t orig_auxv = auxv;
abi_ulong val;
void *ptr;
int i, len;
int len = ts->info->auxv_len;

/*
* Auxiliary vector is stored in target process stack. It contains
* {type, value} pairs that we need to dump into note. This is not
* strictly necessary but we do it here for sake of completeness.
*/

/* find out length of the vector, AT_NULL is terminator */
i = len = 0;
do {
get_user_ual(val, auxv);
i += 2;
auxv += 2 * sizeof (elf_addr_t);
} while (val != AT_NULL);
len = i * sizeof (elf_addr_t);

/* read in whole auxv vector and copy it to memelfnote */
ptr = lock_user(VERIFY_READ, orig_auxv, len, 0);
if (ptr != NULL) {
Expand Down
7 changes: 7 additions & 0 deletions linux-user/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2945,6 +2945,11 @@ static void handle_arg_log(const char *arg)
cpu_set_log(mask);
}

static void handle_arg_log_filename(const char *arg)
{
cpu_set_log_filename(arg);
}

static void handle_arg_set_env(const char *arg)
{
char *r, *p, *token;
Expand Down Expand Up @@ -3125,6 +3130,8 @@ struct qemu_argument arg_table[] = {
#endif
{"d", "QEMU_LOG", true, handle_arg_log,
"options", "activate log"},
{"D", "QEMU_LOG_FILENAME", true, handle_arg_log_filename,
"logfile", "override default logfile location"},
{"p", "QEMU_PAGESIZE", true, handle_arg_pagesize,
"pagesize", "set the host page size to 'pagesize'"},
{"singlestep", "QEMU_SINGLESTEP", false, handle_arg_singlestep,
Expand Down
3 changes: 3 additions & 0 deletions linux-user/mips64/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,7 @@ struct target_pt_regs {



/* Nasty hack: define a fake errno value for use by sigreturn. */
#define TARGET_QEMU_ESIGRETURN 255

#define UNAME_MACHINE "mips64"
3 changes: 3 additions & 0 deletions linux-user/mipsn32/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,7 @@ struct target_pt_regs {



/* Nasty hack: define a fake errno value for use by sigreturn. */
#define TARGET_QEMU_ESIGRETURN 255

#define UNAME_MACHINE "mips64"
3 changes: 2 additions & 1 deletion linux-user/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct image_info {
abi_ulong code_offset;
abi_ulong data_offset;
abi_ulong saved_auxv;
abi_ulong auxv_len;
abi_ulong arg_start;
abi_ulong arg_end;
int personality;
Expand Down Expand Up @@ -123,10 +124,10 @@ typedef struct TaskState {
#endif
#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32)
/* Extra fields for semihosted binaries. */
uint32_t stack_base;
uint32_t heap_base;
uint32_t heap_limit;
#endif
uint32_t stack_base;
int used; /* non zero if used */
struct image_info *info;
struct linux_binprm *bprm;
Expand Down
8 changes: 8 additions & 0 deletions linux-user/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,11 @@ int do_sigaction(int sig, const struct target_sigaction *act,
#endif
if (oact) {
oact->_sa_handler = tswapal(k->_sa_handler);
#if defined(TARGET_MIPS) || defined (TARGET_ALPHA)
oact->sa_flags = bswap32(k->sa_flags);
#else
oact->sa_flags = tswapal(k->sa_flags);
#endif
#if !defined(TARGET_MIPS)
oact->sa_restorer = tswapal(k->sa_restorer);
#endif
Expand All @@ -596,7 +600,11 @@ int do_sigaction(int sig, const struct target_sigaction *act,
if (act) {
/* FIXME: This is not threadsafe. */
k->_sa_handler = tswapal(act->_sa_handler);
#if defined(TARGET_MIPS) || defined (TARGET_ALPHA)
k->sa_flags = bswap32(act->sa_flags);
#else
k->sa_flags = tswapal(act->sa_flags);
#endif
#if !defined(TARGET_MIPS)
k->sa_restorer = tswapal(act->sa_restorer);
#endif
Expand Down
19 changes: 14 additions & 5 deletions linux-user/strace.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <stdio.h>
#include <errno.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/sem.h>
Expand Down Expand Up @@ -284,8 +283,13 @@ print_ipc(const struct syscallname *name,
static void
print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
{
if( ret == -1 ) {
gemu_log(" = -1 errno=%d (%s)\n", errno, target_strerror(errno));
char *errstr = NULL;

if (ret < 0) {
errstr = target_strerror(-ret);
}
if (errstr) {
gemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr);
} else {
gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
}
Expand Down Expand Up @@ -1515,14 +1519,19 @@ void
print_syscall_ret(int num, abi_long ret)
{
int i;
char *errstr = NULL;

for(i=0;i<nsyscalls;i++)
if( scnames[i].nr == num ) {
if( scnames[i].result != NULL ) {
scnames[i].result(&scnames[i],ret);
} else {
if( ret < 0 ) {
gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", -ret, target_strerror(-ret));
if (ret < 0) {
errstr = target_strerror(-ret);
}
if (errstr) {
gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n",
-ret, errstr);
} else {
gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
}
Expand Down
Loading

0 comments on commit cb437e4

Please sign in to comment.