* [PATCH] powerpc: Clean up tm_abort duplication in hash_utils_64.c
@ 2016-08-26 3:50 Rui Teng
2016-09-01 15:46 ` Thiago Jung Bauermann
0 siblings, 1 reply; 3+ messages in thread
From: Rui Teng @ 2016-08-26 3:50 UTC (permalink / raw)
To: linuxppc-dev, linux-kernel; +Cc: benh, paulus, mpe, 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>
---
arch/powerpc/mm/hash_utils_64.c | 45 +++++++++++++++++------------------------
1 file changed, 19 insertions(+), 26 deletions(-)
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 0821556..69ef702 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -1460,6 +1460,23 @@ 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.
+ */
+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);
+ }
+}
+
/* WARNING: This is called from hash_low_64.S, if you change this prototype,
* do not forget to update the assembly call site !
*/
@@ -1487,19 +1504,7 @@ void flush_hash_page(unsigned long vpn, real_pte_t pte, int psize, int ssize,
} 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);
- }
+ local_tm_abort(local);
#endif
}
@@ -1558,19 +1563,7 @@ void flush_hash_hugepage(unsigned long vsid, unsigned long addr,
}
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);
- }
+ local_tm_abort(local);
#endif
return;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc: Clean up tm_abort duplication in hash_utils_64.c
2016-08-26 3:50 [PATCH] powerpc: Clean up tm_abort duplication in hash_utils_64.c Rui Teng
@ 2016-09-01 15:46 ` Thiago Jung Bauermann
2016-09-02 2:52 ` Rui Teng
0 siblings, 1 reply; 3+ messages in thread
From: Thiago Jung Bauermann @ 2016-09-01 15:46 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Rui Teng, linux-kernel, paulus
Am Freitag, 26 August 2016, 11:50:10 schrieb 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>
> ---
> arch/powerpc/mm/hash_utils_64.c | 45
> +++++++++++++++++------------------------ 1 file changed, 19
> insertions(+), 26 deletions(-)
>
> diff --git a/arch/powerpc/mm/hash_utils_64.c
> b/arch/powerpc/mm/hash_utils_64.c index 0821556..69ef702 100644
> --- a/arch/powerpc/mm/hash_utils_64.c
> +++ b/arch/powerpc/mm/hash_utils_64.c
> @@ -1460,6 +1460,23 @@ 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.
> + */
> +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);
> + }
> +}
> +
Since local_tm_abort is only used in this file, it should be static.
Also, since both places calling it are guarded by
CONFIG_PPC_TRANSACTIONAL_MEM, wouldn't it be cleaner if the #ifdef was here
instead and the #else block defined an empty static inline function? Then
the call sites wouldn't need to be guarded.
--
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc: Clean up tm_abort duplication in hash_utils_64.c
2016-09-01 15:46 ` Thiago Jung Bauermann
@ 2016-09-02 2:52 ` Rui Teng
0 siblings, 0 replies; 3+ messages in thread
From: Rui Teng @ 2016-09-02 2:52 UTC (permalink / raw)
To: Thiago Jung Bauermann, linuxppc-dev; +Cc: linux-kernel, paulus
On 9/1/16 11:46 PM, Thiago Jung Bauermann wrote:
> Am Freitag, 26 August 2016, 11:50:10 schrieb 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>
>> ---
>> arch/powerpc/mm/hash_utils_64.c | 45
>> +++++++++++++++++------------------------ 1 file changed, 19
>> insertions(+), 26 deletions(-)
>>
>> diff --git a/arch/powerpc/mm/hash_utils_64.c
>> b/arch/powerpc/mm/hash_utils_64.c index 0821556..69ef702 100644
>> --- a/arch/powerpc/mm/hash_utils_64.c
>> +++ b/arch/powerpc/mm/hash_utils_64.c
>> @@ -1460,6 +1460,23 @@ 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.
>> + */
>> +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);
>> + }
>> +}
>> +
>
> Since local_tm_abort is only used in this file, it should be static.
OK
>
> Also, since both places calling it are guarded by
> CONFIG_PPC_TRANSACTIONAL_MEM, wouldn't it be cleaner if the #ifdef was here
> instead and the #else block defined an empty static inline function? Then
> the call sites wouldn't need to be guarded.
I have considered this style before, but I am worried about the call
stacks increased by empty function and forgot the inline function.
Will send v2 with your comments.
Thanks!
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-02 2:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-26 3:50 [PATCH] powerpc: Clean up tm_abort duplication in hash_utils_64.c Rui Teng
2016-09-01 15:46 ` Thiago Jung Bauermann
2016-09-02 2:52 ` Rui Teng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).