mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
linux-user: fix abi_(u)long, target_ulong mismatch
abi_(u)long might be different from target_ulong, so don't use tswapl but introduce a new tswapal Signed-off-by: Matthias Braun <matze@braunis.de> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
This commit is contained in:
committed by
Riku Voipio
parent
6cafd027be
commit
cbb21eed18
@@ -9,6 +9,12 @@ typedef int32_t abi_long;
|
||||
#define TARGET_ABI_FMT_ld "%d"
|
||||
#define TARGET_ABI_FMT_lu "%u"
|
||||
#define TARGET_ABI_BITS 32
|
||||
|
||||
static inline abi_ulong tswapal(abi_ulong v)
|
||||
{
|
||||
return tswap32(v);
|
||||
}
|
||||
|
||||
#else
|
||||
typedef target_ulong abi_ulong;
|
||||
typedef target_long abi_long;
|
||||
@@ -20,5 +26,11 @@ typedef target_long abi_long;
|
||||
#if TARGET_ABI_BITS == 32
|
||||
#define TARGET_ABI32 1
|
||||
#endif
|
||||
|
||||
static inline abi_ulong tswapal(abi_ulong v)
|
||||
{
|
||||
return tswapl(v);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+11
-11
@@ -152,7 +152,7 @@ void host_to_target_sigset(target_sigset_t *d, const sigset_t *s)
|
||||
|
||||
host_to_target_sigset_internal(&d1, s);
|
||||
for(i = 0;i < TARGET_NSIG_WORDS; i++)
|
||||
d->sig[i] = tswapl(d1.sig[i]);
|
||||
d->sig[i] = tswapal(d1.sig[i]);
|
||||
}
|
||||
|
||||
static void target_to_host_sigset_internal(sigset_t *d,
|
||||
@@ -173,7 +173,7 @@ void target_to_host_sigset(sigset_t *d, const target_sigset_t *s)
|
||||
int i;
|
||||
|
||||
for(i = 0;i < TARGET_NSIG_WORDS; i++)
|
||||
s1.sig[i] = tswapl(s->sig[i]);
|
||||
s1.sig[i] = tswapal(s->sig[i]);
|
||||
target_to_host_sigset_internal(d, &s1);
|
||||
}
|
||||
|
||||
@@ -234,14 +234,14 @@ static void tswap_siginfo(target_siginfo_t *tinfo,
|
||||
if (sig == SIGILL || sig == SIGFPE || sig == SIGSEGV ||
|
||||
sig == SIGBUS || sig == SIGTRAP) {
|
||||
tinfo->_sifields._sigfault._addr =
|
||||
tswapl(info->_sifields._sigfault._addr);
|
||||
tswapal(info->_sifields._sigfault._addr);
|
||||
} else if (sig == SIGIO) {
|
||||
tinfo->_sifields._sigpoll._fd = tswap32(info->_sifields._sigpoll._fd);
|
||||
} else if (sig >= TARGET_SIGRTMIN) {
|
||||
tinfo->_sifields._rt._pid = tswap32(info->_sifields._rt._pid);
|
||||
tinfo->_sifields._rt._uid = tswap32(info->_sifields._rt._uid);
|
||||
tinfo->_sifields._rt._sigval.sival_ptr =
|
||||
tswapl(info->_sifields._rt._sigval.sival_ptr);
|
||||
tswapal(info->_sifields._rt._sigval.sival_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo)
|
||||
info->si_pid = tswap32(tinfo->_sifields._rt._pid);
|
||||
info->si_uid = tswap32(tinfo->_sifields._rt._uid);
|
||||
info->si_value.sival_ptr =
|
||||
(void *)(long)tswapl(tinfo->_sifields._rt._sigval.sival_ptr);
|
||||
(void *)(long)tswapal(tinfo->_sifields._rt._sigval.sival_ptr);
|
||||
}
|
||||
|
||||
static int fatal_signal (int sig)
|
||||
@@ -586,19 +586,19 @@ int do_sigaction(int sig, const struct target_sigaction *act,
|
||||
sig, act, oact);
|
||||
#endif
|
||||
if (oact) {
|
||||
oact->_sa_handler = tswapl(k->_sa_handler);
|
||||
oact->sa_flags = tswapl(k->sa_flags);
|
||||
oact->_sa_handler = tswapal(k->_sa_handler);
|
||||
oact->sa_flags = tswapal(k->sa_flags);
|
||||
#if !defined(TARGET_MIPS)
|
||||
oact->sa_restorer = tswapl(k->sa_restorer);
|
||||
oact->sa_restorer = tswapal(k->sa_restorer);
|
||||
#endif
|
||||
oact->sa_mask = k->sa_mask;
|
||||
}
|
||||
if (act) {
|
||||
/* FIXME: This is not threadsafe. */
|
||||
k->_sa_handler = tswapl(act->_sa_handler);
|
||||
k->sa_flags = tswapl(act->sa_flags);
|
||||
k->_sa_handler = tswapal(act->_sa_handler);
|
||||
k->sa_flags = tswapal(act->sa_flags);
|
||||
#if !defined(TARGET_MIPS)
|
||||
k->sa_restorer = tswapl(act->sa_restorer);
|
||||
k->sa_restorer = tswapal(act->sa_restorer);
|
||||
#endif
|
||||
k->sa_mask = act->sa_mask;
|
||||
|
||||
|
||||
+2
-2
@@ -169,7 +169,7 @@ print_fdset(int n, abi_ulong target_fds_addr)
|
||||
return;
|
||||
|
||||
for (i=n; i>=0; i--) {
|
||||
if ((tswapl(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1)
|
||||
if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1)
|
||||
gemu_log("%d,", i );
|
||||
}
|
||||
unlock_user(target_fds, target_fds_addr, 0);
|
||||
@@ -245,7 +245,7 @@ print_execve(const struct syscallname *name,
|
||||
arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
|
||||
if (!arg_ptr)
|
||||
return;
|
||||
arg_addr = tswapl(*arg_ptr);
|
||||
arg_addr = tswapal(*arg_ptr);
|
||||
unlock_user(arg_ptr, arg_ptr_addr, 0);
|
||||
if (!arg_addr)
|
||||
break;
|
||||
|
||||
+126
-124
File diff suppressed because it is too large
Load Diff
@@ -209,9 +209,9 @@ __target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cms
|
||||
struct target_cmsghdr *__ptr;
|
||||
|
||||
__ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
|
||||
+ TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len)));
|
||||
if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapl(__mhdr->msg_control))
|
||||
> tswapl(__mhdr->msg_controllen))
|
||||
+ TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len)));
|
||||
if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapal(__mhdr->msg_control))
|
||||
> tswapal(__mhdr->msg_controllen))
|
||||
/* No more entries. */
|
||||
return (struct target_cmsghdr *)0;
|
||||
return __cmsg;
|
||||
@@ -292,7 +292,7 @@ static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
|
||||
{
|
||||
int i;
|
||||
for(i = 0;i < TARGET_NSIG_WORDS; i++)
|
||||
d->sig[i] = tswapl(s->sig[i]);
|
||||
d->sig[i] = tswapal(s->sig[i]);
|
||||
}
|
||||
#else
|
||||
static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s)
|
||||
|
||||
+2
-2
@@ -432,7 +432,7 @@ int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr)
|
||||
env->eflags = (env->eflags & ~SAFE_MASK) |
|
||||
(tswap32(target_v86->regs.eflags) & SAFE_MASK) | VM_MASK;
|
||||
|
||||
ts->vm86plus.cpu_type = tswapl(target_v86->cpu_type);
|
||||
ts->vm86plus.cpu_type = tswapal(target_v86->cpu_type);
|
||||
switch (ts->vm86plus.cpu_type) {
|
||||
case TARGET_CPU_286:
|
||||
ts->v86mask = 0;
|
||||
@@ -468,7 +468,7 @@ int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr)
|
||||
&target_v86->int_revectored, 32);
|
||||
memcpy(&ts->vm86plus.int21_revectored,
|
||||
&target_v86->int21_revectored, 32);
|
||||
ts->vm86plus.vm86plus.flags = tswapl(target_v86->vm86plus.flags);
|
||||
ts->vm86plus.vm86plus.flags = tswapal(target_v86->vm86plus.flags);
|
||||
memcpy(&ts->vm86plus.vm86plus.vm86dbg_intxxtab,
|
||||
target_v86->vm86plus.vm86dbg_intxxtab, 32);
|
||||
unlock_user_struct(target_v86, vm86_addr, 0);
|
||||
|
||||
Reference in New Issue
Block a user