From: =?gb2312?B?wO7Rx8ft?= Subject: =?gb2312?B?tPC4tDogW1hlbi1kZXZlbF0gQWJvdXQgVFNTIGluaXRpYWxpemF0aQ==?= =?gb2312?B?b24gd2hlbiBYZW4gYm9vdGluZy4=?= Date: Tue, 7 Aug 2007 09:27:06 +0800 Message-ID: <20070807011555.A0158136853@ncic.ac.cn> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1728005573==" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "'Li, Xin B'" Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --===============1728005573== Content-Type: multipart/alternative; boundary="----=_NextPart_000_004C_01C7D8D5.1EF4C5A0" This is a multi-part message in MIME format. ------=_NextPart_000_004C_01C7D8D5.1EF4C5A0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Thanks, Xin! But __context_switch will be invoked only when system is scheduled. = During the initialization, Xen invokes percpu_traps_init and cpu_init to = initialize a physical cpu. In this two functions, tss will be assigned with a value from guest_cpu_user_regs. But till this time, __context_switch has never been invoked. In other words, idle_domain=A1=AFs tss is assigned with a = trivial value. After all, when Xen is in the idle domain, a stack switch will = occur when a interrupt occurs. Is it correct? Another question is about percpu_traps_init whick code is following: void __init percpu_traps_init(void) { char *stack_bottom, *stack; . . . stack_bottom =3D (char *)get_stack_bottom(); stack =3D (char *)((unsigned long)stack_bottom & ~(STACK_SIZE = - 1)); =20 /* Double-fault handler has its own per-CPU 2kB stack. */ init_tss[cpu].ist[0] =3D (unsigned long)&stack[2048]; =20 /* NMI handler has its own per-CPU 1kB stack. */ init_tss[cpu].ist[1] =3D (unsigned long)&stack[3072]; =20 /* * Trampoline for SYSCALL entry from long mode. */ =20 /* Skip the NMI and DF stacks. */ stack =3D &stack[3072]; wrmsr(MSR_LSTAR, (unsigned long)stack, ((unsigned long)stack>>32)); =20 /* movq %rsp, saversp(%rip) */ stack[0] =3D 0x48; stack[1] =3D 0x89; stack[2] =3D 0x25; *(u32 *)&stack[3] =3D (stack_bottom - &stack[7]) - 16; . . . } The question is about the variables, =A1=B0stack=A1=B1 and = =A1=B0stack_bottom=A1=B1. At this moment, if guest_cpu_user_regs has not been initialized, =A1=B0stack_bottom=A1=B1 will be zero when the cpu is the first physical = cpu ( its stack is initialized with zero in file boot.S). And then = =A1=B0stack=A1=B1 will be zero, too. Is it correct? =20 -Techie, lee 2007-8-7 _____ =20 =B7=A2=BC=FE=C8=CB: Li, Xin B [mailto:xin.b.li@intel.com]=20 =B7=A2=CB=CD=CA=B1=BC=E4: 2007=C4=EA8=D4=C26=C8=D5 23:50 =CA=D5=BC=FE=C8=CB: =C0=EE=D1=C7=C7=ED; xen-devel@lists.xensource.com =D6=F7=CC=E2: RE: [Xen-devel] About TSS initialization when Xen booting. =20 In __context_switch, there is a memcpy to do this job. -Xin=20 =20 =20 _____ =20 From: xen-devel-bounces@lists.xensource.com = [mailto:xen-devel-bounces@lists. xensource.com] On Behalf Of =C0=EE=D1=C7=C7=ED Sent: Monday, August 06, 2007 8:46 PM To: xen-devel@lists.xensource.com Subject: [Xen-devel] About TSS initialization when Xen booting. Hi, I have a doubt on the Tss initialization. In the function cpu_init(),t->rsp0 =3D get_stack_bottom(). #define get_stack_bottom() \ ((unsigned long)&get_cpu_info()->guest_cpu_user_regs.es) But I can=A1=AFt find where the guest_cpu_user_regs has been initialized. Anybody can help me? =20 -Techie.lee =20 =20 ------=_NextPart_000_004C_01C7D8D5.1EF4C5A0 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable

Thanks, = Xin!

But = __context_switch will be invoked only when system is scheduled. During the initialization, Xen = invokes percpu_traps_init and cpu_init to initialize a physical cpu. In this two functions, tss = will be assigned with a value from guest_cpu_user_regs. But till this time, = __context_switch has never been invoked. In other words, idle_domain=A1=AFs tss is assigned = with a trivial value. After all, when Xen is in the idle domain, a stack switch will = occur when a interrupt occurs. Is it correct?

Another question = is about percpu_traps_init whick code is following:

void __init percpu_traps_init(void)

{

char *stack_bottom, *stack;

.

.

.

   = stack_bottom =3D (char = *)get_stack_bottom();

   = stack        =3D (char *)((unsigned long)stack_bottom & ~(STACK_SIZE - 1));

 <= /span>

   = /* Double-fault handler has its own per-CPU 2kB stack. = */

   = init_tss[cpu].ist[0] =3D (unsigned long)&stack[2048];

 <= /span>

   = /* NMI handler has its own per-CPU 1kB stack. */

   = init_tss[cpu].ist[1] =3D (unsigned = long)&stack[3072];

 <= /span>

   = /*

   =   * Trampoline for SYSCALL entry from long = mode.

   =   */

 <= /span>

   = /* Skip the NMI and DF stacks. */

   = stack =3D &stack[3072];

   = wrmsr(MSR_LSTAR, (unsigned long)stack, ((unsigned = long)stack>>32));

 <= /span>

   = /* movq %rsp, saversp(%rip) */

   = stack[0] =3D 0x48;

   = stack[1] =3D 0x89;

   = stack[2] =3D 0x25;

*(u32 *)&stack[3] =3D (stack_bottom - &stack[7]) - = 16;

.

.

.

}

The question is about the variables,  =A1=B0stack=A1=B1 =  and =A1=B0stack_bottom=A1=B1. At this moment, if guest_cpu_user_regs has not been initialized, = =A1=B0stack_bottom=A1=B1 will be zero when the cpu is the first physical cpu ( its stack is = initialized with zero in file boot.S). And then =A1=B0stack=A1=B1 will be zero, too. Is = it correct?

 

-Techie, lee

2007-8-7


=B7=A2= =BC=FE=C8=CB: Li, Xin B [mailto:xin.b.li@intel.com]
=B7=A2=CB=CD=CA=B1=BC=E4: 2007=C4=EA8=D4=C26=C8=D5 = 23:50
=CA=D5=BC=FE=C8=CB: =C0=EE=D1=C7=C7=ED; xen-devel@lists.xensource.com
=D6=F7=CC=E2: RE: [Xen-devel] About TSS initialization when Xen = booting.

 

In = __context_switch, there is a memcpy to = do this job.

-Xin 

 

 


From: xen-devel-bounces@lists.xensource.com = [mailto:xen-devel-bounces@lists.xensource.com] On Behalf Of = =C0=EE=D1=C7=C7=ED
Sent: Monday, August 06, = 2007 8:46 PM
To: = xen-devel@lists.xensource.com
Subject: [Xen-devel] = About TSS initialization when Xen booting.

Hi,<= /p>

     = ;    I have a doubt on the Tss initialization. In the function = cpu_init(),t->rsp0 =3D get_stack_bottom().

#define get_stack_bottom()         &= nbsp;            \

     = ;      ((unsigned = long)&get_cpu_info()->guest_cpu_user_regs.es)

     = ;    But I can=A1=AFt find where the guest_cpu_user_regs has been = initialized. Anybody can help me?

 

-Techie.lee=

 

 

------=_NextPart_000_004C_01C7D8D5.1EF4C5A0-- --===============1728005573== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1728005573==--