Commit bbe7d996 authored by Anton Blanchard's avatar Anton Blanchard

ppc64: move permissions check outside of hash table lock

parent 7fec647d
...@@ -780,7 +780,6 @@ void hpte_init_pSeries(void) ...@@ -780,7 +780,6 @@ void hpte_init_pSeries(void)
*/ */
int hash_page(unsigned long ea, unsigned long access) int hash_page(unsigned long ea, unsigned long access)
{ {
int rc = 1;
void * pgdir = NULL; void * pgdir = NULL;
unsigned long va, vsid, vpn; unsigned long va, vsid, vpn;
unsigned long newpp, hash_ind, prpn; unsigned long newpp, hash_ind, prpn;
...@@ -856,6 +855,16 @@ int hash_page(unsigned long ea, unsigned long access) ...@@ -856,6 +855,16 @@ int hash_page(unsigned long ea, unsigned long access)
return 1; return 1;
} }
/*
* Check the user's access rights to the page. If access should be
* prevented then send the problem up to do_page_fault.
*/
access |= _PAGE_PRESENT;
if (access & ~(pte_val(*ptep))) {
spin_unlock(&mm->page_table_lock);
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
...@@ -890,13 +899,8 @@ int hash_page(unsigned long ea, unsigned long access) ...@@ -890,13 +899,8 @@ int hash_page(unsigned long ea, unsigned long access)
* This case is always an error and is not dealt with further here. * This case is always an error and is not dealt with further here.
* 5. This is a Kernel address (0xC---) for which there is no page directory. * 5. This is a Kernel address (0xC---) for which there is no page directory.
* There is no HPTE for this page. * There is no HPTE for this page.
* Check the user's access rights to the page. If access should be prevented
* then send the problem up to do_page_fault.
*/ */
access |= _PAGE_PRESENT;
if ( 0 == ( access & ~(pte_val(old_pte)) ) ) {
/* /*
* Check if pte might have an hpte, but we have * Check if pte might have an hpte, but we have
* no slot information * no slot information
...@@ -995,13 +999,9 @@ int hash_page(unsigned long ea, unsigned long access) ...@@ -995,13 +999,9 @@ int hash_page(unsigned long ea, unsigned long access)
} }
/* Indicate success */
rc = 0;
}
spin_unlock(&hash_table_lock); spin_unlock(&hash_table_lock);
spin_unlock(&mm->page_table_lock); spin_unlock(&mm->page_table_lock);
return rc; return 0;
} }
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)
......
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