10d1fb0a4SAlex Dewar // SPDX-License-Identifier: GPL-2.0 2ee56314bSJeff Dike /* 32eb5f31bSAnton Ivanov * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de) 4ee56314bSJeff Dike * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 5ee56314bSJeff Dike */ 69786a8f3SBodo Stroesser 7ee56314bSJeff Dike #include <signal.h> 8ee56314bSJeff Dike #include <sched.h> 9ee56314bSJeff Dike #include <asm/unistd.h> 10ee56314bSJeff Dike #include <sys/time.h> 1137185b33SAl Viro #include <as-layout.h> 1237185b33SAl Viro #include <ptrace_user.h> 1337185b33SAl Viro #include <stub-data.h> 1437185b33SAl Viro #include <sysdep/stub.h> 15ee56314bSJeff Dike 16ee56314bSJeff Dike /* 17ee56314bSJeff Dike * This is in a separate file because it needs to be compiled with any 189786a8f3SBodo Stroesser * extraneous gcc flags (-pg, -fprofile-arcs, -ftest-coverage) disabled 19aa1a64eeSJeff Dike * 20aa1a64eeSJeff Dike * Use UM_KERN_PAGE_SIZE instead of PAGE_SIZE because that calls getpagesize 21aa1a64eeSJeff Dike * on some systems. 229786a8f3SBodo Stroesser */ 2339d730abSJeff Dike 24bf9a76a4SLinus Torvalds void __attribute__ ((__section__ (".__syscall_stub"))) stub_clone_handler(void)259786a8f3SBodo Stroesserstub_clone_handler(void) 269786a8f3SBodo Stroesser { 27*6032aca0SJohannes Berg struct stub_data *data = get_stub_data(); 289786a8f3SBodo Stroesser long err; 299786a8f3SBodo Stroesser 309786a8f3SBodo Stroesser err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD, 31*6032aca0SJohannes Berg (unsigned long)data + 32*6032aca0SJohannes Berg STUB_DATA_PAGES * UM_KERN_PAGE_SIZE / 2); 3384b2789dSJohannes Berg if (err) { 3484b2789dSJohannes Berg data->parent_err = err; 3584b2789dSJohannes Berg goto done; 3684b2789dSJohannes Berg } 379786a8f3SBodo Stroesser 389786a8f3SBodo Stroesser err = stub_syscall4(__NR_ptrace, PTRACE_TRACEME, 0, 0, 0); 3984b2789dSJohannes Berg if (err) { 4084b2789dSJohannes Berg data->child_err = err; 4184b2789dSJohannes Berg goto done; 4284b2789dSJohannes Berg } 439786a8f3SBodo Stroesser 449f0b4807SJohannes Berg remap_stack_and_trap(); 455b7b15afSJeff Dike 465b7b15afSJeff Dike done: 479786a8f3SBodo Stroesser trap_myself(); 489786a8f3SBodo Stroesser } 49