From patchwork Mon Mar 18 04:28:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 1057674 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44N39g1Hzqz9sBr for ; Mon, 18 Mar 2019 15:29:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44N39f4jnKzDqJk for ; Mon, 18 Mar 2019 15:29:26 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=au1.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=andrew.donnellan@au1.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com 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 44N39Z4jcXzDqJ5 for ; Mon, 18 Mar 2019 15:29:21 +1100 (AEDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2I4Sexo023195 for ; Mon, 18 Mar 2019 00:29:19 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ra44ura9m-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Mar 2019 00:29:18 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Mar 2019 04:29:16 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 18 Mar 2019 04:29:14 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2I4TERo35651834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Mar 2019 04:29:14 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 05B68A405C for ; Mon, 18 Mar 2019 04:29:14 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB835A405F for ; Mon, 18 Mar 2019 04:29:13 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Mon, 18 Mar 2019 04:29:13 +0000 (GMT) Received: from intelligence.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 39512A0206 for ; Mon, 18 Mar 2019 15:29:12 +1100 (AEDT) From: Andrew Donnellan To: skiboot@lists.ozlabs.org Date: Mon, 18 Mar 2019 15:28:54 +1100 X-Mailer: git-send-email 2.11.0 X-TM-AS-GCONF: 00 x-cbid: 19031804-0028-0000-0000-000003553D57 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031804-0029-0000-0000-00002413D3AE Message-Id: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-18_03:, , 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-1903180034 Subject: [Skiboot] [PATCH 1/7] core/stack: Remove r1 argument from ___backtrace() 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" ___backtrace() is always called with r1 = __builtin_frame_address(0), and it's unlikely we're going to need it to do something else any time soon, so simplify the API by removing the parameter. Signed-off-by: Andrew Donnellan --- core/stack.c | 6 ++---- include/stack.h | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/core/stack.c b/core/stack.c index 3a86a3768655..5e4cf4bc0c53 100644 --- a/core/stack.c +++ b/core/stack.c @@ -28,11 +28,10 @@ static struct bt_entry bt_buf[STACK_BUF_ENTRIES]; /* Dumps backtrace to buffer */ void __nomcount ___backtrace(struct bt_entry *entries, unsigned int *count, - unsigned long r1, unsigned long *token, unsigned long *r1_caller) { unsigned int room = *count; - unsigned long *fp = (unsigned long *)r1; + unsigned long *fp = __builtin_frame_address(0); unsigned long top_adj = top_of_ram; struct stack_frame *eframe = (struct stack_frame *)fp; @@ -128,8 +127,7 @@ void backtrace(void) lock(&bt_lock); - ___backtrace(bt_buf, &ents, (unsigned long)__builtin_frame_address(0), - &token, &r1_caller); + ___backtrace(bt_buf, &ents, &token, &r1_caller); ___print_backtrace(mfspr(SPR_PIR), bt_buf, ents, token, r1_caller, NULL, NULL, true); diff --git a/include/stack.h b/include/stack.h index 7578cc34517d..ae910a3211a0 100644 --- a/include/stack.h +++ b/include/stack.h @@ -118,15 +118,12 @@ extern void *boot_stack_top; /* Create a backtrace */ void ___backtrace(struct bt_entry *entries, unsigned int *count, - unsigned long r1, unsigned long *token, unsigned long *r1_caller); static inline void __backtrace(struct bt_entry *entries, unsigned int *count) { unsigned long token, r1_caller; - ___backtrace(entries, count, - (unsigned long)__builtin_frame_address(0), - &token, &r1_caller); + ___backtrace(entries, count, &token, &r1_caller); } /* Convert a backtrace to ASCII */ From patchwork Mon Mar 18 04:28:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 1057676 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44N3B95ZGHz9sBV for ; Mon, 18 Mar 2019 15:29:53 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44N3B94Gl0zDqMn for ; Mon, 18 Mar 2019 15:29:53 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=au1.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=andrew.donnellan@au1.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com 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 44N39Z4gDZzDqHx for ; Mon, 18 Mar 2019 15:29:22 +1100 (AEDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2I4SeDY001213 for ; Mon, 18 Mar 2019 00:29:19 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ra44bgbcr-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Mar 2019 00:29:19 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Mar 2019 04:29:15 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 18 Mar 2019 04:29:13 -0000 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 x2I4TEgc44761178 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Mar 2019 04:29:14 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4ABD24C04A for ; Mon, 18 Mar 2019 04:29:14 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ABE204C040 for ; Mon, 18 Mar 2019 04:29:13 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Mon, 18 Mar 2019 04:29:13 +0000 (GMT) Received: from intelligence.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 497C8A024A for ; Mon, 18 Mar 2019 15:29:12 +1100 (AEDT) From: Andrew Donnellan To: skiboot@lists.ozlabs.org Date: Mon, 18 Mar 2019 15:28:55 +1100 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> References: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19031804-4275-0000-0000-0000031C348A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031804-4276-0000-0000-0000382AAE96 Message-Id: <20190318042900.32558-2-andrew.donnellan@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-18_03:, , 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=832 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903180034 Subject: [Skiboot] [PATCH 2/7] core/stack: Define a backtrace metadata struct 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Every time we take a backtrace, we have to store the number of entries, the OPAL API token, r1 caller and PIR values. Rather than defining these and passing them around all over the place, let's throw them in a struct. Define a struct, struct bt_metadata, to store these details, and convert ___backtrace() and ___print_backtrace() to use it. We change the wrapper functions __backtrace() and __print_backtrace() to call ___backtrace()/___print_backtrace() with struct bt_metadata, but don't change their parameter profiles for now - we'll do that later. Signed-off-by: Andrew Donnellan --- core/stack.c | 53 ++++++++++++++++++++++++++--------------------------- include/stack.h | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/core/stack.c b/core/stack.c index 5e4cf4bc0c53..773d91e34eea 100644 --- a/core/stack.c +++ b/core/stack.c @@ -27,10 +27,9 @@ static struct bt_entry bt_buf[STACK_BUF_ENTRIES]; /* Dumps backtrace to buffer */ -void __nomcount ___backtrace(struct bt_entry *entries, unsigned int *count, - unsigned long *token, unsigned long *r1_caller) +void __nomcount ___backtrace(struct bt_entry *entries, unsigned int max_ents, + struct bt_metadata *metadata) { - unsigned int room = *count; unsigned long *fp = __builtin_frame_address(0); unsigned long top_adj = top_of_ram; struct stack_frame *eframe = (struct stack_frame *)fp; @@ -39,8 +38,8 @@ void __nomcount ___backtrace(struct bt_entry *entries, unsigned int *count, if (top_of_ram == SKIBOOT_BASE + SKIBOOT_SIZE) top_adj = top_of_ram + STACK_SIZE; - *count = 0; - while(room) { + metadata->ents = 0; + while (max_ents) { fp = (unsigned long *)fp[0]; if (!fp || (unsigned long)fp > top_adj) break; @@ -48,22 +47,20 @@ void __nomcount ___backtrace(struct bt_entry *entries, unsigned int *count, entries->sp = (unsigned long)fp; entries->pc = fp[2]; entries++; - *count = (*count) + 1; - room--; + metadata->ents++; + max_ents--; } - *r1_caller = eframe->gpr[1]; + metadata->r1_caller = eframe->gpr[1]; if (fp) - *token = eframe->gpr[0]; + metadata->token = eframe->gpr[0]; else - *token = -1UL; + metadata->token = -1UL; } -void ___print_backtrace(unsigned int pir, struct bt_entry *entries, - unsigned int count, unsigned long token, - unsigned long r1_caller, char *out_buf, - unsigned int *len, bool symbols) +void ___print_backtrace(struct bt_entry *entries, struct bt_metadata *metadata, + char *out_buf, unsigned int *len, bool symbols) { static char bt_text_buf[4096]; int i, l = 0, max; @@ -77,14 +74,14 @@ void ___print_backtrace(unsigned int pir, struct bt_entry *entries, } else max = *len - 1; - bottom = cpu_stack_bottom(pir); - normal_top = cpu_stack_top(pir); - top = cpu_emergency_stack_top(pir); + bottom = cpu_stack_bottom(metadata->pir); + normal_top = cpu_stack_top(metadata->pir); + top = cpu_emergency_stack_top(metadata->pir); tbot = SKIBOOT_BASE; ttop = (unsigned long)&_etext; - l += snprintf(buf, max, "CPU %04x Backtrace:\n", pir); - for (i = 0; i < count && l < max; i++) { + l += snprintf(buf, max, "CPU %04lx Backtrace:\n", metadata->pir); + for (i = 0; i < metadata->ents && l < max; i++) { if (entries->sp < bottom || entries->sp > top) mark = '!'; else if (entries->sp > normal_top) @@ -101,9 +98,11 @@ void ___print_backtrace(unsigned int pir, struct bt_entry *entries, l += snprintf(buf + l, max - l, "\n"); entries++; } - if (token <= OPAL_LAST) - l += snprintf(buf + l, max - l, " --- OPAL call token: 0x%lx caller R1: 0x%016lx ---\n", token, r1_caller); - else if (token == -1UL) + if (metadata->token <= OPAL_LAST) + l += snprintf(buf + l, max - l, + " --- OPAL call token: 0x%lx caller R1: 0x%016lx ---\n", + metadata->token, metadata->r1_caller); + else if (metadata->token == -1UL) l += snprintf(buf + l, max - l, " --- OPAL boot ---\n"); if (!out_buf) write(stdout->fd, bt_text_buf, l); @@ -122,14 +121,14 @@ struct lock bt_lock = LOCK_UNLOCKED; void backtrace(void) { - unsigned int ents = STACK_BUF_ENTRIES; - unsigned long token, r1_caller; + struct bt_metadata metadata = { + .pir = mfspr(SPR_PIR), + }; lock(&bt_lock); - ___backtrace(bt_buf, &ents, &token, &r1_caller); - ___print_backtrace(mfspr(SPR_PIR), bt_buf, ents, token, r1_caller, - NULL, NULL, true); + ___backtrace(bt_buf, STACK_BUF_ENTRIES, &metadata); + ___print_backtrace(bt_buf, &metadata, NULL, NULL, true); unlock(&bt_lock); } diff --git a/include/stack.h b/include/stack.h index ae910a3211a0..d8baf8dc7773 100644 --- a/include/stack.h +++ b/include/stack.h @@ -107,36 +107,52 @@ struct stack_frame { uint64_t dar; } __attribute__((aligned(16))); -/* Backtrace */ +/* Backtrace entry */ struct bt_entry { unsigned long sp; unsigned long pc; }; +/* Backtrace metadata */ +struct bt_metadata { + unsigned int ents; + unsigned long token; + unsigned long r1_caller; + unsigned long pir; +}; + /* Boot stack top */ extern void *boot_stack_top; /* Create a backtrace */ -void ___backtrace(struct bt_entry *entries, unsigned int *count, - unsigned long *token, unsigned long *r1_caller); +void ___backtrace(struct bt_entry *entries, unsigned int max_ents, + struct bt_metadata *metadata); + static inline void __backtrace(struct bt_entry *entries, unsigned int *count) { - unsigned long token, r1_caller; + struct bt_metadata metadata; + + ___backtrace(entries, *count, &metadata); - ___backtrace(entries, count, &token, &r1_caller); + *count = metadata.ents; } /* Convert a backtrace to ASCII */ -extern void ___print_backtrace(unsigned int pir, struct bt_entry *entries, - unsigned int count, unsigned long token, - unsigned long r1_caller, char *out_buf, - unsigned int *len, bool symbols); +extern void ___print_backtrace(struct bt_entry *entries, + struct bt_metadata *metadata, char *out_buf, + unsigned int *len, bool symbols); static inline void __print_backtrace(unsigned int pir, struct bt_entry *entries, - unsigned int count, char *out_buf, - unsigned int *len, bool symbols) + unsigned int count, char *out_buf, + unsigned int *len, bool symbols) { - ___print_backtrace(pir, entries, count, OPAL_LAST + 1, 0, out_buf, len, symbols); + struct bt_metadata metadata = { + .ents = count, + .token = OPAL_LAST + 1, + .r1_caller = 0, + .pir = pir + }; + ___print_backtrace(entries, &metadata, out_buf, len, symbols); } /* For use by debug code, create and print backtrace, uses a static buffer */ From patchwork Mon Mar 18 04:28:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 1057679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44N3By5VFNz9sBV for ; Mon, 18 Mar 2019 15:30:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44N3By4NWWzDqM3 for ; Mon, 18 Mar 2019 15:30:34 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=au1.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=andrew.donnellan@au1.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com 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 44N39Z4d3LzDqHg for ; Mon, 18 Mar 2019 15:29:22 +1100 (AEDT) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2I4ScbV042799 for ; Mon, 18 Mar 2019 00:29:18 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ra2ey3bf6-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Mar 2019 00:29:18 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Mar 2019 04:29:14 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 18 Mar 2019 04:29:12 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2I4TEWJ27525178 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Mar 2019 04:29:14 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 06A67A4062 for ; Mon, 18 Mar 2019 04:29:14 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC0CEA4060 for ; Mon, 18 Mar 2019 04:29:13 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Mon, 18 Mar 2019 04:29:13 +0000 (GMT) Received: from intelligence.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 5A056A02C7 for ; Mon, 18 Mar 2019 15:29:12 +1100 (AEDT) From: Andrew Donnellan To: skiboot@lists.ozlabs.org Date: Mon, 18 Mar 2019 15:28:56 +1100 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> References: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19031804-0016-0000-0000-000002641793 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031804-0017-0000-0000-000032BF21BB Message-Id: <20190318042900.32558-3-andrew.donnellan@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-18_03:, , 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=865 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903180034 Subject: [Skiboot] [PATCH 3/7] core/stack: Store PIR in ___backtrace() 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" In ___backtrace(), store the current PIR in the metadata struct, rather than relying on the caller to do it. Signed-off-by: Andrew Donnellan --- core/stack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/stack.c b/core/stack.c index 773d91e34eea..f7eca1ffb0ff 100644 --- a/core/stack.c +++ b/core/stack.c @@ -57,6 +57,8 @@ void __nomcount ___backtrace(struct bt_entry *entries, unsigned int max_ents, metadata->token = eframe->gpr[0]; else metadata->token = -1UL; + + metadata->pir = mfspr(SPR_PIR); } void ___print_backtrace(struct bt_entry *entries, struct bt_metadata *metadata, @@ -121,9 +123,7 @@ struct lock bt_lock = LOCK_UNLOCKED; void backtrace(void) { - struct bt_metadata metadata = { - .pir = mfspr(SPR_PIR), - }; + struct bt_metadata metadata; lock(&bt_lock); From patchwork Mon Mar 18 04:28:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 1057677 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44N3BP6qwLz9sBr for ; Mon, 18 Mar 2019 15:30:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44N3BP5j9nzDqM1 for ; Mon, 18 Mar 2019 15:30:05 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=au1.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=andrew.donnellan@au1.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com 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 44N39Z4Y51zDqHV for ; Mon, 18 Mar 2019 15:29:21 +1100 (AEDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2I4SfMp032138 for ; Mon, 18 Mar 2019 00:29:19 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ra42v0cek-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Mar 2019 00:29:19 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Mar 2019 04:29:17 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 18 Mar 2019 04:29:14 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2I4TEX033882136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 18 Mar 2019 04:29:14 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 07E00A404D for ; Mon, 18 Mar 2019 04:29:14 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ABBEDA4051 for ; Mon, 18 Mar 2019 04:29:13 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Mon, 18 Mar 2019 04:29:13 +0000 (GMT) Received: from intelligence.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 669C9A0321 for ; Mon, 18 Mar 2019 15:29:12 +1100 (AEDT) From: Andrew Donnellan To: skiboot@lists.ozlabs.org Date: Mon, 18 Mar 2019 15:28:57 +1100 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> References: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19031804-0028-0000-0000-000003553D58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031804-0029-0000-0000-00002413D3AF Message-Id: <20190318042900.32558-4-andrew.donnellan@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-18_03:, , 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-1903180034 Subject: [Skiboot] [PATCH 4/7] hw/fsp, hw/ipmi: Convert attn code to not use backtrace wrappers 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" We're about to get rid of __backtrace() and __print_backtrace(), convert the FSP/IPMI attn code to not use them. Signed-off-by: Andrew Donnellan --- hw/fsp/fsp-attn.c | 10 +++++----- hw/ipmi/ipmi-attn.c | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/hw/fsp/fsp-attn.c b/hw/fsp/fsp-attn.c index ff702ab2602c..6774dd84cee7 100644 --- a/hw/fsp/fsp-attn.c +++ b/hw/fsp/fsp-attn.c @@ -92,7 +92,8 @@ static void update_sp_attn_area(const char *msg) { #define STACK_BUF_ENTRIES 20 struct bt_entry bt_buf[STACK_BUF_ENTRIES]; - unsigned int ent_cnt, len; + struct bt_metadata metadata; + unsigned int len; if (!fsp_present()) return; @@ -105,11 +106,10 @@ static void update_sp_attn_area(const char *msg) cpu_to_be32((uint32_t)((uint64_t)__builtin_return_address(0) & 0xffffffff)); snprintf(ti_attn->msg.version, VERSION_LEN, "%s", version); - ent_cnt = STACK_BUF_ENTRIES; - __backtrace(bt_buf, &ent_cnt); + ___backtrace(bt_buf, STACK_BUF_ENTRIES, &metadata); + metadata.token = OPAL_LAST + 1; len = BT_FRAME_LEN; - __print_backtrace(mfspr(SPR_PIR), bt_buf, ent_cnt, - ti_attn->msg.bt_buf, &len, false); + ___print_backtrace(bt_buf, &metadata, ti_attn->msg.bt_buf, &len, false); snprintf(ti_attn->msg.file_info, FILE_INFO_LEN, "%s", msg); ti_attn->msg_len = VERSION_LEN + BT_FRAME_LEN + diff --git a/hw/ipmi/ipmi-attn.c b/hw/ipmi/ipmi-attn.c index 8ff872c62669..8407188401a3 100644 --- a/hw/ipmi/ipmi-attn.c +++ b/hw/ipmi/ipmi-attn.c @@ -38,7 +38,7 @@ static struct bt_entry bt_buf[STACK_BUF_ENTRIES]; /* Log eSEL event with OPAL backtrace */ static void ipmi_log_terminate_event(const char *msg) { - unsigned int bt_entry_cnt = STACK_BUF_ENTRIES; + struct bt_metadata metadata; unsigned int ti_len; unsigned int ti_size; struct errorlog *elog_buf; @@ -53,9 +53,10 @@ static void ipmi_log_terminate_event(const char *msg) ti_size = IPMI_TI_BUFFER_SIZE - ti_len; /* Backtrace */ - __backtrace(bt_buf, &bt_entry_cnt); - __print_backtrace(mfspr(SPR_PIR), bt_buf, bt_entry_cnt, - ti_buffer + ti_len, &ti_size, true); + ___backtrace(bt_buf, STACK_BUF_ENTRIES, &metadata); + metadata.token = OPAL_LAST + 1; + ___print_backtrace(bt_buf, &metadata, ti_buffer + ti_len, &ti_size, + true); /* Create eSEL event and commit */ elog_buf = opal_elog_create(&e_info(OPAL_RC_ATTN), 0); From patchwork Mon Mar 18 04:28:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 1057678 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44N3Bh3kLFz9sBV for ; Mon, 18 Mar 2019 15:30:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44N3Bh2KLjzDqMn for ; Mon, 18 Mar 2019 15:30:20 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=au1.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=andrew.donnellan@au1.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com 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 44N39b0cY2zDqJV for ; Mon, 18 Mar 2019 15:29:22 +1100 (AEDT) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2I4ScBN093474 for ; Mon, 18 Mar 2019 00:29:20 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ra3khh8bk-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Mar 2019 00:29:20 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Mar 2019 04:29:13 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 18 Mar 2019 04:29:13 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2I4TElS34078858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 18 Mar 2019 04:29:14 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 05E2311C050 for ; Mon, 18 Mar 2019 04:29:14 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB1CF11C04C for ; Mon, 18 Mar 2019 04:29:13 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Mon, 18 Mar 2019 04:29:13 +0000 (GMT) Received: from intelligence.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 72E87A0349 for ; Mon, 18 Mar 2019 15:29:12 +1100 (AEDT) From: Andrew Donnellan To: skiboot@lists.ozlabs.org Date: Mon, 18 Mar 2019 15:28:58 +1100 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> References: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19031804-4275-0000-0000-0000031C3489 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031804-4276-0000-0000-0000382AAE94 Message-Id: <20190318042900.32558-5-andrew.donnellan@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-18_03:, , 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=847 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903180034 Subject: [Skiboot] [PATCH 5/7] core/stack: Convert stack check code to not use backtrace wrapper 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" We're about to get rid of __backtrace() and __print_backtrace(), convert the stack check code to not use them. Signed-off-by: Andrew Donnellan --- Someone wanna review this to make sure I haven't subtly broken it? --- core/stack.c | 10 +++++----- include/cpu.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/stack.c b/core/stack.c index f7eca1ffb0ff..2e47cd4dbd4a 100644 --- a/core/stack.c +++ b/core/stack.c @@ -175,13 +175,12 @@ void __nomcount __mcount_stack_check(uint64_t sp, uint64_t lr) /* Capture lowest stack for this thread */ if (mark < c->stack_bot_mark) { - unsigned int count = CPU_BACKTRACE_SIZE; lock(&stack_check_lock); c->stack_bot_mark = mark; c->stack_bot_pc = lr; c->stack_bot_tok = c->current_token; - __backtrace(c->stack_bot_bt, &count); - c->stack_bot_bt_count = count; + backtrace_create(c->stack_bot_bt, CPU_BACKTRACE_SIZE, + &c->stack_bot_bt_metadata); unlock(&stack_check_lock); } @@ -232,8 +231,9 @@ void check_stacks(void) " pc=%08llx token=%lld\n", lowest->pir, lowest->stack_bot_mark, lowest->stack_bot_pc, lowest->stack_bot_tok); - __print_backtrace(lowest->pir, lowest->stack_bot_bt, - lowest->stack_bot_bt_count, NULL, NULL, true); + backtrace_print(lowest->stack_bot_bt, + &lowest->stack_bot_bt_metadata, + NULL, NULL, true); unlock(&stack_check_lock); } diff --git a/include/cpu.h b/include/cpu.h index 06d5c0d11229..39071a191793 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -81,7 +81,7 @@ struct cpu_thread { uint64_t stack_bot_tok; #define CPU_BACKTRACE_SIZE 60 struct bt_entry stack_bot_bt[CPU_BACKTRACE_SIZE]; - unsigned int stack_bot_bt_count; + struct bt_metadata stack_bot_bt_metadata; #endif struct lock job_lock; struct list_head job_queue; From patchwork Mon Mar 18 04:28:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 1057675 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44N39w0bVRz9sBr for ; Mon, 18 Mar 2019 15:29:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44N39v5kDBzDqM3 for ; Mon, 18 Mar 2019 15:29:39 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=au1.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=andrew.donnellan@au1.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com 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 44N39Z3jSHzDqF1 for ; Mon, 18 Mar 2019 15:29:21 +1100 (AEDT) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2I4Spjw140837 for ; Mon, 18 Mar 2019 00:29:20 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2r9vmhm9nw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Mar 2019 00:29:19 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Mar 2019 04:29:16 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 18 Mar 2019 04:29:15 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2I4TF5218809002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Mar 2019 04:29:15 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE6B952051 for ; Mon, 18 Mar 2019 04:29:15 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 1BE155204F for ; Mon, 18 Mar 2019 04:29:15 +0000 (GMT) Received: from intelligence.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 74845A0351 for ; Mon, 18 Mar 2019 15:29:12 +1100 (AEDT) From: Andrew Donnellan To: skiboot@lists.ozlabs.org Date: Mon, 18 Mar 2019 15:28:59 +1100 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> References: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19031804-0008-0000-0000-000002CE8322 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031804-0009-0000-0000-0000223A8F5F Message-Id: <20190318042900.32558-6-andrew.donnellan@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-18_03:, , 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-1903180034 Subject: [Skiboot] [PATCH 6/7] core/stack: Rename backtrace functions, get rid of wrappers 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Rename ___backtrace() to backtrace_create() and ___print_backtrace() to backtrace_print(). Get rid of __backtrace() and __print_backtrace() wrappers. Signed-off-by: Andrew Donnellan --- core/stack.c | 13 +++++++------ hw/fsp/fsp-attn.c | 4 ++-- hw/ipmi/ipmi-attn.c | 5 ++--- include/stack.h | 32 +++++--------------------------- 4 files changed, 16 insertions(+), 38 deletions(-) diff --git a/core/stack.c b/core/stack.c index 2e47cd4dbd4a..d33d2fe771f7 100644 --- a/core/stack.c +++ b/core/stack.c @@ -27,8 +27,9 @@ static struct bt_entry bt_buf[STACK_BUF_ENTRIES]; /* Dumps backtrace to buffer */ -void __nomcount ___backtrace(struct bt_entry *entries, unsigned int max_ents, - struct bt_metadata *metadata) +void __nomcount backtrace_create(struct bt_entry *entries, + unsigned int max_ents, + struct bt_metadata *metadata) { unsigned long *fp = __builtin_frame_address(0); unsigned long top_adj = top_of_ram; @@ -61,8 +62,8 @@ void __nomcount ___backtrace(struct bt_entry *entries, unsigned int max_ents, metadata->pir = mfspr(SPR_PIR); } -void ___print_backtrace(struct bt_entry *entries, struct bt_metadata *metadata, - char *out_buf, unsigned int *len, bool symbols) +void backtrace_print(struct bt_entry *entries, struct bt_metadata *metadata, + char *out_buf, unsigned int *len, bool symbols) { static char bt_text_buf[4096]; int i, l = 0, max; @@ -127,8 +128,8 @@ void backtrace(void) lock(&bt_lock); - ___backtrace(bt_buf, STACK_BUF_ENTRIES, &metadata); - ___print_backtrace(bt_buf, &metadata, NULL, NULL, true); + backtrace_create(bt_buf, STACK_BUF_ENTRIES, &metadata); + backtrace_print(bt_buf, &metadata, NULL, NULL, true); unlock(&bt_lock); } diff --git a/hw/fsp/fsp-attn.c b/hw/fsp/fsp-attn.c index 6774dd84cee7..667d9ab5810c 100644 --- a/hw/fsp/fsp-attn.c +++ b/hw/fsp/fsp-attn.c @@ -106,10 +106,10 @@ static void update_sp_attn_area(const char *msg) cpu_to_be32((uint32_t)((uint64_t)__builtin_return_address(0) & 0xffffffff)); snprintf(ti_attn->msg.version, VERSION_LEN, "%s", version); - ___backtrace(bt_buf, STACK_BUF_ENTRIES, &metadata); + backtrace_create(bt_buf, STACK_BUF_ENTRIES, &metadata); metadata.token = OPAL_LAST + 1; len = BT_FRAME_LEN; - ___print_backtrace(bt_buf, &metadata, ti_attn->msg.bt_buf, &len, false); + backtrace_print(bt_buf, &metadata, ti_attn->msg.bt_buf, &len, false); snprintf(ti_attn->msg.file_info, FILE_INFO_LEN, "%s", msg); ti_attn->msg_len = VERSION_LEN + BT_FRAME_LEN + diff --git a/hw/ipmi/ipmi-attn.c b/hw/ipmi/ipmi-attn.c index 8407188401a3..c6c1c59b5f34 100644 --- a/hw/ipmi/ipmi-attn.c +++ b/hw/ipmi/ipmi-attn.c @@ -53,10 +53,9 @@ static void ipmi_log_terminate_event(const char *msg) ti_size = IPMI_TI_BUFFER_SIZE - ti_len; /* Backtrace */ - ___backtrace(bt_buf, STACK_BUF_ENTRIES, &metadata); + backtrace_create(bt_buf, STACK_BUF_ENTRIES, &metadata); metadata.token = OPAL_LAST + 1; - ___print_backtrace(bt_buf, &metadata, ti_buffer + ti_len, &ti_size, - true); + backtrace_print(bt_buf, &metadata, ti_buffer + ti_len, &ti_size, true); /* Create eSEL event and commit */ elog_buf = opal_elog_create(&e_info(OPAL_RC_ATTN), 0); diff --git a/include/stack.h b/include/stack.h index d8baf8dc7773..004beb047471 100644 --- a/include/stack.h +++ b/include/stack.h @@ -125,35 +125,13 @@ struct bt_metadata { extern void *boot_stack_top; /* Create a backtrace */ -void ___backtrace(struct bt_entry *entries, unsigned int max_ents, - struct bt_metadata *metadata); - -static inline void __backtrace(struct bt_entry *entries, unsigned int *count) -{ - struct bt_metadata metadata; - - ___backtrace(entries, *count, &metadata); - - *count = metadata.ents; -} +void backtrace_create(struct bt_entry *entries, unsigned int max_ents, + struct bt_metadata *metadata); /* Convert a backtrace to ASCII */ -extern void ___print_backtrace(struct bt_entry *entries, - struct bt_metadata *metadata, char *out_buf, - unsigned int *len, bool symbols); - -static inline void __print_backtrace(unsigned int pir, struct bt_entry *entries, - unsigned int count, char *out_buf, - unsigned int *len, bool symbols) -{ - struct bt_metadata metadata = { - .ents = count, - .token = OPAL_LAST + 1, - .r1_caller = 0, - .pir = pir - }; - ___print_backtrace(entries, &metadata, out_buf, len, symbols); -} +extern void backtrace_print(struct bt_entry *entries, + struct bt_metadata *metadata, char *out_buf, + unsigned int *len, bool symbols); /* For use by debug code, create and print backtrace, uses a static buffer */ extern void backtrace(void); From patchwork Mon Mar 18 04:29:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 1057680 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44N3CD3ZL1z9sBV for ; Mon, 18 Mar 2019 15:30:48 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44N3CD2VmdzDqMg for ; Mon, 18 Mar 2019 15:30:48 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=au1.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=andrew.donnellan@au1.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=au1.ibm.com 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 44N39b5KPRzDqF1 for ; Mon, 18 Mar 2019 15:29:23 +1100 (AEDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2I4Sc4D045839 for ; Mon, 18 Mar 2019 00:29:21 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ra44tra7v-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Mar 2019 00:29:21 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Mar 2019 04:29:19 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 18 Mar 2019 04:29:17 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2I4TG7l34078878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Mar 2019 04:29:16 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AFB6252050 for ; Mon, 18 Mar 2019 04:29:16 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 1C6C75204E for ; Mon, 18 Mar 2019 04:29:16 +0000 (GMT) Received: from intelligence.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 766DBA037D for ; Mon, 18 Mar 2019 15:29:12 +1100 (AEDT) From: Andrew Donnellan To: skiboot@lists.ozlabs.org Date: Mon, 18 Mar 2019 15:29:00 +1100 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> References: <20190318042900.32558-1-andrew.donnellan@au1.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19031804-0028-0000-0000-000003553D59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031804-0029-0000-0000-00002413D3B0 Message-Id: <20190318042900.32558-7-andrew.donnellan@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-18_03:, , 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-1903180034 Subject: [Skiboot] [PATCH 7/7] core/lock: Add debug options to store backtrace of where lock was taken 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Contrary to popular belief, skiboot developers are imperfect and occasionally write locking bugs. When we exit skiboot, we check if we're still holding any locks, and if so, we print an error with a list of the locks currently held and the locations where they were taken. However, this only tells us the location where lock() was called, which may not be enough to work out what's going on. To give us more to go on with, we can store backtrace data in the lock and print that out when we unexpectedly still hold locks. Because the backtrace data is rather big, we only enable this if DEBUG_LOCKS_BACKTRACE is defined, which in turn is switched on when DEBUG=1. Signed-off-by: Andrew Donnellan --- RFC->v1: - Switch this on when DEBUG=1 (Stewart) - Rebase on top of some backtrace API changes --- core/lock.c | 19 +++++++++++++++++-- include/config.h | 7 +++++++ include/lock.h | 11 +++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/core/lock.c b/core/lock.c index fbf0b21ed5c6..6fbb5eb9bf5e 100644 --- a/core/lock.c +++ b/core/lock.c @@ -208,6 +208,12 @@ bool try_lock_caller(struct lock *l, const char *owner) cpu->con_suspend++; if (__try_lock(cpu, l)) { l->owner = owner; + +#ifdef DEBUG_LOCKS_BACKTRACE + backtrace_create(l->bt_buf, LOCKS_BACKTRACE_MAX_ENTS, + &l->bt_metadata); +#endif + list_add(&cpu->locks_held, &l->list); return true; } @@ -312,8 +318,12 @@ void dump_locks_list(void) struct lock *l; prlog(PR_ERR, "Locks held:\n"); - list_for_each(&this_cpu()->locks_held, l, list) + list_for_each(&this_cpu()->locks_held, l, list) { prlog(PR_ERR, " %s\n", l->owner); +#ifdef DEBUG_LOCKS_BACKTRACE + backtrace_print(l->bt_buf, &l->bt_metadata, NULL, NULL, true); +#endif + } } void drop_my_locks(bool warn) @@ -322,8 +332,13 @@ void drop_my_locks(bool warn) disable_fast_reboot("Lock corruption"); while((l = list_top(&this_cpu()->locks_held, struct lock, list)) != NULL) { - if (warn) + if (warn) { prlog(PR_ERR, " %s\n", l->owner); +#ifdef DEBUG_LOCKS_BACKTRACE + backtrace_print(l->bt_buf, &l->bt_metadata, NULL, NULL, + true); +#endif + } unlock(l); } } diff --git a/include/config.h b/include/config.h index 438f1b0f3373..7059e39ddb91 100644 --- a/include/config.h +++ b/include/config.h @@ -39,6 +39,13 @@ /* Enable lock debugging */ #define DEBUG_LOCKS 1 +/* Enable printing of backtraces when locks not released */ +#ifdef DEBUG +#define DEBUG_LOCKS_BACKTRACE 1 +#else +//#define DEBUG_LOCKS_BACKTRACE 1 +#endif + /* Enable lock dependency checker */ #define DEADLOCK_CHECKER 1 diff --git a/include/lock.h b/include/lock.h index b18757394dbb..e08ec08fcdfb 100644 --- a/include/lock.h +++ b/include/lock.h @@ -23,6 +23,12 @@ #include #include +#ifdef DEBUG_LOCKS_BACKTRACE +#include + +#define LOCKS_BACKTRACE_MAX_ENTS 60 +#endif + struct lock { /* Lock value has bit 63 as lock bit and the PIR of the owner * in the top 32-bit @@ -38,6 +44,11 @@ struct lock { /* file/line of lock owner */ const char *owner; +#ifdef DEBUG_LOCKS_BACKTRACE + struct bt_entry bt_buf[LOCKS_BACKTRACE_MAX_ENTS]; + struct bt_metadata bt_metadata; +#endif + /* linkage in per-cpu list of owned locks */ struct list_node list; };