Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <mpe@ellerman.id.au>
Signed-off-by: Rui Teng <rui.teng@linux.vnet.ibm.com>
[mpe: Rename to tm_flush_hash_page() and move comment into the function]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Rui Teng and committed by
Michael Ellerman
f1a55ce0 6060e9ea

+25 -31
+25 -31
arch/powerpc/mm/hash_utils_64.c
··· 1485 1485 local_irq_restore(flags); 1486 1486 } 1487 1487 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 + 1488 1511 /* WARNING: This is called from hash_low_64.S, if you change this prototype, 1489 1512 * do not forget to update the assembly call site ! 1490 1513 */ ··· 1534 1511 ssize, local); 1535 1512 } pte_iterate_hashed_end(); 1536 1513 1537 - #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1538 - /* Transactions are not aborted by tlbiel, only tlbie. 1539 - * Without, syncing a page back to a block device w/ PIO could pick up 1540 - * transactional data (bad!) so we force an abort here. Before the 1541 - * sync the page will be made read-only, which will flush_hash_page. 1542 - * BIG ISSUE here: if the kernel uses a page from userspace without 1543 - * unmapping it first, it may see the speculated version. 1544 - */ 1545 - if (local && cpu_has_feature(CPU_FTR_TM) && 1546 - current->thread.regs && 1547 - MSR_TM_ACTIVE(current->thread.regs->msr)) { 1548 - tm_enable(); 1549 - tm_abort(TM_CAUSE_TLBI); 1550 - } 1551 - #endif 1514 + tm_flush_hash_page(local); 1552 1515 } 1553 1516 1554 1517 #ifdef CONFIG_TRANSPARENT_HUGEPAGE ··· 1591 1582 MMU_PAGE_16M, ssize, local); 1592 1583 } 1593 1584 tm_abort: 1594 - #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1595 - /* Transactions are not aborted by tlbiel, only tlbie. 1596 - * Without, syncing a page back to a block device w/ PIO could pick up 1597 - * transactional data (bad!) so we force an abort here. Before the 1598 - * sync the page will be made read-only, which will flush_hash_page. 1599 - * BIG ISSUE here: if the kernel uses a page from userspace without 1600 - * unmapping it first, it may see the speculated version. 1601 - */ 1602 - if (local && cpu_has_feature(CPU_FTR_TM) && 1603 - current->thread.regs && 1604 - MSR_TM_ACTIVE(current->thread.regs->msr)) { 1605 - tm_enable(); 1606 - tm_abort(TM_CAUSE_TLBI); 1607 - } 1608 - #endif 1609 - return; 1585 + tm_flush_hash_page(local); 1610 1586 } 1611 1587 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 1612 1588