Re: Kernel 2.4.8, XFree86 4.1.0


Subject: Re: Kernel 2.4.8, XFree86 4.1.0
From: Bill Fink (billfink@capu.net)
Date: Wed Aug 22 2001 - 21:45:00 MDT


On Wed Aug 22 2001, Sundar Amancherla wrote:

> I am not sure whether I am asking this at the right place. The question is
> about "mol". Since I changed the kernel. I recompiled
> mol-0.9.59-1a.src.rpm and mol-kmods-0.9.59-1.src.rpm. Now when I startmol
> after molvconfig, this is the stdout/stderr.
> +++++++++++++++++++++++++++++++++++++++++++++++++++
> =================================================================
> Mac-on-Linux 0.9.59 <www.maconlinux.org>
> (C) 1997-2001 Samuel Rydh <samuel@ibrium.se>
> =================================================================
> Loading the Mac-on-Linux kernel module.
> /usr/lib/mol/modules/mol.o: unresolved symbol MUNGE_CONTEXT

Aman,

The mol-0.9.59-1a.src.rpm and mol-kmods-0.9.59-1.src.rpm RPMs that
come with YDL 2.0 require the attached patches (slightly modified from
one posted by Samuel Rydh to apply cleanly) to build properly on newer
2.4 kernels because of a change to the memory management organization.
Alternatively, you can try the newer experimental 0.9.60 version of mol.
I can only vouch for this with the 2.4.6 kernel, but it'll hopefully
also work fine with even newer 2.4 kernels.

                                                -Bill

mol-0.9.59-mm.patch:
--------------------------------------------------------------------------------
diff -ur mol-0.9.59.dist/debugger/mmu_cmds.c mol-0.9.59.mod/debugger/mmu_cmds.c
--- mol-0.9.59.dist/debugger/mmu_cmds.c Sat May 12 19:16:47 2001
+++ mol-0.9.59.mod/debugger/mmu_cmds.c Fri Jul 6 04:17:25 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 );
diff -ur mol-0.9.59.dist/emulation/mainloop_asm.S mol-0.9.59.mod/emulation/mainloop_asm.S
--- mol-0.9.59.dist/emulation/mainloop_asm.S Sat May 12 19:16:46 2001
+++ mol-0.9.59.mod/emulation/mainloop_asm.S Fri Jul 6 04:17:25 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
--------------------------------------------------------------------------------

mol-kmods-0.9.59-mm.patch:
--------------------------------------------------------------------------------
diff -ur mol-kmods-0.9.59.dist/kernel_module/emu.c mol-kmods-0.9.59.mod/kernel_module/emu.c
--- mol-kmods-0.9.59.dist/kernel_module/emu.c Sat May 12 19:16:46 2001
+++ mol-kmods-0.9.59.mod/kernel_module/emu.c Fri Jul 6 05:13:23 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;
diff -ur mol-kmods-0.9.59.dist/kernel_module/hook.c mol-kmods-0.9.59.mod/kernel_module/hook.c
--- mol-kmods-0.9.59.dist/kernel_module/hook.c Sat May 12 19:16:47 2001
+++ mol-kmods-0.9.59.mod/kernel_module/hook.c Fri Jul 6 05:13:23 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;
diff -ur mol-kmods-0.9.59.dist/kernel_module/include/mmu.h mol-kmods-0.9.59.mod/kernel_module/include/mmu.h
--- mol-kmods-0.9.59.dist/kernel_module/include/mmu.h Sat May 12 19:16:46 2001
+++ mol-kmods-0.9.59.mod/kernel_module/include/mmu.h Fri Jul 6 05:13:23 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 */
diff -ur mol-kmods-0.9.59.dist/kernel_module/linux.S mol-kmods-0.9.59.mod/kernel_module/linux.S
--- mol-kmods-0.9.59.dist/kernel_module/linux.S Sat May 12 19:16:47 2001
+++ mol-kmods-0.9.59.mod/kernel_module/linux.S Fri Jul 6 05:13:23 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
diff -ur mol-kmods-0.9.59.dist/kernel_module/mmu.c mol-kmods-0.9.59.mod/kernel_module/mmu.c
--- mol-kmods-0.9.59.dist/kernel_module/mmu.c Sat May 12 19:16:46 2001
+++ mol-kmods-0.9.59.mod/kernel_module/mmu.c Fri Jul 6 05:15:23 2001
@@ -1,7 +1,7 @@
 /**************************************************************
 *
 * Creation Date: <1998-11-11 11:56:45 samuel>
-* Time-stamp: <2001/04/16 13:18:51 samuel>
+* Time-stamp: <2001/06/24 20:04:12 samuel>
 *
 * <mmu.c>
 *
@@ -145,8 +145,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
@@ -504,6 +505,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.
@@ -520,8 +536,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 */
@@ -537,9 +553,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;
 
@@ -659,14 +678,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;
 }
 
@@ -692,7 +707,7 @@
 **************************************************************/
 
 void
-do_flush( ulong context, ulong va )
+do_flush( ulong context, ulong va, ulong *ptep )
 {
         int i;
         kernel_vars_t **kvp;
@@ -841,7 +856,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;
diff -ur mol-kmods-0.9.59.dist/kernel_module/mmu_vsid.c mol-kmods-0.9.59.mod/kernel_module/mmu_vsid.c
--- mol-kmods-0.9.59.dist/kernel_module/mmu_vsid.c Sat May 12 19:16:46 2001
+++ mol-kmods-0.9.59.mod/kernel_module/mmu_vsid.c Fri Jul 6 05:13:23 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;
 
diff -ur mol-kmods-0.9.59.dist/kernel_module/molsymglue.c mol-kmods-0.9.59.mod/kernel_module/molsymglue.c
--- mol-kmods-0.9.59.dist/kernel_module/molsymglue.c Sat May 12 19:16:47 2001
+++ mol-kmods-0.9.59.mod/kernel_module/molsymglue.c Fri Jul 6 05:13:23 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
--------------------------------------------------------------------------------



This archive was generated by hypermail 2a24 : Wed Aug 22 2001 - 20:53:30 MDT