From: Paul M. <pau...@no...> - 2005-02-06 15:04:55
|
On Fri, Feb 04, 2005 at 07:28:47PM +0000, Stuart MENEFY wrote: > On Fri, 4 Feb 2005 17:36:11 +0200 Paul Mundt <pau...@no...> wrote: > > Eek, no. This is the fundamental basis for PAGE_SHARED, which we need f= or > > page protection (see for instance the mmap protection_map). >=20 > Are you sure? Back in the dim and distant past (2.3.? - 2.4.5) this was > used to implement cache flushing of shared pages to overcome D-cache > aliasing problems. However in recent 2.4 and 2.6 kernels I can't find > anything which actually uses it. Yes, it is set, but I can't find anything > which ever tests it. >=20 Looking into early 2.4, there was a software _PAGE_SHARED bit, it seems that this was being used for pte_shared() (with appropriate dcache purging in update_mmu_cache()), which seemed fairly short lived. _PAGE_U0_SHARED was introduced at 2.4.1-pre9 time by NIIBE-san: 2001-01-23 NIIBE Yutaka <gn...@m1...> [ ... ] * include/asm-sh/pgtable.h (_PAGE_SHARED): Always _PAGE_U0_SHARED. (was conditionally _PAGE_HW_SHARED on SH-3). With _PAGE_HW_SHARED, all processes share the page, while proper semantics is "some processes share the page". (flush_cache_sigtramp): New function. * Updated to 2.4.1-pre9. [ ... ] since then this is being used for _PAGE_SHARED, but looking closer, I likew= ise don't see anything explicitly testing for it. pte_shared() was later removed, but the _PAGE_SHARED stuff remained: 2001-06-30 NIIBE Yutaka <gn...@m1...> [ ... ] * arch/sh/mm/fault.c (update_mmu_cache): Removed pte_shared handling. (__flush_tlb_phys): Removed. * include/asm-sh/pgtable.h (pte_shared): Removed. Given that, this is probably a left over artifact of pte_shared() and with that gone, we can probably get away with reallocating this bit for _PAGE_FI= LE and freeing up the WT bit (though this will probably want some testing to m= ake sure that things like MAP_SHARED mmaps aren't breaking all over themselves). Perhaps something like this (completely untested).. --- orig/include/asm-sh/pgtable.h +++ mod/include/asm-sh/pgtable.h @@ -64,10 +64,8 @@ #define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */ #define _PAGE_PRESENT 0x100 /* V-bit : page is valid */ #define _PAGE_PROTNONE 0x200 /* software: if not present */ -#define _PAGE_ACCESSED 0x400 /* software: page referenced */ -#define _PAGE_U0_SHARED 0x800 /* software: page is shared in user space */ - -#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */ +#define _PAGE_ACCESSED 0x400 /* software: page referenced */ +#define _PAGE_FILE 0x800 /* software: pagecache or swap? */ =20 /* software: moves to PTEA.TC (Timing Control) */ #define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */ @@ -83,11 +81,8 @@ #define _PAGE_PCC_ATR16 0x60000001 /* Attribute Memory space, 6 bit bus */ =20 =20 -/* Mask which drop software flags - * We also drop WT bit since it is used for _PAGE_FILE - * bit in this implementation. - */ -#define _PAGE_CLEAR_FLAGS (_PAGE_WT | _PAGE_PROTNONE | _PAGE_ACCESSED | _P= AGE_U0_SHARED) +/* Mask which drop software flags */ +#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_FILE) =20 #if defined(CONFIG_CPU_SH3) /* @@ -108,15 +103,13 @@ #define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1) #endif =20 -#define _PAGE_SHARED _PAGE_U0_SHARED - #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSE= D | _PAGE_DIRTY) #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_D= IRTY) -#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE= _DIRTY | _PAGE_SHARED) +#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE= _DIRTY) =20 #ifdef CONFIG_MMU #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE |_PAGE_ACCESSED= | _PAGE_FLAGS_HARD) -#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE= _CACHABLE |_PAGE_ACCESSED | _PAGE_SHARED | _PAGE_FLAGS_HARD) +#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE= _CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD) #define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _= PAGE_ACCESSED | _PAGE_FLAGS_HARD) #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE= | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | _= PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD) @@ -209,6 +202,7 @@ } =20 #define pgprot_writecombine(prot) __pgprot(pgprot_val(prot) & ~_PAGE_CACHA= BLE) +#define pgprot_writethrough(prot) __pgprot(pgprot_val(prot) | _PAGE_WT) =20 /* * Conversion functions: convert a page and protection to a page entry, |