Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752550AbdLLPjp convert rfc822-to-8bit (ORCPT ); Tue, 12 Dec 2017 10:39:45 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45888 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752111AbdLLPjg (ORCPT ); Tue, 12 Dec 2017 10:39:36 -0500 Date: Tue, 12 Dec 2017 21:09:26 +0530 From: "Naveen N. Rao" Subject: Re: [PATCH] powerpc/perf: Dereference bhrb entries safely To: mpe@ellerman.id.au, Ravi Bangoria Cc: benh@kernel.crashing.org, kamalesh@linux.vnet.ibm.com, kan.liang@intel.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, maddy@linux.vnet.ibm.com, paulus@samba.org, tglx@linutronix.de References: <20171212122915.20338-1-ravi.bangoria@linux.vnet.ibm.com> In-Reply-To: <20171212122915.20338-1-ravi.bangoria@linux.vnet.ibm.com> User-Agent: astroid/0.10.2 (https://github.com/astroidmail/astroid) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT X-TM-AS-GCONF: 00 x-cbid: 17121215-0016-0000-0000-0000050C3C89 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17121215-0017-0000-0000-000028484FD4 Message-Id: <1513093135.p9uc48ls6m.naveen@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-12_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712120224 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1019 Lines: 26 Ravi Bangoria wrote: > It may very well happen that branch instructions recorded by > bhrb entries already get unmapped before they get processed by > the kernel. Hence, trying to dereference such memory location > will endup in a crash. Ex, > > Unable to handle kernel paging request for data at address 0xc008000019c41764 > Faulting instruction address: 0xc000000000084a14 > NIP [c000000000084a14] branch_target+0x4/0x70 > LR [c0000000000eb828] record_and_restart+0x568/0x5c0 > Call Trace: > [c0000000000eb3b4] record_and_restart+0xf4/0x5c0 (unreliable) > [c0000000000ec378] perf_event_interrupt+0x298/0x460 > [c000000000027964] performance_monitor_exception+0x54/0x70 > [c000000000009ba4] performance_monitor_common+0x114/0x120 > > Fix this by deferefencing them safely. > > Suggested-by: Naveen N. Rao > Signed-off-by: Ravi Bangoria Reviewed-by: Naveen N. Rao - Naveen