All of lore.kernel.org
 help / color / mirror / Atom feed
* Question re do_switch_stack()
@ 2005-06-09 14:41 Avi Kivity
  2005-06-09 14:44 ` Kip Macy
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2005-06-09 14:41 UTC (permalink / raw)
  To: xen-devel

looking at do_stack_switch() (x86-32), I see that the switch is effected
by moving the new stack pointer into current->arch.kernel_sp. however,
entry.S only looks at kernel_sp in create_bounce_frame, but only if
we're not returning into ring 1.

how then is the switch caused? obviously the call to do_stack_switch
came from ring 1.

confused,
Avi

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

* Re: Question re do_switch_stack()
  2005-06-09 14:41 Question re do_switch_stack() Avi Kivity
@ 2005-06-09 14:44 ` Kip Macy
  2005-06-09 15:22   ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Kip Macy @ 2005-06-09 14:44 UTC (permalink / raw)
  To: Avi Kivity; +Cc: xen-devel

The stack_switch you're looking at is for setting the trap stack.

On 6/9/05, Avi Kivity <avi.kivity@qumranet.com> wrote:
> looking at do_stack_switch() (x86-32), I see that the switch is effected
> by moving the new stack pointer into current->arch.kernel_sp. however,
> entry.S only looks at kernel_sp in create_bounce_frame, but only if
> we're not returning into ring 1.
> 
> how then is the switch caused? obviously the call to do_stack_switch
> came from ring 1.
> 
> confused,
> Avi
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
>

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

* Re: Question re do_switch_stack()
  2005-06-09 14:44 ` Kip Macy
@ 2005-06-09 15:22   ` Avi Kivity
  2005-06-09 15:32     ` Keir Fraser
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2005-06-09 15:22 UTC (permalink / raw)
  To: Kip Macy; +Cc: xen-devel

On Thu, 2005-06-09 at 07:44 -0700, Kip Macy wrote:
> The stack_switch you're looking at is for setting the trap stack.
> 

I'm still confused :(

the guest kernel's __switch_to() does

  
	tss->esp0 = next->esp0;
	mcl->op      = __HYPERVISOR_stack_switch;
	mcl->args[0] = tss->ss0;
	mcl->args[1] = tss->esp0;
	mcl++;


eventually calling into xen with that multicall. do_multicall_call()
calls, via hypercall_table, do_stack_switch(). there is only one
do_stack_switch() (for x86-32) which reads:

    int nr = smp_processor_id();
    struct tss_struct *t = &init_tss[nr];

    if ( (ss & 3) != 1 )
        return -EPERM;

    current->arch.kernel_ss = ss;
    current->arch.kernel_sp = esp;
    t->ss1  = ss;
    t->esp1 = esp;

    return 0;

the tss is not consulted on iretd as far as I can tell, and kernel_sp is
only loaded in create_bounce_frame. what did I miss?

thanks in advance.


> On 6/9/05, Avi Kivity <avi.kivity@qumranet.com> wrote:
> > looking at do_stack_switch() (x86-32), I see that the switch is effected
> > by moving the new stack pointer into current->arch.kernel_sp. however,
> > entry.S only looks at kernel_sp in create_bounce_frame, but only if
> > we're not returning into ring 1.
> > 
> > how then is the switch caused? obviously the call to do_stack_switch
> > came from ring 1.
> > 
> > confused,
> > Avi
> > 
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xensource.com
> > http://lists.xensource.com/xen-devel
> >

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

* Re: Question re do_switch_stack()
  2005-06-09 15:22   ` Avi Kivity
@ 2005-06-09 15:32     ` Keir Fraser
  2005-06-09 15:51       ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Keir Fraser @ 2005-06-09 15:32 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Kip Macy, xen-devel


On 9 Jun 2005, at 16:22, Avi Kivity wrote:

> the tss is not consulted on iretd as far as I can tell, and kernel_sp 
> is
> only loaded in create_bounce_frame. what did I miss?
>
> thanks in advance.

The actual stack switch occurs in do_switch() macro defined in 
include/asm-xen/asm-i386/system.h.

do_stack_switch() changes the stack that Xen switches to when switching 
to ring 1 when previously the guest was executing in ring 3.

  -- Keir

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

* Re: Question re do_switch_stack()
  2005-06-09 15:32     ` Keir Fraser
@ 2005-06-09 15:51       ` Avi Kivity
  0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2005-06-09 15:51 UTC (permalink / raw)
  To: Keir Fraser; +Cc: Kip Macy, xen-devel

On Thu, 2005-06-09 at 16:32 +0100, Keir Fraser wrote:
> On 9 Jun 2005, at 16:22, Avi Kivity wrote:
> 
> > the tss is not consulted on iretd as far as I can tell, and kernel_sp 
> > is
> > only loaded in create_bounce_frame. what did I miss?
> >
> > thanks in advance.
> 
> The actual stack switch occurs in do_switch() macro defined in 
> include/asm-xen/asm-i386/system.h.
> 

switch_to(), I think you mean.

> do_stack_switch() changes the stack that Xen switches to when switching 
> to ring 1 when previously the guest was executing in ring 3.
> 

all clear now. thanks!

Avi


>   -- Keir
> 

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

end of thread, other threads:[~2005-06-09 15:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-09 14:41 Question re do_switch_stack() Avi Kivity
2005-06-09 14:44 ` Kip Macy
2005-06-09 15:22   ` Avi Kivity
2005-06-09 15:32     ` Keir Fraser
2005-06-09 15:51       ` Avi Kivity

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.