[Top] [All Lists]

Re: How to detect STACKOVEFLOW on mips

To: Adam Jiang <>
Subject: Re: How to detect STACKOVEFLOW on mips
From: Phil Staub <>
Date: Wed, 30 Jun 2010 07:27:10 -0700
In-reply-to: <>
Organization: Wind River Systems
References: <>
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100430 Fedora/3.0.4-2.fc11 Thunderbird/3.0.4
On 06/29/2010 10:59 PM, Adam Jiang wrote:
Hello, list.

I'm having a problem with kernel mode stack on my box. It seems that
STACKOVERFLOW happened to Linux kernel. However, I can't prove it
because the lack of any detection in __do_IRQ() function just like on
the other architectures. If you know something about, please help me
on following two questions.
- Is there any possible to do this on MIPS?

The mechanisms I know about for detecting stack overflow include:

1. Use of the MMU - stack ends at a page boundary, adjacent page is
either unmapped or mapped read-only and causes an exception if violated.

2. Hooks inserted into toolchain to cause any stack decrement to be
first tested against a limit.

3. Fill entire stack with a recognizable pattern before first
use. After suspected stack overflow, check to see if the pattern has
been disturbed in the area of the stack limit.

(Disclaimer: I've used all of these in some form on other OSes, but
not on Linux. Someone else may have a more directly relevant answer.)

- or, more simple question, how could I get the address $sp pointed by
asm() notation in C?

How about something like:

        long x;
        asm("move %0,$29":"=g"(x));


Any suggestion from you will be appreciated.

Best regards,

Phil Staub, Senior Member of Technical Staff, Wind River
Direct: 702.290.0470 Fax: 702.982.0085

<Prev in Thread] Current Thread [Next in Thread>