* [PATCH] [v2] powerpc: Clean up tm_abort duplication in hash_utils_64.c
@ 2016-09-02 6:17 Rui Teng
2016-09-25 3:00 ` Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Rui Teng @ 2016-09-02 6:17 UTC (permalink / raw)
To: linuxppc-dev, linux-kernel
Cc: benh, paulus, mpe, Thiago Jung Bauermann, Rui Teng
The same logic appears twice and should probably be pulled out into a function.
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Rui Teng <rui.teng@linux.vnet.ibm.com>
---
Changes in V2:
- Change function to static and inline
- Use #else block to define an empty static inline function
---
arch/powerpc/mm/hash_utils_64.c | 55 +++++++++++++++++++----------------------
1 file changed, 25 insertions(+), 30 deletions(-)
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 0821556..b68f6d0 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -1460,6 +1460,29 @@ out_exit:
local_irq_restore(flags);
}
+/*
+ * Transactions are not aborted by tlbiel, only tlbie.
+ * Without, syncing a page back to a block device w/ PIO could pick up
+ * transactional data (bad!) so we force an abort here. Before the
+ * sync the page will be made read-only, which will flush_hash_page.
+ * BIG ISSUE here: if the kernel uses a page from userspace without
+ * unmapping it first, it may see the speculated version.
+ */
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+static inline void local_tm_abort(int local)
+{
+ if (local && cpu_has_feature(CPU_FTR_TM) && current->thread.regs &&
+ MSR_TM_ACTIVE(current->thread.regs->msr)) {
+ tm_enable();
+ tm_abort(TM_CAUSE_TLBI);
+ }
+}
+#else
+static inline void local_tm_abort(int local)
+{
+}
+#endif
+
/* WARNING: This is called from hash_low_64.S, if you change this prototype,
* do not forget to update the assembly call site !
*/
@@ -1486,21 +1509,7 @@ void flush_hash_page(unsigned long vpn, real_pte_t pte, int psize, int ssize,
ssize, local);
} pte_iterate_hashed_end();
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
- /* Transactions are not aborted by tlbiel, only tlbie.
- * Without, syncing a page back to a block device w/ PIO could pick up
- * transactional data (bad!) so we force an abort here. Before the
- * sync the page will be made read-only, which will flush_hash_page.
- * BIG ISSUE here: if the kernel uses a page from userspace without
- * unmapping it first, it may see the speculated version.
- */
- if (local && cpu_has_feature(CPU_FTR_TM) &&
- current->thread.regs &&
- MSR_TM_ACTIVE(current->thread.regs->msr)) {
- tm_enable();
- tm_abort(TM_CAUSE_TLBI);
- }
-#endif
+ local_tm_abort(local);
}
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -1557,21 +1566,7 @@ void flush_hash_hugepage(unsigned long vsid, unsigned long addr,
MMU_PAGE_16M, ssize, local);
}
tm_abort:
-#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
- /* Transactions are not aborted by tlbiel, only tlbie.
- * Without, syncing a page back to a block device w/ PIO could pick up
- * transactional data (bad!) so we force an abort here. Before the
- * sync the page will be made read-only, which will flush_hash_page.
- * BIG ISSUE here: if the kernel uses a page from userspace without
- * unmapping it first, it may see the speculated version.
- */
- if (local && cpu_has_feature(CPU_FTR_TM) &&
- current->thread.regs &&
- MSR_TM_ACTIVE(current->thread.regs->msr)) {
- tm_enable();
- tm_abort(TM_CAUSE_TLBI);
- }
-#endif
+ local_tm_abort(local);
return;
}
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [v2] powerpc: Clean up tm_abort duplication in hash_utils_64.c
2016-09-02 6:17 [PATCH] [v2] powerpc: Clean up tm_abort duplication in hash_utils_64.c Rui Teng
@ 2016-09-25 3:00 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2016-09-25 3:00 UTC (permalink / raw)
To: Rui Teng, linuxppc-dev, linux-kernel
Cc: Thiago Jung Bauermann, Rui Teng, paulus
On Fri, 2016-02-09 at 06:17:26 UTC, Rui Teng wrote:
> The same logic appears twice and should probably be pulled out into a function.
>
> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> Signed-off-by: Rui Teng <rui.teng@linux.vnet.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/f1a55ce0544251746d9b52fb85
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-25 3:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-02 6:17 [PATCH] [v2] powerpc: Clean up tm_abort duplication in hash_utils_64.c Rui Teng
2016-09-25 3:00 ` Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.