Skip to content

Commit f1a55ce

Browse files
Rui Tengmpe
authored andcommitted
powerpc: Clean up tm_abort duplication in hash_utils_64.c
The same logic appears twice and should probably be pulled out into a function. Suggested-by: Michael Ellerman <[email protected]> Signed-off-by: Rui Teng <[email protected]> [mpe: Rename to tm_flush_hash_page() and move comment into the function] Signed-off-by: Michael Ellerman <[email protected]>
1 parent 6060e9e commit f1a55ce

File tree

1 file changed

+25
-31
lines changed

1 file changed

+25
-31
lines changed

arch/powerpc/mm/hash_utils_64.c

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,29 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
14851485
local_irq_restore(flags);
14861486
}
14871487

1488+
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1489+
static inline void tm_flush_hash_page(int local)
1490+
{
1491+
/*
1492+
* Transactions are not aborted by tlbiel, only tlbie. Without, syncing a
1493+
* page back to a block device w/PIO could pick up transactional data
1494+
* (bad!) so we force an abort here. Before the sync the page will be
1495+
* made read-only, which will flush_hash_page. BIG ISSUE here: if the
1496+
* kernel uses a page from userspace without unmapping it first, it may
1497+
* see the speculated version.
1498+
*/
1499+
if (local && cpu_has_feature(CPU_FTR_TM) && current->thread.regs &&
1500+
MSR_TM_ACTIVE(current->thread.regs->msr)) {
1501+
tm_enable();
1502+
tm_abort(TM_CAUSE_TLBI);
1503+
}
1504+
}
1505+
#else
1506+
static inline void tm_flush_hash_page(int local)
1507+
{
1508+
}
1509+
#endif
1510+
14881511
/* WARNING: This is called from hash_low_64.S, if you change this prototype,
14891512
* do not forget to update the assembly call site !
14901513
*/
@@ -1511,21 +1534,7 @@ void flush_hash_page(unsigned long vpn, real_pte_t pte, int psize, int ssize,
15111534
ssize, local);
15121535
} pte_iterate_hashed_end();
15131536

1514-
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1515-
/* Transactions are not aborted by tlbiel, only tlbie.
1516-
* Without, syncing a page back to a block device w/ PIO could pick up
1517-
* transactional data (bad!) so we force an abort here. Before the
1518-
* sync the page will be made read-only, which will flush_hash_page.
1519-
* BIG ISSUE here: if the kernel uses a page from userspace without
1520-
* unmapping it first, it may see the speculated version.
1521-
*/
1522-
if (local && cpu_has_feature(CPU_FTR_TM) &&
1523-
current->thread.regs &&
1524-
MSR_TM_ACTIVE(current->thread.regs->msr)) {
1525-
tm_enable();
1526-
tm_abort(TM_CAUSE_TLBI);
1527-
}
1528-
#endif
1537+
tm_flush_hash_page(local);
15291538
}
15301539

15311540
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -1582,22 +1591,7 @@ void flush_hash_hugepage(unsigned long vsid, unsigned long addr,
15821591
MMU_PAGE_16M, ssize, local);
15831592
}
15841593
tm_abort:
1585-
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1586-
/* Transactions are not aborted by tlbiel, only tlbie.
1587-
* Without, syncing a page back to a block device w/ PIO could pick up
1588-
* transactional data (bad!) so we force an abort here. Before the
1589-
* sync the page will be made read-only, which will flush_hash_page.
1590-
* BIG ISSUE here: if the kernel uses a page from userspace without
1591-
* unmapping it first, it may see the speculated version.
1592-
*/
1593-
if (local && cpu_has_feature(CPU_FTR_TM) &&
1594-
current->thread.regs &&
1595-
MSR_TM_ACTIVE(current->thread.regs->msr)) {
1596-
tm_enable();
1597-
tm_abort(TM_CAUSE_TLBI);
1598-
}
1599-
#endif
1600-
return;
1594+
tm_flush_hash_page(local);
16011595
}
16021596
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
16031597

0 commit comments

Comments
 (0)