Without this fix the value of a0 spilled from the oldest live window is
wrong if the newest window has only 4 live registers, because a4 in the
newest window overlaps a0 in the oldest one.

This may be reproduced by invoking spill syscall after the following
sequence of calls: 4 -> 12 -> 12 -> 4 on configuration with 32 physical
registers.

Cc: [email protected]
Signed-off-by: Max Filippov <[email protected]>
---
 arch/xtensa/kernel/entry.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index 4dd391d..90c6fc6 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -1241,6 +1241,7 @@ ENTRY(_spill_registers)
         * Rotate ws right so that a4 = yyxxxwww1.
         */
 
+       wsr     a4, depc                # save a4: we may need to spill it
        rsr     a4, windowbase
        rsr     a3, windowstart         # a3 = xxxwww1yy
        ssr     a4                      # holds WB
@@ -1271,6 +1272,7 @@ ENTRY(_spill_registers)
 
        rsr     a3, windowbase
        add     a3, a3, a4
+       rsr     a4, depc                # restore a4
        wsr     a3, windowbase
        rsync
 
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to