PERFORCE change 44796 for review
Juli Mallett
jmallett at FreeBSD.org
Sun Jan 4 17:43:02 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=44796
Change 44796 by jmallett at jmallett_oingo on 2004/01/04 17:42:37
Handle page sizing/masking appropriately, along with all the
fun bit shifting that goes along with that. Did this on a hunch,
due to bad things happening with allocated memory... And now I
see SI_SUB_VFS scroll by.
Affected files ...
.. //depot/projects/mips/sys/mips/include/pte.h#19 edit
.. //depot/projects/mips/sys/mips/mips/tlb.c#18 edit
Differences ...
==== //depot/projects/mips/sys/mips/include/pte.h#19 (text+ko) ====
@@ -67,13 +67,11 @@
#define MIPS_HI_FILL_MASK ((0x7FFFFFUL) << MIPS_HI_FILL_SHIFT)
#define MIPS_HI_VA_FILL(va) ((((va) & (1UL << 63)) != 0 ? MIPS_HI_FILL_MASK : 0))
#define MIPS_HI_VPN2_SHIFT (PAGE_SHIFT + 1)
-/* XXX VPN2 masking is wrong. Should trim off below VPN2_SHIFT, and from FILL_SHIFT up. */
#ifdef LOCORE
-#define MIPS_HI_VPN2_BMASK 0xFFFFFFF
+#define MIPS_HI_VPN2_MASK (((~((1 << MIPS_HI_VPN2_SHIFT) - 1)) << (63 - MIPS_HI_FILL_SHIFT)) >> (63 - MIPS_HI_FILL_SHIFT))
#else
-#define MIPS_HI_VPN2_BMASK 0xFFFFFFFUL
+#define MIPS_HI_VPN2_MASK (((~((1UL << MIPS_HI_VPN2_SHIFT) - 1)) << (63 - MIPS_HI_FILL_SHIFT)) >> (63 - MIPS_HI_FILL_SHIFT))
#endif
-#define MIPS_HI_VPN2_MASK (MIPS_HI_VPN2_BMASK << MIPS_HI_VPN2_SHIFT)
#define MIPS_HI_VA_TO_VPN2(va) ((va) & MIPS_HI_VPN2_MASK)
#define MIPS_HI_ENTRY(va, asid) ((MIPS_HI_VA_R((va))) /* Region. */ | \
(MIPS_HI_VA_FILL((va))) /* Fill. */ | \
==== //depot/projects/mips/sys/mips/mips/tlb.c#18 (text+ko) ====
@@ -66,12 +66,32 @@
static int tlb_maxasid = MIPS_TLB_NUM_ASIDS;
#endif
+/*
+ * Set up the page size, chop off the low PAGE_SHIFT bits,
+ * and then shift off the upper bits.
+ */
+static u_long
+tlb_pagemask(vm_size_t pageshift)
+{
+ u_long pm;
+
+ pm = ~0UL;
+ pm >>= PAGE_SHIFT + 1;
+ pm <<= PAGE_SHIFT + 1;
+ pm <<= 7;
+ pm >>= 7;
+
+ return (pm);
+}
+
void
tlb_bootstrap(vm_size_t pages, vm_offset_t (*ptalloc)(vm_size_t))
{
pt_entry_t *pte;
vm_size_t i;
+ mips_wr_pagemask(tlb_pagemask(PAGE_SHIFT));
+
/*
* Set up KPT.
*/
@@ -166,6 +186,7 @@
mips_wr_entrylo0(pte0);
mips_wr_entrylo1(pte1);
mips_wr_entryhi(ehi);
+ mips_wr_pagemask(tlb_pagemask(PAGE_SHIFT));
if (i < 0)
mips_tlbwr();
else
More information about the p4-projects
mailing list