From owner-freebsd-ia64@FreeBSD.ORG Wed Jun 27 12:17:10 2007 Return-Path: X-Original-To: ia64@freebsd.org Delivered-To: freebsd-ia64@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6682D16A400 for ; Wed, 27 Jun 2007 12:17:10 +0000 (UTC) (envelope-from christian.kandeler@hob.de) Received: from mailgate.hob.de (mailgate.hob.de [212.185.199.3]) by mx1.freebsd.org (Postfix) with ESMTP id EDC7013C469 for ; Wed, 27 Jun 2007 12:17:09 +0000 (UTC) (envelope-from christian.kandeler@hob.de) Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgate.hob.de (Postfix) with ESMTP id E5CF127F8F; Wed, 27 Jun 2007 14:17:08 +0200 (CEST) Received: from mailgate.hob.de ([127.0.0.1]) by localhost (mailgate.hob.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 32742-09; Wed, 27 Jun 2007 14:17:08 +0200 (CEST) Received: from imap.hob.de (mail2.hob.de [172.25.1.102]) by mailgate.hob.de (Postfix) with ESMTP id B0BD627FA5; Wed, 27 Jun 2007 14:17:08 +0200 (CEST) Received: from [172.22.0.190] (linux03.hob.de [172.22.0.190]) by imap.hob.de (Postfix on SuSE eMail Server 2.0) with ESMTP id 5539AC644D; Wed, 27 Jun 2007 14:17:08 +0200 (CEST) From: Christian Kandeler Organization: HOB To: Marcel Moolenaar Date: Wed, 27 Jun 2007 14:17:02 +0200 User-Agent: KMail/1.6.2 References: <200706211132.32524.christian.kandeler@hob.de> <3700F902-9CC0-4A6A-B625-8E81C12C5D5E@mac.com> In-Reply-To: <3700F902-9CC0-4A6A-B625-8E81C12C5D5E@mac.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200706271417.02968.christian.kandeler@hob.de> X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at hob.de Cc: ia64@freebsd.org Subject: Re: Syscalls and RSE X-BeenThere: freebsd-ia64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the IA-64 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2007 12:17:10 -0000 On Thursday 21 June 2007 19:41, Marcel Moolenaar wrote: > When we switch to the kernel stack, we align BSPSTORE to the user stack > (WRT to NaT collections). In other words we preserve the least > significant 9 bits of BSPSTORE. Since these bits determine when a NaT > collection will happen and which bit in the RNAT register will take the NaT > bit of the stacked register on a flush, we effectively preserved all the NaT > bits without explicitly saving or restoring anything. Yes, I understand that. > As such, we never clobber "used" bits in the RNAT register and it also > allows us to flush the dirty registers onto the kernel stack and copy > them back to user space knowing that any NaT collections on the kernel stack > will be copied to the right location on the user stack. Also, any NaT > bits left in RNAT after the loadrs on our way out of the kernel will be > those of the user process. The problem, I think, is not the RNAT on the way out of the syscall, but a collection of undefined NaT bits saved in the kernel and loaded later in user space. As I have mentioned in my first mail, this is due to the fact that we can advance the saved user space BSPSTORE (and therefore BspLoad too) over such a NaT collection in ia64_flush_dirty(). The reason that this does not usually lead to problems in practice is probably that the current Itanium processors set RNAT to zero after a backing store switch, so no NaT bits are actually set to 1 by the RSE load that restores the undefined NaT collection. This is not guaranteed, of course. I've tried to verify my theory, and I believe I have succeeded: If the code in epc_syscall is correct, then it should tolerate any value in RNAT after the backing store switch, since the value of this register is undefined anyway. However, when I manually set RNAT to -1 and boot the resulting kernel, the system crashes right after entering user space (Illegal Instruction in the sh process). I assume this is due to one of the many NaT bits the process receives after making a system call. Regards, Christian Kandeler