Some ppc/ppc64 fixes:
- we can run now most of the targets on a ppc64 host with 64kB pages - add swapcontext syscall to run tests/test-coroutine in debian-powerpc-user-cross -----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJbVdBdAAoJEPMMOL0/L748vuUP/2gxM37iTEKRs/tT46fWj1/u Lq+TQqsTJ0xKzrTJr47HgpHJfIbYdqx0Smd1/0bkDN99H402d+4n6m+Oj62YCaBK XxtO9CC7fuzLdd99g8NVVvactzhmXYpFKm8E8O+FLogV+ku1hEZHsnPo+l2bZmBv GSxoy2pvaogFK1BP4vIvcLxbzUCyg1V6GIzLJpTdfaGMoezTeg7WT+n5SdYXIbdR YB9RkMo0Qxjr4mM9g8B39oTGQwp8XHGk1E2QKzDNxP1ydG4MWyBbwGKW1hA/n1/F 6GcAtClsBy6lOFY2t/YR8VxXWuDHMRwoRWhEtMUhF8TsWdAtm3KfzuZ7PibuetMO cneSNzT6Nbyc4qrbqINlBLmbqT201fWRPXUAt9XiblmDG2c9A4w1uiHAQ4zOoCWx cPiDFXKrJe4OSLgHlBJdH1hox8kaSeb/ryZyOz98Zb95/ETYOQ0ZlF5zwEzp+R1N BRTy+0ryAeRQCg0zg/D1NS5cptK4oP328xsobaqPcWDAhUKbUpS1zjWBuFSzwKFQ SCSQAOKnq3XtwT4OZJw7gBdo9fyWBdb6MbV5uCuJXzX+Bv2/XeTWJFj3oeml5CkR 6+M+J3f82SYBLW6EuUyikbAOLdeKQqcIsDSHwC7mdt4pZrFTusGEWssAJVDFDZEH jdk4ZlUXuLj+oPMTs3ZL =DTRa -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-3.0-pull-request' into staging Some ppc/ppc64 fixes: - we can run now most of the targets on a ppc64 host with 64kB pages - add swapcontext syscall to run tests/test-coroutine in debian-powerpc-user-cross # gpg: Signature made Mon 23 Jul 2018 13:55:57 BST # gpg: using RSA key F30C38BD3F2FBE3C # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" # gpg: aka "Laurent Vivier <laurent@vivier.eu>" # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * remotes/vivier2/tags/linux-user-for-3.0-pull-request: linux-user/ppc: Implement swapcontext syscall linux-user: fix ELF load alignment error Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
55b1f14cef
@ -1875,7 +1875,13 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
|
||||
NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff));
|
||||
NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr)));
|
||||
NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum));
|
||||
NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(MAX(TARGET_PAGE_SIZE, getpagesize())));
|
||||
if ((info->alignment & ~qemu_host_page_mask) != 0) {
|
||||
/* Target doesn't support host page size alignment */
|
||||
NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE));
|
||||
} else {
|
||||
NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(MAX(TARGET_PAGE_SIZE,
|
||||
qemu_host_page_size)));
|
||||
}
|
||||
NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_info ? interp_info->load_addr : 0));
|
||||
NEW_AUX_ENT(AT_FLAGS, (abi_ulong)0);
|
||||
NEW_AUX_ENT(AT_ENTRY, info->entry);
|
||||
@ -2202,6 +2208,7 @@ static void load_elf_image(const char *image_name, int image_fd,
|
||||
/* Find the maximum size of the image and allocate an appropriate
|
||||
amount of memory to handle that. */
|
||||
loaddr = -1, hiaddr = 0;
|
||||
info->alignment = 0;
|
||||
for (i = 0; i < ehdr->e_phnum; ++i) {
|
||||
if (phdr[i].p_type == PT_LOAD) {
|
||||
abi_ulong a = phdr[i].p_vaddr - phdr[i].p_offset;
|
||||
@ -2213,6 +2220,7 @@ static void load_elf_image(const char *image_name, int image_fd,
|
||||
hiaddr = a;
|
||||
}
|
||||
++info->nsegs;
|
||||
info->alignment |= phdr[i].p_align;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -675,3 +675,59 @@ sigsegv:
|
||||
force_sig(TARGET_SIGSEGV);
|
||||
return -TARGET_QEMU_ESIGRETURN;
|
||||
}
|
||||
|
||||
/* This syscall implements {get,set,swap}context for userland. */
|
||||
abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx,
|
||||
abi_ulong unew_ctx, abi_long ctx_size)
|
||||
{
|
||||
struct target_ucontext *uctx;
|
||||
struct target_mcontext *mctx;
|
||||
|
||||
/* For ppc32, ctx_size is "reserved for future use".
|
||||
* For ppc64, we do not yet support the VSX extension.
|
||||
*/
|
||||
if (ctx_size < sizeof(struct target_ucontext)) {
|
||||
return -TARGET_EINVAL;
|
||||
}
|
||||
|
||||
if (uold_ctx) {
|
||||
TaskState *ts = (TaskState *)thread_cpu->opaque;
|
||||
|
||||
if (!lock_user_struct(VERIFY_WRITE, uctx, uold_ctx, 1)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
|
||||
#ifdef TARGET_PPC64
|
||||
mctx = &uctx->tuc_sigcontext.mcontext;
|
||||
#else
|
||||
/* ??? The kernel aligns the pointer down here into padding, but
|
||||
* in setup_rt_frame we don't. Be self-compatible for now.
|
||||
*/
|
||||
mctx = &uctx->tuc_mcontext;
|
||||
__put_user(h2g(mctx), &uctx->tuc_regs);
|
||||
#endif
|
||||
|
||||
save_user_regs(env, mctx);
|
||||
host_to_target_sigset(&uctx->tuc_sigmask, &ts->signal_mask);
|
||||
|
||||
unlock_user_struct(uctx, uold_ctx, 1);
|
||||
}
|
||||
|
||||
if (unew_ctx) {
|
||||
int err;
|
||||
|
||||
if (!lock_user_struct(VERIFY_READ, uctx, unew_ctx, 1)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
err = do_setcontext(uctx, env, 0);
|
||||
unlock_user_struct(uctx, unew_ctx, 1);
|
||||
|
||||
if (err) {
|
||||
/* We cannot return to a partially updated context. */
|
||||
force_sig(TARGET_SIGSEGV);
|
||||
}
|
||||
return -TARGET_QEMU_ESIGRETURN;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ struct image_info {
|
||||
abi_ulong file_string;
|
||||
uint32_t elf_flags;
|
||||
int personality;
|
||||
abi_ulong alignment;
|
||||
|
||||
/* The fields below are used in FDPIC mode. */
|
||||
abi_ulong loadmap_addr;
|
||||
@ -395,6 +396,8 @@ long do_sigreturn(CPUArchState *env);
|
||||
long do_rt_sigreturn(CPUArchState *env);
|
||||
abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);
|
||||
int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
|
||||
abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx,
|
||||
abi_ulong unew_ctx, abi_long ctx_size);
|
||||
/**
|
||||
* block_signals: block all signals while handling this guest syscall
|
||||
*
|
||||
|
@ -12790,6 +12790,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
||||
ret = get_errno(kcmp(arg1, arg2, arg3, arg4, arg5));
|
||||
break;
|
||||
#endif
|
||||
#ifdef TARGET_NR_swapcontext
|
||||
case TARGET_NR_swapcontext:
|
||||
/* PowerPC specific. */
|
||||
ret = do_swapcontext(cpu_env, arg1, arg2, arg3);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
unimplemented:
|
||||
|
Loading…
Reference in New Issue
Block a user