mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* start_thread question...
@ 2001-05-20 16:24 Dave Airlie
  2001-05-20 17:16 ` Ingo Molnar
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dave Airlie @ 2001-05-20 16:24 UTC (permalink / raw)
  To: linux-vax, linux-kernel


I'm implementing start_thread for the VAX port and am wondering does
start_thread have to return to load_elf_binary? I'm working on the init
thread and what is happening is it is returning the whole way back to the
execve caller .. which I know shouldn't happen.....

so I suppose what I'm looking for is the point where the user space code
gets control... is it when the registers are set in the start_thread? if
so how does start_thread return....

On the VAX we have to call a return from interrupt to get to user space
and I'm trying to figure out where this should happen...

Dave.

-- 
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied@skynet.ie
pam_smb / Linux DecStation / Linux VAX / ILUG person



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

* Re: start_thread question...
  2001-05-20 16:24 start_thread question Dave Airlie
@ 2001-05-20 17:16 ` Ingo Molnar
  2001-05-20 19:34 ` Jeff Dike
  2001-05-20 22:07 ` [LV] " Kenn Humborg
  2 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2001-05-20 17:16 UTC (permalink / raw)
  To: Dave Airlie; +Cc: linux-vax, linux-kernel


On Sun, 20 May 2001, Dave Airlie wrote:

> I'm implementing start_thread for the VAX port and am wondering does
> start_thread have to return to load_elf_binary? I'm working on the
> init thread and what is happening is it is returning the whole way
> back to the execve caller .. which I know shouldn't happen.....

start_thread() doesnt do what one would intuitively think it does.

start_thread() simply prepares the new task's register set to be ready to
start user-space (which task is the current task as well, so certain
current CPU registers might have to be manually bootstrapped as well), but
start_thread() does not actually start execution of user-space code yet.

(a more correct name for start_thread() would be prepare_user_thread().)

> so I suppose what I'm looking for is the point where the user space
> code gets control... is it when the registers are set in the
> start_thread? if so how does start_thread return....

execution starts when the process returns from sys_execve(). By that time
we have already changed pagetables and other context information, dropped
basically everything from the previous context - without actually doing a
context-switch. In fact sys_execve() has an implicit context-switch,
without ever changing the kernel-stack though.

> On the VAX we have to call a return from interrupt to get to user
> space and I'm trying to figure out where this should happen...

this is how it happens on x86 too. Basically you start the new binary by
returning from an syscall that has bootstrapped all userspace context -
this approach should work on any architecture. (because every architecture
has to be able to execute user-space code after syscalls.)

	Ingo


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

* Re: start_thread question...
  2001-05-20 16:24 start_thread question Dave Airlie
  2001-05-20 17:16 ` Ingo Molnar
@ 2001-05-20 19:34 ` Jeff Dike
  2001-05-20 22:07 ` [LV] " Kenn Humborg
  2 siblings, 0 replies; 5+ messages in thread
From: Jeff Dike @ 2001-05-20 19:34 UTC (permalink / raw)
  To: Dave Airlie; +Cc: linux-vax, linux-kernel

airlied@skynet.ie said:
> I'm implementing start_thread for the VAX port and am wondering does
> start_thread have to return to load_elf_binary? I'm working on the
> init thread and what is happening is it is returning the whole way
> back to the execve caller .. which I know shouldn't happen.....

Ingo answered that specific question (and that had me puzzled for a while, too 
:-), but, in the future, you might want to look at UML if you have similar 
questions.  All this stuff works, and it's implemented in terms of the system 
calls that we all know and love, so you don't have to learn about a totally 
different piece of hardware in order to figure out what's going on.

				Jeff



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

* Re: [LV] start_thread question...
  2001-05-20 16:24 start_thread question Dave Airlie
  2001-05-20 17:16 ` Ingo Molnar
  2001-05-20 19:34 ` Jeff Dike
@ 2001-05-20 22:07 ` Kenn Humborg
  2001-05-20 22:38   ` Dave Airlie
  2 siblings, 1 reply; 5+ messages in thread
From: Kenn Humborg @ 2001-05-20 22:07 UTC (permalink / raw)
  To: linux-vax; +Cc: linux-kernel

On Sun, May 20, 2001 at 05:24:48PM +0100, Dave Airlie wrote:
> 
> I'm implementing start_thread for the VAX port and am wondering does
> start_thread have to return to load_elf_binary? I'm working on the init
> thread and what is happening is it is returning the whole way back to the
> execve caller .. which I know shouldn't happen.....
> 
> so I suppose what I'm looking for is the point where the user space code
> gets control... is it when the registers are set in the start_thread? if
> so how does start_thread return....
> 
> On the VAX we have to call a return from interrupt to get to user space
> and I'm trying to figure out where this should happen...

I haven't got time to look at this in detail, but you could
probably do it by frobbing the saved registers that will be
restored by the ret_from_syscall in entry.S.  Do you have
a pt_regs *regs function argument at the right point?  If
so, it should point to these saved registers.

Later,
Kenn


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

* Re: [LV] start_thread question...
  2001-05-20 22:07 ` [LV] " Kenn Humborg
@ 2001-05-20 22:38   ` Dave Airlie
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Airlie @ 2001-05-20 22:38 UTC (permalink / raw)
  To: linux-vax; +Cc: linux-kernel


Okay I think I've gotten it solved most of the way, we weren't calling
execve via the system call interface, so once I made it go via the system
call and I fill out pc, sp and psl registers in start_thread, it seems to
go further..

Thanks for all the help...

Dave.

On Sun, 20 May 2001, Kenn Humborg wrote:

> On Sun, May 20, 2001 at 05:24:48PM +0100, Dave Airlie wrote:
> >
> > I'm implementing start_thread for the VAX port and am wondering does
> > start_thread have to return to load_elf_binary? I'm working on the init
> > thread and what is happening is it is returning the whole way back to the
> > execve caller .. which I know shouldn't happen.....
> >
> > so I suppose what I'm looking for is the point where the user space code
> > gets control... is it when the registers are set in the start_thread? if
> > so how does start_thread return....
> >
> > On the VAX we have to call a return from interrupt to get to user space
> > and I'm trying to figure out where this should happen...
>
> I haven't got time to look at this in detail, but you could
> probably do it by frobbing the saved registers that will be
> restored by the ret_from_syscall in entry.S.  Do you have
> a pt_regs *regs function argument at the right point?  If
> so, it should point to these saved registers.
>
> Later,
> Kenn
>
>

-- 
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied@skynet.ie
pam_smb / Linux DecStation / Linux VAX / ILUG person



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

end of thread, other threads:[~2001-05-20 22:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-20 16:24 start_thread question Dave Airlie
2001-05-20 17:16 ` Ingo Molnar
2001-05-20 19:34 ` Jeff Dike
2001-05-20 22:07 ` [LV] " Kenn Humborg
2001-05-20 22:38   ` Dave Airlie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®