All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] USE_CODE_COPY breaks clone
@ 2004-09-01 17:32 Rafael Ávila de Espíndola
  2004-09-01 23:17 ` Rafael Ávila de Espíndola
  0 siblings, 1 reply; 2+ messages in thread
From: Rafael Ávila de Espíndola @ 2004-09-01 17:32 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 736 bytes --]

The cvs version of qemu (i386->i386) generates a segmentation fault in the 
emulated code of the attached test program. Commenting the definition of 
USE_CODE_COPY make the test execute successfully.

I think that the problem is in the fact that cpu_init is called in the parent 
process and this functions calls modify_ldt.

Where can I found some documentation about modify_ldt? What is USE_CODE_COPY 
supposed to do?

I will try to call cpu_init from within the new thread and see if it works.

One more question: What do you think about breaking the do_fork function in 
do_fork, do_clone and do_vfork? Presently it tries to guess if it should call 
fork or clone, but do_syscall knows the answer :)

Thanks for any comment,
Rafael

[-- Attachment #2: teste.c --]
[-- Type: text/x-csrc, Size: 487 bytes --]

#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

int f(void *oie) {
    printf("%s\n",(char *)oie);
    return 0;
}

int main() {
    const int stack_size = 8192;
    int ret;
    void *buf = malloc(stack_size);
    void *buff_end = buf + stack_size;
    unsigned int flags =CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND;
    char msg[] = "tata";
    ret = clone(f, buff_end, flags, (void *) msg);
    assert(ret != -1);
    printf("blit\n");
    return 0;
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] USE_CODE_COPY breaks clone
  2004-09-01 17:32 [Qemu-devel] USE_CODE_COPY breaks clone Rafael Ávila de Espíndola
@ 2004-09-01 23:17 ` Rafael Ávila de Espíndola
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael Ávila de Espíndola @ 2004-09-01 23:17 UTC (permalink / raw)
  To: qemu-devel

On Wednesday 01 September 2004 14:32, Rafael Ávila de Espíndola wrote:
> I think that the problem is in the fact that cpu_init is called in the
> parent process and this functions calls modify_ldt.
>
> Where can I found some documentation about modify_ldt? What is
> USE_CODE_COPY supposed to do?
Ok. It translate i386 to i386 code by copying it.

> I will try to call cpu_init from within the new thread and see if it works.
No it doesn't. If clone is called with CLONE_VM then the kernel does  
mm = oldmm;
and both processes share the ldt. So the parent ldt is "also" changed when 
cpu_init is called from clone_func.

I could not find out why it is necessary to modify the ltd of the process for 
code copy to work. Is there some documentation? Could someone explain?

Does someone have an Idea of how to solve this?

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-01 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-01 17:32 [Qemu-devel] USE_CODE_COPY breaks clone Rafael Ávila de Espíndola
2004-09-01 23:17 ` Rafael Ávila de Espíndola

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.