Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7747251ybi; Thu, 6 Jun 2019 00:32:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwv4cSKWe+tnupn5xfhxs0DtCz37seZH4g3zL9+6y3dctJTvUnMwCDe0b6SfSXwPyjcrgm7 X-Received: by 2002:a17:902:ac85:: with SMTP id h5mr41757735plr.198.1559806326527; Thu, 06 Jun 2019 00:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559806326; cv=none; d=google.com; s=arc-20160816; b=Yi2sd4OC9jhlfyBXnIoRy+cfT8W+hO8RHErq3ZDOD/IzZZEFPVaiDkRV8phEtcbsgZ k8GELq2RHwba32E1mxXcvKImjItfs7ZmDtxOKM2aUnXVNwNhelO7Gvkd0TXyLukjcjOm 4z+jJ+E/XRwizPZ/mGahcSfj8U1x0jtJ+CI5O6n3h+A04yfGNViAG2QpWLghXDhM/jay Qm6kynmNVSONQl6PbsLzF0kVndE1gvqKa9fELaM5kDHu6lCoGj2/o9NsCjT7xb2FhAdW otQZZmsFZNUdp5/ZsDSepbSqyNiUdpUvAePJqSsh4xk52mSAJxu//20zxKmA/s1L+DR2 QuXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:date:subject:cc:to:from; bh=2vkvIe9xB/2dMyn7v5QujEjDAj0EXlJB0dTIQmmwmr4=; b=NN0v5xZVPKs+VgXF/2AYa1xCAV+dUWCK58NgEVRPpO8tBNWY96F11rczkzKfgJcKw8 81hcgRgAyl1bQuMdSLuHGnCnSypBOfrl/CfHp+qtsIWkItC+rShTc/lUYfiEg11/GLVP mR88A+X4yvJCkE3//pKVlmiKqoCAK6c4ZkvML84Kh98RS4mXJaLDL/pLkGTycwEYK2fw 3sCH9iCsGxUXrCqTFavRlqAtBZjBQsyuQftyU4ZMAglpwMroWmrEHyUN0wqfI0TZO1dN 6D9PIoa5piARz1IfVKOOc5gns3A7fdBwYVV12sJwaLDA7Zh1R4oYlYPGi4aOvZqatXCQ dv0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si1353609pgk.417.2019.06.06.00.31.48; Thu, 06 Jun 2019 00:32:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726223AbfFFHa2 (ORCPT + 99 others); Thu, 6 Jun 2019 03:30:28 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60450 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726014AbfFFHa2 (ORCPT ); Thu, 6 Jun 2019 03:30:28 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x567ML43159113 for ; Thu, 6 Jun 2019 03:30:26 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2sxv7ee25q-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 06 Jun 2019 03:30:26 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Jun 2019 08:30:24 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 6 Jun 2019 08:30:21 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x567UKgS31785094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Jun 2019 07:30:20 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D7DF4C076; Thu, 6 Jun 2019 07:30:20 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F6E84C07F; Thu, 6 Jun 2019 07:30:18 +0000 (GMT) Received: from bangoria.in.ibm.com (unknown [9.122.210.87]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 6 Jun 2019 07:30:18 +0000 (GMT) From: Ravi Bangoria To: mpe@ellerman.id.au Cc: mikey@neuling.org, benh@kernel.crashing.org, paulus@samba.org, npiggin@gmail.com, christophe.leroy@c-s.fr, mahesh@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Ravi Bangoria Subject: [PATCH] Powerpc/Watchpoint: Restore nvgprs while returning from exception Date: Thu, 6 Jun 2019 12:59:51 +0530 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19060607-0020-0000-0000-000003470E65 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19060607-0021-0000-0000-0000219A210D Message-Id: <20190606072951.32116-1-ravi.bangoria@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-06_06:,, 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-1810050000 definitions=main-1906060054 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Powerpc hw triggers watchpoint before executing the instruction. To make trigger-after-execute behavior, kernel emulates the instruction. If the instruction is 'load something into non- volatile register', exception handler should restore emulated register state while returning back, otherwise there will be register state corruption. Ex, Adding a watchpoint on a list can corrput the list: # cat /proc/kallsyms | grep kthread_create_list c00000000121c8b8 d kthread_create_list Add watchpoint on kthread_create_list->next: # perf record -e mem:0xc00000000121c8c0 Run some workload such that new kthread gets invoked. Ex, I just logged out from console: list_add corruption. next->prev should be prev (c000000001214e00), \ but was c00000000121c8b8. (next=c00000000121c8b8). WARNING: CPU: 59 PID: 309 at lib/list_debug.c:25 __list_add_valid+0xb4/0xc0 CPU: 59 PID: 309 Comm: kworker/59:0 Kdump: loaded Not tainted 5.1.0-rc7+ #69 ... NIP __list_add_valid+0xb4/0xc0 LR __list_add_valid+0xb0/0xc0 Call Trace: __list_add_valid+0xb0/0xc0 (unreliable) __kthread_create_on_node+0xe0/0x260 kthread_create_on_node+0x34/0x50 create_worker+0xe8/0x260 worker_thread+0x444/0x560 kthread+0x160/0x1a0 ret_from_kernel_thread+0x5c/0x70 Signed-off-by: Ravi Bangoria --- arch/powerpc/kernel/exceptions-64s.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 9481a11..96de0d1 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1753,7 +1753,7 @@ handle_dabr_fault: ld r5,_DSISR(r1) addi r3,r1,STACK_FRAME_OVERHEAD bl do_break -12: b ret_from_except_lite +12: b ret_from_except #ifdef CONFIG_PPC_BOOK3S_64 -- 1.8.3.1