From: Keir Fraser Subject: Re: memguard_guard_stack() Date: Fri, 28 Apr 2006 17:30:47 +0100 Message-ID: References: <445258FB.76E4.0078.0@novell.com> Mime-Version: 1.0 (Apple Message framework v623) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <445258FB.76E4.0078.0@novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On 28 Apr 2006, at 17:03, Jan Beulich wrote: > Is it really intended that the stack size, specifically bumped to 4 > pages in include/asm-x86/config.h for x86-64 when > debugging, gets shrunk to a single page in memguard_guard_stack()? To > me it would seem much more reasonable if indeed > only the first page (or at most, the first two pages) was used as a > guard page here. The only reason that the stack is 4 pages on a 64-bit debug build is because we put syscall-entry trampolines at the start of the per-cpu stack area. Therefore simply allocating 2 pages for a debug stack and then removing the mapping of the first page, as we do on i386, does not work -- that would unmap the trampolines! Instead we allocate 4 pages (next power of two) and zap the middle two page mappings. This has the desirable effect of placing the guard between the trampolines and the actual stack (otherwise the trampolines would get overwritten before the guard page gets trodden on!). It should never be possible for Xen to overflow 4kB of stack. Very little is done in interrupt contexts so we don't have the overflow problems that Linux has suffered. -- Keir