From patchwork Wed May 11 04:55:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 620894 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r4P464kStz9t3x for ; Wed, 11 May 2016 14:57:10 +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=xySyiNzH; dkim-atps=neutral Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3r4P463V0kzDqHc for ; Wed, 11 May 2016 14:57:10 +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=xySyiNzH; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::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 3r4P2c57MtzDqCm for ; Wed, 11 May 2016 14:55:52 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=xySyiNzH; dkim-atps=neutral Received: by mail-pf0-x242.google.com with SMTP id y7so2867194pfb.0 for ; Tue, 10 May 2016 21:55:52 -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=6pZGh4GIzPV2u4oFqksCh0CE+qoFPCuePbiVc7gMRLI=; b=xySyiNzHNWMq1NJD1aXP+WCwuoVh6l9KZ+jO5Ncx6njyi/yoO3kTMUnCmYeOvMYjxM TuB70p7HcwuLI2CSi46dFcyKX32L3VJgrF3vAC6oOSVTcoAZZBGpPJAIIBALUGvKuVyQ 0YfRKOBmcUmw+OSYwdCV3MTVPKzoVitCT50lJ/w8QnKomYZt0DYXCcoZsQSNf3FV3AZn Ut3XqgDlGS6PYrUa1Xgdfp/cT6iAgVAsfQKpp9rVLsJVtywsN03OI8J6ecBvVlKFhXKz Rra/1SZ8Nhp7hCHHkFz5LJjW36RVXTFK6OTyNJqA+U5GwVe2a6qg8IooId2OqzdrCgzz 9g+g== 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=6pZGh4GIzPV2u4oFqksCh0CE+qoFPCuePbiVc7gMRLI=; b=cnZPXQ0C+t5XoD56Dfzl4k5dd/0zcjFA0DRdL6F0SLLKBp+b7CLJ3218TEUg5I/s8b 7siIk4eQC8gcbDpGNUF2YFJxprm392Z6Vsn76xd162WiVb/opBsAbiLDwul4E3vFO5P4 1zwuOVL6QPcrT3s8KU7rEJHlB9mGkq1DwoZdNb6v7oSEEAcgsZLqm+5WISj/vzoR2O2t mACKR3jXL9S4opU+ZH8F9qjkvVRcOPaYN5Vfvut/tmUNhqezgwuT6EL89dE5cRzB266f tOPhVl2+ohs1LpstBH2ULbyVJKxn4Z/FfddOMfCCB+rEB94ZgraOqLmC+ndoOCPrTxqO 8ciQ== X-Gm-Message-State: AOPr4FVKe5u0O1UhqKkdiAC87R5hn+NmyHoxDBm/wbqS3q6oGGymYYilvP2ecQT6IZ9fgw== X-Received: by 10.98.21.131 with SMTP id 125mr1812379pfv.92.1462942550654; Tue, 10 May 2016 21:55:50 -0700 (PDT) Received: from circle.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id we8sm8204665pac.29.2016.05.10.21.55.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 May 2016 21:55:49 -0700 (PDT) From: Rashmica Gupta To: mpe@ellerman.id.au Subject: [PATCH] powerpc/tm: Clean up duplication of code Date: Wed, 11 May 2016 14:55:00 +1000 Message-Id: <1462942500-30188-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 --- arch/powerpc/mm/hash_utils_64.c | 47 ++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index 7635b1c6b5da..1cef8f5aee9b 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c @@ -1318,6 +1318,25 @@ out_exit: local_irq_restore(flags); } +#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. + */ +static inline void 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); + } +} +#endif + /* WARNING: This is called from hash_low_64.S, if you change this prototype, * do not forget to update the assembly call site ! */ @@ -1344,19 +1363,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); - } + abort_tm(local); #endif } @@ -1415,19 +1422,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); - } + abort_tm(local); #endif return; }