From patchwork Mon Jul 18 15:46:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ryan Grimm X-Patchwork-Id: 1657552 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=UY7/ZAVP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LmmXr1Q2Fz9s2R for ; Tue, 19 Jul 2022 01:46:35 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4LmmXp434wz3bkm for ; Tue, 19 Jul 2022 01:46:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=UY7/ZAVP; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=grimm@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=UY7/ZAVP; dkim-atps=neutral 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 4LmmXh71Ksz30Mr for ; Tue, 19 Jul 2022 01:46:28 +1000 (AEST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26IFfrjN011153 for ; Mon, 18 Jul 2022 15:46:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=MWHrTJd7mpyVC7CuY7szpsi3GJa5QjZlNWnnDHsGWPE=; b=UY7/ZAVPyKbIMzphjviNIdjbnKckh5pgnTiciSTGB94U7tJ5yna34duDvv5TqzmmgBhX j0XspLo07194ssdUCGuYdYRu63eHlY1TnVx0/uIdqnJXvVGOX7LDonN1Q/arJDApv5BL GgbKssi8QsqNlZ09K9HXGtewOgV+P7/mJMPQgRIO8GvNxfD5tZIzXlmctG+uME9CxHk7 aNxK3pLoG63eHpEVG3yLu3DQ6gUdeyU1st4CLR7dlU9bZv5kSyMyrjRi/yf4iYBwA0rO 14THRYLiT2tDRwdx2Ux1xf7pgPmGiv99MBwYnct3Dhzo1MH0eb6INH3HpSUoya2dTl+a gA== Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hdacu03n9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Jul 2022 15:46:25 +0000 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26IFKo2g024104 for ; Mon, 18 Jul 2022 15:46:24 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma04dal.us.ibm.com with ESMTP id 3hbmy9h4m4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Jul 2022 15:46:24 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26IFkN1v54067708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Jul 2022 15:46:23 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71787112064; Mon, 18 Jul 2022 15:46:23 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C1AD112062; Mon, 18 Jul 2022 15:46:22 +0000 (GMT) Received: from alain.ibm.com (unknown [9.211.109.146]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 18 Jul 2022 15:46:22 +0000 (GMT) From: Ryan Grimm To: skiboot@lists.ozlabs.org Date: Mon, 18 Jul 2022 11:46:20 -0400 Message-Id: <20220718154620.132195-1-grimm@linux.ibm.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: WGpGBhbI68VqfLqy82Qaqe1YDLW6WdMN X-Proofpoint-ORIG-GUID: WGpGBhbI68VqfLqy82Qaqe1YDLW6WdMN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-18_14,2022-07-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 clxscore=1011 phishscore=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207180067 Subject: [Skiboot] [PATCH] mambo: Fix backtrace when trace mixes endian code X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ryan Grimm Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" In the case of LE kernel and BE skiboot, the bt functions triggers an illegal address when the kernel has a stack pointer in skiboot. For example, in copy_and_flush: pc: 0x000000000000C25C +0x000000000000C25C lr: 0x000000000000C240 +0x000000000000C240 stack:0x0000000031C13D20 0x8428023000000000 +0x8428023000000000 Illegal Address 0x001EC13100000007 The bad address is from mem_display_64 and is fixed up by inverting the LE bit: systemsim % mem_display_64 [ expr 0x0000000031C13D20 ] 1 0x103EC13100000000 systemsim % mem_display_64 [ expr 0x0000000031C13D20 ] 0 0x0000000031C13E10 This patch tests the pointer by catching the illegal access and inverting the LE bit. Now the stack trace looks good: pc: 0x000000000000C254 +0x000000000000C254 lr: 0x000000000000C240 +0x000000000000C240 stack:0x0000000031C13D20 0x0000000030022884 .load_and_boot_kernel+0xc6c stack:0x0000000031C13E10 0x0000000030023344 .main_cpu_entry+0x8bc Opal calls also look good too now: pc: 0x0000000030028588 .cpu_idle_delay+0xb8 lr: 0x000000003002856C .cpu_idle_delay+0x9c stack:0x0000000031C13A10 0x0000000030028514 .cpu_idle_delay+0x44 stack:0x0000000031C13AB0 0x000000003002D6C0 .time_wait_nopoll+0x34 stack:0x0000000031C13B20 0x000000003002D77C .time_wait+0xa8 stack:0x0000000031C13BA0 0x000000003002821C .cpu_wait_job+0x3c stack:0x0000000031C13C40 0x0000000030029554 .opal_reinit_cpus+0x3c0 stack:0x0000000031C13D10 0x00000000300038AC opal_entry+0x14c stack:0x000000000071FDA0 0xC0000000000537B0 opal_call+0x40 stack:0x000000000071FE60 0xC00000000005450C opal_reinit_cpus+0x20 stack:0x000000000071FED0 0xC00000000065FDAC opal_configure_cores+0x48 stack:0x000000000071FF00 0xC000000000656554 early_setup+0x134 Signed-off-by: Ryan Grimm Reviewed-by: Dan HorĂ¡k Acked-by: Nicholas Piggin --- external/mambo/mambo_utils.tcl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/external/mambo/mambo_utils.tcl b/external/mambo/mambo_utils.tcl index 96f8971a..f8f64eb9 100644 --- a/external/mambo/mambo_utils.tcl +++ b/external/mambo/mambo_utils.tcl @@ -423,6 +423,13 @@ proc bt { {sp 0} } { set sym [addr2func $lr] puts "stack:$pa \t$lr\t$sym" if { $bc == 0 } { break } + + # catch illegal address in case of endian mismatch + set tstpa [ mysim cpu $p:$c:$t util dtranslate $bc ] + if {[catch { set tst [ mem_display_64 $tstpa $le ] } ]} { + set le [ expr ! $le ] + set bc [ mem_display_64 $pa $le ] + } set sp $bc } puts ""