From: Ian Campbell Subject: Re: =?UTF-8?Q?=E7=AD=94=E5=A4=8D=3A?= About TSS initialization when Xen booting. Date: Tue, 07 Aug 2007 07:52:37 +0100 Message-ID: <1186469557.6686.5.camel@localhost.localdomain> References: <20070807011555.A0158136853@ncic.ac.cn> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20070807011555.A0158136853@ncic.ac.cn> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: =?UTF-8?Q?=E6=9D=8E=E4=BA=9A=E7=90=BC?= Cc: "'Li, Xin B'" , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Tue, 2007-08-07 at 09:27 +0800, =E6=9D=8E=E4=BA=9A=E7=90=BC wrote: > Thanks, Xin! >=20 > 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=E2= =80=99s > 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? get_cpu_info returns a pointer into the stack. guest_cpu_user_regs is a member of the structure this pointer points to (but not a pointer itself). It has been arranged so that guest_cpu_user_regs overlaps the part of the stack where entry.S will save the guests registers (mainly in the SAVE_ALL macro). This should make sense because the TSS is being initialised with exactly the value you wish the stack to have when transitioning to ring0. > The question is about the variables, =E2=80=9Cstack=E2=80=9D and =E2=80= =9Cstack_bottom=E2=80=9D. At > this moment, if guest_cpu_user_regs has not been initialized, > =E2=80=9Cstack_bottom=E2=80=9D will be zero when the cpu is the first phy= sical cpu > ( its stack is initialized with zero in file boot.S). And then =E2=80=9Cs= tack=E2=80=9D > will be zero, too. Is it correct? Remember that guest_cpu_user_regs isn't a pointer, it's just a member of a struct so it's address will currently be the address of that struct plus an offset. Ian.