sparc64: Fix sun4u execute bit check in TSB I-TLB load.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, February 19, 2010 - 8:59 pm

Gitweb:     http://git.kernel.org/linus/1f474646fdc36b457606bbcd6a3592e6cbd31ac4
Commit:     1f474646fdc36b457606bbcd6a3592e6cbd31ac4
Parent:     d7ecfb3c2aa155c9f6152ebe91de92067d16ba6e
Author:     David S. Miller <davem@davemloft.net>
AuthorDate: Fri Feb 19 15:19:52 2010 -0800
Committer:  David S. Miller <davem@davemloft.net>
CommitDate: Fri Feb 19 15:19:52 2010 -0800

    sparc64: Fix sun4u execute bit check in TSB I-TLB load.
    
    Thanks to testcase and report from Brad Spengler:
    
    --------------------
    #include <stdio.h>
    
    typedef int (* _wee)(void);
    
    int main(void)
    {
            char buf[8] = { '\x81', '\xc7', '\xe0', '\x08', '\x81', '\xe8',
                            '\x00', '\x00' };
            _wee wee;
            printf("%p\n", &buf);
            wee = (_wee)&buf;
            wee();
    
            return 0;
    }
    --------------------
    
    TSB I-tlb load code tries to use andcc to check the _PAGE_EXEC_4U bit,
    but that's bit 12 so it gets sign extended all the way up to bit 63
    and the test nearly always passes as a result.
    
    Use sethi to fix the bug.
    
    Signed-off-by: David S. Miller <davem@davemloft.net>
---
 arch/sparc/kernel/tsb.S |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/tsb.S b/arch/sparc/kernel/tsb.S
index 8c91d9b..db15d12 100644
--- a/arch/sparc/kernel/tsb.S
+++ b/arch/sparc/kernel/tsb.S
@@ -191,10 +191,12 @@ tsb_dtlb_load:
 
 tsb_itlb_load:
 	/* Executable bit must be set.  */
-661:	andcc		%g5, _PAGE_EXEC_4U, %g0
-	.section	.sun4v_1insn_patch, "ax"
+661:	sethi		%hi(_PAGE_EXEC_4U), %g4
+	andcc		%g5, %g4, %g0
+	.section	.sun4v_2insn_patch, "ax"
 	.word		661b
 	andcc		%g5, _PAGE_EXEC_4V, %g0
+	nop
 	.previous
 
 	be,pn		%xcc, tsb_do_fault
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
sparc64: Fix sun4u execute bit check in TSB I-TLB load., Linux Kernel Mailing ..., (Fri Feb 19, 8:59 pm)