From owner-freebsd-arm@FreeBSD.ORG Thu Feb 12 22:56:45 2009 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C228F106564A for ; Thu, 12 Feb 2009 22:56:45 +0000 (UTC) (envelope-from mlfbsd@dong.ci0.org) Received: from dong.ci0.org (dong.ci0.org [IPv6:2001:7a8:2066:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 16B9B8FC08 for ; Thu, 12 Feb 2009 22:56:44 +0000 (UTC) (envelope-from mlfbsd@dong.ci0.org) Received: from dong.ci0.org (localhost.ci0.org [127.0.0.1]) by dong.ci0.org (8.14.1/8.13.8) with ESMTP id n1D1ag2Q041431; Fri, 13 Feb 2009 02:36:42 +0100 (CET) (envelope-from mlfbsd@dong.ci0.org) Received: (from mlfbsd@localhost) by dong.ci0.org (8.14.1/8.13.8/Submit) id n1D1ageR041430; Fri, 13 Feb 2009 02:36:42 +0100 (CET) (envelope-from mlfbsd) Date: Fri, 13 Feb 2009 02:36:41 +0100 From: Olivier Houchard To: Mark Tinguely Message-ID: <20090213013641.GA41307@ci0.org> References: <200902122201.n1CM1wbK018744@casselton.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200902122201.n1CM1wbK018744@casselton.net> User-Agent: Mutt/1.4.1i Cc: freebsd-arm@freebsd.org Subject: Re: thread0.td_frame overwritten in cpu_startup() X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 22:56:46 -0000 On Thu, Feb 12, 2009 at 04:01:58PM -0600, Mark Tinguely wrote: > > on startup, the initarm() sets the thread0.td_frame to a local trapframe > structure. > > in arm/ARCH/ARCH_machdep.c > thread0.td_frame = &proc0_tf; > > But cpu_startup() in arm/arm/machdep.c overwrites it with a value at the end > of the kernel stack. unfortunately, that space is also used by the thread0 > pcb structure. > > in arm/ARCH/ARCH_machdep.c > thread0.td_pcb = (struct pcb *) > (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1 > > in arm/arm/machdep.c > pcb->un_32.pcb32_sp = (u_int)thread0.td_kstack + > USPACE_SVC_STACK_TOP; > > note: USPACE_SVC_STACK_TOP is defined as KSTACK_PAGES * PAGE_SIZE, so this > is the top of the kernel stack. > > thread0.td_frame = (struct trapframe *)pcb->un_32.pcb32_sp - 1; > > This td_frame assignment in arm/arm/machdep.c should be removed. Not only > did it overwrite a perfectly good trapframe, it overwrited it with memory > that is shared with the pcb. > True, committed. Thanks ! Olivier