Re: Current MoL rsync does not build against benh's 2.4.6-pre3


Subject: Re: Current MoL rsync does not build against benh's 2.4.6-pre3
From: Samuel Rydh (samuel@ibrium.se)
Date: Mon Jun 25 2001 - 19:00:21 MDT


On Mon, Jun 25, 2001 at 03:32:12PM -0700, Michael Blakeley wrote:
> Ben's 2.4.6 no longer locks up the airport, but mol-rsync still stops
> with the missing SEGREG and MUNGE_CONTEXT errors. Copying them from
> an older kernel just drops me into xmon when I try to run startmol.
>
> Anyone know what the SEGREG and MUNGE_CONTEXT were all about, and why
> they disappeared?

Paul's changes to the MM layer are included in 2.4.6. The
included patch from Paul makes MOL compatible with
the new MM code. I will push it to the bitkeeper tree
once I have fixed backward compatibility.

BTW: The MOL bitkeeper and rsync services are currently
*down* due to maintenance.

===== debugger/mmu_cmds.c 1.7 vs edited =====
--- 1.7/debugger/mmu_cmds.c Sun Apr 15 19:27:38 2001
+++ edited/debugger/mmu_cmds.c Sun Jun 24 19:57:26 2001
@@ -26,16 +26,17 @@
 #include "nub.h"
 
 /* borrowed from the headerfile <asm/pgtable.h> */
-#define _PAGE_PRESENT 0x001 /* software: pte contains a translation */
-#define _PAGE_USER 0x002 /* matches one of the PP bits */
-#define _PAGE_RW 0x004 /* software: user write access allowed */
-#define _PAGE_GUARDED 0x008
-#define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
-#define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
-#define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
-#define _PAGE_DIRTY 0x080 /* C: page changed */
-#define _PAGE_ACCESSED 0x100 /* R: page referenced */
-#define _PAGE_HWWRITE 0x200 /* software: _PAGE_RW & _PAGE_DIRTY */
+#define _PAGE_PRESENT 0x001 /* software: pte contains a translation */
+#define _PAGE_HASHPTE 0x002 /* hash_page has made an HPTE for this pte */
+#define _PAGE_USER 0x004 /* usermode access allowed */
+#define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
+#define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
+#define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
+#define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
+#define _PAGE_DIRTY 0x080 /* C: page changed */
+#define _PAGE_ACCESSED 0x100 /* R: page referenced */
+#define _PAGE_EXEC 0x200 /* software: i-cache coherency required */
+#define _PAGE_RW 0x400 /* software: user write access allowed */
 
 static int cmd_tea( int, char**); /* translate data ea */
 static int cmd_itea( int, char**); /* translate inst ea */
@@ -452,6 +453,7 @@
         }
         printm("LV: %08lX ",(ulong)lvptr&0xfffff000);
         printm( (pte & _PAGE_PRESENT)? "[P" : "[p");
+ printm( (pte & _PAGE_HASHPTE)? "H": "h");
         printm( (pte & _PAGE_USER)? " U" : " u");
         printm( (pte & _PAGE_RW)? "W" : "w");
         printm( (pte & _PAGE_GUARDED)? "G" : "g");
@@ -459,8 +461,7 @@
         printm( (pte & _PAGE_DIRTY)? "C" : "c");
         printm( (pte & _PAGE_WRITETHRU)? " W" : " w");
         printm( (pte & _PAGE_NO_CACHE)? "I" : "i");
- printm( (pte & _PAGE_COHERENT)? "M" : "m");
- printm( (pte & _PAGE_HWWRITE)? " 1]" : " 0]");
+ printm( (pte & _PAGE_COHERENT)? "M]" : "m]");
 
         printm(" PPN: %08lX\n",
                pte & 0xfffff000 );
===== emulation/mainloop_asm.S 1.13 vs edited =====
--- 1.13/emulation/mainloop_asm.S Thu Jun 21 15:12:04 2001
+++ edited/emulation/mainloop_asm.S Sun Jun 24 19:57:27 2001
@@ -87,7 +87,7 @@
 .macro SETVEC, name, rvec, func, scr, scr2
         bl 1f
         .ascii "\name\0"
- .balign 4
+ .balign 4,0
 1:
         LOADI \scr,gRVECtable
         LOADI \scr2,\func
===== kernel_module/linux.S 1.5 vs edited =====
--- 1.5/kernel_module/linux.S Wed Apr 18 19:43:33 2001
+++ edited/kernel_module/linux.S Mon Jun 25 00:50:09 2001
@@ -1,6 +1,6 @@
 /*
  * Creation Date: <2001/02/24 14:08:28 samuel>
- * Time-stamp: <2001/04/16 12:52:07 samuel>
+ * Time-stamp: <2001/06/25 00:50:09 samuel>
  *
  * <platform.S>
  *
@@ -14,18 +14,18 @@
  *
  */
 
-#ifdef LINUX_VERSION_CODE
         
         ////////////////////////////////////////////////////////
         // flush_hash_page_hook
         //
         // Kernel hook
         //
- // r3: context (vsid>>4)
+ // r3: context
         // r4: virtual address
+ // r5: pointer to linux PTE (2.4.6 or later)
         // r10: return address
         //
- // [must not modify: r3,r4,r10 - otherwise normal C-function]
+ // [must not modify: r3-r5,r10 - otherwise normal C-function]
         // MMU is ON
 
 .set STACK_SPACE, 32
@@ -34,48 +34,10 @@
 .set STACK_V1, 12
 .set STACK_V2, 16
 .set STACK_V3, 20
-
+.set STACK_V4, 24
 
 FHOOK( FHOOK_FLUSH_HASH_PAGE )
 GLOBAL_SYMBOL( r__flush_hash_page_hook ):
-#if 1
- stwu r1,-STACK_SPACE(r1) // Push stackframe
- mflr r0
- stw r0,STACK_LR(r1)
-
- stw r10,STACK_V1(r1) // Save registers
- stw r3,STACK_V2(r1)
- stw r4,STACK_V3(r1)
-
- LI_VIRT( r7,do_flush )
- mtctr r7
- bctrl
-
- lwz r10,STACK_V1(r1) // Restore registers
- lwz r3,STACK_V2(r1)
- lwz r4,STACK_V3(r1)
-
- lwz r0,STACK_LR(r1) // Pop stackframe
- addi r1,r1,STACK_SPACE
- mtlr r0
- blr
-
-#else
-#if 0
- LI_VIRT_VARBASE(r9)
-#else
- /**************** XXXXXXXXXXXXXXXXXXXX FIXME XXXXXXXXXXXXXX ********************/
- LI_VIRT(r7, k_session_table_virt) // for now, lets just use kvars[0]
- lwz r9,0(r7)
-#endif
- lwz r7,K_SEGR_EMULATOR(r9) // emualtor segreg
- cmpwi r7,0 // zero ? */
- beqlr
- rlwinm r7,r7,0,8,27 // VSID base (24-4 bits)
- rlwinm r8,r3,4,8,27
- cmpw r7,r8
- bnelr // not emulator
-
         stwu r1,-STACK_SPACE(r1) // Push stackframe
         mflr r0
         stw r0,STACK_LR(r1)
@@ -83,6 +45,7 @@
         stw r10,STACK_V1(r1) // Save registers
         stw r3,STACK_V2(r1)
         stw r4,STACK_V3(r1)
+ stw r5,STACK_V4(r1)
                 
         LI_VIRT( r7,do_flush )
         mtctr r7
@@ -91,10 +54,9 @@
         lwz r10,STACK_V1(r1) // Restore registers
         lwz r3,STACK_V2(r1)
         lwz r4,STACK_V3(r1)
+ lwz r5,STACK_V4(r1)
 
         lwz r0,STACK_LR(r1) // Pop stackframe
         addi r1,r1,STACK_SPACE
         mtlr r0
         blr
-#endif
-#endif
\ No newline at end of file
===== kernel_module/emu.c 1.12 vs edited =====
--- 1.12/kernel_module/emu.c Thu Jun 21 15:12:04 2001
+++ edited/kernel_module/emu.c Sun Jun 24 19:57:28 2001
@@ -79,8 +79,12 @@
          * user_sr is used if key=1, otherwise sv_sr is used.
          * Bit3 is the no-execute bit (now supported).
          */
- user_sr |= (value & (0xf | BIT(3))) | BIT(2);
- sv_sr |= (value & (0xf | BIT(3))) | BIT(2);
+ user_sr |= (value & BIT(3)) | BIT(2);
+ user_sr += (value & 0xf) * 0x111;
+ user_sr &= ~BIT(7); /* mask off overflow from VSID field */
+ sv_sr |= (value & BIT(3)) | BIT(2);
+ sv_sr += (value & 0xf) * 0x111;
+ sv_sr &= ~BIT(7); /* mask off overflow from VSID field */
 
         kv->mmu.user_sr[sr] = (value & BIT(2)) ? user_sr : sv_sr;
         kv->mmu.sv_sr[sr] = (value & BIT(1)) ? user_sr : sv_sr;
===== kernel_module/mmu.c 1.28 vs edited =====
--- 1.28/kernel_module/mmu.c Sat Jun 16 17:24:22 2001
+++ edited/kernel_module/mmu.c Sun Jun 24 20:04:12 2001
@@ -1,7 +1,7 @@
 /**************************************************************
 *
 * Creation Date: <1998-11-11 11:56:45 samuel>
-* Time-stamp: <2001/06/16 17:14:16 samuel>
+* Time-stamp: <2001/06/24 20:04:12 samuel>
 *
 * <mmu.c>
 *
@@ -39,6 +39,17 @@
 #include "misc.h"
 #include "rvec.h"
 
+/* Segment Register */
+typedef struct _SEGREG {
+ unsigned long t:1; /* Normal or I/O type */
+ unsigned long ks:1; /* Supervisor 'key' (normally 0) */
+ unsigned long kp:1; /* User 'key' (normally 1) */
+ unsigned long n:1; /* No-execute */
+ unsigned long :4; /* Unused */
+ unsigned long vsid:24; /* Virtual Segment Identifier */
+} SEGREG;
+
+
 // #define DEBUG_FORCE_601_SPLITMODE
 #define PERFORMANCE_INFO
 #include "performance.h"
@@ -175,8 +186,9 @@
 
         // setup unmapped context
         for(i=0; i<16; i++) {
- MMU.split_sr[i] = MMU.illegal_sr + i; // for the 601 only
- MMU.unmapped_sr[i] = sr_unmapped + i;
+ // MMU.split_sr is for the 601 only
+ MMU.split_sr[i] = (MMU.illegal_sr + i * 0x111) & ~0x01000000;
+ MMU.unmapped_sr[i] = (sr_unmapped + i * 0x111) & ~0x01000000;
         }
 
         // Invalidate all VSIDs in order to make sure
@@ -534,6 +546,21 @@
         return NULL;
 }
 
+/* stolen from include/asm-ppc/pgtable.h */
+static inline unsigned long update_pte(ulong *p, unsigned long set)
+{
+ unsigned long old, tmp;
+
+ __asm__ __volatile__("\
+1: lwarx %0,0,%3\n\
+ or %1,%0,%4\n\
+ stwcx. %1,0,%3\n\
+ bne- 1b"
+ : "=&r" (old), "=&r" (tmp), "=m" (*p)
+ : "r" (p), "r" (set), "m" (*p)
+ : "cc" );
+ return old;
+}
 
 /*
  * Get physical page corresponding to linux virtual address.
@@ -550,8 +577,8 @@
         struct mm_struct *mm;
         struct vm_area_struct *vma;
 
- // _PAGE_USER (bit30), _PAGE_RW (bit29), _PAGE_PRESENT (bit31)
- flags = request_rw ? 0x7 : 0x3;
+ // _PAGE_USER (0x4), _PAGE_RW (0x400), _PAGE_PRESENT (0x1)
+ flags = request_rw ? 0x405 : 0x5;
         
 #ifdef LINUX_24
         uptr = ((ulong*)current->thread.pgdir)[va>>22]; /* top 10 bits */
@@ -567,9 +594,12 @@
         if( flags & ~val ) /* check access priv */
                 goto no_page;
 
- // 0x100 == _PAGE_ACCESSED, _PAGE_DIRTY(bit24), _PAGE_HWWRITE(bit 22)
- val |= request_rw? 0x100 + BIT(24) + BIT(22) : 0x100;
- *ptr = val;
+ // 0x100 == _PAGE_ACCESSED, _PAGE_DIRTY(bit24), 0x2 = _PAGE_HASHPTE
+ // we set _PAGE_HASHPTE in order to ensure that we get to
+ // know about TLB invalidations for this page via our
+ // flush_hash_page hook.
+ update_pte(ptr, (request_rw? 0x102 + BIT(24) : 0x102));
+ // printk("pte at %p was %lx now %lx\n", ptr, val, *ptr);
 
         return val & 0xfffff000;
 
@@ -689,14 +719,10 @@
                 }
         
         // just grab a slot
- grab_add = (grab_add+1) & 0xf;
+ grab_add = (grab_add+1) & 0x7;
 
         // printk("Grabbing slot %d, EA %08X\n",grab_add, ea );
 
- if( grab_add>7 ) {
- pte->h=1;
- return ((PTE*)(pteg^(hw_hash_mask<<6))) + grab_add-8;
- }
         return (PTE*)pteg + grab_add;
 }
 
@@ -722,7 +748,7 @@
 **************************************************************/
 
 void
-do_flush( ulong context, ulong va )
+do_flush( ulong context, ulong va, ulong *ptep )
 {
         int i;
         kernel_vars_t **kvp;
@@ -871,7 +897,7 @@
                 vsid = MMU.user_sr[va>>28];
                 break;
         case kContextEmulator:
- vsid = (MMU.emulator_context << 4) | (va>>28);
+ vsid = (MUNGE_CONTEXT(MMU.emulator_context) + ((va>>28) * 0x111)) & 0xffffff;
                 break;
         case kContextKernel:
                 vsid = 0;
===== kernel_module/mmu_vsid.c 1.8 vs edited =====
--- 1.8/kernel_module/mmu_vsid.c Sun Apr 15 19:27:39 2001
+++ edited/kernel_module/mmu_vsid.c Sun Jun 24 19:57:30 2001
@@ -197,7 +197,7 @@
         vsid = MUNGE_CONTEXT( vsid );
 
         vd->cache[1]=*user_ret = vsid << 4;
- vd->cache[2]=*su_ret = ((vsid + 897) & LAST_CONTEXT) << 4;
+ vd->cache[2]=*su_ret = ((vsid + 897) & CTX_MASK) << 4;
         
         cword.s.lvsid = vsid;
 
===== kernel_module/hook.c 1.3 vs edited =====
--- 1.3/kernel_module/hook.c Sat Apr 21 20:33:44 2001
+++ edited/kernel_module/hook.c Sun Jun 24 20:17:10 2001
@@ -1,6 +1,6 @@
 /*
  * Creation Date: <2001/04/07 17:33:52 samuel>
- * Time-stamp: <2001/04/21 17:14:38 samuel>
+ * Time-stamp: <2001/06/24 20:17:10 samuel>
  *
  * <hook.c>
  *
@@ -319,7 +319,7 @@
         /* we need to spin here for a while to ensure that no
          * processor is in the destroyed code.
          */
- usleep(1000);
+// usleep(1000);
 #endif
         lowmem_free_all();
         hooks_written = 0;
===== kernel_module/molsymglue.c 1.1 vs edited =====
--- 1.1/kernel_module/molsymglue.c Mon Apr 9 22:24:25 2001
+++ edited/kernel_module/molsymglue.c Sun Jun 24 19:57:31 2001
@@ -50,6 +50,8 @@
 ulong mc_next_mmu_context = 0;
 ulong mc_giveup_altivec = 0; /* used only for 2.2 */
 
+int next_mol_context = 32768;
+
 EXPORT_SYMBOL_NOVERS( mc_flush_hash_page );
 EXPORT_SYMBOL_NOVERS( mc_handle_mm_fault );
 EXPORT_SYMBOL_NOVERS( mc_molif );
@@ -83,7 +85,7 @@
 
         mc_flush_hash_page = (ulong)&flush_hash_page;
         mc_handle_mm_fault = (ulong)&handle_mm_fault;
- mc_next_mmu_context = (ulong)&next_mmu_context;
+ mc_next_mmu_context = (ulong)&next_mol_context;
         SET_GIVEUP_ALTIVEC;
         
 #elif COMPAT == 2
===== kernel_module/include/mmu.h 1.10 vs edited =====
--- 1.10/kernel_module/include/mmu.h Sun Apr 15 19:27:38 2001
+++ edited/kernel_module/include/mmu.h Sun Jun 24 19:57:29 2001
@@ -57,7 +57,7 @@
 
 extern void clear_tlb_table( kernel_vars_t *kv );
 extern void do_tlbia( kernel_vars_t *kv );
-extern void do_flush( ulong vsid, ulong va );
+extern void do_flush( ulong vsid, ulong va, ulong *ptep );
 
 extern void mmu_add_map( kernel_vars_t *kv, struct mmu_mapping *m );
 extern void mmu_remove_map( kernel_vars_t *kv, struct mmu_mapping *m );
@@ -126,6 +126,11 @@
 extern int get_PTE( kernel_vars_t *kv, int context, ulong va, PTE *ret );
 extern int get_physical_pte( ulong va, ulong *retptr );
 extern int dbg_translate_ea( kernel_vars_t *kv, int context, ulong va, PTE *retpte, int data_access );
+
+#ifndef MUNGE_CONTEXT
+#define CTX_MASK 0xfffff
+#define MUNGE_CONTEXT(c) (((c) * 897) & CTX_MASK)
+#endif
 
 #endif /* __ASSEMBLY__ */
 #endif /* _H_MMU */

----------------------------------------------------------
 E-mail <samuel@ibrium.se> WWW: <http://www.ibrium.se>
  Phone/fax: (home) +46 8 4418431, (work) +46 8 7908470
----------------------------------------------------------



This archive was generated by hypermail 2a24 : Mon Jun 25 2001 - 18:06:21 MDT