--- head.S-orig Tue Feb 1 14:33:58 2000 +++ head.S Tue Feb 1 14:49:47 2000 @@ -903,8 +903,14 @@ ori r21,r21,1 /* Set valid bit */ mtspr MI_TWC, r21 /* Set page attributes */ mtspr MD_TWC, r21 /* Load pte table base address */ - mfspr r21, MD_TWC /* ....and get the pte address */ - lwz r21, 0(r21) /* Get the pte */ + mfspr r20, MD_TWC /* ....and get the pte address */ + lwz r21, 0(r20) /* Get the pte */ + andi. r21, r21, _PAGE_PRESENT /* Set cr0 if it's invalid */ + lwz r21, 0(r20) /* Get the pte again */ + beq 3f /* Skip update if invalid */ + ori r21, r21, _PAGE_ACCESSED /* Set the accessed flag */ + stw r21, 0(r20) /* Update the pte */ +3: /* Set four subpage valid bits (24, 25, 26, and 27). * Since we currently run MI_CTR.PPCS = 0, the manual says, @@ -1025,8 +1031,22 @@ tophys(r21, r21, 0) ori r21, r21, 1 /* Set valid bit in physical L2 page */ mtspr MD_TWC, r21 /* Load pte table base address */ - mfspr r20, MD_TWC /* ....and get the pte address */ - lwz r20, 0(r20) /* Get the pte */ + stw r21, 8(r0) /* Save a copy of pte base address */ + mfspr r21, MD_TWC /* ....and get the pte address */ + lwz r20, 0(r21) /* Get the pte */ + andi. r20, r20, _PAGE_PRESENT /* Set cr0 if it's invalid */ + beq 4f /* Skip update if invalid */ + mfspr r20, DSISR /* Check for store op */ + andis. r20, r20, 0x0200 /* If set, indicates store */ + lwz r20, 0(r21) /* Get the pte again */ + beq 3f + ori r20, r20, _PAGE_DIRTY|_PAGE_HWWRITE /* Set the dirty flags */ +3: + ori r20, r20, _PAGE_ACCESSED /* Set the accessed flag */ + stw r20, 0(r21) /* Update the pte */ +4: + lwz r20, 0(r21) /* Get the pte again */ + lwz r21, 8(r0) /* Restore pte base address */ /* Insert the Guarded flag into the TWC from the Linux PTE. * It is bit 27 of both the Linux PTE and the TWC (at least @@ -1121,7 +1141,7 @@ andi. r20, r21, _PAGE_RW /* Is it writeable? */ beq 2f /* Bail out if not */ - ori r21, r21, _PAGE_DIRTY /* Update changed bit */ + ori r21, r21, _PAGE_DIRTY|_PAGE_HWWRITE|_PAGE_ACCESSED mfspr r20, MD_TWC /* Get pte address again */ stw r21, 0(r20) /* and update pte in table */