Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1688102

[RFC v6 08/62] powerpc: use helper functions in __hash_page_4K() for 64K PTE

From Ram Pai <linuxram@us.ibm.com>
Newsgroups linux.kernel
Subject [RFC v6 08/62] powerpc: use helper functions in __hash_page_4K() for 64K PTE
Date 2017-07-16 06:20 +0200
Message-ID <u3Jcd-2ea-11@gated-at.bofh.it> (permalink)
References <u3ISR-1St-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


replace redundant code in __hash_page_4K() with helper
functions pte_get_hash_gslot() and pte_set_hash_slot()

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 arch/powerpc/mm/hash64_64k.c |   34 +++++++++-------------------------
 1 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/arch/powerpc/mm/hash64_64k.c b/arch/powerpc/mm/hash64_64k.c
index 645f621..c658cb5 100644
--- a/arch/powerpc/mm/hash64_64k.c
+++ b/arch/powerpc/mm/hash64_64k.c
@@ -39,9 +39,8 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid,
 {
 	real_pte_t rpte;
 	unsigned long hpte_group;
-	unsigned long *hidxp;
 	unsigned int subpg_index;
-	unsigned long rflags, pa, hidx;
+	unsigned long rflags, pa;
 	unsigned long old_pte, new_pte, subpg_pte;
 	unsigned long vpn, hash, slot, gslot;
 	unsigned long shift = mmu_psize_defs[MMU_PAGE_4K].shift;
@@ -114,18 +113,13 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid,
 	if (__rpte_sub_valid(rpte, subpg_index)) {
 		int ret;
 
-		hash = hpt_hash(vpn, shift, ssize);
-		hidx = __rpte_to_hidx(rpte, subpg_index);
-		if (hidx & _PTEIDX_SECONDARY)
-			hash = ~hash;
-		slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
-		slot += hidx & _PTEIDX_GROUP_IX;
-
-		ret = mmu_hash_ops.hpte_updatepp(slot, rflags, vpn,
+		gslot = pte_get_hash_gslot(vpn, shift, ssize, rpte,
+				subpg_index);
+		ret = mmu_hash_ops.hpte_updatepp(gslot, rflags, vpn,
 						 MMU_PAGE_4K, MMU_PAGE_4K,
 						 ssize, flags);
 		/*
-		 *if we failed because typically the HPTE wasn't really here
+		 * if we failed because typically the HPTE wasn't really here
 		 * we try an insertion.
 		 */
 		if (ret == -1)
@@ -221,20 +215,10 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid,
 				   MMU_PAGE_4K, MMU_PAGE_4K, old_pte);
 		return -1;
 	}
-	/*
-	 * Insert slot number & secondary bit in PTE second half,
-	 * clear H_PAGE_BUSY and set appropriate HPTE slot bit
-	 * Since we have H_PAGE_BUSY set on ptep, we can be sure
-	 * nobody is undating hidx.
-	 */
-	hidxp = (unsigned long *)(ptep + PTRS_PER_PTE);
-	rpte.hidx &= ~(0xfUL << (subpg_index << 2));
-	*hidxp = rpte.hidx  | (slot << (subpg_index << 2));
-	/*
-	 * check __real_pte for details on matching smp_rmb()
-	 */
-	smp_wmb();
-	new_pte |=  H_PAGE_HASHPTE;
+
+	new_pte |= pte_set_hash_slot(ptep, rpte, subpg_index, slot);
+	new_pte |= H_PAGE_HASHPTE;
+
 	*ptep = __pte(new_pte & ~H_PAGE_BUSY);
 	return 0;
 }
-- 
1.7.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC v6 00/62] powerpc: Memory Protection Keys Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:00 +0200
  [RFC v6 11/62] powerpc: initial pkey plumbing Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:00 +0200
  [RFC v6 31/62] powerpc: Handle exceptions caused by pkey violation Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:00 +0200
  [RFC v6 15/62] powerpc: helper functions to initialize AMR, IAMR and UMOR registers Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:00 +0200
  [RFC v6 06/62] powerpc: use helper functions in __hash_page_64K() for 64K PTE Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:00 +0200
  [RFC v6 33/62] powerpc: introduce get_pte_pkey() helper Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:00 +0200
  [RFC v6 26/62] powerpc: Program HPTE key protection bits Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:00 +0200
  [RFC v6 49/62] selftest/vm: fix alloc_random_pkey() to make it really random Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 45/62] selftest/vm: generics function to handle shadow key register Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 53/62] selftest/vm: powerpc implementation for generic abstraction Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 51/62] selftest/vm: pkey register should match shadow pkey Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 38/62] powerpc: implementation for arch_pkeys_enabled() Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 37/62] x86: implementation for arch_pkeys_enabled() Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 46/62] selftest/vm: fix the wrong assert in pkey_disable_set() Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 62/62] Documentation/vm: PowerPC specific updates to memory protection keys Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 22/62] powerpc: ability to associate pkey to a vma Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 27/62] powerpc: helper to validate key-access permissions of a pte Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 30/62] powerpc: implementation for arch_vma_access_permitted() Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 44/62] selftest/vm: typecast the pkey register Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 24/62] powerpc: map vma key-protection bits to pte key bits. Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 55/62] selftest/vm: associate key on a mapped page and detect access violation Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 58/62] selftest/vm: detect no write key-violation on a freed key Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 61/62] Documentation/x86: Move protecton key documentation to arch neutral directory Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 52/62] selftest/vm: generic cleanup Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 54/62] selftest/vm: fix an assertion in test_pkey_alloc_exhaust() Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 60/62] selftest/vm: sub-page allocator Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 32/62] powerpc: capture AMR register content on pkey violation Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 34/62] powerpc: capture the violated protection key on fault Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 50/62] selftest/vm: introduce two arch independent abstraction Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 25/62] powerpc: sys_pkey_mprotect() system call Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 59/62] selftest/vm: detect write violation on a mapped access-denied-key page Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 57/62] selftest/vm: associate key on a mapped page and detect write violation Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 36/62] mm: introduce arch_pkeys_enabled() Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 40/62] x86: delete arch_show_smap() Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 29/62] powerpc: Macro the mask used for checking DSI exception Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 47/62] selftest/vm: fixed bugs in pkey_disable_clear() Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 28/62] powerpc: check key protection for user page access Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 48/62] selftest/vm: clear the bits in shadow reg when a pkey is freed. Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 56/62] selftest/vm: detect no key violation on a freed key Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 39/62] mm: display pkey in smaps if arch_pkeys_enabled() is true Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 42/62] selftest/vm: rename all references to pkru to a generic name Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:10 +0200
  [RFC v6 07/62] powerpc: use helper functions in __hash_page_huge() for 64K PTE Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 12/62] mm: introduce an additional vma bit for powerpc pkey Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 13/62] powerpc: track allocation status of all pkeys Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 09/62] powerpc: use helper functions in __hash_page_4K() for 4K PTE Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 01/62] powerpc: Free up four 64K PTE bits in 4K backed HPTE pages Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 08/62] powerpc: use helper functions in __hash_page_4K() for 64K PTE Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 05/62] powerpc: capture the PTE format changes in the dump pte report Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 02/62] powerpc: Free up four 64K PTE bits in 64K backed HPTE pages Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 14/62] powerpc: helper function to read,write AMR,IAMR,UAMOR registers Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 18/62] powerpc: sys_pkey_alloc() and sys_pkey_free() system calls Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 03/62] powerpc: introduce pte_set_hash_slot() helper Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 21/62] powerpc: introduce execute-only pkey Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 10/62] powerpc: use helper functions in flush_hash_page() Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 16/62] powerpc: cleaup AMR,iAMR when a key is allocated or freed Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200
  [RFC v6 20/62] powerpc: store and restore the pkey state across context switches Ram Pai <linuxram@us.ibm.com> - 2017-07-16 06:20 +0200

csiph-web