Index: kernel/arch/abs32le/include/arch/stack.h
===================================================================
--- kernel/arch/abs32le/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/abs32le/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup abs32le	
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_STACK_H_
+#define KERN_abs32le_STACK_H_
+
+#include <config.h>
+
+#define MEM_STACK_SIZE	STACK_SIZE
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/amd64/include/arch/stack.h
===================================================================
--- kernel/arch/amd64/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/amd64/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amd64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_amd64_STACK_H_
+#define KERN_amd64_STACK_H_
+
+#include <config.h>
+
+#define MEM_STACK_SIZE	STACK_SIZE
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/arm32/include/arch/stack.h
===================================================================
--- kernel/arch/arm32/include/arch/stack.h	(revision 40a0e3bd205a795440ad80ae31717206bcbd7cce)
+++ kernel/arch/arm32/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -37,4 +37,8 @@
 #define KERN_arm32_STACK_H_
 
+#include <config.h>
+
+#define MEM_STACK_SIZE	STACK_SIZE
+
 #define STACK_ITEM_SIZE		4
 
Index: kernel/arch/ia32/include/arch/stack.h
===================================================================
--- kernel/arch/ia32/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/ia32/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup ia32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_ia32_STACK_H_
+#define KERN_ia32_STACK_H_
+
+#include <config.h>
+
+#define MEM_STACK_SIZE	STACK_SIZE
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/ia64/include/arch/stack.h
===================================================================
--- kernel/arch/ia64/include/arch/stack.h	(revision 40a0e3bd205a795440ad80ae31717206bcbd7cce)
+++ kernel/arch/ia64/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -36,4 +36,8 @@
 #define KERN_ia64_STACK_H_
 
+#include <config.h>
+
+#define MEM_STACK_SIZE	(STACK_SIZE / 2)
+
 #define STACK_ITEM_SIZE			8
 #define STACK_ALIGNMENT			16
Index: kernel/arch/mips32/include/arch/stack.h
===================================================================
--- kernel/arch/mips32/include/arch/stack.h	(revision 40a0e3bd205a795440ad80ae31717206bcbd7cce)
+++ kernel/arch/mips32/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -36,4 +36,8 @@
 #define KERN_mips32_STACK_H_
 
+#include <config.h>
+
+#define MEM_STACK_SIZE	STACK_SIZE
+
 #define STACK_ITEM_SIZE  4
 #define STACK_ALIGNMENT  8
Index: kernel/arch/mips64/include/arch/stack.h
===================================================================
--- kernel/arch/mips64/include/arch/stack.h	(revision 40a0e3bd205a795440ad80ae31717206bcbd7cce)
+++ kernel/arch/mips64/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -36,4 +36,8 @@
 #define KERN_mips64_STACK_H_
 
+#include <config.h>
+
+#define MEM_STACK_SIZE	STACK_SIZE
+
 #define STACK_ITEM_SIZE  8
 #define STACK_ALIGNMENT  8
Index: kernel/arch/ppc32/include/arch/stack.h
===================================================================
--- kernel/arch/ppc32/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/ppc32/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup ppc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_ppc32_STACK_H_
+#define KERN_ppc32_STACK_H_
+
+#include <config.h>
+
+#define MEM_STACK_SIZE	STACK_SIZE
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc64/include/arch/stack.h
===================================================================
--- kernel/arch/sparc64/include/arch/stack.h	(revision 40a0e3bd205a795440ad80ae31717206bcbd7cce)
+++ kernel/arch/sparc64/include/arch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -36,4 +36,8 @@
 #define KERN_sparc64_STACK_H_
 
+#include <config.h>
+
+#define MEM_STACK_SIZE	STACK_SIZE
+
 #define STACK_ITEM_SIZE			8
 
Index: kernel/generic/src/interrupt/interrupt.c
===================================================================
--- kernel/generic/src/interrupt/interrupt.c	(revision 40a0e3bd205a795440ad80ae31717206bcbd7cce)
+++ kernel/generic/src/interrupt/interrupt.c	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -54,4 +54,5 @@
 #include <proc/thread.h>
 #include <arch/cycle.h>
+#include <arch/stack.h>
 #include <str.h>
 #include <trace.h>
@@ -222,8 +223,7 @@
 	/*
 	 * The istate structure should be right at the bottom of the kernel
-	 * stack.
+	 * memory stack.
 	 */
-	return (istate_t *) ((uint8_t *)
-	    thread->kstack + STACK_SIZE - sizeof(istate_t));
+	return (istate_t *) &thread->kstack[MEM_STACK_SIZE - sizeof(istate_t)];
 }
 
Index: uspace/lib/c/arch/mips32/include/libarch/stack.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/stack.h	(revision 40a0e3bd205a795440ad80ae31717206bcbd7cce)
+++ uspace/lib/c/arch/mips32/include/libarch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -1,1 +1,45 @@
-../../../../../../../kernel/arch/mips32/include/arch/stack.h
+/*
+ * Copyright (c) 2006 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcmips32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_mips32_STACK_H_
+#define LIBC_mips32_STACK_H_
+
+#define STACK_ITEM_SIZE  4
+#define STACK_ALIGNMENT  8
+#define ABI_STACK_FRAME  32
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/mips64/include/libarch/stack.h
===================================================================
--- uspace/lib/c/arch/mips64/include/libarch/stack.h	(revision 40a0e3bd205a795440ad80ae31717206bcbd7cce)
+++ uspace/lib/c/arch/mips64/include/libarch/stack.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
@@ -1,1 +1,45 @@
-../../../../../../../kernel/arch/mips64/include/arch/stack.h
+/*
+ * Copyright (c) 2006 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libcmips64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_mips64_STACK_H_
+#define LIBC_mips64_STACK_H_
+
+#define STACK_ITEM_SIZE  8
+#define STACK_ALIGNMENT  8
+#define ABI_STACK_FRAME  64
+
+#endif
+
+/** @}
+ */
