From patchwork Mon Apr 18 13:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12816593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB6BFC433EF for ; Mon, 18 Apr 2022 13:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=L9MZ+IbRodhETpt0qU5rIQ65tV2qp2MPTX4HHHOBl2w=; b=xQDxypW72iWczY Xy0byYqodZpBcTqgb3PA0Pps+LAsx98QqpciOvWl1X0Q6ahFzZ4LOOwH0iaZDJiXuuuVk80uxoSLw TOrQfx4AGegJ/mCCjiYnt4LHD69bcAxX11c5pNa++H/73GWAhUay65qLNr0CrDVvbLakG10onKjFY uV0QF5x6j9AzBMSpymPHyKaDt49UQcbBEDf1XbQMOjwazONsUv1jXZj0CuaI2uNZwqN8CADvE+GiP iVEhae8xX0bi+RD/E1LA03ghuyhGFak1/U75l5IURBaI9qUQIY58ePQhqR+D1GVc1DgaXN5OTCKAa 59FvE3Ax9/091xpope/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRO2-00H1kG-0H; Mon, 18 Apr 2022 13:25:50 +0000 Received: from mx0b-0064b401.pphosted.com ([205.220.178.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRLg-00H0I1-7i; Mon, 18 Apr 2022 13:23:27 +0000 Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23ICwbRE025232; Mon, 18 Apr 2022 13:22:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=ftnAEPg6j9NnJafF63j580R9jqMTcER28Lpds1cKwVc=; b=Uq7P3lxIaXU02QF3STbt8YyXPx1kVZclZjwrdCxriEcSjHM1fULlBvgCEGx+ZmadsCJr yEJLuvWQEVTSlfnAcFH+1dh33MbP9HxhBYiO1OXJjpjpQUxf55EXxgnGiUvukqWOyE6a R7nCzF4oVDOiYv84l7A01T58BS9Znb2UtfD4H0ielWBdvJqCY0Pg6h0Rc/+S8mT2m6to oJ2vSLbPvvuQGtLO3hevonY5lBf3D24zETnT0GvM57qvUkNofu5goLA+zXB+7ipYeC5P I3A1DyAOuEr1pcKULhD4JriEmt0zmN3rb16zhyGGP1Yz3gckBZ09xyKjNlRYhOf890/W bw== Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2047.outbound.protection.outlook.com [104.47.56.47]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ffpj2sav6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 13:22:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U3L4cn8/iN76FQZOLZhfMj/RQSFAXMLNNYTXbKP8f3m1FVKf7DriTWRrbMXmHtInHNgGDewWXlhcOW1nDlargKFPxIhV+0vU8k0qrkKKZ/jkjUIjpsb41s5vbo0flVJOsTn+ARicGjV735tg5YZ9Ean80sEeMDr17GlcfL8jxqvqIAcIK0yIybTt52zSAGy/QYxDoLgy49OgaPM3hMVilpPO5YtmGhgMGQrLyTkVMEm28CfZd+44NSYAcDTNKaV+eluN9OZzbkw0d0Ofr5eXmFFjULPyEwuhwqQL5tldyZ4VQMlGgVjtnDt/ROhpnJfjtDDiw4OZLwX4MrczD5ZOGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ftnAEPg6j9NnJafF63j580R9jqMTcER28Lpds1cKwVc=; b=Kq1LlS1bSXArds7+KXWKJOWW4j/PtwFrT63szOjiyMcGKIK6H7UqrPcbCdMOJr5gDjyaATK+stA4w6upFxjWBHFkvghASGFxPYkT50v/VAQTMnFRxU+K8N1cvptJpSZ/seGy81zV5qViQRsje8H2mFpBJg3SqEXffbdT5UlFADancfVwbzY3Hc5y9gCmqKmKaW43ZAa89FG3eWJRTSKWvm0c+aZlhwvuRHzcq7ILlJmeAIDL6JHaiMCpn3p23Tt4G+4Nu9Pnok5QcNnmqFXOSkyiOp5S7pivozSQ2+NueQb92zNQKqwDvYWlUPgFGpLWGLr0N2qNzlDeJF1XDz56xA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) by DM6PR11MB2857.namprd11.prod.outlook.com (2603:10b6:5:cb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Mon, 18 Apr 2022 13:22:41 +0000 Received: from MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc]) by MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc%7]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 13:22:41 +0000 From: He Zhe To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, keescook@chromium.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, benh@kernel.crashing.org, paulus@samba.org, borntraeger@linux.ibm.com, svens@linux.ibm.com, hpa@zytor.com Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH RFC 1/8] stacktrace: Change callback prototype to pass more information Date: Mon, 18 Apr 2022 21:22:10 +0800 Message-Id: <20220418132217.1573072-2-zhe.he@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220418132217.1573072-1-zhe.he@windriver.com> References: <20220418132217.1573072-1-zhe.he@windriver.com> X-ClientProxiedBy: HK2PR02CA0133.apcprd02.prod.outlook.com (2603:1096:202:16::17) To MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e16a17b-10ad-4b7b-2073-08da213e83ed X-MS-TrafficTypeDiagnostic: DM6PR11MB2857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VAPL1TNZfmyLt15PqYvr9hk9MmZhq9HfJBfQDmFmBagLDKTqMhlYYp7xKNEUFYJG8gxbyRx0jH4IayMYGesaGf4Ki8y6fROeY9kolB3p/63FbqKIzOKt1GGLvlqNANpJjL0DwDjYXA3tEoB97afDMarrWc5xIdBiEAQQ7tf9NeeU4ktgHELi9dPdfkWqHVtC7VEX05ZwzOONvZyc9HJHbGplLk3AywN54PlfV/X0lccSyphes1ze8IytFJ8G2baphWUW0ZZjdaX/OQkl04iQN9l76/TyRM4+3debSKPW8IpT9d4XCOEdUBbwzwbAZnQ09H7mr61kvk7pR08QXKGF+o21NJltyNEBwk3UTUMz6HIrW3konV/Soh60Ig2mOKIjZ1Ba0hlBBKtpOd6UgRz9JhX3XQstd1re40d+n4ENKRdnYsaTUYm61cJE6GAwGDMVELIEjQUJ2mj6AP7EukfQ1bYKwBjRu9Gv6F77iIKi6WjlAbyJUk6jQpZ5cYt7b6kCelK2FOIuk6X6PEqJuA4EdDfAxwfl3agGn+UUwLB2qaPWdBwIVtT4KFy5h3mVnPw85Cgg31YM7Qct8LBJV8iGwawtQzfzYygtDj9tkLrdk4mw7ihbaam5PVKnEaXnlsoCTgfL3vqgGGuXGWRQ0Vb20FXj531HZdsz7XR+QJsotUjqUi6K/yFjO7HbrwT9kANIAns7ZTWUsdZ0XawaLnuQAE4Zt1ZsPzecwSwXrNC8VB0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(66556008)(2616005)(186003)(86362001)(83380400001)(1076003)(38100700002)(66946007)(316002)(66476007)(7416002)(107886003)(8936002)(2906002)(4326008)(6506007)(38350700002)(5660300002)(508600001)(36756003)(52116002)(8676002)(26005)(6486002)(921005)(6512007)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1G5vd0Ybv8HM3FCPYqjd9mXiVer/C+fKv23CbNha6wgswBx2dhFPDYVhM5dEPTrwnx11XiSvy9GIBxthzV8A13e0FI+HnDYIp0U9fQbY8Z9pozkAQQlE36eM5LFV9+TYkY5HyHh/dA4SWUzEdHQ6nmK6idP0aaVh19ipjaYuPDiz99T/YO4H2tDWbZ/iVVFY7WohVwVH0aSPVaSlBQIEvZSxola3Fze70s6wyXvlwqYrvhsZeDfqbFN396OyfqjZe2uV1azSW4RtZaHKahdSiB34TkidvAIQgJz6RtoHg2BkAisFTQOTERGYWb3SsuoeMcDnKIEojaeoXoJqL7m46rt7zzahLqTeIHsgT4HrQ2b3reMBOir9usPJ6uRluAWoN1ZZ63nz7txidDifkFSJ+D88m6CkQylPOq+lcpU3jQZdNz44K6CUpxRstoGJDo1U7CiWEr0Wkgh5qoLoXeL4QhKFswwV4AI+VpY57tDQk9SYMkapd0fRXg8i4TdqJGBx5rtqEisGvZioz25XcLXbG6vmFIFxcS3DYvIitYLFGSR1AhZhc/uzf3poM9LUjFjo6Va8kDTiS2RnLnPEjfgxjFQLljlOxC/IxHKmKyIqmEAuvwOyNYyYQB04vzy3C1SlDxpqEnR3PsWWz7OSJmGplVyeOGnAs3djdQgWi5utP7g48dtPNiLXL2jQ55pnoxoEu1HnFrNu6uDotJxvU5SadwYdhDdm2dVdw7Mk3Mj+/7zRoeBA9pIz5NPornzYJ0lmtBi4pnNcdwaAOe3hc4CFhVzlVHprL7ptfam684doBv8/MrBmYSlrCHVouWxR5D4B4fNLcxg/NXFE1Tukh3cxQanAMN0nNNtF/tCSeGJJjyKDqqyRj27csw4sRdYbswu40fX+17QW1EWQ4p2Hv6DQBQIle4SdPVcXTbdFiT2xvAuIMsmnGHy4ZnM8FuzxumCbmFyka8DpIEbpOXA/b6yqZx0n2VLAL0jJUjRvxieqTNbt0WVdkh2BRUoVM5XaMKnBEI/nQ6k/fYpryGjE7kJi+wd+oFr0cY9em4ntk5pDst5PWo5NfKduS5Bj8urjf049BRGMKhARPnbtRZvFas7+d/q3MOO7g4bbevOic0TFQZc8UR4a6r67WOSQx/Z97dwR/oLXRWk/72VBWoKoEatBX9kP+Qp7M1SHOLhyvWgJqIh2HQDEdxxcQxgTtfJbzxj/cejN/jjQwyGFDJEmewkx8LuL8td3jcW8S3AzzZl/WjEj7e0NIt/9lNnyyft0AxVEexMu+Uktw7eNHHo4EHABs+dnaMUQkF8E/Ysz00Xma6vElLNvuIRmchW4mwW3nNhXwgOescuYzKvfJRMvRDO9oNcNMUy/aB/2ClSZ5+cuO8ixdF+iX+Dg6nHwqlFS8+jrYX8jfkAP+S8NL3uLW/WVNfj36sQt1f6GBQUQX6wb0Hv+aXT/NEjZjhn+1oeka1SEPPGe7ygOEpHfH1BMoebbJ1imjlgTQ23zusfwFKuQ9lIu3d335n9UDbWrVxu+GcLiR87W/XSLp2XzN9joL6+jBpT0FGLKsUvjXNgYo2XhP/B135cX+NHAVFFNuAcC6Yi8S6cZwASGmOkyqQvvpg0SPwxnx07irWiL0aoWzXifSHnSt56vDxVjRT3ROLxOjNS6fhi/nyNPmE74Eve03NBxaugq9RVXjLN9ft7H9ZB9gs563MvMOhJR2G/BMq+2Li65Pg2vS9rzW+InNeb3G9WRpQ== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e16a17b-10ad-4b7b-2073-08da213e83ed X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 13:22:41.2797 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +lstCnSzfGIOGe6KYoiIR1ao/Ad0x2Ed4qqeFO//mtX0/f+P2UccQL8rsfVQTW8WyIc+xSV1tt8KYutGX5mSgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2857 X-Proofpoint-ORIG-GUID: SIdr9PT7NXeP8IqkC7E_0A_OlAie3zR2 X-Proofpoint-GUID: SIdr9PT7NXeP8IqkC7E_0A_OlAie3zR2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=984 clxscore=1015 phishscore=0 impostorscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180078 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220418_062324_452980_8264FD4C X-CRM114-Status: GOOD ( 17.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently stack_trace_consume_fn can only have pc of each frame of the stack. Copying-beyond-the-frame-detection also needs fp of current and previous frame. Other detection algorithm in the future may need more information of the frame. We define a frame_info to include them all. Signed-off-by: He Zhe --- include/linux/stacktrace.h | 9 ++++++++- kernel/stacktrace.c | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h index 97455880ac41..5a61bfafe6f0 100644 --- a/include/linux/stacktrace.h +++ b/include/linux/stacktrace.h @@ -10,15 +10,22 @@ struct pt_regs; #ifdef CONFIG_ARCH_STACKWALK +struct frame_info { + unsigned long pc; + unsigned long fp; + unsigned long prev_fp; +}; + /** * stack_trace_consume_fn - Callback for arch_stack_walk() * @cookie: Caller supplied pointer handed back by arch_stack_walk() * @addr: The stack entry address to consume + * @fi: The frame information to consume * * Return: True, if the entry was consumed or skipped * False, if there is no space left to store */ -typedef bool (*stack_trace_consume_fn)(void *cookie, unsigned long addr); +typedef bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); /** * arch_stack_walk - Architecture specific function to walk the stack * @consume_entry: Callback which is invoked by the architecture code for diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c index 9ed5ce989415..2d0a2812e92b 100644 --- a/kernel/stacktrace.c +++ b/kernel/stacktrace.c @@ -79,7 +79,7 @@ struct stacktrace_cookie { unsigned int len; }; -static bool stack_trace_consume_entry(void *cookie, unsigned long addr) +static bool stack_trace_consume_entry(void *cookie, struct frame_info *fi) { struct stacktrace_cookie *c = cookie; @@ -90,15 +90,15 @@ static bool stack_trace_consume_entry(void *cookie, unsigned long addr) c->skip--; return true; } - c->store[c->len++] = addr; + c->store[c->len++] = fi->pc; return c->len < c->size; } -static bool stack_trace_consume_entry_nosched(void *cookie, unsigned long addr) +static bool stack_trace_consume_entry_nosched(void *cookie, struct frame_info *fi) { - if (in_sched_functions(addr)) + if (in_sched_functions(fi->pc)) return true; - return stack_trace_consume_entry(cookie, addr); + return stack_trace_consume_entry(cookie, fi); } /** From patchwork Mon Apr 18 13:22:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12816604 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 899E4C433EF for ; Mon, 18 Apr 2022 13:29:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=991790YuiW3a/1C40KuGfz1de0oMRYreso/uxWA0k84=; b=XvffqmhoVb2S1+ XvcM11O53RM8ndpSeBqZqc3t2GgJQzZ/UC6322rQoVyUZElk6h9a2qVO1nLhjdYmU/edYNsfa8LhW WXC/rvJj3SJYmprSefh1TGSp/3tZlgdI+PTYq0WiYIAYP8Ktg2cvbr08j5OqFVW106/r9EArCKquW 0AQ5s5KDjHLCmo983q11Lo7ry8zA26i886FuDNcWIRtczqYHEBqiUj2E6WZl0AuLKOxN5+3n4sYEG tF1E46UMhHnPDoKUCV94WSV6arb0dW4jZW+IbIvGKzsxsnvkFYvY/jcz0he1Ej5c728xfar2hMfrZ C8PQ6es9+m8CQLpSVRBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRPZ-00H2T7-78; Mon, 18 Apr 2022 13:27:27 +0000 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRLg-00H0IA-Ko; Mon, 18 Apr 2022 13:23:28 +0000 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23IDA5an010696; Mon, 18 Apr 2022 06:22:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=k/NQfZS4NJCNCzJzOq5gcpOFjgri9NwJbvn+CXXa+Ps=; b=Ch0ah0hqbV0q8DS2UrmGk3ov8fToeA739c05vyClXJeYkgKyYi2NQEUNbJZ3Oel/bzil iIokmhEKDBqZMNXhn8/WUXkHmU153Ddc2qR8j6/6CetOxfHPS/x4Aqs6OQjAA2QkxJ3K VL7567OeWcsUPr9WPQpwVqENPTcyJm7sWxRC8pXfxuXKlNDezAObTQA6phjkJdZMPf5A LmwiYgEKIOdvc8LXtkmCkUnGZiJMR87BE94pgTug1yFgae5WeNn7bH8SSwaoMfdhjvDV V+Qr/EwXo25UwRm3BpxriFhhp0eZgMAciJUzawcVjcd6LaDD7O39lQCmpsBMeuMHPsjZ Wg== Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2042.outbound.protection.outlook.com [104.47.56.42]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ffs3118r0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 06:22:47 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ogipQrW1wyyCC3sYu6LD+jazraozzCmVLaj9Y/oyFrJgfRjz5o1yg2aSjy9NDkLQC1EHSJglJYxI440rS7DFRXTx4P0FUJOPjtGE0FSj863w7IAmhrj/vdgHNmv0wC+TjTeaOdyoOmH2XMIxTrQ8yaLcbEfQIgYH60T43WTVqaWApa2mJg9+flJ5uRZtxUwUQ0cK6Yo3/Vbw89TyG7IVPkySnzA46XNpMm/XT3JzqVnTbnNfMpV2qlaTTBCmcNr8TZypInP5GBY3YIm01XEZH6bC2AiJeUTeFP2B3HbnRglz29Xfy64a+4Ww0r2V7V0ZGf8lXNCOCnBISkzvUaxy+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k/NQfZS4NJCNCzJzOq5gcpOFjgri9NwJbvn+CXXa+Ps=; b=FbsjgynPymMeaXjV0kKQaeXnJTCgqRXSg2cMkzGOXu6DYndQE3zb+oYd2rxGHJly1Pbi+WLCON/p9COCMFVGXG9VrueqCPBcmPeKJjfKSVgBrZAVqdqy6pROVAtraW2G/X6GUB+ojcF/jOpsvUgFrGekF/NaQHNcgZs9e0bibUdLZqYXDYC0U1kZ7ddJ/4xuRbUUHJvKqOUOOh/9p03tjqDBkzlpW4QCcTrVbxaH7PqPs0/bYDQMQBf7m8Q2ZtSBOnV8FespnevMl2yzQwcOQXjkWzT3WuDnxOz12epDcp4plnreu/r65JLeahwNx1Wb2ykkz2cqK8ohJNGnKawejg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) by DM6PR11MB2857.namprd11.prod.outlook.com (2603:10b6:5:cb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Mon, 18 Apr 2022 13:22:46 +0000 Received: from MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc]) by MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc%7]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 13:22:46 +0000 From: He Zhe To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, keescook@chromium.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, benh@kernel.crashing.org, paulus@samba.org, borntraeger@linux.ibm.com, svens@linux.ibm.com, hpa@zytor.com Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH RFC 2/8] arm64: stacktrace: Add arch_within_stack_frames Date: Mon, 18 Apr 2022 21:22:11 +0800 Message-Id: <20220418132217.1573072-3-zhe.he@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220418132217.1573072-1-zhe.he@windriver.com> References: <20220418132217.1573072-1-zhe.he@windriver.com> X-ClientProxiedBy: HK2PR02CA0133.apcprd02.prod.outlook.com (2603:1096:202:16::17) To MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7b7c11b-d83b-4079-650d-08da213e86ea X-MS-TrafficTypeDiagnostic: DM6PR11MB2857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UBwWdgNkXaFT+EExp710LA0Xz/Ktn1dTrkz92/dXZ/Kv9B9E1NQVoTd45/pIS/ntADGXrDgvLwYIP+Ca/IJu8Iq+g9TMJl17c/M86aLC/WQa76/I2e2exzYnK+P6Y0q7+ydjmSd/njjK6B9vEmALtvVozU/kIi/eqe4Ld14lSFB/u+xu6zsOfYGqcC54mudbUl1mFbqZRAHUzXSp9McpiHTQbEatsF697XX4kfTC8BSoFJScw0IXIZTgZT3KlsasPzo44cu0Xa3YKGbKtVRNP+MabnKMlh+ris+ubeU8Ciwa05uIlq+I9wn6rrxlbjzXUvfZCRA0aEVwcHqYLYYt6aW1ClZVZxWBr+E3df8pKwTVrKdth9LHw2sh7gqZIewE8a1p/X5xKIfjoDTrf+EijTaeOz2kSfBZjCuugAhyX7hh8naEAc0Z8INhRJHKh4ujt3zwNhvJpW2vmmNfnqINEpjUNbjKH9oFjUiOSUa0Ee7XAQwQfjeMdyi3HxdtZLBU63x3D9RZV558fTPSkpDosnd76R2S1UT2yxC7dNZEwTjkvqZ55t6WlkU19zvXCHk+ndWjWQcyxrBJXL4Iy39RVrFDSvciLbub1EYIfEUsPD4ywul2gZe+Oe4wyaMbKEAO2N79eeQNcYcbYzo4mxVCVfD9iacIJHZOSRHPoDde75KXRCE8Jbu8Fi67UfhJuzVh/FImn0Owy5tmTVPNCPmfSpIl5ZHDHvrd7UcU/N2zv0w= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(66556008)(2616005)(186003)(86362001)(83380400001)(1076003)(38100700002)(66946007)(316002)(66476007)(7416002)(107886003)(8936002)(2906002)(4326008)(6506007)(38350700002)(5660300002)(508600001)(36756003)(52116002)(8676002)(26005)(6486002)(921005)(6512007)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cI5QHA39fhqVvKLCszKi+qlJwj8q3cmRp3l8DIX/186Zgu0pPeAZaFzJM6jmipk3bxZXuErq02ZNi4rYDh/ZhC1vLg6iUSK+MG+Lbi2lmQYQxOrai5+J2uGDqzACC0dRDnFwlfdeJHbg7yFuF5MJf7gYgT3WEf28TlIcyKdwGsv64gt+lKYfGidUf+GzgJDuPFIkFIOoolu2ordERw+BUJSfB+94PI2fZ6Gssm12ESpCa74tzAPiX6lC/JfgNwzZzHL+T1JvHAYYPzq4+oEWwYYUA/SCu7c+f20GsuXK96MZRV80b3cAaz0oByduV341hf0OR/19Td6nxBnpqaOravvJZ4kgKTdlbvEbMU2iBGLB1AXNH5FVzbmm8AygkCt3lPpaP7V1fcU6JyxJp61xiLVDPdZuo3u7+zbpd2L9bkfIMPfSxcNNVU3irH4LJIsRC2eC55LSJbAP7SNOqcDWUzLTngogCRROvVtLWG/cg/i021WRfC465fRoNAF0+p1zd/zB1zCtnqNbHVE1HeV5pzrpugqvvkpewDRy2FbrX71PUkhJ9Ci/Rlc2Lge7H2p0UhA0iQYgG4I++igrdDSPhwKKqC+pT8H05z7y1iX7c0LOfxzaDNBhRalWLGZquTRLe7/mYh6eGUceJLvNI9zIWGpwVr62xZ9KnvwWqa1z6B3WfPlbnNPwt8AfWO841LQwjGpOMAayZ1yCLCvORF7dbg3RsBboe7MQEaNGI1zI4vtKj/CsHpBHrNXT1WNe65McZXahT09VR+/RuBjz8yTBCPoriZWR6w8d+OFbLfc2qYoyuNf1G6DtqIY+VOXONA57ky/TMwETPn17/QZXzgKBJ6giSGYjP/s5SQbojMVmrNyUqj0tamxWKgmLmnW2ziy135nPrQ8lL8JR5YQ4rAigKbJBCA4MFKtksfKuKKXIhHz+WTMYhyXIVgQ6SfHy5GWmt0zI5qQ+JqFliECZiok9rlq2QMmK5rfKc7IqMc8xcZUYk381EREANdooaDNLR4LWs8PSJGt3mLHKTopc5nhYb5HgGgM8pa29gEalTSphgsXEn29ucqe74aTEesGnQC4EXq7WcnPaXuTyuZJRs8IZNi8l7hIZW43uNGHogyoNAakRKZtSDYQfoP4VwgxeD1rrkRGQuP3i4JIrzoa6g8TJ08XzArKoBVRsg9nrpKz/HPBCMMrvuGkAEeCV09kEpzc2rH4TwIlA69QMPwWTA5IpCohszGfE04EABxaTReLe4jq2AFUgxjXPW6UyYrp5cirvUEjGcE9icnYiclmHg9XkDwvQ6LGgYzKHSc5b/iV8DVjgffwhpecdm8f52aUiJVySPUoRzQwa55TM0dzD+d+2x/RH4OEtdqwSkZ2FnRh3ZZ3LsTKgnlO5RsPQTtf5P0ijRyhds3rdB8tM2m5yXijGxGfiAmFASrTNh58b2hzkpTGiJMN5StgLsoAlso8Z53tEajIRQiv4Ny9SOgQWAwWurOkKE3aKTz6bjKUEKRpvI19bF/gYSr6V9mxj4rBuW3T5ybxR7VlkrLjBL1caHQwhLfvkxgzNJuFh5KpqB1qijqtvE4iGaVR5HG4wyJFfcv13DliJxv8ZQXxURiCLD0xaEi7XKBX8KXYhv+sJ2XthfTBAoZemrxVI/rjYAafO1A4RpjF+C7GrTeX5OfsV0jYtqdrafmAnlLQUS9jcMnDUxIosx9w0GYyOvE1XKEzjQsWfdvOxWETgZ6zozrX+U274qA== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7b7c11b-d83b-4079-650d-08da213e86ea X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 13:22:46.2949 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mqZakgqwmB0vyn3TSYwVBu/RdMvbUtJEdh5LqaXDM8AXaG51Awzks5M2DUdPScwZqkUHQcROsRkgkZE2w8xchw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2857 X-Proofpoint-ORIG-GUID: 0mf7eftsbD7ZzuPT20UYBMvG8hI8wZ4M X-Proofpoint-GUID: 0mf7eftsbD7ZzuPT20UYBMvG8hI8wZ4M X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 clxscore=1015 spamscore=0 bulkscore=0 malwarescore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180078 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220418_062324_782352_44F2FF6D X-CRM114-Status: GOOD ( 20.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This function checks if the given address range crosses frame boundary. It is based on the existing x86 algorithm, but implemented via stacktrace. This can be tested by USERCOPY_STACK_FRAME_FROM and USERCOPY_STACK_FRAME_TO in lkdtm. Signed-off-by: He Zhe --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/thread_info.h | 12 +++++ arch/arm64/kernel/stacktrace.c | 76 ++++++++++++++++++++++++++-- 3 files changed, 85 insertions(+), 4 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 57c4c995965f..0f52a83d7771 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -165,6 +165,7 @@ config ARM64 select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE select HAVE_ARCH_VMAP_STACK + select HAVE_ARCH_WITHIN_STACK_FRAMES select HAVE_ARM_SMCCC select HAVE_ASM_MODVERSIONS select HAVE_EBPF_JIT diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index e1317b7c4525..b839ad9f2248 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -58,6 +58,18 @@ void arch_setup_new_exec(void); void arch_release_task_struct(struct task_struct *tsk); int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); +/* + * Walks up the stack frames to make sure that the specified object is + * entirely contained by a single stack frame. + * + * Returns: + * GOOD_FRAME if within a frame + * BAD_STACK if placed across a frame boundary (or outside stack) + * NOT_STACK unable to determine (no frame pointers, etc) + */ +int arch_within_stack_frames(const void * const stack, + const void * const stackend, + const void *obj, unsigned long len); #endif diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index e4103e085681..219b90c1de12 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -145,12 +145,17 @@ NOKPROBE_SYMBOL(unwind_frame); static void notrace walk_stackframe(struct task_struct *tsk, struct stackframe *frame, - bool (*fn)(void *, unsigned long), void *data) + stack_trace_consume_fn fn, void *data) { + struct frame_info fi; + while (1) { int ret; - if (!fn(data, frame->pc)) + fi.pc = frame->pc; + fi.fp = frame->fp; + fi.prev_fp = frame->prev_fp; + if (!fn(data, &fi)) break; ret = unwind_frame(tsk, frame); if (ret < 0) @@ -159,10 +164,10 @@ static void notrace walk_stackframe(struct task_struct *tsk, } NOKPROBE_SYMBOL(walk_stackframe); -static bool dump_backtrace_entry(void *arg, unsigned long where) +static bool dump_backtrace_entry(void *arg, struct frame_info *fi) { char *loglvl = arg; - printk("%s %pSb\n", loglvl, (void *)where); + printk("%s %pSb\n", loglvl, (void *)fi->pc); return true; } @@ -210,3 +215,66 @@ noinline notrace void arch_stack_walk(stack_trace_consume_fn consume_entry, walk_stackframe(task, &frame, consume_entry, cookie); } + +struct arch_stack_object { + unsigned long start; + unsigned long len; + int flag; +}; + +static bool arch_stack_object_check(void *data, struct frame_info *fi) +{ + struct arch_stack_object *obj = (struct arch_stack_object *)data; + + /* Skip the frame of arch_within_stack_frames itself */ + if (fi->prev_fp == 0) + return true; + + /* + * low ----------------------------------------------> high + * [saved bp][saved ip][args][local vars][saved bp][saved ip] + * ^----------------^ + * allow copies only within here + */ + if (obj->start + obj->len <= fi->fp) { + obj->flag = obj->start >= + fi->prev_fp + 2 * sizeof(void *) ? + GOOD_FRAME : BAD_STACK; + return false; + } else + return true; +} + +/* + * Walks up the stack frames to make sure that the specified object is + * entirely contained by a single stack frame. + * + * Returns: + * GOOD_FRAME if within a frame + * BAD_STACK if placed across a frame boundary (or outside stack) + * NOT_STACK unable to determine (no frame pointers, etc) + */ +int arch_within_stack_frames(const void * const stack, + const void * const stackend, + const void *obj, unsigned long len) +{ +#if defined(CONFIG_FRAME_POINTER) + struct arch_stack_object object; + struct pt_regs regs; + + if (__builtin_frame_address(1) == 0) + return NOT_STACK; + + object.start = (unsigned long)obj; + object.len = len; + object.flag = NOT_STACK; + + regs.regs[29] = (u64)__builtin_frame_address(1); + + arch_stack_walk(arch_stack_object_check, (void *)&object, NULL, ®s); + + return object.flag; +#else + return NOT_STACK; +#endif +} From patchwork Mon Apr 18 13:22:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12816595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8646C433EF for ; Mon, 18 Apr 2022 13:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yB2O525n5nWdQSYzJAACjavu7XV14gdDeSFiZd+v0bE=; b=AY1nHoGUjEeQ5Z h6uKHjQW+6tRf1yLkQW/krsLIak2dVPsGZ2g73JE0/VmmxuuRQDuw3NjvQlYJFqmRh6mZJB0WOkmT PyB5JxT8vJNI0wiVen2eY3jBbk+CQAKMYrHqcHXSdg657Zc21dig+em9PrfgNA74MI92OYpAufFPe jtx0n9KmICpZB9pXiDKK/qghrs685V6uqAU+U6w6x2/UGihuuCQ0dSqinQVF92RT5j5J0DDqowHIy bxDMREBp/R3QBl+WGjn4w96381uvrxZP7qQ8VK0nQJ3sQHgFXcM7n+7Pp3H8dtNI8pRMQVigolWcK GVL3sJwPhJO4RkOXWYrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngROk-00H26u-LU; Mon, 18 Apr 2022 13:26:35 +0000 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRLg-00H0Jk-QT; Mon, 18 Apr 2022 13:23:28 +0000 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23IC03fF017303; Mon, 18 Apr 2022 06:22:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=zbDgblK7RewJFoMTrbxTkPOFdnN0ql1h+vVBC3YB56s=; b=li90JFSz9j8n4ca65kS5PF7ENAFQkXf37M4gcYUV72uiskH4cnK/UreWqsDCF2bAZssI KoxKZuwG1A97q25TBl1SgHsxRSiVX+DI3USvkr5rL2MChcAfu3uOio8Op2KJeCLn1a2b aMxi6bv9sj8UTclFbj85xu6YG5FSQ4PTZJ+yjDEVq0EMFj6SEotGHDncvX5b5D7KseSZ cNQAr5kcBU8LlfXQ71nMa/G37ZTVOA/d3RyLu09aga3ZJiSiEH0dTE0wUAXQHNy7bNiC iJnlpUdqvaX/3VIPl1Bp7hY9rZ+X1jvuMq2DpwRpWvmkTC6g+Jx8c/bLtFV4eesVtkAH xQ== Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2048.outbound.protection.outlook.com [104.47.56.48]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ffs3118r4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 06:22:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M8C3puzHERKphpID9gcNtI7rr3TqCG1JeGDvmQBHg+RoSI02gZQ3FbwSOp7GILjkgcobeHkuQi9inox6//Tig47yM2PODi1Zh8lVVNEMwtMOjJnkRhGNdUQcmbxc5rTjDjb5vUVLyvODfuPFNOIJf2QT3HztIbDxZWe18LZn3zAVYV6WZZakoCtUCS/wIBgxqBNVfSrQPxVApBOuv20AcRpHX1nzRSWCjYLiOaedO2NfEORE8w7CDtKFW/UvbI+IDjl8cdbg+kKJCoOP2UwoC9WVTEPO2ndizDuW8wzpYiqUeZ2qBVDB5IIfKGInPjVLUfhm231nCeBEWfwlPHGcmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zbDgblK7RewJFoMTrbxTkPOFdnN0ql1h+vVBC3YB56s=; b=J5y/kZGvJq/O6IeWfsqlX5IWDF+PGmniftC4Tt1sn6DXvNT19U5OYY6fTQwEY8Cq3mhLVK22I7qWNr1lyLjsy/o50xqQCAggi0NZKu3VqP8nBkOTu7+Ms+rh3UP58Vj0AphfRIf6h8DCEjpoGDAOSqH+1kbype6lkfoWmjAfi9jn+l9vZU/HnGbGOsCTpcKIbUkKkFLpkxHoNtsNb/Vqc5q5XydRPwze7oaOSESlSkk7G8VTzTuIm0DC7i9l6wqEAwN0dWj6QQ5tUdjHMevyNUdWsQJuS6Dhu4cGhaLyEWOyg2HAfpJFdSaj4o3LkatdnRm6xzqJk9nUpUz24/AQ3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) by DM6PR11MB2857.namprd11.prod.outlook.com (2603:10b6:5:cb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Mon, 18 Apr 2022 13:22:51 +0000 Received: from MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc]) by MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc%7]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 13:22:51 +0000 From: He Zhe To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, keescook@chromium.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, benh@kernel.crashing.org, paulus@samba.org, borntraeger@linux.ibm.com, svens@linux.ibm.com, hpa@zytor.com Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH RFC 3/8] arm64: stacktrace: Make callbacks use new prototype with frame info Date: Mon, 18 Apr 2022 21:22:12 +0800 Message-Id: <20220418132217.1573072-4-zhe.he@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220418132217.1573072-1-zhe.he@windriver.com> References: <20220418132217.1573072-1-zhe.he@windriver.com> X-ClientProxiedBy: HK2PR02CA0133.apcprd02.prod.outlook.com (2603:1096:202:16::17) To MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d60d8851-3b6b-4b3d-a9a4-08da213e89e7 X-MS-TrafficTypeDiagnostic: DM6PR11MB2857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R2OomJ1ud8x1JfD/EgMKQOtn0GBgI7M1gxYnmAtJZp3eDOWcyQFsWEUzkRdtlFqHTn0TRtih3ykpmsHqFCwaWPEdNZmMyjZ+Yg6xVlTInwIOYoeZRESxqaZfLT8ABZ6mXDJRn/sY/erzVAey6Ild7z/61Mv26EMMB5P/OMshd5LdkPffT3VatpPy1Jy8oGeEwONKBZcSWOJphRIJ6dbUfGURCv9lyKcdvc/yv+vtUkxqvZ2FnV9yI/LCqmzc+mxJ4v6ai/37A/817MuYIc2F2yGFMTCvMEIzMlnm1IUvLxRoF5c6959/P1znVF2JluAYdUMzje3neALwIZ/09SjRnYZV962LOAnVyO0L/oz4frXFpb4V4QZ0Ll99YcT8llYN81FKll+puYvE7bMOaSGPK2bFWSlqx7rpL9zbb++A4yum8nYtetvhmUQkITXS1kO5BDWc8Yp8M+Ng9h1OIGl6rRTlLIIna2XdUTiApIm73g+lH2yxtTNkO6kyKKw2VqETUP9WzHNAeN+hWQ5TLSjoPpkafQtsNHj7s7aWXUeQejfHmOdKedmWI+ToBmfR+Qgq8y9zxjH60rNJaHA7IWU+ZlpvFJoWTMeS+XQG5ZD3iskVTXsDB2M/re+eNnUOz5FzQFZR9gSO2d4wx7Ir+LfguoSAo3+A9f5ItgW3Po8O/PYZNH1iwIbAhZQ5PSRHfpaBd5WYdZMv/yV1AJd43z0h8AVY3NFj0lptredcBb67l6s= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(66556008)(2616005)(186003)(86362001)(83380400001)(1076003)(38100700002)(66946007)(316002)(66476007)(7416002)(107886003)(8936002)(2906002)(4326008)(6506007)(38350700002)(5660300002)(508600001)(36756003)(52116002)(8676002)(26005)(6486002)(921005)(6512007)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ibstF8u78mMOLkjC+DkMbtk6BeGVIf2sN4/j11j5t9C07J8ntkXQNdwmng229DnBAV5IWnDMfoqQkSSEC8uHaK/9kJjR0tpGrP8aViDjMsAbrmPOMTc59anOO1jS0NBNpwilMQZIUJCdJyWzT5htH/81jkty/zBVwDMz1V3GrIayD3QWCiO+X9gFBhdeFi2UbH5GGfm3YJsLaw5BdePN9XhVOqZXo+hvQkq2WY0Zll3JHXqRLCWWk3Sr/XMZMMoYEd+nprSvmVuMfr1R6BIxinMvkMcgpFcSq1/FiEfkMMU037EmsZbG3gdG2DS3rqJ2RmTBi2zRJFWsCCw/TyDBu1wdNyswPRen6A6jbUsU7WDXIyDGL4XHDB1lhzmc/dcJfC5zhQShHRNrEGd6v1xtpeAB3qtAHBA7/YugEHBYvRc1tps18LV6TopqTtVI6juRv1TvXTA2mmwHPUrAtVi3nyVpL5GLcb0uFoqJzHZvJAW/REZAxx/eYTqE/jQI7oi7L5GMSp7Ij3GoSw5dNSTWPg0bzRCJ6s6QRGQeBgrwTYnMT+7UEFuR1vW9LY9bIjLCfdD5fj/Zjc2T/dJ7qCBJX/dTD5oyULXCjLjFLkB2cYCj3G0mbINKet13c5ma9g7c4b5lSGOZ/mE4SX4FxiWPMxMc86P35lVanGri/LDnPgcfgxOIbDEmRpaRMlnFpldxnybIXbkrqpFelOt8c8sqzvxmZrCWw2MIg429izz2Bv1mEfIxQGSrpxwHLd+dR0P14dFs+k/R0EiRXSrD0wbYewpQYwwvtwQf2RcQp/0so3cMl3ye/PDUVG1qYqYWJ5lSuJHt6ldgHsnGvgV6fv+5yt8LVTTn86IAZlBywbbtY3ZSQowdEJyjuU5fNWEoErmTYCTMAS4ZJhUFfIJ7BbuL5Duj3Mq6TUz3knsWd8qcH7HhAoRq8XWT1NWT/aTHwE5MxEWK1aNeC9wAhplvRJsgTQc/pDE31oGPw0XEC44J7njhreTU4+K0HYdny9P7xylx2haCRAIWkVOKM0alzjKhevlBTwOBhtxIye9DDgZqog6QWv+rm+w9BX79e3baZJgF0C2qAL7PYrF3n0gNO3IMaNlGqAwGFLY2nOdiki21KZ96EoDoXQt3eAlJuUUVbackzHrKtXeHr05r1iaF1hq6j2vKCg31Hd4rVH4WTPnRJ7WqxkBSYWb+VeqUrr7kVGMGpFqah9EKx39RBKifffkuqPzNpe+9q7Xq0hR3HkX4U+LmJpI+y98o+6BQm1n+l6iZ/RtTGDlfaCSviEAmMvsrXtqbEBBBLtvF5gIHCvtAJl2ESLO2JfZcR681l7poou7w4xN/YAqMkobb9zL+vt59CBp8t1PLpRnXLN3EZqPkGuEcnqF0STt6DvO03XNKE4wPPM74/LgVy7dZWtc0N6yJoHgpzDEtz6A9WaOzSsmxAFDdwhFQJ2wCHjmJcuza2h1E0W8fmulWWUAuGfMl9oL3uH56N4S+9Hlq2rxsWvvbdRzg50ejLz4cyhhrxP5zQLr4QrjqvrgUaMVVkacisxAYrwCvsYn5yEdrZqjIcXSO0jEyVTnWIraqy3q67sSlah6U1Wq/msR7ATZ+wWzm5Ui1sfe0FD1BTU4bmsNV1hwqWC0rzYaAmnxPoIpS6z+8SJYQy3yzWR8Vb27DfN8EqdrO6Dqf5iS4C1Jj20p96av7PKf/+qYdsyxZ5pPqhkf07UQnObvpriXv3KF3QGlZtV2vwA== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: d60d8851-3b6b-4b3d-a9a4-08da213e89e7 X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 13:22:51.2789 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5AM5bRFD8rqvRXLZ7tVS2yBZbLqXJMSQywW/01BsmIw3f7qLzsRtbDgsYtppCpm+bTtovIYSWNYU7gazJIHSVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2857 X-Proofpoint-ORIG-GUID: A3MrDu8cp4c8-4S824gXgQ6jMmsr-U6w X-Proofpoint-GUID: A3MrDu8cp4c8-4S824gXgQ6jMmsr-U6w X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=795 mlxscore=0 adultscore=0 clxscore=1015 spamscore=0 bulkscore=0 malwarescore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180078 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220418_062324_944028_FDCC4F05 X-CRM114-Status: GOOD ( 17.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org stack_trace_consume_fn has been changed to bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); to be able to pass more information. Turn to use pc in struct frame_info in arch_stack_walk callbacks without functinoal change. Signed-off-by: He Zhe --- arch/arm64/kernel/perf_callchain.c | 4 ++-- arch/arm64/kernel/process.c | 6 +++--- arch/arm64/kernel/return_address.c | 4 ++-- arch/arm64/kernel/time.c | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/perf_callchain.c b/arch/arm64/kernel/perf_callchain.c index 65b196e3ca6c..d32918b34c0c 100644 --- a/arch/arm64/kernel/perf_callchain.c +++ b/arch/arm64/kernel/perf_callchain.c @@ -132,10 +132,10 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry, } } -static bool callchain_trace(void *data, unsigned long pc) +static bool callchain_trace(void *data, struct frame_info *fi) { struct perf_callchain_entry_ctx *entry = data; - return perf_callchain_store(entry, pc) == 0; + return perf_callchain_store(entry, fi->pc) == 0; } void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 7fa97df55e3a..e96a8a614a1a 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -527,12 +527,12 @@ struct wchan_info { int count; }; -static bool get_wchan_cb(void *arg, unsigned long pc) +static bool get_wchan_cb(void *arg, struct frame_info *fi) { struct wchan_info *wchan_info = arg; - if (!in_sched_functions(pc)) { - wchan_info->pc = pc; + if (!in_sched_functions(fi->pc)) { + wchan_info->pc = fi->pc; return false; } return wchan_info->count++ < 16; diff --git a/arch/arm64/kernel/return_address.c b/arch/arm64/kernel/return_address.c index 68330017d04f..ec9be91623c4 100644 --- a/arch/arm64/kernel/return_address.c +++ b/arch/arm64/kernel/return_address.c @@ -18,12 +18,12 @@ struct return_address_data { void *addr; }; -static bool save_return_addr(void *d, unsigned long pc) +static bool save_return_addr(void *d, struct frame_info *fi) { struct return_address_data *data = d; if (!data->level) { - data->addr = (void *)pc; + data->addr = (void *)fi->pc; return false; } else { --data->level; diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c index b5855eb7435d..6b1a9de7c852 100644 --- a/arch/arm64/kernel/time.c +++ b/arch/arm64/kernel/time.c @@ -32,13 +32,13 @@ #include #include -static bool profile_pc_cb(void *arg, unsigned long pc) +static bool profile_pc_cb(void *arg, struct frame_info *fi) { unsigned long *prof_pc = arg; - if (in_lock_functions(pc)) + if (in_lock_functions(fi->pc)) return true; - *prof_pc = pc; + *prof_pc = fi->pc; return false; } From patchwork Mon Apr 18 13:22:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12816594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8411BC433EF for ; Mon, 18 Apr 2022 13:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QiH1ACaXusfwe40kSV/ldw3Djh7rPxwtFQLWkZOshZU=; b=H5b++OCc+uWBrZ wrUhbljlK2l7JMcHuRM1gjloagHEutC8UOz9dzONe5K8U5jih6eopuxMXK1c9F3sa7JTtnw2h3T95 +YTWnQemAC23ca6hl9QgGw2wOe1IVNfSNnwNgjC6b08dkxKbhVFe4nQ73TTm2fm0ck62UKe2DZ5o9 BkafVbA9n4g7iwKTr5jEUjIJciOH2hJuYjBQNq5p7ZI9Ep9oK+bd7NvAb4LBhogduTje9vRNoIKbM iD+jaLDheqe8RYOe1djM0eaTvMDFvvIBLAjRNwN52hHqnOYo0A3X/Twsp0VmlLokk3QS4abSAMM8Y IVEaL69k7oAezZ8UqFWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngROK-00H1uD-Qy; Mon, 18 Apr 2022 13:26:09 +0000 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRLg-00H0Jj-Pk; Mon, 18 Apr 2022 13:23:27 +0000 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23ICBnc3014635; Mon, 18 Apr 2022 06:22:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=nnChPSqJXpUTi6zekwIMRyrlocC10UkdDcqufEsb44w=; b=Qo6H6/trWCLSLXZKyBZa4d3WirD2S0Ch7QM+t6fWvy+EPbRdBmHwmK+H4GVTbJJQNKI3 RD9oPh0uap2IfIe0robdfuKteUFc0B2M7ym2jmInh1UuV9fKqEPDuGCbRDxVF5hDOkuB cPK42OWTT49Pd2kvWgJNTDvT02HYZeFFYwwBUgJr5Vd6Hn3wmEM/IEPs4A1xuYEGwIYu X4Tke1UqsM6cUBzCPAA9dQ8U+umUuX068eW+uXmlb+WCkmqr2YrKppaOdAZ1DEdmX0ru 5+SYpzODssiSbehXNazKKNJnoMey78F7f9i37OkH9Kp0AyzxRy5n2zYx0xZ/aAp7wmWT bw== Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2048.outbound.protection.outlook.com [104.47.56.48]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ffwah150p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 06:22:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pvk4wjTHAXItKiubxoVELZYLZus3YgY4kUPvMIKiNrW8IMuJDrOP2YPA5D+o9/XBsYfVdiSGV12Hd9MNvKenE9CeDXR5xMkB0fI2PsN08IPZ3Iuc41Wj5CHKu2bWTSquYn2mD8uezf2r6MeF/tuniROGpGaLEHYJjcprBognVV/+x4MkrBBqoDwxVtyDIY4VRjLZLmjeBz28OjJLHEn5qGJdrPHJfX8cRjy6QQ7jZsKKgRn7ena8XNONw9zwD8Mia3vLLevQa6NygtJeuqS4Rw6IkmySY3jDlc4ry6TMMzudN6q33AS6KJWxVVy4TNG+MZV9CA503F+dsIp9YbG6pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nnChPSqJXpUTi6zekwIMRyrlocC10UkdDcqufEsb44w=; b=PEFsoz7kmPuHp/1Fe32FHNnLcNPGswiIl08gtrJNwaHLr77nYzuwevoKiuOWZFSJ3Q55Qdvx+BExyBf0EXGxB7LoYIWIoIuWKs2fVKPGOV8zkC2ZRGRJg2fFFQJGaf6U6bdu+kQscPwdN4rCx5hWAEuObWZd+OUDOlGK90TOhFlyz4jjHIH1EKCU800S4gHXYX5fBSa4D5NLtaWqxDprgTQX/+CaO4uxnRmVBFSpYKVPDzP+zqj1IKNucuiJquQ63jFo45w5nepwLWa7/iH+OnvOVlWwnNPOM0NWOgt4KtdlODWo0xhjTVD8JhaZZ+UfHKS7KlT5gY2Duk3AWnlwgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) by DM6PR11MB2857.namprd11.prod.outlook.com (2603:10b6:5:cb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Mon, 18 Apr 2022 13:22:56 +0000 Received: from MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc]) by MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc%7]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 13:22:56 +0000 From: He Zhe To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, keescook@chromium.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, benh@kernel.crashing.org, paulus@samba.org, borntraeger@linux.ibm.com, svens@linux.ibm.com, hpa@zytor.com Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH RFC 4/8] powerpc: stacktrace: Make callbacks use new prototype with frame info Date: Mon, 18 Apr 2022 21:22:13 +0800 Message-Id: <20220418132217.1573072-5-zhe.he@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220418132217.1573072-1-zhe.he@windriver.com> References: <20220418132217.1573072-1-zhe.he@windriver.com> X-ClientProxiedBy: HK2PR02CA0133.apcprd02.prod.outlook.com (2603:1096:202:16::17) To MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 99599bfd-ae8b-48dd-c355-08da213e8d1b X-MS-TrafficTypeDiagnostic: DM6PR11MB2857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Tq3U57KdIFMlbl8ue0MywnQFRK/3rPd30+fZeCPH/iaxGXfAThGMFPg4bHWSIO9V4uk+KRtYZ126GDfac8blLbqjePWPJ4dCu2VX/Fbz+NcUHJXVNhjmiZGT22vgYT0aFnCcl3xNUhKIfMm72cea+sijm3osto7HCKmqbLD/1NihjeZuTPj4W1UQ1Ku/pHUDZf5xbl8WvlUt3BYlEWtQ3kErdKqq3jLDPelytKW3el/mKPA5sbCCTCDdHgJwHEfteNtSjFrp2MGVVlR6q+DpyXMugyr+Yl/7FelOEv8o0MGAnoTN71jD8Gs6WfSCnraHZkiOleTvDOlY0LK9AgvQnBwnjtWZoXx2Lm/XidTIwsa1zyReKSrD8KtC1vHbPcBGedGZzE9kTDjYTN1fIaDPaRi8h/RWgAeRMcKVLmEu9PnMwOkd2iBePvceESZzz+4PET0/8JsvaMioe4bzROBKlyVW5Mvt0xu1lzKu5KZqRzboygbMw2Xz6hfSn8FBArW3mGMc8M0Srk2thBBR9+duydOOE6m/gCaeiLAPIxwN59ytU303zUnkKRdVE53WB2fq/ds5dmr4pxOV9GTbOLMOYB+7QYUdpm3KfoUkQ1K5Focpt66eL3nyQfp3fEwjU6RI1b/60aSlq0hb6n0X6fyXGBtqdVtbO2F0fMGAH2cjNtw8O814URh0BkGuk6sCOq3OiKvXc1HDhItN1lguBHBM9ZvW6zq5csKyqvtK+v3f62E= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(66556008)(2616005)(186003)(86362001)(83380400001)(1076003)(38100700002)(66946007)(316002)(66476007)(7416002)(107886003)(8936002)(2906002)(4326008)(6506007)(38350700002)(5660300002)(508600001)(36756003)(52116002)(8676002)(26005)(6486002)(921005)(6512007)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EMneee429EMJNL1cg+AD+ytfgDz+cxg6LiqjTBkL4v4x45Zjc3T2tpvSR3tB0snds8dQxaP/OpARzYUOSajoB1e6kf85kprsJl6AjI/XBOx/XJSUpkwDNpubiZj/iAVnKxDkiYVtKyMpsezPpuETLRxwSFliADnm6UEttldHpBIC/psCqCg+/rq57nDXJRro4XbFhjJaSY251a7sYCY7UodDZJc0NWtskm6woWdLaukzntTadVMV0ruqEg62QJk55tyfYmWdbracd6hkmvbQP9aYUk2Cwp5g6kDUM1Il9WBYaWSDafMDvG4UOEVI9PQthmoPrT6go0mgEpCsqSjWVHseMHkSQ3oXZqr6Faqgjs6OtaxDEbKlbLAWnqHzyib9qpR5IqkSxzhDmKTn88qiIwg3+QUSe2MMQHBYUpLm6do0eeQ741Ipyqbbh/FxL1tA0Uzd+Fyzb2FhEG6gxKueq8jq7anhuYqnbMx5jlq4vLarEhauRfSHLwBdd4ROBeTqzc8Ho3TpSgi6HQo1G+xmpsZq5Z7NZd0xmmRrY1HKrD21SXHFi0OR4ZkZzYBtWLehTxOQ7v/5Ff8N3wfHFVjyyE+vRj51tjHHEk5Rp76aRrv4UX926EafqwgFsRpS5hrh41HbsEO7gXEU7GMMCL4n6lU1S4QiNladvijpT8RPn1yWoyiOGOP358pdvlgQBPcX2BFFsLSkwqbcg4juL1zRoXlSLbNXbQJO4IUxyIQnfTLFDAwSveN4XLNXNQ92MNuQ/r9hLk90MMwfwK/mmLbbBLQ5MR2TM2bV1wJDHFxaAofqJtvCD8WFe3bF/TrcS+irxoLeVEvWM8FgtWzxcD1Z5X1UFkKl04avZBcsB73KDk2pr1eezyonUguShN4wqC6AHjfVBo7xOHKf2hJo94fuIj9cv44kfnJ4Oswabk1/s893i+qPGGoLLNZoZJuaHzpHtvOOw0Vt7hjr6I5wcLBLsq4racLvlkUZRIk13wrD5jiC4w1DgPvt3zl+fJege7mlufy3DDQckXallDGigP0CXQ88Dr4perj73MhAeEh/gbcr1/9bziyFFAsMD3Xo1I5DgT79Iem9U2OF4mM4rxFIxZqP04P51mXQ4+fwqa5QXRt3YWSuwD2Ni0ceqXayJDdZHXqf2+ONtCfiC/WS0cO/7kDHIKxsDSUZvp1ec6KXirmxgW/+/ATcW4U6fORUparBE44toxWT1CqeTTeTRUCwf/q1STzzbkaYazT+qJ1X2bDRaDG4KHemS9o1ywIgGwqaG7bFXZo1oLVu2bRGM47qX4Y2ktBH8tFz7BmZxWUCP/ly811ZQmQMLc1g6Jmb1DdqtPMT18JuNcGLzYOucjJifAjWi3Dw8pfsA/uw78RbyEJXNWdmpOKVq3kiCThUydcIPFvq0RWckbTREH/DK86u5nmZ36j5E50ECbeyY7qev21ek89Vsy5U+QCJDydRCSz/gb+C7NDck3Xy24oua5oExrQ3IdTrE/NKSE0t9uWTArEVenXzAU9S+v9gICJrqzEf3R1GehmK/P7X/oj7HH/ElNl0Wxa+66pYrqNRjA/lk6p/xk9Wr2V6x+4JouRmlnKifGE7phVLwQSl/35c7V2YlLZR6K0gHErTagwBXZupcjSn6l9h5yP11zuBbjyeVpGyXQmkCFPd70bQg02cubz73cU0U4ExLbAL06XJ66Th2XjC1mtDyCwvF75grVdTnCQdpnv1MKalxAhILTTXPe4QOw== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99599bfd-ae8b-48dd-c355-08da213e8d1b X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 13:22:56.7004 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SgqWfGxXAtBIAy+cVXXJZTRz4gwknKCsyPADuFg+VgxWRE4vD81EJUwYVCYvNaMMkfxRTDZBMXafQ9MT+y3JzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2857 X-Proofpoint-ORIG-GUID: DPEj9QxHWeM-U3XqjFdxjg-BG26mSCZo X-Proofpoint-GUID: DPEj9QxHWeM-U3XqjFdxjg-BG26mSCZo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 mlxlogscore=468 phishscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 adultscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180078 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220418_062324_923648_1EC64413 X-CRM114-Status: GOOD ( 16.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org stack_trace_consume_fn has been changed to bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); to be able to pass more information. Turn to use pc in struct frame_info in arch_stack_walk callbacks without functinoal change. Signed-off-by: He Zhe --- arch/powerpc/kernel/stacktrace.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c index a2443d61728e..8640e9acfa29 100644 --- a/arch/powerpc/kernel/stacktrace.c +++ b/arch/powerpc/kernel/stacktrace.c @@ -28,9 +28,13 @@ void __no_sanitize_address arch_stack_walk(stack_trace_consume_fn consume_entry, struct task_struct *task, struct pt_regs *regs) { unsigned long sp; + struct frame_info fi; - if (regs && !consume_entry(cookie, regs->nip)) - return; + if (regs) { + fi.pc = regs->nip; + if (!consume_entry(cookie, &fi)) + return; + } if (regs) sp = regs->gpr[1]; @@ -41,15 +45,15 @@ void __no_sanitize_address arch_stack_walk(stack_trace_consume_fn consume_entry, for (;;) { unsigned long *stack = (unsigned long *) sp; - unsigned long newsp, ip; + unsigned long newsp; if (!validate_sp(sp, task, STACK_FRAME_OVERHEAD)) return; newsp = stack[0]; - ip = stack[STACK_FRAME_LR_SAVE]; + fi.pc = stack[STACK_FRAME_LR_SAVE]; - if (!consume_entry(cookie, ip)) + if (!consume_entry(cookie, &fi)) return; sp = newsp; @@ -71,6 +75,7 @@ int __no_sanitize_address arch_stack_walk_reliable(stack_trace_consume_fn consum unsigned long stack_end; int graph_idx = 0; bool firstframe; + struct frame_info fi; stack_end = stack_page + THREAD_SIZE; if (!is_idle_task(task)) { @@ -159,7 +164,8 @@ int __no_sanitize_address arch_stack_walk_reliable(stack_trace_consume_fn consum return -EINVAL; #endif - if (!consume_entry(cookie, ip)) + fi.pc = ip; + if (!consume_entry(cookie, &fi)) return -EINVAL; } return 0; From patchwork Mon Apr 18 13:22:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12816605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F05AC433EF for ; Mon, 18 Apr 2022 13:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nin0TcScdztQQS8tjDm8RlfcY2fysJn4qyg5TbLmUlA=; b=hpqUHZUIfhZlI3 unJf3q1Tp/O8kxYr6BYCKdHDZ7WNqLyLYUT0sIaekGSKNTu8cT9Dixf2HKvRr3JU2hl78g3mHt3uf PPKUqJxfeKnA/vPVZs+OYklBukk++blsOs6PKERwzW7jGCX3Tr6ZT6wGDTzSJO3LioNyoNOfwWaIx h4z4wQMBF0U7uM9gXIaKeP2Ox95iff8CypFK+6NuIXKTIcYm79Wf6l8QcxObcVYDTTfGaH20lM86W DwdHpJG5/DHpqA5D3EZ/FzzEdoi+T3Csb64+P7RfNRbKHKA1clPkICUl4fQvvLA2E8DkxXlp/oN2j ux/DVBUlUqNq7ExOk9rA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRRQ-00H3Qz-57; Mon, 18 Apr 2022 13:29:23 +0000 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRLk-00H0NA-8v; Mon, 18 Apr 2022 13:23:30 +0000 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23ICBBTB014126; Mon, 18 Apr 2022 06:23:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=ri8NbMErtUsmIwZuPVcvvPn+8AwVXaNNfl5A5CVR35w=; b=lxDlMZFRz5HYi7JHEC5ub3JgynobxfsZLAAuzt4w2h7XfPqwQCGfjNRjy+Wq7lsKznHO vyKQ1NWCthctZoOJpsTHJNQ8EagempC00KiZheJYGKZHRqe3Qgh+MM6udijMqfFoudLh eI6mtPzKX03PgZj8TBUcs6ylbwuT52om2FJ6A3TgrhRoeC1xAGQwvl+001ExsTVr8u9Y 4160tEiqwfnlyb11T05PySTeY3m8/lFgJ6MqBpw4dckfiNEdUJSof5+Mtzt/vrQLaeNk EDkzb9G1Zwfa+7pRnYsmxxOFdNpIo5xxeOFoanzID9KGTdIijWk4N6is48W1E6Fw6kfo UQ== Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2047.outbound.protection.outlook.com [104.47.56.47]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ffwah150s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 06:23:03 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E5vYZsMq9+zKGI4vMTSzF3ijW2Ri3x4mdbVD3FMQGM6eOIEpK++PEEXtguqfuve8wogvpExNHLWgThmfNI+sUrx7/oAnFyTZOdOqHQA4O+bBB0qE++3XYhZwRusaEJi/gU4XzY7Rm+KIiLm9eG2yywRshejPVIeg9cmz4boBrrTY2haZhtdVX26IlR/UUQSm0qgoAoVofRvrfIvooAcIRcDxhSL/5gR9A902bCDelh2fzzwNEUhuz2ihUtnV4qMpIc/V5eEsBbju8GqFj6/MxjrfCT23VJm3jxPiDtASKikPAL0iLhSvXItCmaC8ZQRs0AH8Y2xqbG6rD46h6ke0Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ri8NbMErtUsmIwZuPVcvvPn+8AwVXaNNfl5A5CVR35w=; b=B757VIUv5BtKqNkgirBKryovwveKkghjpzly7GPt7IPWbGE2c88qFwMEG5aZ4gksvUorGQ/uGd8lM8ON++xKhxFS6k0Ul3VMWYILWfzu+VBUL95/JU4JI9bIeasRQNXSKoETkuWxqiyIv1NyG4bn3N1GayFmvOYeQCJEOD11wGc7uYsjyO+UQwnB/84UCaoKAwGGVhXHR+A5Wfa3BPEsZvVQHvDyyG83J2H6VaLkj0Q3PAGvKdAFLLU34JotkZ4JQUUDK8i/eaVRHHUTObDx4SJq/z7qGdpkYNjeLC6V5bIeDQicd2zeFOY/RsOkiVIS8MoGAkAILhVs5D+DEmiHKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) by DM6PR11MB2857.namprd11.prod.outlook.com (2603:10b6:5:cb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Mon, 18 Apr 2022 13:23:01 +0000 Received: from MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc]) by MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc%7]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 13:23:01 +0000 From: He Zhe To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, keescook@chromium.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, benh@kernel.crashing.org, paulus@samba.org, borntraeger@linux.ibm.com, svens@linux.ibm.com, hpa@zytor.com Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH RFC 5/8] riscv: stacktrace: Make callbacks use new prototype with frame info Date: Mon, 18 Apr 2022 21:22:14 +0800 Message-Id: <20220418132217.1573072-6-zhe.he@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220418132217.1573072-1-zhe.he@windriver.com> References: <20220418132217.1573072-1-zhe.he@windriver.com> X-ClientProxiedBy: HK2PR02CA0133.apcprd02.prod.outlook.com (2603:1096:202:16::17) To MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33923727-9cb3-4956-9125-08da213e9022 X-MS-TrafficTypeDiagnostic: DM6PR11MB2857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U1snG/qP8BEe2R6G9vcemDhtS38JSN4LEAtxjAy/cJ/YnLdm4iw1ZZslb3Y/T8UL3Hy1iW7uqOy15ezuhVvK9F2ySDvnE9f6Oe4iajP4/1eDIqj0F+q8O5IVk/t3VN741f3+ojRk3EJ3M/Ri+aDj1c0OmYUXdlV/Y3nWrzO5fvyCCeIC8zMAkbWfbDEEbxeHw6C0st2mbUhVC9oUTtseUFz9IY4ng/XUUgWmf3/8FIN5jPv2OcbBOxW+bQfUu4JyiBxtl2guHjEqTfHkFSUNndKvKs+rbdVlkJv+IhWHMkaoXNyIfNKz56ZIbjieSUJo+ADfuHF/D6PojMWmtN6Kw7NolgJXzZYyQvZGDfLJyif1KLiFOy0em01Td6gFWCXkOaw5RPgl+VquaNaSkROGujr1zkf3i7rr6yfdL1VRyNmX+TqqaefymH3GwqV72IsiPZ/yzCDhjodV/8+Y14V0nnp/UX/zjFkSfJjV2zy/i9Fpzai9rqqeRqH4gBSeAMwQ2aZ/48TfMeZhCBogCKFqQkY5/627Zzl2rmGF/k77bq/3dhHusTaabXYidzrpJX0XYM7lu2k+U+YmrvXeZFD555i9TlaZgGL/iAxYK/YBflRWVBUINhgiuMZlEFQYyw6J6pVi6Vps2NtAo6Uv6nH7Ig3svebCN/aq/QWxAwprtmTg3vb9SVuLEZ4jAQLimWF/b2Q4A4tokQKhXbW+F7EFDcgV6Hyc1QTX/65CBb0YOis= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(66556008)(2616005)(186003)(86362001)(83380400001)(1076003)(38100700002)(66946007)(316002)(66476007)(7416002)(107886003)(8936002)(2906002)(4326008)(6506007)(38350700002)(5660300002)(508600001)(36756003)(52116002)(8676002)(26005)(6486002)(921005)(6512007)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0D2Nh60ZK0WbyVdl8tFNkd1FehpnekWO1HsUqM3vFift6JwoA00nfHEGD4GVvRGOfMjmYqun6za+KsLDAZ4PwO3yDPRbBdXtdJOD+9T+nF1/OmvdUmSHFBYO6Q2/o51m+IGvQMe+lLCHf1sc+/JflT858QuoFywkENmBH0hNpO7aPt32gPLKc7cpl/aQjVhwjxa0804sQ1IAoP2ecZapxwTmcF4t6ai+2fIPZA2XPXZBD0lyxrYi++NHHt1TSX/jp2iqu5KNmJLEttTixScru0sfsLHn51GbWIFeM0BjDB73lq4fRzdH5FjHbG1Ze8yce8jUhhlpewixfoRJ6jAOR4L7dfxwlEnPWig48bEn6pXxAeWmdRqyDpIvXZs+tHWIBfOV/KKsAatV7mLqXBTeTnaUKnIqGe8eI6V9uAC4Li1DE8kSBT+j+DUrZYMyLzveI8H2wwXsaEnK2tiAnVgjcrztxnOwjZ7sPLhAdLnvunBLAl6CC7fkO+uPYRDmRc1wVtIMcdhcsYJdZD8wglluOgVXcoc3PHSouXzhdM24J55d4CVtBKwr++qqjQ/P/q+VfeG+fAHDZACGAnFVwnqfGqsPm2pzRpUcozIcaJxy3W2PkPd3rBDeV+y1n6V3HQy2qSa4n1M8/tajEhdj/zjgSN1nPRryu2YmlT3sk036adW4W4sbpPBwVSwG309///rsLMrmnEM9Njc7PGZGDgVjyfe8pD7aNjm7mNiyus0YiR96R07rvyaUZvCEffuQsZXvTGCYhr06+53x7SWvIBq38/XtLUx+nDwaT2XTK/YBGpvLh0RC0XK9Otzq0u3oLsXh6Z06fs6g962pZdmAKTGIwQ51Sz//yZi2q6aNFiLXy6RbuJvKBjxVZEp6EA7BSEzMKmnpBkdHQxGNlsJFWv3URFlWm0Xa6qwVqQ6dDvWymeSOmiJJC2GXjZiDu+62whG8Wyb5KgUBmqHDP4tLHZtmJVZmh+a2bk74LpD8UGtjrIAsH8obHkS/19YILEfA7CcUzBoI1tUdisDttXunA4vTXut8PGik/+3wljFPOZGDqanBmjinpLZKoLFQ7Nn8vnlyicWDgoJOtNQNr4IH4Sh2YtVI04Eh6uX587eAXNnQJPOHz9Vkd4fBj9HsWeWrgEeDlBziAhGhTFDWNWisb/vBBDFENUlO7WXhrtPuCy5n2bxrvK4nbT4BLJa0832p1T33TjDW+f//dzZGmNyEdFepwLpa2Im+AHfPmbsDwR++za9uADo07M0DM06tl6UAJymvS37Mo1xgBVdQtGLFnjbJWO+hy5bXma2dVRK0YDWNIUguhQdc5oD4cRnvvb60qT2z1pmxM2ehL+a5Pkx4jzXszfyclevfidemXqnhQtEX35g50UYSWh4Wo0ENWKGT0TEtywVZSMBD9nKZ2QfABTa+EOB52i783NH3Q9ctA4yJ5Unt759yEkN3Z7aNX95qRA1HBbugD1MKR5NADwlfrTaw+fz8KUGOLLUngKtk/AqBzAx6lpvhghP7wcywSiWAxqXJWitpgPobEvnZmZrzQOYE8mXaCeC9w0Tvmf2RLbLqebffAeNUz3yUEEABG5cmlDuvH1V6lPTXhbntKbtaxsbCxLa6hqhTza9e8ODVZVvFka+Pasks5QF/hFUV+y4hjEMsLoxAGejJKsBDyti0LxKem7dnRiJpRhyQu3d4IzP/Mn+8STwO4mFUR9zdInTTWP85iyMdUIqAWu+abFqBZiEMvQ== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33923727-9cb3-4956-9125-08da213e9022 X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 13:23:01.7469 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oJurLbPzfQMbpwhQJv4oULxunsiuwEatCMQTq8cQ8SD9v64QM/Do8zLtADiNgHJSls/JNLsDp1p+3Z2RIZsBgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2857 X-Proofpoint-ORIG-GUID: Aod_roRjV79KpNthk3_U2ND7CEqM04FS X-Proofpoint-GUID: Aod_roRjV79KpNthk3_U2ND7CEqM04FS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 mlxlogscore=736 phishscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 adultscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180078 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220418_062328_410032_269A5906 X-CRM114-Status: GOOD ( 18.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org stack_trace_consume_fn has been changed to bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); to be able to pass more information. Turn to use pc in struct frame_info in arch_stack_walk callbacks without functinoal change. Signed-off-by: He Zhe --- arch/riscv/include/asm/stacktrace.h | 2 +- arch/riscv/kernel/perf_callchain.c | 4 ++-- arch/riscv/kernel/stacktrace.c | 22 +++++++++++++--------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/arch/riscv/include/asm/stacktrace.h b/arch/riscv/include/asm/stacktrace.h index 3450c1912afd..486ed6a96b89 100644 --- a/arch/riscv/include/asm/stacktrace.h +++ b/arch/riscv/include/asm/stacktrace.h @@ -12,7 +12,7 @@ struct stackframe { }; extern void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, - bool (*fn)(void *, unsigned long), void *arg); + stack_trace_consume_fn fn, void *arg); extern void dump_backtrace(struct pt_regs *regs, struct task_struct *task, const char *loglvl); diff --git a/arch/riscv/kernel/perf_callchain.c b/arch/riscv/kernel/perf_callchain.c index 3348a61de7d9..413abf094818 100644 --- a/arch/riscv/kernel/perf_callchain.c +++ b/arch/riscv/kernel/perf_callchain.c @@ -66,9 +66,9 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry, fp = user_backtrace(entry, fp, 0); } -static bool fill_callchain(void *entry, unsigned long pc) +static bool fill_callchain(void *entry, struct frame_info *fi) { - return perf_callchain_store(entry, pc) == 0; + return perf_callchain_store(entry, fi->pc) == 0; } void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c index 08d11a53f39e..9cc5013a5ea4 100644 --- a/arch/riscv/kernel/stacktrace.c +++ b/arch/riscv/kernel/stacktrace.c @@ -17,10 +17,11 @@ #ifdef CONFIG_FRAME_POINTER void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, - bool (*fn)(void *, unsigned long), void *arg) + stack_trace_consume_fn fn, void *arg) { unsigned long fp, sp, pc; int level = 0; + struct frame_info fi; if (regs) { fp = frame_pointer(regs); @@ -41,7 +42,8 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, unsigned long low, high; struct stackframe *frame; - if (unlikely(!__kernel_text_address(pc) || (level++ >= 1 && !fn(arg, pc)))) + fi.pc = pc; + if (unlikely(!__kernel_text_address(pc) || (level++ >= 1 && !fn(arg, &fi)))) break; /* Validate frame pointer */ @@ -67,10 +69,11 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, #else /* !CONFIG_FRAME_POINTER */ void notrace walk_stackframe(struct task_struct *task, - struct pt_regs *regs, bool (*fn)(void *, unsigned long), void *arg) + struct pt_regs *regs, stack_trace_consume_fn fn, void *arg) { unsigned long sp, pc; unsigned long *ksp; + struct frame_info fi; if (regs) { sp = user_stack_pointer(regs); @@ -89,7 +92,8 @@ void notrace walk_stackframe(struct task_struct *task, ksp = (unsigned long *)sp; while (!kstack_end(ksp)) { - if (__kernel_text_address(pc) && unlikely(!fn(arg, pc))) + fi.pc = pc; + if (__kernel_text_address(pc) && unlikely(!fn(arg, &fi))) break; pc = (*ksp++) - 0x4; } @@ -97,11 +101,11 @@ void notrace walk_stackframe(struct task_struct *task, #endif /* CONFIG_FRAME_POINTER */ -static bool print_trace_address(void *arg, unsigned long pc) +static bool print_trace_address(void *arg, struct frame_info *fi) { const char *loglvl = arg; - print_ip_sym(loglvl, pc); + print_ip_sym(loglvl, fi->pc); return true; } @@ -117,11 +121,11 @@ void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl) dump_backtrace(NULL, task, loglvl); } -static bool save_wchan(void *arg, unsigned long pc) +static bool save_wchan(void *arg, struct frame_info *fi) { - if (!in_sched_functions(pc)) { + if (!in_sched_functions(fi->pc)) { unsigned long *p = arg; - *p = pc; + *p = fi->pc; return false; } return true; From patchwork Mon Apr 18 13:22:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12816621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9DAB5C433F5 for ; Mon, 18 Apr 2022 13:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TRmgBahmPzsqDqXqWQ+VfyqW7qNM0xCVCtSFFGHEoUI=; b=UoM8rDqDQsUeMt 63Nb+VVNxCtNypDobpDU5Znr9QWiMYeeh4GJkZGJV1SZoJelRNR7dT7An2EtjtFD+ZIMFr9JjIoXg 7xs4+N1xwU8r69Co+iDaIKomnQkl/m4k6A7u4AdK/LNnx1uBTHnBAsruPfCvW5q3kMzvY93xClkmH kvL3xHGOoO8VjoNIZGxjxz9UwoaRP8gnvFAPZETMd4qs+s47/fNmUBxThJqryESpxD6Q9IZoyNlnM oX6zCCyTAKh5GrvxiOQVu3IVOC4ONw36XM/kGr7bLvNc+lJpS7mgx3Pv4IxrPkK2PPxA0Gd/yzuhB DZi/EYdJiogUI13WjXNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRVg-00H5OH-1S; Mon, 18 Apr 2022 13:33:48 +0000 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRLj-00H0MO-Nz; Mon, 18 Apr 2022 13:23:30 +0000 Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23ICpX2o007677; Mon, 18 Apr 2022 06:23:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=+ZlBGbmmFuH0EnsblfGqUbucFTvETbcXmwFeuOEOMkU=; b=GnoF1GZSc42SUp2R2+eM0qX5TZzwqiEFt3azsmsE9SlfiGba0YNDv53rX4VKgmsNmYrM h8+pKZCv6BSr/yIIwGVH9yKnLqP9GT8yJKpdc3z2kCcf7YZ2GQ6BmEtutO8DaeKuIPo/ qQlSD6Kgvg6j32Dr51WtKcHPq9h5osYQXZOiKd4aSVc03C5q4a3Nm26gImZ+7KX+tz6r QAoo5qoGBRAcjU6K7KVl7Ub21w2WQAzGYK192aUlezhBCMFm3wM+kyzmE3Pp1Jcalwgt kla+R3ahG/D1eX7i/fQ5KC2f1wuQRazHOlq5+CQbhYNO+j6qq0OUQCFXemjN/v3froFj 6A== Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2041.outbound.protection.outlook.com [104.47.74.41]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ffs3118r9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 06:23:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S+NQy8ZXT4CVp3bQBw3ehPG4rtu11IDJ2LI6L6Gf+T/8PPxmmaTVIIbJCt8SAjv1erbJbu4AX0SiuSFFPHKFF4ijCHwOTbcZR1m33t87AtL+d/pUX83cPfgEZhPwIE0e2V82r4AqF77X4/fG7mafzSuCPoayZIcxXdmA5mBiOeUQ7tNJQKCsTGxYNYAvBJYK8zlKZ8Yess7UapYjyzohhBAbUQw78lz7l1filpwSvi65v25VgOu8hSIUxsBadVBIe7gWlPkco88Xq9l8qunrV3rfz1FiAMI9cej1a9jQkLIxMjV8enVkFLqlwu67H8TpPvnU7swcqu+VB2iDSg/wCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+ZlBGbmmFuH0EnsblfGqUbucFTvETbcXmwFeuOEOMkU=; b=jeyXHRPsQUK+uIBWBz3ODTQgnj36mKLZLXwzHAFJ6Be5w9Y3MOTKOgE/0cf/lbxzy+AN3IUbCeNButH/JxeZWTDrGUwl5V4v0J2GJL3HxiB7JiBeAhauVf7A6J1M3U8rUV+Jgt/b/WQZdgC474j/VagP6xpCBPmVXLIcX1j7TihEGffTkpXgXVkQwORN9f1uZY0BZrZIepPVISY7UYSpbl2XD3rZbpUSM3CCPsvmu9y6stjuM2FFP4jDgMh3tE30nl23lZCfniz62wAfSxrijfuE6Pxmn/3Iavkwwj0AVmx5nvG/PAHlIKXsiZLGLh67cBUqJqTKsXbEpjkshG1r5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) by BN6PR11MB1473.namprd11.prod.outlook.com (2603:10b6:405:a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Mon, 18 Apr 2022 13:23:07 +0000 Received: from MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc]) by MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc%7]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 13:23:06 +0000 From: He Zhe To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, keescook@chromium.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, benh@kernel.crashing.org, paulus@samba.org, borntraeger@linux.ibm.com, svens@linux.ibm.com, hpa@zytor.com Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH RFC 6/8] s390: stacktrace: Make callbacks use new prototype with frame info Date: Mon, 18 Apr 2022 21:22:15 +0800 Message-Id: <20220418132217.1573072-7-zhe.he@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220418132217.1573072-1-zhe.he@windriver.com> References: <20220418132217.1573072-1-zhe.he@windriver.com> X-ClientProxiedBy: HK2PR02CA0133.apcprd02.prod.outlook.com (2603:1096:202:16::17) To MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb629049-01cc-414e-111d-08da213e931b X-MS-TrafficTypeDiagnostic: BN6PR11MB1473:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nYHQPLbE2qMzo0bog1p+QqBu+aoUoFBh6D1wWKJ9rLtI0VzQdVErZtCXiEmJvYVD0DOTPm3vO4WNLTeul8PahplGMeCxWRoVPknJ3ImuL9eP0dX6b4pxuK/qGzMBUOB8WGbDgX99l20Zqyx9/S3UTxGrnSulAxFwGBLeEdixJMHRKeLrFz6A5INxo00C54+LSyzsT2TJdETNh4BbWLl9kjnnI8wxa+MaELrThRfUDrRLkp6HQL3+Z8GSJRiMYciEwtBCeqW7hYNZl2Mfubr4FqLLOuHArXh+2oBzIy4ChJe0FX1LOFIcpGmf2FbBH7kvGAKQrM5bPfq83w3x1DJ1eFWCwSGqOngkCv7/pG1M599puPw4UlRwPXROANI8kXDWyAOH5NYbLQMuslR7dkmYNlDXKuER1Aeokcwc67e74yzlmMmq7rIuYxTcNjwevNJQGYFFGvzooUDb6LWIcC77VW9ni/8Crxd5NeewlNI/QZ4Fg+busg/ug3n4Q0xCTGOET0MoiCFB/QNa0dwrIBFgpO4Bkfrvyx5qFjfuaRVdxoDKm5FSIeWF35JSdC9YkdzL9VLTMjbnjxSDftkMDDhXzIBzfcfAqzszRpJMYpWnJ+6WQRK9y3Qe0a4irAbvBshFALgbkQWLdiAkzeo8r04GFGoZLko1d41/V+nuYuA79v48I0L+90c7SeSjV5+ZYEtL7lvGUBTU0vvZcvMhsj0ASww4aiGjQ7+atcUU/eUjQNM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(86362001)(5660300002)(83380400001)(52116002)(26005)(6506007)(6512007)(8936002)(1076003)(107886003)(2616005)(38350700002)(38100700002)(186003)(2906002)(7416002)(508600001)(36756003)(921005)(6666004)(6486002)(316002)(66946007)(66556008)(66476007)(4326008)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NOIxFjHCwuZ5kpb1Yz7IzQZEt47p3HN5QHFw8/Hts8AoSarh2PppAqpbomKArafp72MnGyE9VGJV2Z1KsM1TuKmb7Lp6UKNYq6PGZgoO0F2YyVf8kAX+qbqZeLoh/A4VUVqlerV8/sI5K8Lm5Mv7uG0HAF+dGkX/CMC4ZEJFTGPYSr9uGKoZPJL9rYwqfCYYxnRgMzhLU1DFZrI3WDKMKz1a78q4KomP1XZeDy11aX8C+GqF2J1h7hZf0DDeWHpLBVjDbwK8/CDiHbXuGlr77EwDAeAZeFCQv+/CwvUqWEX54e81z1W03IYcOgevGgTwFhMCTpQWoZRMC3nUfSJOeXni+TJTsBipO4lZjzPv5oKbbC+Fd6rvanP/tmYf3h+TBQIBQvBDwhJWFlHGcgAVj6AbMQpg/CromGtdjyE0kpVgKdc5xKmoT7qWLTB+z3iZ6P5PQLICHgdAgAUlo5f53Xd/AiEUYYzJtr9u5bDdTaW7ddk21J3nc3KDXAka+MFdhQHr5fCGxKe7gUf6RziV2zqj87q/SsYTdotO6k/Bch0ukMP0Y+VTVGNkn0cWep8+x4NaNC4ekSZK+YIoQqFkvexJDYPxAi/a5DZ/UC4H7clx7KIc5GX2GIA7i2cVIYBNg6DomMwwsnyZadS1m0hFj799nH7yuv+p9LEpm7bxgGqk7wQU92RdJ7PeXoHBGPvJbffNudEHiYEY+akh+hydweD35z/S5RgBNTowtm0lvxrzfPtlGwEEp1ZutQqWUC31b5Dd8/PONRkCVBPxWIw48aoecz1IBpxDkIWm/J1xpeO+Wr/7uSIXpOb59RqIkWMSg01JX46FkUWzyuAXtdkIx1vkpvRRcNyW63JijeqtOfDq7jSHsZIMT7KE3u4qZjLPg+8cFthfqKGZv9tY3SDDvh844rCuVTofEBVnALvmncvclbrRH1n77hXXz4akOXk+QwVVYYbgYuyUB6WamiRp7WFvK2ktxuvxv/KEd0scPEG1/wAHGHdQRkNMgHVz1LVV1c+h3SN4+qqL19538WhPl1lIQW19wTM/fseT3uHIxNJw73W3dswI9sM1Tl3awc93tSOzKOOGoa6nmfZAQU1NOBKlTp0xhEd8myWQEVByMOp4dXB8PYSpP5PNpz20HiGQKT84PDvXw/BSxRt4OCnpqjEtEKGYHETrZKJY79Xcra5l476faBXDfDAFfvY5BgHNrNlWWYwjCKoLkEoGrm/lsk/8GvhQ6EMva0DDhHcEd9H0nhuPGMl6GHWlou/4dTRHvGRyF/Fo7XRqY7SgBiwjLwxbbkSRN+3Xkg+B3m4Plbdcu4YBSFjCa3/NW17vdYDJrA243Krhxhv/p4pGTl4Ng76r61KYI7FtyLqGZMGGZNBZhSFzfBcgZfXPfFPv5Zv1bpT0i+BCVfXK0V1f+btZRFxMGH7/D5AoRbQ6EXnNJXwHmoZBGSbfeyKGW72CCyEe4uCtcg2rilZqUWm74pIVqPqRmYK0P4vjfF4eSGYC5rDbgqSP3HGIXcJ/I0ZcqIIRkotqk9/JHRM2uzn1L9Stu9b6I4WXfRdLEo1jMkpNjNb1JWCYiht48fIjMcPJi+47r0sQTcvtKu3eXXZnbUI7l0bvInXzQ+UwuqXyOfVvuXACNdYrQgUK2r2D+1izpRZY11d3lIjxjMueh6IEPmbMjcnUCaMlqeiqyVCm2LAZNI9aeDBOWKzpH0+on2A0V2PjlKxhQzEwr6VwOaR1lnmvzQ== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb629049-01cc-414e-111d-08da213e931b X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 13:23:06.7466 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VoYCIAxzwI9rBjncuFQNduLOburjZpVxN5hmb7dRDU/W4kHgMY9R4ka2wLG5PZQKHt8YRcy+I7OdsnhYJPBGnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1473 X-Proofpoint-ORIG-GUID: fl8Os_InqEnXl8h61EvDV0gQnr-XMSCN X-Proofpoint-GUID: fl8Os_InqEnXl8h61EvDV0gQnr-XMSCN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=573 mlxscore=0 adultscore=0 clxscore=1015 spamscore=0 bulkscore=0 malwarescore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180078 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220418_062327_860998_CA2344BE X-CRM114-Status: GOOD ( 15.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org stack_trace_consume_fn has been changed to bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); to be able to pass more information. Turn to use pc in struct frame_info in arch_stack_walk callbacks without functinoal change. Signed-off-by: He Zhe --- arch/s390/kernel/stacktrace.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c index 7ee455e8e3d5..66aa7da0d974 100644 --- a/arch/s390/kernel/stacktrace.c +++ b/arch/s390/kernel/stacktrace.c @@ -14,11 +14,11 @@ void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, struct task_struct *task, struct pt_regs *regs) { struct unwind_state state; - unsigned long addr; + struct frame_info fi; unwind_for_each_frame(&state, task, regs, 0) { - addr = unwind_get_return_address(&state); - if (!addr || !consume_entry(cookie, addr)) + fi.pc = unwind_get_return_address(&state); + if (!fi.pc || !consume_entry(cookie, &fi)) break; } } @@ -27,7 +27,7 @@ int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, void *cookie, struct task_struct *task) { struct unwind_state state; - unsigned long addr; + struct frame_info fi; unwind_for_each_frame(&state, task, NULL, 0) { if (state.stack_info.type != STACK_TYPE_TASK) @@ -36,8 +36,8 @@ int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, if (state.regs) return -EINVAL; - addr = unwind_get_return_address(&state); - if (!addr) + fi.pc = unwind_get_return_address(&state); + if (!fi.pc) return -EINVAL; #ifdef CONFIG_KPROBES @@ -49,7 +49,7 @@ int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, return -EINVAL; #endif - if (!consume_entry(cookie, addr)) + if (!consume_entry(cookie, &fi)) return -EINVAL; } From patchwork Mon Apr 18 13:22:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12816620 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1443C433F5 for ; Mon, 18 Apr 2022 13:33:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FYui55FrDlDn5ibAHyDFzcBmsuLJQn047rg6t1N4V0A=; b=dJAV15MCmTKbD7 v7nbNg1X9WRijPYVZUvA+2IIHurh4iJsiwRhhdehBjcn/mHNs02QXGjRk3529LOm3L5CSqzbdFE8W NBym51eEscEk7a8EdBbnMuYkORJOEIPsz3zof5N7QdGQ5JjFo4Vol5INyMLF2wqAbbDceg4DStW5M TJfgEWnTtRLK7uyPyZSxti7FGtlpCUX0BKy8/Be4AFdftinHrp0M4pNBU1UiNe2tfriOAICxeReva asqa3gWzRk+36kePxMNc+XivmRr+W1T+F4jfR0v9eRWHtur0wdgVPGyzXZUzxCQBbTgalev/Dn1Qy fjkCSm7CJmuZncUxStFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRTD-00H4Ex-3H; Mon, 18 Apr 2022 13:31:13 +0000 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRLp-00H0Q2-AM; Mon, 18 Apr 2022 13:23:36 +0000 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23IBQZXI006105; Mon, 18 Apr 2022 06:23:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=4T4k7AJWg1onXCT+MoZl7G9b+vfHIAVH1rxxfvWk87k=; b=giPM6ZZtzgANB9pFB9v9ABtn0lS2U/zAQYksYR6RcwPN2rVD6sk6BKfMj5ev6VV5nAzO XJKwigiahgZNKtn2xMxeOujWapxDGT3IgQgAE6knBBkM1nsDF7X4kloJCQ0dWoBmAyIU xcnwdvnNUptM1NtWM/VGbFvIaumefBQ1estl/zEo1Wdrsr09ueHfJfj36FHgTA0AG4BW cUTiGSvhffaTWvOR62t0ekVYxy5S1z7ZOd0e1dTC9qNtXGwwfyegGKH6/9tuhYHYKiWo D4Xotr2x4mtYQTLK4Bbja58GdjzKpggvO10j6TzjB4zj0xEk7A1brzXOJUY1CGq0RBj6 CA== Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2048.outbound.protection.outlook.com [104.47.74.48]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ffwah150u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 06:23:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GYqmvbibddXACk90k/Q10banTuCOLBhgEg1r8klN7jX1g6IXvVo0YPOP13p/a6BYdtxavOiis7D7CkLB2/zWUzsBZOLt0HWXHJs57CE1zpmFGF22yaWPh4n4cIYe9HT4heB9jGXtHfC4IkhHF3IG9xj5y9n75qlNPWoGhJ+jtMwHXqU0TJeN8ae7DFBS8i4drSmZpI8wHFU3U6ZUp5pq/AxF+fxL7XbtyCEdBBAB94LOI/SOdYapi4NpApvMSr1mqiXw1MWB6AQx+GY03/d6/g9O9HUKrXXoErE5dtmP6oruVjwHNLhgjtOijXLADkFvJnBJZB/zYMOq9junhLuurw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4T4k7AJWg1onXCT+MoZl7G9b+vfHIAVH1rxxfvWk87k=; b=lNHuQKvpOTekG+Q9/oQB5QLpkArn1Y3uIF+PqRlo8u9TA4RPzJtQB0ttluCKofLfODfjriMSUE1B8bzS+kFaZ9s/ty8pUwTh/haeVP4dyCyFqBIYd9KmxvZGHuHNvjqVWZmZ4/wvpcqm50vGGUzBgL+F00zmjEWd61lhjN8XqoXLyBUR4UVrH+UNNBOUypUNxviEXXAKzXadNlpjAFG/Y+stXMTQuH9kjw6KkEwl+L6JloqOYQr3cfpXL5JU72PvanGkE8w8hOypRrdnenE2LP80/UpYfBv3xk0vz4MVaMgqrBLU/17dZLgATefjNC6aM2gxBWZW7XCVvDaxHe6mjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) by BN6PR11MB1473.namprd11.prod.outlook.com (2603:10b6:405:a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Mon, 18 Apr 2022 13:23:11 +0000 Received: from MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc]) by MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc%7]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 13:23:11 +0000 From: He Zhe To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, keescook@chromium.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, benh@kernel.crashing.org, paulus@samba.org, borntraeger@linux.ibm.com, svens@linux.ibm.com, hpa@zytor.com Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH RFC 7/8] x86: stacktrace: Make callbacks use new prototype with frame info Date: Mon, 18 Apr 2022 21:22:16 +0800 Message-Id: <20220418132217.1573072-8-zhe.he@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220418132217.1573072-1-zhe.he@windriver.com> References: <20220418132217.1573072-1-zhe.he@windriver.com> X-ClientProxiedBy: HK2PR02CA0133.apcprd02.prod.outlook.com (2603:1096:202:16::17) To MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eaefada3-48a3-4032-b805-08da213e961a X-MS-TrafficTypeDiagnostic: BN6PR11MB1473:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d+Q8QSz/HWcG/dliv4pKuUgzf6IHcUNEk1JJ+UAGiWn3ZvJPgTr3BgUWo6/5VgWTpIEG97dnDJPJNBHH54dp3dnaxZAEaWl0WTPxPMxor7eDs9G0TwONZF/rQF1kTQJvfrd1Toy7py1H/UXsxLAAsl4q4ps+ZKyzTLEFgDlI+9E+CUYC7mKa/GYsNZR3gAcIkaH+kG7IlG1E7cEIZXHluopfot/2/7zuTB4oZR9EadNoaGRT8y0rgF5O5uYKY2gf4pSoOpB4GUhnlHiwvCLQwjhtmVZ89IQCpDXutlpRkp/d/kxz3RX6OfRHPua78G+R610aJZH7Ni7C7Eq3T2bkwkMce8t14gIxsnA0G1ht5WFVnhi5Ln7X7fgm5wp7KOYzvOvX2EzpN7VAn4yzRwQjXzEeYB1Aji5thAOBmBom3y5bo4bdXLDQg8Dp9A5T7yJIeYArll9AFTgLAD//xqlnBcdjAe5OBr6C6TQ3RSUkpGNH/r5/75+JZ9wU+wZaPeBOHkFBEP+IvJJCACxtdJXOySIECotUm8fnNtiHYatFg1wq1DfVZLtGWM/Lq73HGv7VrAjB0sPGmSkmWrHdUJQPSeRQeL1aOKDX4lszxbA5nXOpmRcBHsuIjm5QLlNwuscW6Np5QTKnbfhOT85ZC3b1BWv5/D9BmfHye0qfOzdRZQgBOBtZtEZXfsK2nA7gUmOcKGjjyx8XC19XHIgiicnGomCt/jdVz/pH5fRNS+vMP/A= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(86362001)(5660300002)(83380400001)(52116002)(26005)(6506007)(6512007)(8936002)(1076003)(107886003)(2616005)(38350700002)(38100700002)(186003)(2906002)(7416002)(508600001)(36756003)(921005)(6486002)(316002)(66946007)(66556008)(66476007)(4326008)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z6bkF825XZRbVG8kepe279GOl41l0xkH9o5ZKj5nZ/GZjrm+t18RnKCmweKRvLnTmswTQYVj76PhJnjm0QrD1Uaf3JCHkGODcPPL1Ek9xrTl+LxNeRPqthJcyHsLkPZVk4Fwhl8NMWeboQr4zHAgChH4rWpAA3GSesg9yTY9iwwhlytsvHFy73GW8WGXOthKp1HRV0Uy96v65uBnJM8UgZgF1OKk18O7sgoBTBH2uBnjEuuJygA9LX/g/4BCcSGkBdYfyWU1D4ZGRetpgz6ZSBDg6uXotOmivNpoJMMRFaEl2MPTWbRcJGCYRE6Y5r5dvTj0Fu7N6axaCq0dpKfI5SxvZ1BWlszvlOf0VoBOL+KZYLv5XQc3Bn8q0slCpSCewZfO6rMKWUYsHvUWNkJo1mcWP5J+JGohyzbsyYL4/CE4erSCWyUNtRhGsHxgNC7okTfTcfmHQsa6f4/QTeHCZMK+lZ2ZroGlG8DfOH6/jUzwSlahBp7LSymhRPiwIfKI3eVoY/AEeCATeIGA4A46GvImOAjQDqIdK7l5ZdyAr/pikJgQLD8a5lgmwvqUfw6E+lTJVr/ebQatljqVjrVL9R8AD5kpDJe3ZhI42HyKUx1zdnTBSfzDqCKO9idMFlw5cpL2caiMWJeYgXYuLQl9zm3nCXkt2WjRpO6OgHlzm9oen0TgcGVqiJCixGP7KMq/xv7KnUf3v4CzOJcN0s2Rtuj1K6F/oZajy17qG0tTo9C1406AU8vAw7PpSHnSt8YNvT25/ssRBr13k/1o12ZzY0s5RGbl6c7uCvCRxClYQJ+LlsRwzNOu0jEvpaJXdoZZGnqSnsecjT4WB9JF7zxWXNwMVumjFHVF64LVvqs9toqWp/rXCa1x/fwJ0X0iaTBYQsp3KoK5N+PEFYPWvnetKACDx304hsS++/0YXWTb5kmpQdIsxvnniXiSClXZhvr3y5MjjSa4WNSU7CLjlx1vdvItsSclNp2Uxml9inzd+GkP10b/jMStwED+m3GB+tGj43STRL8OnD5gXeE9MuZZe9Yd+koklvfLmH8QLN1/6SKiEx4BbDO8Fu7tRJU62c+39MKGP21q/J5JYZA2L60iM8S15C9NJZRlm6bOXcIOSZes0plShneJ/0JYO0xRhzn4oNVsoaFJ98+4PLki7tThMtPviKgTdCfIzfhx/uvDgkc8ZOrE7umV84tnP9y7XfI4oxM0XBg9YcY5Ez3OD1ArEe6Zw8leWYfCH2NVI1YksfjYodgpFu70xQmkGoDxpgtTt8yD2/OnzqqTfF6+OyZB5RlHw/PiIVyRReKlsbd1fRqrmW3FXClHllL1biLdahR7fWCKwB9MGew4Rvmmq5oUeglCEciK+jtDtOjOcCuGMGvkKdCOzvE9FpL4HOTJsUMB1JUhYmuu1Ut/3/EJvtN9dpGdJAWUC4YzOuJ9Nk38kVORPokmHqnL2CvtwEPhZoFmIKXNj3TyY8SpeOKLzS02QQJF/OgfbzuANk1qm7fsHqqA83tcQ4s1XdgGGxzPXhndXzSOh7BENmxcJTm34fXIGPPwIWF3h4N2mNDpzjMMDKJUaPB6JmrGOpM0g4l/FqUewzbfQgvu7qU9h/OZME1a8sfrwY4lRkP2FSsYlLIv0BOlE+OGocjGphOpWdtKLtpCOYvEfASBsp187KpYnX751dIykeh5eHuzgBeam1TsIAEGP7xEYixGs/GxYrx1XY4R75nngnQOwT+Q46IoXf2qMQ== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: eaefada3-48a3-4032-b805-08da213e961a X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 13:23:11.7618 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QHl/7ZXaMtJW3Ru3c5CDGsxc5u3mlO4FUaPoSsJ6xxxAcUrTXBQKPf9om8+ghL6xmvzqTRPjI5Sk1zWMJgZXxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1473 X-Proofpoint-ORIG-GUID: gq7Q_ToLEqTuYqJWrR4GtxPdVbJYAin0 X-Proofpoint-GUID: gq7Q_ToLEqTuYqJWrR4GtxPdVbJYAin0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 mlxlogscore=559 phishscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 adultscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180078 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220418_062333_611578_51E30369 X-CRM114-Status: GOOD ( 18.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org stack_trace_consume_fn has been changed to bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); to be able to pass more information. Turn to use pc in struct frame_info in arch_stack_walk callbacks without functinoal change. Signed-off-by: He Zhe --- arch/x86/kernel/stacktrace.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c index ee117fcf46ed..c88bfbb5f157 100644 --- a/arch/x86/kernel/stacktrace.c +++ b/arch/x86/kernel/stacktrace.c @@ -16,15 +16,18 @@ void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, struct task_struct *task, struct pt_regs *regs) { struct unwind_state state; - unsigned long addr; + struct frame_info fi; - if (regs && !consume_entry(cookie, regs->ip)) - return; + if (regs) { + fi.pc = regs->ip; + if (!consume_entry(cookie, &fi)) + return; + } for (unwind_start(&state, task, regs, NULL); !unwind_done(&state); unwind_next_frame(&state)) { - addr = unwind_get_return_address(&state); - if (!addr || !consume_entry(cookie, addr)) + fi.pc = unwind_get_return_address(&state); + if (!fi.pc || !consume_entry(cookie, &fi)) break; } } @@ -34,7 +37,7 @@ int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, { struct unwind_state state; struct pt_regs *regs; - unsigned long addr; + struct frame_info fi; for (unwind_start(&state, task, NULL, NULL); !unwind_done(&state) && !unwind_error(&state); @@ -56,17 +59,17 @@ int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, return -EINVAL; } - addr = unwind_get_return_address(&state); + fi.pc = unwind_get_return_address(&state); /* * A NULL or invalid return address probably means there's some * generated code which __kernel_text_address() doesn't know * about. */ - if (!addr) + if (!fi.pc) return -EINVAL; - if (!consume_entry(cookie, addr)) + if (!consume_entry(cookie, &fi)) return -EINVAL; } @@ -107,8 +110,10 @@ void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie, const struct pt_regs *regs) { const void __user *fp = (const void __user *)regs->bp; + struct frame_info fi; - if (!consume_entry(cookie, regs->ip)) + fi.pc = regs->ip; + if (!consume_entry(cookie, &fi)) return; while (1) { @@ -122,7 +127,8 @@ void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie, break; if (!frame.ret_addr) break; - if (!consume_entry(cookie, frame.ret_addr)) + fi.pc = frame.ret_addr; + if (!consume_entry(cookie, &fi)) break; fp = frame.next_fp; } From patchwork Mon Apr 18 13:22:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: He Zhe X-Patchwork-Id: 12816622 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BC11C433FE for ; Mon, 18 Apr 2022 13:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jx2rtuCNTHpMf8kHM1c7UD65akDgNe1JlmAmGOU0dlE=; b=dVukQ83nORhJbE cdB2lEHGL/Mz3VkaDMPDjLFiQ0DPb8q2ISoS6ydBea4+l67SfAFkpDhdslA4fa7+ee2FJOY0+51AD s7PCvqGn4TW7t9X91t8CN/JKB2eRG4I7fjymKiktn1Df1rQTQrdhJ40MmekBpRn+1xvF5CyVQBk6h yMjDq7Qm3zBjFmmzBGqa2dwqnPbtxMOetLoqp7tTR/ICQL7c7IGXAL02y0xZeWP034mw+iYjbsiC3 j6AvMoXWnwJ8BFYD8kTMJxzEs+gY4BCLO0fZ1y0O7V808LF3Mnpo4fJVkuNmTAexN2s/lLesNIpYf q2Qx2AbqVdiWTxYwLLrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRXC-00H64U-Ow; Mon, 18 Apr 2022 13:35:23 +0000 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngRLt-00H0Sp-1y; Mon, 18 Apr 2022 13:23:39 +0000 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23ICp82j006460; Mon, 18 Apr 2022 06:23:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=ug0HQU3Kvh0LBBEJuxPqFxupe6g38RAI5corIgOKzi0=; b=IHTcGntlqccwUXMmWr6U3AE3rcvvyMzMFTQ6TkZU3kW+la9ediKWnj4RTJf8g+dV3/Rz ASkd/l5rO2DVBD0axCHPBoo9U9m5tMQzMh0zChDMCeEeRdcEyNtMCWOkvSeYYbrsvilU MYpZska4PWorSBPv7ZTnaArEc1yE0jYme3ICAkSdZRCTvQlPQHRWn+CWoyMq+35iCDen JAr3KUaTI/O2ChDb/I8sXj3k7Rv/D3fLodcjz+GNv3ADjaD+Fsrhi21jT1FrscnNNrdy sUdwVVsO6lgD1YOKfjgLjc/eswUGSqVqH8eXJbitNa1pbn4ynYMz0Ai6Wmfq7HiyD3Fo XQ== Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2043.outbound.protection.outlook.com [104.47.74.43]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3ffwah150v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 06:23:18 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H6udojAcfC6uOBRZvHNpijVh4uC1mhHVMTj7NpC75uPfrtpHIuU3FqYIlGfRzWPDhIhjKqm/yVVGVUwyy8ghExox6EymrLSbskX8CkhJmVjShVvd72HzfIr0ZqabBqrIvt3ZvFmubH3UkIXyPhgldaFxF7gyehwPRvvfNhGLNeBSclfzveG9Etd6Rby+Ls5VfOhaYghQkvTbbUDVmsaqxjcuHvFYxAaKoaIiwpe3EZy0R8Yk/iiGrj8dxanK/SDxasGbdoZoygKNXFeaq+wKYIuLBGsAf1i2rIpSHkr+o6mwy5OX5xchQiW5uAAcSaBZT/8S8xgdAEtNraoQwhI8LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ug0HQU3Kvh0LBBEJuxPqFxupe6g38RAI5corIgOKzi0=; b=h5yoa2RR0SZfhFVA9P3NornbSdwk2/QegcBGWmqtOwoVEjAc3QIlcGIj3l6Tjyksdey0HgHIVLfTnNwTWr4PTmHJPVbxAJnpqlbukCy2JhJKm/ZpqVCNJ7+x2jzG2M1rOnMddDEc/tuwfQheXfMvFOV7snt4XKWwZlkeEKuWb1uRvzKQjGJWz/1ekfEm2ct5kEwRt9VvpxZS3ZC44YN+JQMPo4Z37C7RYZn8mTuAnOKkr9SIDLjH4Cc8e7Dk9nktUo+TEKmA69vpFztWXsnp6uafzSAXNg72G9BhKp960nt+WPJUYnHBZ1x01r2t4SndcAdjTu/tunw2Ped46iNRGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) by BN6PR11MB1473.namprd11.prod.outlook.com (2603:10b6:405:a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.18; Mon, 18 Apr 2022 13:23:16 +0000 Received: from MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc]) by MWHPR11MB1358.namprd11.prod.outlook.com ([fe80::1cd4:125:344:9fc%7]) with mapi id 15.20.5164.025; Mon, 18 Apr 2022 13:23:16 +0000 From: He Zhe To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, keescook@chromium.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, benh@kernel.crashing.org, paulus@samba.org, borntraeger@linux.ibm.com, svens@linux.ibm.com, hpa@zytor.com Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhe.he@windriver.com Subject: [PATCH RFC 8/8] lkdtm: usercopy: Make USERCOPY_STACK_FRAME_x able to work for all archs Date: Mon, 18 Apr 2022 21:22:17 +0800 Message-Id: <20220418132217.1573072-9-zhe.he@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220418132217.1573072-1-zhe.he@windriver.com> References: <20220418132217.1573072-1-zhe.he@windriver.com> X-ClientProxiedBy: HK2PR02CA0133.apcprd02.prod.outlook.com (2603:1096:202:16::17) To MWHPR11MB1358.namprd11.prod.outlook.com (2603:10b6:300:23::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 42be3c65-3b61-45a3-fc99-08da213e9917 X-MS-TrafficTypeDiagnostic: BN6PR11MB1473:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nsrNGr3SCouLebJu/jKF1Nrkg21TzYarT94HKK+YVTYal2goe9u+EJHOZtqWwepcMOn3QvDOlvv5xtaLZOlFVKan4hhV0pV/pvRCAKypLNt9ZovLGgkA2On7qgGSkyUIXOrZxU5QGi09Fg1i+rZA8sypBIdCtV/LYVEfASr0TXzqfUAirsRF6z/zGCzPzF0cT3XE8P3dfwlyQjp85MhAzDCyQ1jwM8AHCd8QIUC/bgW5ahFQJBByDuatOr7zGul4/Z2uJfrYJCM2Kcy3V8N8igw1ZOY03KQIJKtHoRX45QFI49UfraA82Cd3XUU2BJdtQ20X0OuGtr0JLKU4vqkb75gZ/9BzY9lz/Pl3OHijBUmUZtk2reklTP16O2wVX8qNTJ95xB1YXbJA/1eDI1SM9aiISwHnnJlP2g/FeqwPBLv5zhhn+2gWKpkRWfA1VEhPKb4GZYoLlj5U5HfKuIPC4/40lNU2VnFy+PH2Y1sYn1QsNYgI/CQJckJKX3Twh1rK+oYB9z6N4Y8a+lc/7Jr+UwnkCOH5yDK8W3Tep26YCe6JJwgc17B8NQQ0LvOBQ2B5F0oZxro76hkUXCevBGCKTmb9ZuBSe9ULm7kCTQ1uSCEH25Ucc+736CuyV7h0zfkaH3Nx78kAGszSpXY5IEuKQm62+J5Ddc43RJQvHqCs97pbZoEPlV4OaoVF9IDDuTlrbS9QIcrxMIi2AkmTV+8nGJqFTGPdpGrjevrPre9Su+8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1358.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(86362001)(5660300002)(83380400001)(52116002)(26005)(6506007)(6512007)(8936002)(1076003)(107886003)(2616005)(38350700002)(38100700002)(186003)(2906002)(7416002)(508600001)(36756003)(921005)(6486002)(316002)(66946007)(66556008)(66476007)(4326008)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I67i49faRicY7KH8Z2bAniN5bMQg2ZOTPyfA3LZVoHQ65SNxRPY9eFA8TzyvsCDapEVCsOcHSlLXdEmrx+LjYjv+R8ui2f6KrkNqrKNI4xSG7r3VSzM9ZePjosXgLd5CvXBWxs+LwsvzOVlZL8AfwKWF4fdJJL7m7bR0viUktd64g7G2lxpl+ELxAxOwDjkcgxcN9E1OKnJTRsgZjI3m+Jem/nup+1CJMhIcxCJ01jOV1jema+5e+7jbpEN/B4UV5OXabImLI6T74wgufutpmISQVDpeWg2LymUVhFmt2Kz6Ti/XGQRrmgweW8cauBFr0V/PLExTuVtSJcEhiYD1HPKXiZh4NJvrSQwbpeuKAN44SZ0F7IFHMIhnZytR6Icec6Nt/98fvJNFFey5SgIWAMMf3qCkTyM56Xaa4TekVWtgkuYI5Pzv1vNw2THBXcGKRdRRI3rl46XLH8iqM7Q6ZX7QutgFWbfnTP3qNtz5vcNjRVi9VD9lO73JaKmNSraftjVi7Bk/fazXMGvFir6cI/7tXyPldAtWit11ouo4eH/vqXJhvCcedACK1CKcGu3jRAmxYKr1e8eE1/W7JguIn7fErCfZckBuvXJJ0jhupfboVWgySvk7Uy59QWNNN4goHuGL2Sr2ChEPgewKnWDMIoKYRAQNl1KgK3tuhEYmok39+fRwCNLjWPpgmkRUad8W11Tffs6v/tCEuGUbSnbl5ZTNlFhc4/yp4AWSyqSRwIeeD70D0/FIAzFmTr+fOPYLvibkOk4RkSEv35mzRwK0kkOI6JaeB0MmRQDZKIAMbTk3TPkdjesqcQ+xwRpYS9JDivejV3AJy3dq7HrxtChzmIQGlG2GwzNVxoMtqjIZQ6qmJl97AQqcbjibUbJzCrzd+bWp1kQB9XIw4l9MDrXPtU5XWf0aU06zgS+Aaw128pyGkcpZnK4lwdoGPpi10gYYvjAVonSBZLYtThxgJ/Dy5ueuPQJu0vYNjBT+To35rI8EfDNxnj/sK6MICTtGywdxet5o0bHtBbpK75lSySWV4u0MdY2aSIv/8p/rsRGZuVfvcfeBImx71CWxy7UtN3PtfPnyyV8WH1jCXAmK6pve6TyHTi4KX7sfUxmxBOGzVCt+yWR2OZSsUKb/xrtAko/H3HB57mBWcvqxKEGYUYnNnWwwKf9AnStcTQmXgEI/ShLunAc6Xu/vcUvIIxjHU48fv3OClh0S6g1c1Fkw6dWMlm5XbIw1uAF4lGcF/l68GjSu5V8wuA6g2neLxR/zu9EAix2uk4bNpVo6tJ0yIR/xW5ICIV0ujcwsRs/ob2B0l+PF5qJRihpA8WmwQUHLf7Row5nsFegEPo2YV5PE3jkBc7tu7dCSTN0fNttN0XcTZDH+IIpV3c92Tsk8SbL/MRlBv2N4Z02NjaUeceUDuYf/VzYZU6Q5w5lgkk2jXKCbU4caHJ47obqJs5i6cmr9OOuFax18c41jIPYRQ+vGsVy92XDoMwufG7Jt10PZxemPIisLELc2S638NgKm4/c7GblQc/AQC90brZOJWiqyeDyVKZPlzUo7u0co6YM1UD4HpOOcToBry+cugNycWavjw4hph5QRcDlbDXxYQCgkTmanDH9j9LAyotlifxfjAKPsYQjEsJx492jn2omx6CptyNRy9f0pjEC/3kWdU6j615oRaTEk2JPUzMcrxxAGsx5Bw7rgS2xy/+syWRmDLdV/SYSFE0LlgWj9EmQkR66gldcgow== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42be3c65-3b61-45a3-fc99-08da213e9917 X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1358.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2022 13:23:16.7615 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4EYttejDG/fzP0CMKXiqS3f4PPnoe9CdjA11GRZ8pStjZT1ACsBSp3hsZ273Y2U7GmCn8XgD0IzadJqCOnZyNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1473 X-Proofpoint-ORIG-GUID: rGlnIKPyJRpc8SVfH1iCUMo_VJfQbid8 X-Proofpoint-GUID: rGlnIKPyJRpc8SVfH1iCUMo_VJfQbid8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 adultscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204180078 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220418_062337_181465_A89BF2B6 X-CRM114-Status: GOOD ( 24.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently the way to generate bad frame use depends on stack layout of the architecture and compiler. It happens to work with x86 but does not work with arm64 since it ruins the stack. On x86, the original do_usercopy_stack_callee returns the start address of its local buffer which is located deeply enough in the stack, so that the following arch_within_stack_frames finds that the address is out of the frame under check and gives the warning. While on arm64, the local buffer of do_usercopy_stack_callee is just not deep enough and happens to lands in the range of a frame so that arch_within_stack_frames cannot detect it with current algorithm. And worse in USERCOPY_STACK_FRAME_FROM, the following writing 0 to the formed buffer just overwrites the return address of the call chain. $ echo USERCOPY_STACK_FRAME_FROM > /sys/kernel/debug/provoke-crash/DIRECT lkdtm: Performing direct entry USERCOPY_STACK_FRAME_FROM lkdtm: attempting good copy_from_user of local stack lkdtm: attempting bad copy_from_user of distant stack Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 The detection algorithm may be improved in the future, but before that let's tune the test case to validate current one. We can simply use __builtin_frame_address(0) as a bad start address that can be detected for all architectures. Signed-off-by: He Zhe --- drivers/misc/lkdtm/usercopy.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/misc/lkdtm/usercopy.c b/drivers/misc/lkdtm/usercopy.c index 9161ce7ed47a..000a1be15200 100644 --- a/drivers/misc/lkdtm/usercopy.c +++ b/drivers/misc/lkdtm/usercopy.c @@ -24,28 +24,6 @@ static struct kmem_cache *whitelist_cache; static const unsigned char test_text[] = "This is a test.\n"; -/* - * Instead of adding -Wno-return-local-addr, just pass the stack address - * through a function to obfuscate it from the compiler. - */ -static noinline unsigned char *trick_compiler(unsigned char *stack) -{ - return stack + 0; -} - -static noinline unsigned char *do_usercopy_stack_callee(int value) -{ - unsigned char buf[32]; - int i; - - /* Exercise stack to avoid everything living in registers. */ - for (i = 0; i < sizeof(buf); i++) { - buf[i] = value & 0xff; - } - - return trick_compiler(buf); -} - static noinline void do_usercopy_stack(bool to_user, bool bad_frame) { unsigned long user_addr; @@ -59,7 +37,7 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame) /* This is a pointer to outside our current stack frame. */ if (bad_frame) { - bad_stack = do_usercopy_stack_callee((uintptr_t)&bad_stack); + bad_stack = __builtin_frame_address(0); } else { /* Put start address just inside stack. */ bad_stack = task_stack_page(current) + THREAD_SIZE;