From patchwork Thu May 12 03:39:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 621335 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r4zKN4gvlz9t6Z for ; Thu, 12 May 2016 13:40:40 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=xk+r/chF; dkim-atps=neutral Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3r4zKN3sZhzDqDV for ; Thu, 12 May 2016 13:40:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=xk+r/chF; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pa0-x242.google.com (mail-pa0-x242.google.com [IPv6:2607:f8b0:400e:c03::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3r4zHp1VSSzDqCm for ; Thu, 12 May 2016 13:39:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=xk+r/chF; dkim-atps=neutral Received: by mail-pa0-x242.google.com with SMTP id gh9so4965500pac.0 for ; Wed, 11 May 2016 20:39:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=g/O8kS4hqb3bU8Ca5ejUK90ieyM2DHGYZ2DHdWyeDhA=; b=xk+r/chFbWRyHc7D+ILeJSTcdFYwD2LMb0jPqQKorSPbmug5f1TAAHhDLkNfXY3l2n JZqpVyrz+HvdYKvHWozDDSG1/2uti9pLumhloyKbggUyFTiSr/AoersANrhvKHCUhqhr A15/rwD42cnFYaX0vCAYimD1vxDLu6TAjTh2/P4C5TVVZqhunFM6m02pJCJOgmUuBVVU KQpsJAiF0FYwan8ASa6m6Lxr/elMHZI7DGJrikFFrDShofd+UuMlBfvvs3+uOjVnLnqf dNz4TjBCnuFnod+70J9vDqNyBDVKQnTu+0cOzGDss6AYjXwDT/Q7yjv9uMjvjvF2egDe b1OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=g/O8kS4hqb3bU8Ca5ejUK90ieyM2DHGYZ2DHdWyeDhA=; b=j1sFTwzX9WzuYwDCT4TO/4mX47yP7IVEaoO2mBazB2G+wNUO/RzSeSw9W6XGzhszoY 9MHPw7mIG6qWPm4WgjTcdsIrpmegO0ykJD8RiywTrC7tGtZ/whC7lxHYuiyuwVfOEywd /QiC1d5R/8ekvlJEwaH/vnQ3l0YuaIy/s1EPzIXM4DM5SR2DzFOjUeVaKU18GtX4f9PH zGM1bwvd1equ30E6l4Wn1gLTeGYtC5LXuLFbya/vezQsvu0ckloLqGlgzYY+779DOaET qD7N9nPPTgeWGPEABc8SjDwHQLG7Z4tWoUMpXeR1RsOwHKeitXHyJ72EovLwUoOSCYGT gdjA== X-Gm-Message-State: AOPr4FU+FdL5D6DlW928YhWwJmoy5DKLHRsPx8EfTgPUc/WZ7CNPEhE0oPO+9IBl8Sjcpg== X-Received: by 10.66.199.66 with SMTP id ji2mr10392567pac.34.1463024356337; Wed, 11 May 2016 20:39:16 -0700 (PDT) Received: from circle.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id we8sm15566275pac.29.2016.05.11.20.39.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 20:39:15 -0700 (PDT) From: Rashmica Gupta To: mpe@ellerman.id.au, bsingharora@gmail.com Subject: [PATCH V2] powerpc/tm: Clean up duplication of code Date: Thu, 12 May 2016 13:39:02 +1000 Message-Id: <1463024342-16130-1-git-send-email-rashmicy@gmail.com> X-Mailer: git-send-email 2.5.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The same logic for tm_abort appears twice, so pull it out into a function. Signed-off-by: Rashmica Gupta Reviewed-by: Balbir Singh --- v2: Removed some #ifdefs from inside C code and changed the formatting of the comment. arch/powerpc/mm/hash_utils_64.c | 56 +++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index 7635b1c6b5da..b92cca033131 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c @@ -1318,6 +1318,30 @@ 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 tlb_flush_abort_tm(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 tlb_flush_abort_tm(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 ! */ @@ -1343,21 +1367,7 @@ void flush_hash_page(unsigned long vpn, real_pte_t pte, int psize, int ssize, ppc_md.hpte_invalidate(slot, vpn, psize, psize, 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 + tlb_flush_abort_tm(local); } #ifdef CONFIG_TRANSPARENT_HUGEPAGE @@ -1414,21 +1424,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 + tlb_flush_abort_tm(local); return; } #endif /* CONFIG_TRANSPARENT_HUGEPAGE */