From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH] x86/boot: Explicitly clean pcpu stacks in debug builds Date: Thu, 15 Aug 2013 21:49:01 +0100 Message-ID: <1376599741-31694-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Keir Fraser , Jan Beulich List-Id: xen-devel@lists.xenproject.org This reduces confusion when looking at a hexdump of the pcpu stacks and wondering were on earth some of the junk was coming from. Also leave some grep fodder for finding where the BSP switches stack (because it took me far longer to find than I care to admit to) Signed-off-by: Andrew Cooper CC: Keir Fraser CC: Jan Beulich --- I came across this while developing my pcpu stack hexdumping capability into the crashdump analyser. While I know it is not neccessary for Xen to function correctly, I do feel that it is quite important when getting to this level of debugging. I guess this patch is partly RFC, but it does successfully boot on my test box, and fix stack junk seen on all CPUs. --- xen/arch/x86/boot/x86_64.S | 9 +++++++++ xen/arch/x86/smpboot.c | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index ed3888d..a45549b 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -13,6 +13,15 @@ mov mmu_cr4_features(%rip),%rcx mov %rcx,%cr4 +#ifndef NDEBUG + /* Clean stack. */ + mov stack_start(%rip),%rdi + mov $(STACK_SIZE>>8),%rcx + xor %eax,%eax + rep stosq +#endif + + /* Move to cpu0_stack. */ mov stack_start(%rip),%rsp or $(STACK_SIZE-CPUINFO_sizeof),%rsp diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 3df4e88..eced9ba 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -662,6 +662,10 @@ static int cpu_smpboot_alloc(unsigned int cpu) stack_base[cpu] = alloc_xenheap_pages(STACK_ORDER, 0); if ( stack_base[cpu] == NULL ) goto oom; +#ifndef NDEBUG + for ( order = 0 ; order < 1<