From patchwork Wed Sep 12 19:40:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969175 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429XKY0nmyz9sCW for ; Thu, 13 Sep 2018 05:44:17 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429XKX5qJSzF39K for ; Thu, 13 Sep 2018 05:44:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFF58WSzF3D1 for ; Thu, 13 Sep 2018 05:40:33 +1000 (AEST) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJYa5C052558 for ; Wed, 12 Sep 2018 15:40:30 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mf60384hw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:40:30 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:40:29 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:40:27 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJeQrp42205350 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:40:26 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C99727805E; Wed, 12 Sep 2018 13:40:26 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B43A78063; Wed, 12 Sep 2018 13:40:24 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:40:24 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 01/11] powerpc/tm: Reclaim transaction on kernel entry Date: Wed, 12 Sep 2018 16:40:09 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-0016-0000-0000-0000092C7872 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087369; UDB=6.00561487; IPR=6.00867382; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:40:29 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-0017-0000-0000-00004054677B Message-Id: <1536781219-13938-2-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=976 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This patch creates a macro that will be invoked on all entrance to the kernel, so, in kernel space the transaction will be completely reclaimed and not suspended anymore. This patchset checks if we are coming from PR, if not, skip. This is useful when there is a irq_replay() being called after recheckpoint, when the IRQ is re-enable. In this case, we do not want to re-reclaim and re-recheckpoint, thus, if not coming from PR, skip it completely. This macro does not care about TM SPR also, it will only be saved and restore in the context switch code now on. This macro will return 0 or 1 in r3 register, to specify if a reclaim was executed or not. This patchset is based on initial work done by Cyril: https://patchwork.ozlabs.org/cover/875341/ Signed-off-by: Breno Leitao --- arch/powerpc/include/asm/exception-64s.h | 46 ++++++++++++++++++++++++ arch/powerpc/kernel/entry_64.S | 10 ++++++ arch/powerpc/kernel/exceptions-64s.S | 12 +++++-- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h index a86feddddad0..db90b6d7826e 100644 --- a/arch/powerpc/include/asm/exception-64s.h +++ b/arch/powerpc/include/asm/exception-64s.h @@ -36,6 +36,7 @@ */ #include #include +#include /* PACA save area offsets (exgen, exmc, etc) */ #define EX_R9 0 @@ -686,10 +687,54 @@ BEGIN_FTR_SECTION \ beql ppc64_runlatch_on_trampoline; \ END_FTR_SECTION_IFSET(CPU_FTR_CTRL) +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM + +/* + * This macro will reclaim a transaction if called when coming from userspace + * (MSR.PR = 1) and if the transaction state is active or suspended. + * + * Since we don't want to reclaim when coming from kernel, for instance after + * a trechkpt. or a IRQ replay, the live MSR is not useful and instead of it the + * MSR from thread stack is used to check the MSR.PR bit. + * This macro has one argument which is the cause that will be used by treclaim. + * and returns in r3 '1' if the reclaim happens or '0' if reclaim didn't + * happen, which is useful to know what registers were clobbered. + * + * NOTE: If addition registers are clobbered here, make sure the callee + * function restores them before proceeding. + */ +#define TM_KERNEL_ENTRY(cause) \ + ld r3, _MSR(r1); \ + andi. r0, r3, MSR_PR; /* Coming from userspace? */ \ + beq 1f; /* Skip reclaim if MSR.PR != 1 */ \ + rldicl. r0, r3, (64-MSR_TM_LG), 63; /* Is TM enabled? */ \ + beq 1f; /* Skip reclaim if TM is off */ \ + rldicl. r0, r3, (64-MSR_TS_LG), 62; /* Is active */ \ + beq 1f; /* Skip reclaim if neither */ \ + /* \ + * If there is a transaction active or suspended, save the \ + * non-volatile GPRs if they are not already saved. \ + */ \ + bl save_nvgprs; \ + /* \ + * Soft disable the IRQs, otherwise it might cause a CPU hang. \ + */ \ + RECONCILE_IRQ_STATE(r10, r11); \ + li r3, cause; \ + bl tm_reclaim_current; \ + li r3, 1; /* Reclaim happened */ \ + b 2f; \ +1: li r3, 0; /* Reclaim didn't happen */ \ +2: +#else +#define TM_KERNEL_ENTRY(cause) +#endif + #define EXCEPTION_COMMON(area, trap, label, hdlr, ret, additions) \ EXCEPTION_PROLOG_COMMON(trap, area); \ /* Volatile regs are potentially clobbered here */ \ additions; \ + TM_KERNEL_ENTRY(TM_CAUSE_MISC); \ addi r3,r1,STACK_FRAME_OVERHEAD; \ bl hdlr; \ b ret @@ -704,6 +749,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CTRL) EXCEPTION_PROLOG_COMMON_3(trap); \ /* Volatile regs are potentially clobbered here */ \ additions; \ + TM_KERNEL_ENTRY(TM_CAUSE_MISC); \ addi r3,r1,STACK_FRAME_OVERHEAD; \ bl hdlr diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 2206912ea4f0..c38677b7442c 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -131,6 +131,16 @@ BEGIN_FW_FTR_SECTION END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR) #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE && CONFIG_PPC_SPLPAR */ +#if CONFIG_PPC_TRANSACTIONAL_MEM + TM_KERNEL_ENTRY(TM_CAUSE_SYSCALL) + cmpdi r3, 0x1 + bne 44f + /* Restore from r4 to r12 */ + REST_8GPRS(4,r1) +44: /* treclaim was not called, just restore r3 and r0 */ + REST_GPR(3, r1) + REST_GPR(0, r1) +#endif /* * A syscall should always be called with interrupts enabled * so we just unconditionally hard-enable here. When some kind diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index ea04dfb8c092..78aba71a4b2d 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -805,6 +805,7 @@ EXC_COMMON_BEGIN(alignment_common) std r3,_DAR(r1) std r4,_DSISR(r1) bl save_nvgprs + TM_KERNEL_ENTRY(TM_CAUSE_ALIGNMENT) RECONCILE_IRQ_STATE(r10, r11) addi r3,r1,STACK_FRAME_OVERHEAD bl alignment_exception @@ -839,6 +840,8 @@ EXC_COMMON_BEGIN(program_check_common) b 3f /* Jump into the macro !! */ 1: EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN) bl save_nvgprs + ld r3, _MSR(r1) + TM_KERNEL_ENTRY(TM_CAUSE_FAC_UNAV) RECONCILE_IRQ_STATE(r10, r11) addi r3,r1,STACK_FRAME_OVERHEAD bl program_check_exception @@ -1738,7 +1741,9 @@ do_hash_page: /* Here we have a page fault that hash_page can't handle. */ handle_page_fault: -11: andis. r0,r4,DSISR_DABRMATCH@h +11: TM_KERNEL_ENTRY(TM_CAUSE_TLBI) + ld r4,_DSISR(r1) + andis. r0,r4,DSISR_DABRMATCH@h bne- handle_dabr_fault ld r4,_DAR(r1) ld r5,_DSISR(r1) @@ -1769,6 +1774,8 @@ handle_dabr_fault: */ 13: bl save_nvgprs mr r5,r3 + TM_KERNEL_ENTRY(TM_CAUSE_TLBI) + REST_GPR(3,r1) addi r3,r1,STACK_FRAME_OVERHEAD ld r4,_DAR(r1) bl low_hash_fault @@ -1783,7 +1790,8 @@ handle_dabr_fault: * the access, or panic if there isn't a handler. */ 77: bl save_nvgprs - mr r4,r3 + TM_KERNEL_ENTRY(TM_CAUSE_TLBI) + ld r4,_DAR(r1) addi r3,r1,STACK_FRAME_OVERHEAD li r5,SIGSEGV bl bad_page_fault From patchwork Wed Sep 12 19:40:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969177 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429XP521mNz9s3x for ; Thu, 13 Sep 2018 05:47:21 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429XP50gLRzF39K for ; Thu, 13 Sep 2018 05:47:21 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFJ5QRqzF3D1 for ; Thu, 13 Sep 2018 05:40:36 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJY17Y101610 for ; Wed, 12 Sep 2018 15:40:34 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mf8mj1c7b-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:40:34 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:40:33 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:40:31 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJeUSh48759002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:40:30 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D29E78064; Wed, 12 Sep 2018 13:40:30 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E81C7805E; Wed, 12 Sep 2018 13:40:28 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:40:27 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 02/11] powerpc/tm: Reclaim on unavailable exception Date: Wed, 12 Sep 2018 16:40:10 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-8235-0000-0000-00000DFE3071 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087370; UDB=6.00561487; IPR=6.00867382; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:40:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-8236-0000-0000-0000429E4E62 Message-Id: <1536781219-13938-3-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" If there is a FP/VEC/Altivec touch inside a transaction and the facility is disabled, then a facility unavailable exception is raised and ends up calling {fp,vec,vsx}_unavailable_tm, which was reclaiming and recheckpointing. This is not required anymore, since the checkpointed state was reclaimed in the trap entrace itself, and it will be recheckpointed by restore_tm_state later. With this new patchset, we only reclaim at exception entrance (except at syscall level if the transaction is suspended), and always recheckpoint on restore_tm_state. Adding a WARN_ON() warning if we hit the _unavailable_tm() in suspended mode, i.e, the reclaim was not executed somehow in the trap entrance. Signed-off-by: Breno Leitao --- arch/powerpc/kernel/exceptions-64s.S | 3 +++ arch/powerpc/kernel/traps.c | 16 ++++------------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 78aba71a4b2d..4108f3944bdd 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -874,6 +874,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_TM) #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 2: /* User process was in a transaction */ bl save_nvgprs + TM_KERNEL_ENTRY(TM_CAUSE_FAC_UNAV) RECONCILE_IRQ_STATE(r10, r11) addi r3,r1,STACK_FRAME_OVERHEAD bl fp_unavailable_tm @@ -1216,6 +1217,7 @@ BEGIN_FTR_SECTION #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 2: /* User process was in a transaction */ bl save_nvgprs + TM_KERNEL_ENTRY(TM_CAUSE_FAC_UNAV) RECONCILE_IRQ_STATE(r10, r11) addi r3,r1,STACK_FRAME_OVERHEAD bl altivec_unavailable_tm @@ -1252,6 +1254,7 @@ BEGIN_FTR_SECTION #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 2: /* User process was in a transaction */ bl save_nvgprs + TM_KERNEL_ENTRY(TM_CAUSE_FAC_UNAV) RECONCILE_IRQ_STATE(r10, r11) addi r3,r1,STACK_FRAME_OVERHEAD bl vsx_unavailable_tm diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index c85adb858271..b973fdb72826 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -1749,19 +1749,12 @@ void fp_unavailable_tm(struct pt_regs *regs) * transaction, and probably retry but now with FP enabled. So the * checkpointed FP registers need to be loaded. */ - tm_reclaim_current(TM_CAUSE_FAC_UNAV); + WARN_ON(MSR_TM_SUSPENDED(mfmsr())); /* Reclaim didn't save out any FPRs to transact_fprs. */ /* Enable FP for the task: */ current->thread.load_fp = 1; - /* This loads and recheckpoints the FP registers from - * thread.fpr[]. They will remain in registers after the - * checkpoint so we don't need to reload them after. - * If VMX is in use, the VRs now hold checkpointed values, - * so we don't want to load the VRs from the thread_struct. - */ - tm_recheckpoint(¤t->thread); } void altivec_unavailable_tm(struct pt_regs *regs) @@ -1773,10 +1766,10 @@ void altivec_unavailable_tm(struct pt_regs *regs) TM_DEBUG("Vector Unavailable trap whilst transactional at 0x%lx," "MSR=%lx\n", regs->nip, regs->msr); - tm_reclaim_current(TM_CAUSE_FAC_UNAV); + WARN_ON(MSR_TM_SUSPENDED(mfmsr())); current->thread.load_vec = 1; - tm_recheckpoint(¤t->thread); current->thread.used_vr = 1; + } void vsx_unavailable_tm(struct pt_regs *regs) @@ -1795,12 +1788,11 @@ void vsx_unavailable_tm(struct pt_regs *regs) current->thread.used_vsr = 1; /* This reclaims FP and/or VR regs if they're already enabled */ - tm_reclaim_current(TM_CAUSE_FAC_UNAV); + WARN_ON(MSR_TM_SUSPENDED(mfmsr())); current->thread.load_vec = 1; current->thread.load_fp = 1; - tm_recheckpoint(¤t->thread); } #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ From patchwork Wed Sep 12 19:40:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969178 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429XR20Rc7z9s3x for ; Thu, 13 Sep 2018 05:49:02 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429XR16HrkzF3S7 for ; Thu, 13 Sep 2018 05:49:01 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFR0Qd0zF3Rp for ; Thu, 13 Sep 2018 05:40:42 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJYX5l134467 for ; Wed, 12 Sep 2018 15:40:40 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2mf5sp8awy-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:40:40 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:40:39 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:40:35 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJeYGH25886876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:40:34 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6239478060; Wed, 12 Sep 2018 13:40:34 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 244E57805F; Wed, 12 Sep 2018 13:40:32 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:40:31 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 03/11] powerpc/tm: Recheckpoint when exiting from kernel Date: Wed, 12 Sep 2018 16:40:11 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-8235-0000-0000-00000DFE3072 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087370; UDB=6.00561487; IPR=6.00867382; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:40:37 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-8236-0000-0000-0000429E4E73 Message-Id: <1536781219-13938-4-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=610 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This is the only place we are going to recheckpoint now. Now the task needs to have TIF_RESTORE_TM flag set, which will get into restore_tm_state() and execute the recheckpoint if MSR shows that the transaction was active. Every time a task is required to recheckpoint, or just have the TM SPRs restore, the TIF_RESTORE_TM flag should be set and the task MSR should properly be in a transactional state, which will be checked by restore_tm_state(). Signed-off-by: Breno Leitao --- arch/powerpc/kernel/process.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 913c5725cdb2..f22f82ce174c 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -1069,6 +1069,10 @@ void restore_tm_state(struct pt_regs *regs) if (!MSR_TM_ACTIVE(regs->msr)) return; + tm_enable(); + /* The only place we recheckpoint */ + tm_recheckpoint(¤t->thread); + msr_diff = current->thread.ckpt_regs.msr & ~regs->msr; msr_diff &= MSR_FP | MSR_VEC | MSR_VSX; From patchwork Wed Sep 12 19:40:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969179 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429XTF24vhz9s3x for ; Thu, 13 Sep 2018 05:50:57 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429XTD6FDfzF37m for ; Thu, 13 Sep 2018 05:50:56 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFT4kdpzF3Rf for ; Thu, 13 Sep 2018 05:40:45 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJYbaj065552 for ; Wed, 12 Sep 2018 15:40:43 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mf5djsrub-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:40:43 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:40:42 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:40:39 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJecWq26083544 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:40:38 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1B7967805C; Wed, 12 Sep 2018 13:40:38 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBE4E7805F; Wed, 12 Sep 2018 13:40:35 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:40:35 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 04/11] powerpc/tm: Always set TIF_RESTORE_TM on reclaim Date: Wed, 12 Sep 2018 16:40:12 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-0004-0000-0000-00001488C635 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087370; UDB=6.00561487; IPR=6.00867382; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:40:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-0005-0000-0000-000088C9EE64 Message-Id: <1536781219-13938-5-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=877 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" If the task data was reclaimed (through TM_KERNEL_ENTRY), then it needs to be recheckpointed later, once exiting to userspace. The recheckpoint is done by restore_tm_state() function, which is called on our way to userspace if the task has the TIF_RESTORE_TM flag set. This patch makes sure the task has TIF_RESTORE_TM tag set every time there is a reclaim, so, a recheckpoint will be executed later. Signed-off-by: Breno Leitao --- arch/powerpc/kernel/process.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index f22f82ce174c..54fddf03b97a 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -891,6 +891,9 @@ static void tm_reclaim_thread(struct thread_struct *thr, uint8_t cause) tm_reclaim(thr, cause); + /* Tag it so restore_tm_state will pay attention to this task */ + set_thread_flag(TIF_RESTORE_TM); + /* * If we are in a transaction and FP is off then we can't have * used FP inside that transaction. Hence the checkpointed From patchwork Wed Sep 12 19:40:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969180 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429XWM2Kr4z9s3x for ; Thu, 13 Sep 2018 05:52:47 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429XWM0wfPzF37X for ; Thu, 13 Sep 2018 05:52:47 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFY0mwpzF3Cq for ; Thu, 13 Sep 2018 05:40:48 +1000 (AEST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJYZZW105689 for ; Wed, 12 Sep 2018 15:40:46 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mf7btmhnn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:40:46 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:40:45 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:40:42 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJefCi24838166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:40:41 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D66DA78068; Wed, 12 Sep 2018 13:40:41 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9824278063; Wed, 12 Sep 2018 13:40:39 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:40:39 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 05/11] powerpc/tm: Function that updates the failure code Date: Wed, 12 Sep 2018 16:40:13 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-8235-0000-0000-00000DFE3074 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087370; UDB=6.00561487; IPR=6.00867382; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:40:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-8236-0000-0000-0000429E4E84 Message-Id: <1536781219-13938-6-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=237 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Now the transaction reclaims happens very earlier in the trap handler, and it is impossible to know precisely, at that early time, what should be set as the failure cause for some specific cases, as, if the task will be rescheduled, thus, the transaction abort case should be updated from TM_CAUSE_MISC to TM_CAUSE_RESCHED, for example. This patch creates a function that will update TEXASR special purpose register in the task thread and set the failure code which will be moved to the live register afterward. Signed-off-by: Breno Leitao --- arch/powerpc/kernel/process.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 54fddf03b97a..fe063c0142e3 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -85,6 +85,7 @@ extern unsigned long _get_SP(void); * other paths that we should never reach with suspend disabled. */ bool tm_suspend_disabled __ro_after_init = false; +static void tm_fix_failure_cause(struct task_struct *task, uint8_t cause); static void check_if_tm_restore_required(struct task_struct *tsk) { @@ -988,6 +989,14 @@ void tm_recheckpoint(struct thread_struct *thread) local_irq_restore(flags); } +/* Change thread->tm.texasr failure code */ +static void tm_fix_failure_cause(struct task_struct *task, uint8_t cause) +{ + /* Clear the cause first */ + task->thread.tm_texasr &= ~TEXASR_FC; + task->thread.tm_texasr |= (unsigned long) cause << 56; +} + static inline void tm_recheckpoint_new_task(struct task_struct *new) { if (!cpu_has_feature(CPU_FTR_TM)) From patchwork Wed Sep 12 19:40:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969181 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429XYn30nVz9s9h for ; Thu, 13 Sep 2018 05:54:53 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429XYn1m5qzF39K for ; Thu, 13 Sep 2018 05:54:53 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFc002QzF3Rg for ; Thu, 13 Sep 2018 05:40:51 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJY34R101707 for ; Wed, 12 Sep 2018 15:40:50 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mf8mj1cfc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:40:49 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:40:49 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:40:46 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJejn962980320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:40:45 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A3A8F7805C; Wed, 12 Sep 2018 13:40:45 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 652557805F; Wed, 12 Sep 2018 13:40:43 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:40:43 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 06/11] powerpc/tm: Refactor the __switch_to_tm code Date: Wed, 12 Sep 2018 16:40:14 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-0020-0000-0000-00000E640D00 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087370; UDB=6.00561487; IPR=6.00867382; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:40:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-0021-0000-0000-000063013380 Message-Id: <1536781219-13938-7-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" __switch_to_tm is the function that switches between two tasks which might have TM enabled. This function is clearly split in two parts, the task that is leaving the CPU, known as 'prev' and the task that is being scheduled, known as new. It starts checking if the previous task had TM enable, if so, it increases the load_tm (this is the only place we increment load_tm). It also saves the TM SPRs here. If the previous task was scheduled out with a transaction active, the failure cause needs to be updated, since it might contain the failure cause that caused the exception, as TM_CAUSE_MISC. In this case, since there was a context switch, overwrite the failure cause. If the previous task has overflowed load_tm, disable TM, putting the facility save/restore lazy mechanism at lazy mode. Regarding the new task, when loading it, it basically restore the SPRs, and TIF_RESTORE_TM (already set by tm_reclaim_current if the transaction was active) would invoke the recheckpoint process later in restore_tm_state() if recheckpoint is somehow required. On top of that, both tm_reclaim_task() and tm_recheckpoint_new_task() functions are not used anymore, removing them. Signed-off-by: Breno Leitao --- arch/powerpc/kernel/process.c | 163 +++++++++++++++------------------- 1 file changed, 74 insertions(+), 89 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index fe063c0142e3..5cace1b744b1 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -921,48 +921,6 @@ void tm_reclaim_current(uint8_t cause) tm_reclaim_thread(¤t->thread, cause); } -static inline void tm_reclaim_task(struct task_struct *tsk) -{ - /* We have to work out if we're switching from/to a task that's in the - * middle of a transaction. - * - * In switching we need to maintain a 2nd register state as - * oldtask->thread.ckpt_regs. We tm_reclaim(oldproc); this saves the - * checkpointed (tbegin) state in ckpt_regs, ckfp_state and - * ckvr_state - * - * We also context switch (save) TFHAR/TEXASR/TFIAR in here. - */ - struct thread_struct *thr = &tsk->thread; - - if (!thr->regs) - return; - - if (!MSR_TM_ACTIVE(thr->regs->msr)) - goto out_and_saveregs; - - WARN_ON(tm_suspend_disabled); - - TM_DEBUG("--- tm_reclaim on pid %d (NIP=%lx, " - "ccr=%lx, msr=%lx, trap=%lx)\n", - tsk->pid, thr->regs->nip, - thr->regs->ccr, thr->regs->msr, - thr->regs->trap); - - tm_reclaim_thread(thr, TM_CAUSE_RESCHED); - - TM_DEBUG("--- tm_reclaim on pid %d complete\n", - tsk->pid); - -out_and_saveregs: - /* Always save the regs here, even if a transaction's not active. - * This context-switches a thread's TM info SPRs. We do it here to - * be consistent with the restore path (in recheckpoint) which - * cannot happen later in _switch(). - */ - tm_save_sprs(thr); -} - extern void __tm_recheckpoint(struct thread_struct *thread); void tm_recheckpoint(struct thread_struct *thread) @@ -997,59 +955,87 @@ static void tm_fix_failure_cause(struct task_struct *task, uint8_t cause) task->thread.tm_texasr |= (unsigned long) cause << 56; } -static inline void tm_recheckpoint_new_task(struct task_struct *new) +static inline void __switch_to_tm(struct task_struct *prev, + struct task_struct *new) { if (!cpu_has_feature(CPU_FTR_TM)) return; - /* Recheckpoint the registers of the thread we're about to switch to. - * - * If the task was using FP, we non-lazily reload both the original and - * the speculative FP register states. This is because the kernel - * doesn't see if/when a TM rollback occurs, so if we take an FP - * unavailable later, we are unable to determine which set of FP regs - * need to be restored. - */ - if (!tm_enabled(new)) - return; - - if (!MSR_TM_ACTIVE(new->thread.regs->msr)){ - tm_restore_sprs(&new->thread); - return; - } - /* Recheckpoint to restore original checkpointed register state. */ - TM_DEBUG("*** tm_recheckpoint of pid %d (new->msr 0x%lx)\n", - new->pid, new->thread.regs->msr); - - tm_recheckpoint(&new->thread); - - /* - * The checkpointed state has been restored but the live state has - * not, ensure all the math functionality is turned off to trigger - * restore_math() to reload. - */ - new->thread.regs->msr &= ~(MSR_FP | MSR_VEC | MSR_VSX); + /* The task leaving the CPU was using TM, let's handle it */ + if (tm_enabled(prev)) { + /* + * Load_tm is incremented only when the task is scheduled out + */ + prev->thread.load_tm++; - TM_DEBUG("*** tm_recheckpoint of pid %d complete " - "(kernel msr 0x%lx)\n", - new->pid, mfmsr()); -} + /* + * If TM is enabled for the thread, it needs to, at least, + * save the SPRs + */ + tm_enable(); + tm_save_sprs(&prev->thread); -static inline void __switch_to_tm(struct task_struct *prev, - struct task_struct *new) -{ - if (cpu_has_feature(CPU_FTR_TM)) { - if (tm_enabled(prev) || tm_enabled(new)) - tm_enable(); + /* + * If we got here with an active transaction, then, it was + * aborted by TM_KERNEL_ENTRY and the fix the failure case + * needs to be fixed, so, indepedently how we arrived here, the + * new TM abort case will be TM_CAUSE_RESCHED now. + */ + if (MSR_TM_ACTIVE(prev->thread.regs->msr)) { + /* + * If there was an IRQ during trecheckpoint, it will + * cause an IRQ to be replayed. This replayed IRQ can + * invoke SCHEDULE_USER, thus, we arrive here with a TM + * active transaction. + * I.e, the task was leaving kernelspace to userspace, + * already trecheckpointed, but there was a IRQ during + * the trecheckpoint process (soft irq disabled), and + * on the IRQ replay, the process was de-scheduled, so, + * SCHEDULE_USER was called and here we are. + * + */ + if (MSR_TM_ACTIVE(mfmsr())) { + /* + * This is the only other case other than + * TM_KERNEL_ENTRY that does a TM reclaim + */ + tm_reclaim_current(TM_CAUSE_RESCHED); + } - if (tm_enabled(prev)) { - prev->thread.load_tm++; - tm_reclaim_task(prev); - if (!MSR_TM_ACTIVE(prev->thread.regs->msr) && prev->thread.load_tm == 0) + /* + * If rescheduled with TM active, update the + * failure cause + */ + tm_fix_failure_cause(prev, TM_CAUSE_RESCHED); + } else { + /* + * TM enabled but not transactional. Just disable TM + * if load_tm overflows. This should be the only place + * that disables the TM and reenables the laziness + * save/restore + */ + if (prev->thread.load_tm == 0) prev->thread.regs->msr &= ~MSR_TM; } + } - tm_recheckpoint_new_task(new); + /* + * It is a *bug* if we arrived so late with a transaction active + * (more precisely suspended) + */ + if (WARN_ON(MSR_TM_ACTIVE(mfmsr()))) { + /* Recovery path. 0x99 shouldn't be exported to UAPI */ + tm_reclaim_current(0x99); + } + + /* + * If the next task has TM enabled, restore the SPRs. Do not need to + * care about recheckpoint at this time. It will be done later if + * TIF_RESTORE_TM was set when the task was scheduled out + */ + if (tm_enabled(new)) { + tm_enable(); + tm_restore_sprs(&new->thread); } } @@ -1101,7 +1087,6 @@ void restore_tm_state(struct pt_regs *regs) } #else -#define tm_recheckpoint_new_task(new) #define __switch_to_tm(prev, new) #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ @@ -1588,9 +1573,9 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) /* * Flush TM state out so we can copy it. __switch_to_tm() does this * flush but it removes the checkpointed state from the current CPU and - * transitions the CPU out of TM mode. Hence we need to call - * tm_recheckpoint_new_task() (on the same task) to restore the - * checkpointed state back and the TM mode. + * transitions the CPU out of TM mode. Hence we need to make sure + * TIF_RESTORE_TM is set so restore_tm_state is called to restore the + * checkpointed state and back to TM mode. * * Can't pass dst because it isn't ready. Doesn't matter, passing * dst is only important for __switch_to() From patchwork Wed Sep 12 19:40:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969182 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429Xbs6Vg8z9s9N for ; Thu, 13 Sep 2018 05:56:41 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429Xbs59P0zF379 for ; Thu, 13 Sep 2018 05:56:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFh0NtKzF3MR for ; Thu, 13 Sep 2018 05:40:55 +1000 (AEST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJYPYi104845 for ; Wed, 12 Sep 2018 15:40:53 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mf7btmhrr-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:40:53 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:40:52 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:40:50 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJenlh65339444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:40:49 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 246AD7805C; Wed, 12 Sep 2018 13:40:49 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 19BBD78063; Wed, 12 Sep 2018 13:40:47 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:40:46 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 07/11] powerpc/tm: Do not recheckpoint at sigreturn Date: Wed, 12 Sep 2018 16:40:15 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-0004-0000-0000-00001488C639 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087370; UDB=6.00561487; IPR=6.00867382; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:40:51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-0005-0000-0000-000088C9EE7E Message-Id: <1536781219-13938-8-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=783 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Do not recheckpoint at signal code return. Just make sure TIF_RESTORE_TM is set, which will restore on the exit to userspace by restore_tm_state. All the FP and VEC lazy restore was already done by tm_reclaim_current(), where it checked if FP/VEC was set, and filled out the ckfp and ckvr registers area to the expected value. The current FP/VEC restoration is not necessary, since the transaction will be aborted and the checkpointed values will be restore. Signed-off-by: Breno Leitao --- arch/powerpc/kernel/signal_32.c | 23 +++-------------------- arch/powerpc/kernel/signal_64.c | 15 ++------------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index e6474a45cef5..4a1b17409bf3 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c @@ -850,28 +850,11 @@ static long restore_tm_user_regs(struct pt_regs *regs, return 1; /* Pull in the MSR TM bits from the user context */ regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr_hi & MSR_TS_MASK); - /* Now, recheckpoint. This loads up all of the checkpointed (older) - * registers, including FP and V[S]Rs. After recheckpointing, the - * transactional versions should be loaded. - */ - tm_enable(); + /* Make sure the transaction is marked as failed */ current->thread.tm_texasr |= TEXASR_FS; - /* This loads the checkpointed FP/VEC state, if used */ - tm_recheckpoint(¤t->thread); - - /* This loads the speculative FP/VEC state, if used */ - msr_check_and_set(msr & (MSR_FP | MSR_VEC)); - if (msr & MSR_FP) { - load_fp_state(¤t->thread.fp_state); - regs->msr |= (MSR_FP | current->thread.fpexc_mode); - } -#ifdef CONFIG_ALTIVEC - if (msr & MSR_VEC) { - load_vr_state(¤t->thread.vr_state); - regs->msr |= MSR_VEC; - } -#endif + /* Make sure restore_tm_state will be called */ + set_thread_flag(TIF_RESTORE_TM); return 0; } diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c index 83d51bf586c7..32402aa23a5e 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c @@ -569,21 +569,10 @@ static long restore_tm_sigcontexts(struct task_struct *tsk, } } #endif - tm_enable(); /* Make sure the transaction is marked as failed */ tsk->thread.tm_texasr |= TEXASR_FS; - /* This loads the checkpointed FP/VEC state, if used */ - tm_recheckpoint(&tsk->thread); - - msr_check_and_set(msr & (MSR_FP | MSR_VEC)); - if (msr & MSR_FP) { - load_fp_state(&tsk->thread.fp_state); - regs->msr |= (MSR_FP | tsk->thread.fpexc_mode); - } - if (msr & MSR_VEC) { - load_vr_state(&tsk->thread.vr_state); - regs->msr |= MSR_VEC; - } + /* Guarantee that restore_tm_state() will be called */ + set_thread_flag(TIF_RESTORE_TM); return err; } From patchwork Wed Sep 12 19:40:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969183 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429Xdx0sBfz9s9N for ; Thu, 13 Sep 2018 05:58:29 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429Xdw6fJ5zF379 for ; Thu, 13 Sep 2018 05:58:28 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFl1bLSzF3RD for ; Thu, 13 Sep 2018 05:40:59 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJYYXS134497 for ; Wed, 12 Sep 2018 15:40:57 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2mf5sp8b63-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:40:57 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:40:56 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:40:53 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJeq0H49020978 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:40:52 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A5A37805C; Wed, 12 Sep 2018 13:40:52 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E9EE7805E; Wed, 12 Sep 2018 13:40:50 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:40:50 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 08/11] powerpc/tm: Do not reclaim on ptrace Date: Wed, 12 Sep 2018 16:40:16 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-8235-0000-0000-00000DFE3077 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087370; UDB=6.00561487; IPR=6.00867382; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:40:55 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-8236-0000-0000-0000429E4E99 Message-Id: <1536781219-13938-9-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=518 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Make sure that we are not suspended on ptrace and that the registers were already reclaimed. Since the data was already reclaimed, there is nothing to be done here except to restore the SPRs. Signed-off-by: Breno Leitao --- arch/powerpc/kernel/ptrace.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 9667666eb18e..cf6ee9154b11 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -136,12 +136,10 @@ static void flush_tmregs_to_thread(struct task_struct *tsk) if ((!cpu_has_feature(CPU_FTR_TM)) || (tsk != current)) return; - if (MSR_TM_SUSPENDED(mfmsr())) { - tm_reclaim_current(TM_CAUSE_SIGNAL); - } else { - tm_enable(); - tm_save_sprs(&(tsk->thread)); - } + WARN_ON(MSR_TM_SUSPENDED(mfmsr())); + + tm_enable(); + tm_save_sprs(&(tsk->thread)); } #else static inline void flush_tmregs_to_thread(struct task_struct *tsk) { } From patchwork Wed Sep 12 19:40:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969185 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429Xgy6bpxz9s3x for ; Thu, 13 Sep 2018 06:00:14 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429Xgy53DDzF3SR for ; Thu, 13 Sep 2018 06:00:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFq5TzKzF3D1 for ; Thu, 13 Sep 2018 05:41:03 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJY17d101610 for ; Wed, 12 Sep 2018 15:41:00 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mf8mj1cmx-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:41:00 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:40:59 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:40:57 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJeu2x20054150 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:40:56 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DCFB7805F; Wed, 12 Sep 2018 13:40:56 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2205478063; Wed, 12 Sep 2018 13:40:54 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:40:53 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 09/11] powerpc/tm: Do not restore default DSCR Date: Wed, 12 Sep 2018 16:40:17 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-8235-0000-0000-00000DFE307B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087370; UDB=6.00561487; IPR=6.00867382; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:40:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-8236-0000-0000-0000429E4E9D Message-Id: <1536781219-13938-10-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=313 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" In the previous TM code, trecheckpoint was being executed in the middle of an exception, thus, DSCR was being restored to default kernel DSCR value after trecheckpoint was done. With this current patchset, trecheckpoint is executed just before getting to userspace, at ret_from_except_lite, for example. Thus, we do not need to set default kernel DSCR value anymore, as we are leaving kernel space. It is OK to keep the checkpointed DSCR value into the live SPR, mainly because the transaction is doomed and it will fail soon (after RFID), so, continuing with the pre-checkpointed DSCR value is what seems correct. That said, we must set the DSCR value that will be used in userspace now. Current trecheckpoint() function sets it to the pre-checkpointed value prior to lines being changed in this patch, so, removing these lines would keep the pre-checkpointed values. Important to say that we do not need to do the same thing with tm_reclaim, since it already set the DSCR to the default value, after TRECLAIM is called, in the following lines: /* Load CPU's default DSCR */ ld r0, PACA_DSCR_DEFAULT(r13) mtspr SPRN_DSCR, r0 Signed-off-by: Breno Leitao --- arch/powerpc/kernel/tm.S | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S index 6bffbc5affe7..5427eda69846 100644 --- a/arch/powerpc/kernel/tm.S +++ b/arch/powerpc/kernel/tm.S @@ -493,10 +493,6 @@ restore_gprs: mtlr r0 ld r2, STK_GOT(r1) - /* Load CPU's default DSCR */ - ld r0, PACA_DSCR_DEFAULT(r13) - mtspr SPRN_DSCR, r0 - blr /* ****************************************************************** */ From patchwork Wed Sep 12 19:40:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969186 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429Xkm0JzJz9s9N for ; Thu, 13 Sep 2018 06:02:40 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429Xkl5W96zDqjV for ; Thu, 13 Sep 2018 06:02:39 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFt6365zF3RF for ; Thu, 13 Sep 2018 05:41:06 +1000 (AEST) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJYdo6052673 for ; Wed, 12 Sep 2018 15:41:05 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mf603853k-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:41:04 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:41:04 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:41:00 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJf0lZ26017958 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:41:00 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 05EDC7805F; Wed, 12 Sep 2018 13:41:00 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0E237805E; Wed, 12 Sep 2018 13:40:57 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:40:57 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 10/11] powerpc/tm: Set failure summary Date: Wed, 12 Sep 2018 16:40:18 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-0036-0000-0000-00000A3600A2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087370; UDB=6.00561487; IPR=6.00867383; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:41:02 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-0037-0000-0000-000048EAD52C Message-Id: <1536781219-13938-11-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=775 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Since the transaction will be doomed with treckpt., the TEXASR[FS] should be set, to reflect that the transaction is a failure. This patch ensures it before recheckpointing, and remove changes from other places that were calling recheckpoint. Signed-off-by: Breno Leitao --- arch/powerpc/kernel/process.c | 6 ++++++ arch/powerpc/kernel/signal_32.c | 2 -- arch/powerpc/kernel/signal_64.c | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 5cace1b744b1..77725b2e4dc1 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -937,6 +937,12 @@ void tm_recheckpoint(struct thread_struct *thread) local_irq_save(flags); hard_irq_disable(); + /* + * Make sure the failure summary is set, since the transaction will be + * doomed. + */ + thread->tm_texasr |= TEXASR_FS; + /* The TM SPRs are restored here, so that TEXASR.FS can be set * before the trecheckpoint and no explosion occurs. */ diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index 4a1b17409bf3..96956d50538e 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c @@ -851,8 +851,6 @@ static long restore_tm_user_regs(struct pt_regs *regs, /* Pull in the MSR TM bits from the user context */ regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr_hi & MSR_TS_MASK); - /* Make sure the transaction is marked as failed */ - current->thread.tm_texasr |= TEXASR_FS; /* Make sure restore_tm_state will be called */ set_thread_flag(TIF_RESTORE_TM); diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c index 32402aa23a5e..c84501711b14 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c @@ -569,8 +569,6 @@ static long restore_tm_sigcontexts(struct task_struct *tsk, } } #endif - /* Make sure the transaction is marked as failed */ - tsk->thread.tm_texasr |= TEXASR_FS; /* Guarantee that restore_tm_state() will be called */ set_thread_flag(TIF_RESTORE_TM); From patchwork Wed Sep 12 19:40:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 969187 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429Xmq370Zz9s3x for ; Thu, 13 Sep 2018 06:04:27 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 429Xmq1VkrzF37s for ; Thu, 13 Sep 2018 06:04:27 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=debian.org (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=leitao@debian.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=debian.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429XFy5v3nzF3MW for ; Thu, 13 Sep 2018 05:41:10 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJY3o4101741 for ; Wed, 12 Sep 2018 15:41:09 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mf8mj1ct4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 15:41:08 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 13:41:08 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 13:41:04 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CJf3Rt45744250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 12:41:03 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A9707805E; Wed, 12 Sep 2018 13:41:03 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FCA47805F; Wed, 12 Sep 2018 13:41:01 -0600 (MDT) Received: from debra.ibm.com (unknown [9.85.149.11]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 12 Sep 2018 13:41:01 -0600 (MDT) From: Breno Leitao To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 11/11] selftests/powerpc: Adapt the test Date: Wed, 12 Sep 2018 16:40:19 -0300 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536781219-13938-1-git-send-email-leitao@debian.org> References: <1536781219-13938-1-git-send-email-leitao@debian.org> X-TM-AS-GCONF: 00 x-cbid: 18091219-0016-0000-0000-0000092C787F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087369; UDB=6.00561488; IPR=6.00867382; MB=3.00023256; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 19:41:06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091219-0017-0000-0000-0000405467D1 Message-Id: <1536781219-13938-12-git-send-email-leitao@debian.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120195 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com, Breno Leitao , ldufour@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The Documentation/powerpc/transactional_memory.txt says: "Syscalls made from within a suspended transaction are performed as normal and the transaction is not explicitly doomed by the kernel. However, what the kernel does to perform the syscall may result in the transaction being doomed by the hardware." With this new TM mechanism, the syscall will continue to be executed if the syscall happens on a suspended syscall, but, the syscall will *fail* if the transaction is still active during the syscall invocation. On the syscall path, if the transaction is active and not suspended, it will call TM_KERNEL_ENTRY which will reclaim and recheckpoint the transaction, thus, dooming the transaction on userspace return, with failure code TM_CAUSE_SYSCALL. This new model will break part of this test, but I understand that that the documentation above didn't guarantee that the syscall would succeed, and it will never succeed anymore now on. In fact, glibc is calling 'tabort' before every syscalls, thus, any syscall called through glibc from inside a transaction will be doomed anyhow. This patch updates the test case to not assume that a syscall inside a active transaction will succeed, because it will not anymore. Signed-off-by: Breno Leitao --- tools/testing/selftests/powerpc/tm/tm-syscall.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/testing/selftests/powerpc/tm/tm-syscall.c b/tools/testing/selftests/powerpc/tm/tm-syscall.c index 454b965a2db3..1439a87eba3a 100644 --- a/tools/testing/selftests/powerpc/tm/tm-syscall.c +++ b/tools/testing/selftests/powerpc/tm/tm-syscall.c @@ -78,12 +78,6 @@ int tm_syscall(void) timeradd(&end, &now, &end); for (count = 0; timercmp(&now, &end, <); count++) { - /* - * Test a syscall within a suspended transaction and verify - * that it succeeds. - */ - FAIL_IF(getppid_tm(true) == -1); /* Should succeed. */ - /* * Test a syscall within an active transaction and verify that * it fails with the correct failure code.