uti: Create tracer when forking
Change-Id: Ic66cf6289ac6f32a884ba1266e641ce61620a239
This commit is contained in:
@@ -2145,26 +2145,8 @@ int main(int argc, char **argv)
|
|||||||
if (opendev() == -1)
|
if (opendev() == -1)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
/* Perform mmap() before fork() in create_tracer() */
|
|
||||||
uti_wp = mmap(NULL, PAGE_SIZE * 3, PROT_READ | PROT_WRITE,
|
|
||||||
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
|
||||||
if (uti_wp == (void *)-1) {
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
uti_desc = mmap(NULL, sizeof(struct uti_desc), PROT_READ | PROT_WRITE,
|
|
||||||
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
|
||||||
if (uti_desc == (void *)-1) {
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
memset(uti_desc, 0, sizeof(struct uti_desc));
|
|
||||||
sem_init(&uti_desc->arg, 1, 0);
|
|
||||||
sem_init(&uti_desc->attach, 1, 0);
|
|
||||||
#if 1
|
#if 1
|
||||||
/* Create tracer before any proxy VMAs are attached */
|
/* Create tracer before anonymous inode is mapped */
|
||||||
if ((error = pipe(uti_pfd)) == -1) {
|
|
||||||
fprintf(stderr, "%s: pipe returned %d\n", __FUNCTION__, error);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ((error = create_tracer())) {
|
if ((error = create_tracer())) {
|
||||||
fprintf(stderr, "%s: create tracer returned %d\n", __FUNCTION__, error);
|
fprintf(stderr, "%s: create tracer returned %d\n", __FUNCTION__, error);
|
||||||
return error;
|
return error;
|
||||||
@@ -2906,9 +2888,28 @@ create_tracer()
|
|||||||
unsigned long code = 0;
|
unsigned long code = 0;
|
||||||
int exited = 0;
|
int exited = 0;
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
//struct tracer_desc desc;
|
|
||||||
unsigned long buf;
|
unsigned long buf;
|
||||||
|
|
||||||
|
/* Perform mmap() before fork() in create_tracer() */
|
||||||
|
uti_desc = mmap(NULL, sizeof(struct uti_desc), PROT_READ | PROT_WRITE,
|
||||||
|
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
||||||
|
if (uti_desc == (void *)-1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memset(uti_desc, 0, sizeof(struct uti_desc));
|
||||||
|
sem_init(&uti_desc->arg, 1, 0);
|
||||||
|
sem_init(&uti_desc->attach, 1, 0);
|
||||||
|
uti_wp = mmap(NULL, PAGE_SIZE * 3, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
||||||
|
if (uti_wp == (void *)-1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pipe(uti_pfd)) {
|
||||||
|
fprintf(stderr, "%s: pipe failed: %s\n", __FUNCTION__, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tpid = fork();
|
tpid = fork();
|
||||||
if (tpid) {
|
if (tpid) {
|
||||||
if (tpid == -1)
|
if (tpid == -1)
|
||||||
@@ -3177,16 +3178,9 @@ util_thread(struct thread_data_s *my_thread, unsigned long uctx_pa, int remote_t
|
|||||||
unsigned long buf;
|
unsigned long buf;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{
|
if ((error = create_tracer())) {
|
||||||
int error;
|
fprintf(stderr, "%s: create_tracer returned %d\n", __FUNCTION__, error);
|
||||||
if ((error = pipe(uti_pfd)) == -1) {
|
rc = error; goto out;
|
||||||
fprintf(stderr, "%s: pipe returned %d\n", __FUNCTION__, error);
|
|
||||||
rc = error; goto out;
|
|
||||||
}
|
|
||||||
if ((error = create_tracer())) {
|
|
||||||
fprintf(stderr, "%s: create_tracer returned %d\n", __FUNCTION__, error);
|
|
||||||
rc = error; goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef POSTK_DEBUG_ARCH_DEP_35
|
#ifdef POSTK_DEBUG_ARCH_DEP_35
|
||||||
@@ -3765,6 +3759,13 @@ gettid_out:
|
|||||||
goto fork_child_sync_pipe;
|
goto fork_child_sync_pipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create tracer before anonymous inode is mapped */
|
||||||
|
if ((ret = create_tracer())) {
|
||||||
|
fs->status = ret;
|
||||||
|
fprintf(stderr, "%s: create tracer returned %d\n", __FUNCTION__, ret);
|
||||||
|
goto fork_child_sync_pipe;
|
||||||
|
}
|
||||||
|
|
||||||
if (ioctl(fd, MCEXEC_UP_CREATE_PPD) != 0) {
|
if (ioctl(fd, MCEXEC_UP_CREATE_PPD) != 0) {
|
||||||
fs->status = -errno;
|
fs->status = -errno;
|
||||||
fprintf(stderr, "ERROR: creating PPD %s\n", dev);
|
fprintf(stderr, "ERROR: creating PPD %s\n", dev);
|
||||||
|
|||||||
Reference in New Issue
Block a user