Skip to contentSkip to conversation

A BTFIXUP'd fix for pte_read()

PATCH In review Art Haas 4 participants 9 messages Feb 2, 2005 – Feb 3, 2005 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

Art Haas

author
#0 lore raw

PATCH 1/1 A BTFIXUP'd fix for pte_read()

Hi.

Here's my attempt at taking Bob Breuer's patch and adding in some of the BTFIXUP magic that sparc32 needs. I'm running the current BK kernel with this patch on my SS20, and things seem to work. The current kernel complains during bootup and shutdown about accessing the system clock, a problem I am guessing is related to changes elsewhere in the kernel.

Art Haas

=== arch/sparc/mm/srmmu.c 1.49 vs edited ==--- 1.49/arch/sparc/mm/srmmu.c 2005-01-20 23:02:11 -06:00
+++ edited/arch/sparc/mm/srmmu.c 2005-02-02 09:39:49 -06:00
@@ -2197,6 +2197,7 @@
BTFIXUPSET_CALL(free_pgd_fast, srmmu_free_pgd_fast, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(get_pgd_fast, srmmu_get_pgd_fast, BTFIXUPCALL_NORM);

+ BTFIXUPSET_HALF(pte_readi, SRMMU_NOREAD);
BTFIXUPSET_HALF(pte_writei, SRMMU_WRITE); BTFIXUPSET_HALF(pte_dirtyi, SRMMU_DIRTY); BTFIXUPSET_HALF(pte_youngi, SRMMU_REF);
=== include/asm-sparc/pgtable.h 1.24 vs edited ==--- 1.24/include/asm-sparc/pgtable.h 2004-12-22 03:36:07 -06:00
+++ edited/include/asm-sparc/pgtable.h 2005-02-02 09:51:07 -06:00
@@ -186,9 +186,16 @@
* The following only work if pte_present() is true.
* Undefined behaviour if not..
*/
+BTFIXUPDEF_HALF(pte_readi)
BTFIXUPDEF_HALF(pte_writei) BTFIXUPDEF_HALF(pte_dirtyi) BTFIXUPDEF_HALF(pte_youngi)
+
+extern int pte_read(pte_t pte) __attribute_const__; +extern __inline__ int pte_read(pte_t pte)
+{
+ return !(pte_val(pte) & BTFIXUP_HALF(pte_readi));
+}

extern int pte_write(pte_t pte) __attribute_const__; extern __inline__ int pte_write(pte_t pte)
=== include/asm-sparc/pgtsrmmu.h 1.12 vs edited ==--- 1.12/include/asm-sparc/pgtsrmmu.h 2004-07-12 01:53:22 -05:00
+++ edited/include/asm-sparc/pgtsrmmu.h 2005-02-01 10:45:31 -06:00
@@ -73,6 +73,7 @@

 #define SRMMU_CACHE        0x80
 #define SRMMU_DIRTY        0x40
 #define SRMMU_REF          0x20
+#define SRMMU_NOREAD       0x10
 #define SRMMU_EXEC         0x08
 #define SRMMU_WRITE        0x04
 #define SRMMU_VALID        0x02 /* SRMMU_ET_PTE */
Signature · 4 lines
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822
#1 lore raw
Quoted 7 lines · Art Haas

Hi.

Here's my attempt at taking Bob Breuer's patch and adding in some of the BTFIXUP magic that sparc32 needs. I'm running the current BK kernel with this patch on my SS20, and things seem to work. The current kernel complains during bootup and shutdown about accessing the system clock, a problem I am guessing is related to changes elsewhere in the kernel.

This patch only covers sun4m. The attached patch covers all sparc32.

~spot
---
Tom "spot" Callaway <tcallawa(a)redhat*com> LCA, RHCE Red Hat Sales Engineer || Aurora Linux Project Leader

"If you are going through hell, keep going."
-- Sir Winston Churchill

arch/sparc/mm/srmmu.c renamed from arch/sparc/mm/srmmu.c.BAD +1 -0
@@ -2197,6 +2197,7 @@
 	BTFIXUPSET_CALL(free_pgd_fast, srmmu_free_pgd_fast, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(get_pgd_fast, srmmu_get_pgd_fast, BTFIXUPCALL_NORM);
 
+	BTFIXUPSET_HALF(pte_readi, SRMMU_NOREAD);
 	BTFIXUPSET_HALF(pte_writei, SRMMU_WRITE);
 	BTFIXUPSET_HALF(pte_dirtyi, SRMMU_DIRTY);
 	BTFIXUPSET_HALF(pte_youngi, SRMMU_REF);
arch/sparc/mm/sun4c.c renamed from arch/sparc/mm/sun4c.c.BAD +1 -0
@@ -2225,6 +2225,7 @@
 	BTFIXUPSET_CALL(free_pgd_fast, sun4c_free_pgd_fast, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(get_pgd_fast, sun4c_get_pgd_fast, BTFIXUPCALL_NORM);
 
+	BTFIXUPSET_HALF(pte_readi, _SUN4C_PAGE_READ);
 	BTFIXUPSET_HALF(pte_writei, _SUN4C_PAGE_WRITE);
 	BTFIXUPSET_HALF(pte_dirtyi, _SUN4C_PAGE_MODIFIED);
 	BTFIXUPSET_HALF(pte_youngi, _SUN4C_PAGE_ACCESSED);
include/asm-sparc/pgtsrmmu.h renamed from include/asm-sparc/pgtsrmmu.h.BAD +1 -0
@@ -73,6 +73,7 @@
 #define SRMMU_CACHE        0x80
 #define SRMMU_DIRTY        0x40
 #define SRMMU_REF          0x20
+#define SRMMU_NOREAD       0x10
 #define SRMMU_EXEC         0x08
 #define SRMMU_WRITE        0x04
 #define SRMMU_VALID        0x02 /* SRMMU_ET_PTE */
include/asm-sparc/pgtable.h renamed from include/asm-sparc/pgtable.h.BAD +21 -0
@@ -186,10 +186,31 @@
  * The following only work if pte_present() is true.
  * Undefined behaviour if not..
  */
+BTFIXUPDEF_HALF(pte_readi)
 BTFIXUPDEF_HALF(pte_writei)
 BTFIXUPDEF_HALF(pte_dirtyi)
 BTFIXUPDEF_HALF(pte_youngi)
 
+extern int pte_read(pte_t pte) __attribute_const__;
+extern __inline__ int pte_read(pte_t pte)
+{
+	switch (sparc_cpu_model){
+	case sun4:
+	case sun4c:
+		return pte_val(pte) & BTFIXUP_HALF(pte_readi);
+	case sun4d:
+	case sun4e:
+	case sun4m:
+		return !(pte_val(pte) & BTFIXUP_HALF(pte_readi));
+	/* pacify gcc warnings */
+	case sun4u:
+	case sun_unknown:
+	case ap1000:
+	default:
+		return 0;
+	}
+}
+
 extern int pte_write(pte_t pte) __attribute_const__;
 extern __inline__ int pte_write(pte_t pte)
 {
#2 lore raw
In reply to Art Haas
Quoted 5 lines · Art Haas
Quoted 5 lines

Here's my attempt at taking Bob Breuer's patch and adding in some of the BTFIXUP magic that sparc32 needs. I'm running the current BK kernel with this patch on my SS20, and things seem to work. The current kernel complains during bootup and shutdown about accessing the system clock, a problem I am guessing is related to changes elsewhere in the kernel.

Quoted 2 lines · Tom 'spot' Callaway

This patch only covers sun4m. The attached patch covers all sparc32.

Doing a quick doublecheck to be sure this actually applies before shipping upstream. Sorry about the delay, folks.

-- wli

maintainer
#3 lore raw
In reply to Art Haas
Quoted 7 lines · On Wed, 2 Feb 2005 14:40:19 -0800 William Lee Irwin III <[email protected]>…
Quoted 5 lines · Art Haas
Quoted 5 lines

Here's my attempt at taking Bob Breuer's patch and adding in some of the BTFIXUP magic that sparc32 needs. I'm running the current BK kernel with this patch on my SS20, and things seem to work. The current kernel complains during bootup and shutdown about accessing the system clock, a problem I am guessing is related to changes elsewhere in the kernel.

Quoted 6 lines
Quoted 2 lines · Tom 'spot' Callaway

This patch only covers sun4m. The attached patch covers all sparc32.

Doing a quick doublecheck to be sure this actually applies before shipping upstream. Sorry about the delay, folks.

I disagree with Tom's patch in that it puts this huge switch() statement inline. The whole point of BTFIXUP_HIGH() is that it resolves the call to a single instruction which can be easily patched at runtime.

If it's going to expand to multiple BTFIXUP_HIGH() calls and a switch statement, just make it a normal BTFIXUP() to a function and place the implementation in sun4c.c and sun4m.c

maintainer
#4 lore raw
In reply to Art Haas
Quoted 11 lines · On Wed, 2 Feb 2005 16:55:41 -0800 William Lee Irwin III <[email protected]>…

On Wed, 2 Feb 2005 14:40:19 -0800 William Lee Irwin III <[email protected]> wrote:

Quoted 7 lines · David S. Miller

I disagree with Tom's patch in that it puts this huge switch() statement inline. The whole point of BTFIXUP_HIGH() is that it resolves the call to a single instruction which can be easily patched at runtime.
If it's going to expand to multiple BTFIXUP_HIGH() calls and a switch statement, just make it a normal BTFIXUP() to a function and place the implementation in sun4c.c and sun4m.c

Quoted 4 lines

I'm on the road and people are antsy for something that builds, so I'm rather tempted to take it for expedience and properly BTFIXUP-ize it after 2.6.11, which appears rather imminent, since I basically won't push anything I've written myself but not tested.

No objection to using it as a short-term fix.

#5 lore raw
In reply to Art Haas
Quoted 2 lines · On Wed, 2 Feb 2005 14:40:19 -0800 William Lee Irwin III <[email protected]>…
Quoted 2 lines

Doing a quick doublecheck to be sure this actually applies before shipping upstream. Sorry about the delay, folks.

Quoted 7 lines · David S. Miller

I disagree with Tom's patch in that it puts this huge switch() statement inline. The whole point of BTFIXUP_HIGH() is that it resolves the call to a single instruction which can be easily patched at runtime.
If it's going to expand to multiple BTFIXUP_HIGH() calls and a switch statement, just make it a normal BTFIXUP() to a function and place the implementation in sun4c.c and sun4m.c

I'm on the road and people are antsy for something that builds, so I'm rather tempted to take it for expedience and properly BTFIXUP-ize it after 2.6.11, which appears rather imminent, since I basically won't push anything I've written myself but not tested. What I have in terms of remote access I've lost for want of time. There's also something of a reluctance to resynch before 2.6.11 out of disgust for certain changes and/or the manner in which they were merged.

Maybe I can cook something better up before my return flight while at the airport, though I'd be glad to see spot or ahaas get done before me.

-- wli

#6 lore raw
In reply to Art Haas
Quoted 8 lines · David S. Miller

I disagree with Tom's patch in that it puts this huge switch() statement inline. The whole point of BTFIXUP_HIGH() is that it resolves the call to a single instruction which can be easily patched at runtime.

If it's going to expand to multiple BTFIXUP_HIGH() calls and a switch statement, just make it a normal BTFIXUP() to a function and place the implementation in sun4c.c and sun4m.c

How about this instead?

~spot
---
Tom "spot" Callaway <tcallawa(a)redhat*com> LCA, RHCE Red Hat Sales Engineer || Aurora Linux Project Leader

"If you are going through hell, keep going."
-- Sir Winston Churchill

arch/sparc/mm/srmmu.c renamed from arch/sparc/mm/srmmu.c.BAD +4 -0
@@ -160,6 +160,9 @@
 static inline int srmmu_pte_present(pte_t pte)
 { return ((pte_val(pte) & SRMMU_ET_MASK) == SRMMU_ET_PTE); }
 
+static inline int srmmu_pte_read(pte_t pte)
+{ return !(pte_val(pte) & SRMMU_NOREAD); }
+
 static inline void srmmu_pte_clear(pte_t *ptep)
 { srmmu_set_pte(ptep, __pte(0)); }
 
@@ -2167,6 +2170,7 @@
 
 	BTFIXUPSET_CALL(pte_present, srmmu_pte_present, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(pte_clear, srmmu_pte_clear, BTFIXUPCALL_SWAPO0G0);
+	BTFIXUPSET_CALL(pte_read, srmmu_pte_read, BTFIXUPCALL_NORM);
 
 	BTFIXUPSET_CALL(pmd_bad, srmmu_pmd_bad, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(pmd_present, srmmu_pmd_present, BTFIXUPCALL_NORM);
arch/sparc/mm/sun4c.c renamed from arch/sparc/mm/sun4c.c.BAD +6 -0
@@ -1745,6 +1745,11 @@
 }
 static void sun4c_pte_clear(pte_t *ptep)	{ *ptep = __pte(0); }
 
+static int sun4c_pte_read(pte_t pte)
+{
+        return (pte_val(pte) & _SUN4C_PAGE_READ);
+}
+
 static int sun4c_pmd_bad(pmd_t pmd)
 {
 	return (((pmd_val(pmd) & ~PAGE_MASK) != PGD_TABLE) ||
@@ -2199,6 +2204,7 @@
 
 	BTFIXUPSET_CALL(pte_present, sun4c_pte_present, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(pte_clear, sun4c_pte_clear, BTFIXUPCALL_STG0O0);
+	BTFIXUPSET_CALL(pte_read, sun4c_pte_read, BTFIXUPCALL_NORM);
 
 	BTFIXUPSET_CALL(pmd_bad, sun4c_pmd_bad, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(pmd_present, sun4c_pmd_present, BTFIXUPCALL_NORM);
include/asm-sparc/pgtable.h renamed from include/asm-sparc/pgtable.h.BAD +2 -0
@@ -150,6 +150,7 @@
 BTFIXUPDEF_SETHI(none_mask)
 BTFIXUPDEF_CALL_CONST(int, pte_present, pte_t)
 BTFIXUPDEF_CALL(void, pte_clear, pte_t *)
+BTFIXUPDEF_CALL(int, pte_read, pte_t)
 
 extern __inline__ int pte_none(pte_t pte)
 {
@@ -158,6 +159,7 @@
 
 #define pte_present(pte) BTFIXUP_CALL(pte_present)(pte)
 #define pte_clear(pte) BTFIXUP_CALL(pte_clear)(pte)
+#define pte_read(pte) BTFIXUP_CALL(pte_read)(pte)
 
 BTFIXUPDEF_CALL_CONST(int, pmd_bad, pmd_t)
 BTFIXUPDEF_CALL_CONST(int, pmd_present, pmd_t)
include/asm-sparc/pgtsrmmu.h renamed from include/asm-sparc/pgtsrmmu.h.BAD +1 -0
@@ -73,6 +73,7 @@
 #define SRMMU_CACHE        0x80
 #define SRMMU_DIRTY        0x40
 #define SRMMU_REF          0x20
+#define SRMMU_NOREAD       0x10
 #define SRMMU_EXEC         0x08
 #define SRMMU_WRITE        0x04
 #define SRMMU_VALID        0x02 /* SRMMU_ET_PTE */
maintainer
#7 lore raw
In reply to Art Haas
Quoted 7 lines · On Wed, 02 Feb 2005 22:22:24 -0600 "Tom 'spot' Callaway" <[email protected]>…
Quoted 5 lines · David S. Miller

I disagree with Tom's patch in that it puts this huge switch() statement inline. The whole point of BTFIXUP_HIGH() is that it resolves the call to a single instruction which can be easily patched at runtime.

Quoted 5 lines
Quoted 3 lines

If it's going to expand to multiple BTFIXUP_HIGH() calls and a switch statement, just make it a normal BTFIXUP() to a function and place the implementation in sun4c.c and sun4m.c

How about this instead?

Perfect Tom.

#8 lore raw
In reply to Art Haas
Quoted 7 lines · David S. Miller
Quoted 7 lines

I disagree with Tom's patch in that it puts this huge switch() statement inline. The whole point of BTFIXUP_HIGH() is that it resolves the call to a single instruction which can be easily patched at runtime.
If it's going to expand to multiple BTFIXUP_HIGH() calls and a switch statement, just make it a normal BTFIXUP() to a function and place the implementation in sun4c.c and sun4m.c

Quoted 2 lines · Tom 'spot' Callaway

How about this instead?

I'll make sure this gets into 2.6.11-final.

-- wli