From 4ea9382ee6d81cb137fd9c21afc9df9fbf9edb92 Mon Sep 17 00:00:00 2001
From: Alex Stewart <Alexander.Stewart@consensuscorp.com>
Date: Thu, 24 Sep 2015 18:32:32 -0700
Subject: [PATCH] Fix bad memory access in NMI handler

CallNMIExceptionHandler was saving/restoring registers to the wrong offsets,
causing it to potentially corrupt the first two slots of the
LoadStoreErrorHandler's save area.
---
 core/exception_vectors.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/exception_vectors.S b/core/exception_vectors.S
index a8d513a..26e542f 100644
--- a/core/exception_vectors.S
+++ b/core/exception_vectors.S
@@ -340,12 +340,12 @@ LoadStoreErrorHandlerStack:
 
 /* Save register relative to a0 */
 .macro SAVE_REG register, regnum
-	s32i \register, a0, (0x20 + 4 * \regnum)
+	s32i \register, a0, (4 * (\regnum + 6))
 .endm
 
 /* Load register relative to sp */
 .macro LOAD_REG register, regnum
-	l32i \register, sp, (0x20 + 4 * \regnum)
+	l32i \register, sp, (4 * (\regnum + 6))
 .endm
 
 	.text