Commit f31e94ef authored by Anton Blanchard's avatar Anton Blanchard

ppc64: stage 1 of hash_page/flush_hash_page rewrite - only random

cleanups
parent 2b6cf10a
...@@ -71,10 +71,6 @@ extern unsigned long _SDR1; ...@@ -71,10 +71,6 @@ extern unsigned long _SDR1;
extern unsigned long klimit; extern unsigned long klimit;
extern struct Naca *naca; extern struct Naca *naca;
extern unsigned long _ASR;
extern inline void make_ste(unsigned long stab,
unsigned long esid, unsigned long vsid);
extern char _stext[], _etext[], __start_naca[], __end_stab[]; extern char _stext[], _etext[], __start_naca[], __end_stab[];
static spinlock_t hash_table_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; static spinlock_t hash_table_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
...@@ -788,12 +784,11 @@ void hpte_init_pSeries(void) ...@@ -788,12 +784,11 @@ void hpte_init_pSeries(void)
ppc_md.hpte_find = hpte_find_pSeries; ppc_md.hpte_find = hpte_find_pSeries;
} }
/* Handle a fault by adding an HPTE /*
* If the address can't be determined to be valid * Handle a fault by adding an HPTE. If the address can't be determined
* via Linux page tables, return 1. If handled * to be valid via Linux page tables, return 1. If handled return 0
* return 0
*/ */
int hash_page( unsigned long ea, unsigned long access ) int hash_page(unsigned long ea, unsigned long access)
{ {
int rc = 1; int rc = 1;
void * pgdir = NULL; void * pgdir = NULL;
...@@ -801,31 +796,29 @@ int hash_page( unsigned long ea, unsigned long access ) ...@@ -801,31 +796,29 @@ int hash_page( unsigned long ea, unsigned long access )
unsigned long newpp, hash_ind, prpn; unsigned long newpp, hash_ind, prpn;
unsigned long hpteflags, regionid; unsigned long hpteflags, regionid;
long slot; long slot;
struct mm_struct * mm; struct mm_struct *mm;
pte_t old_pte, new_pte, *ptep; pte_t old_pte, new_pte, *ptep;
/* Check for invalid addresses. */ /* Check for invalid addresses. */
if (!IS_VALID_EA(ea)) { if (!IS_VALID_EA(ea))
return 1; return 1;
}
regionid = REGION_ID(ea); regionid = REGION_ID(ea);
switch ( regionid ) { switch ( regionid ) {
case USER_REGION_ID: case USER_REGION_ID:
mm = current->mm; mm = current->mm;
if ( mm == NULL ) { if (mm == NULL)
PPCDBG(PPCDBG_MM, "hash_page returning; mm = 0\n");
return 1; return 1;
}
vsid = get_vsid(mm->context, ea ); vsid = get_vsid(mm->context, ea);
break; break;
case IO_REGION_ID: case IO_REGION_ID:
mm = &ioremap_mm; mm = &ioremap_mm;
vsid = get_kernel_vsid( ea ); vsid = get_kernel_vsid(ea);
break; break;
case VMALLOC_REGION_ID: case VMALLOC_REGION_ID:
mm = &init_mm; mm = &init_mm;
vsid = get_kernel_vsid( ea ); vsid = get_kernel_vsid(ea);
break; break;
#ifdef CONFIG_PPC_EEH #ifdef CONFIG_PPC_EEH
case IO_UNMAPPED_REGION_ID: case IO_UNMAPPED_REGION_ID:
...@@ -835,7 +828,8 @@ int hash_page( unsigned long ea, unsigned long access ) ...@@ -835,7 +828,8 @@ int hash_page( unsigned long ea, unsigned long access )
break; break;
#endif #endif
case KERNEL_REGION_ID: case KERNEL_REGION_ID:
/* As htab_initialize is now, we shouldn't ever get here since /*
* As htab_initialize is now, we shouldn't ever get here since
* we're bolting the entire 0xC0... region. * we're bolting the entire 0xC0... region.
*/ */
udbg_printf("Little faulted on kernel address 0x%lx\n", ea); udbg_printf("Little faulted on kernel address 0x%lx\n", ea);
...@@ -849,7 +843,7 @@ int hash_page( unsigned long ea, unsigned long access ) ...@@ -849,7 +843,7 @@ int hash_page( unsigned long ea, unsigned long access )
} }
/* Search the Linux page table for a match with va */ /* Search the Linux page table for a match with va */
va = ( vsid << 28 ) | ( ea & 0x0fffffff ); va = (vsid << 28) | (ea & 0x0fffffff);
vpn = va >> PAGE_SHIFT; vpn = va >> PAGE_SHIFT;
pgdir = mm->pgd; pgdir = mm->pgd;
PPCDBG(PPCDBG_MM, "hash_page ea = 0x%16.16lx, va = 0x%16.16lx\n current = 0x%16.16lx, access = %lx\n", ea, va, current, access); PPCDBG(PPCDBG_MM, "hash_page ea = 0x%16.16lx, va = 0x%16.16lx\n current = 0x%16.16lx, access = %lx\n", ea, va, current, access);
...@@ -870,7 +864,8 @@ int hash_page( unsigned long ea, unsigned long access ) ...@@ -870,7 +864,8 @@ int hash_page( unsigned long ea, unsigned long access )
return 1; return 1;
} }
/* Acquire the hash table lock to guarantee that the linux /*
* Acquire the hash table lock to guarantee that the linux
* pte we fetch will not change * pte we fetch will not change
*/ */
spin_lock( &hash_table_lock ); spin_lock( &hash_table_lock );
...@@ -1046,7 +1041,7 @@ int hash_page( unsigned long ea, unsigned long access ) ...@@ -1046,7 +1041,7 @@ int hash_page( unsigned long ea, unsigned long access )
return rc; return rc;
} }
void flush_hash_page( unsigned long context, unsigned long ea, pte_t pte ) void flush_hash_page(unsigned long context, unsigned long ea, pte_t pte)
{ {
unsigned long vsid, vpn, va, hash, secondary, slot, flags; unsigned long vsid, vpn, va, hash, secondary, slot, flags;
/* Local copy of first doubleword of HPTE */ /* Local copy of first doubleword of HPTE */
...@@ -1055,15 +1050,16 @@ void flush_hash_page( unsigned long context, unsigned long ea, pte_t pte ) ...@@ -1055,15 +1050,16 @@ void flush_hash_page( unsigned long context, unsigned long ea, pte_t pte )
Hpte_dword0 h; Hpte_dword0 h;
} hpte_dw0; } hpte_dw0;
if ( (ea >= USER_START ) && ( ea <= USER_END ) ) if ((ea >= USER_START) && (ea <= USER_END))
vsid = get_vsid( context, ea ); vsid = get_vsid(context, ea);
else else
vsid = get_kernel_vsid( ea ); vsid = get_kernel_vsid(ea);
va = (vsid << 28) | (ea & 0x0fffffff); va = (vsid << 28) | (ea & 0x0fffffff);
vpn = va >> PAGE_SHIFT; vpn = va >> PAGE_SHIFT;
hash = hpt_hash(vpn, 0); hash = hpt_hash(vpn, 0);
secondary = (pte_val(pte) & _PAGE_SECONDARY) >> 15; secondary = (pte_val(pte) & _PAGE_SECONDARY) >> 15;
if ( secondary ) if (secondary)
hash = ~hash; hash = ~hash;
slot = (hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP; slot = (hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP;
slot += (pte_val(pte) & _PAGE_GROUP_IX) >> 12; slot += (pte_val(pte) & _PAGE_GROUP_IX) >> 12;
...@@ -1075,7 +1071,7 @@ void flush_hash_page( unsigned long context, unsigned long ea, pte_t pte ) ...@@ -1075,7 +1071,7 @@ void flush_hash_page( unsigned long context, unsigned long ea, pte_t pte )
(hpte_dw0.h.v) && (hpte_dw0.h.v) &&
(hpte_dw0.h.h == secondary ) ){ (hpte_dw0.h.h == secondary ) ){
/* HPTE matches */ /* HPTE matches */
ppc_md.hpte_invalidate( slot ); ppc_md.hpte_invalidate(slot);
} }
else { else {
unsigned k; unsigned k;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment