From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FB3AC433DF for ; Thu, 15 Oct 2020 21:31:14 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8ED5420759 for ; Thu, 15 Oct 2020 21:31:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0GjU88Yw"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OP5CaNBz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8ED5420759 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=anEMbFNTCkQ5mUziQjVHjFAWRL3VPIY4EtiNbgUwFao=; b=0GjU88YwlZLgBqmndYxakVmlN G6eerMn/He5cxGae/DzJJGiBuPZV50cPOD7qhxE3EgBuEV+kf6nrF7/cX0JDG/ihIDvCjoy33x3pX /U08qqqEmqerrsfYT3xd3xmTszImnx1xG8y/1HlJCc0gA+TL1uen64gQPk156d5LoOowmTGKtaZfG 2NDZsjjT3mL9JnJ2hQ3rO38+DQ7dxZcVxu5xmrAzNsBLPpWd9aTnafXKcxcXo0xQa6KgTSfVRyrqG /Pe5C2jR0gjzdLP2JmDP4dH8A4WSXiAd2Qm5fROkpvo8xvpEQBh92Ntsw926IuFeBrpEHSehbrobG s+JBSxm0g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTAoj-0005nP-Mm; Thu, 15 Oct 2020 21:29:45 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTAog-0005n2-U4 for linux-arm-kernel@lists.infradead.org; Thu, 15 Oct 2020 21:29:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602797381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kx9DiDH08JaCe0i/mT8On9u7ra92vB1BVSutz2Qc+1Y=; b=OP5CaNBzpRvvVcsPejgoSFhKm/MzCSkL37Cq0ISXrRPlqqScKRKV6IX0TYU1+G9o/LSrsE E5UltsOpqKaek+ZAKoI6n/5NeLxgRdhdLVq6TZH16KMjV4iECMfq66mCW1vhQwNcHiYrtF 0uv+Pxyyci7IZ32ccIDW0va/XQdjJBw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-159-MkcSJ-buO8aHZbvmQMrHsA-1; Thu, 15 Oct 2020 17:29:38 -0400 X-MC-Unique: MkcSJ-buO8aHZbvmQMrHsA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D780B835B91; Thu, 15 Oct 2020 21:29:36 +0000 (UTC) Received: from treble (ovpn-115-218.rdu2.redhat.com [10.10.115.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9B3961983; Thu, 15 Oct 2020 21:29:34 +0000 (UTC) Date: Thu, 15 Oct 2020 16:29:31 -0500 From: Josh Poimboeuf To: Mark Brown Subject: Re: [RFC PATCH 0/3] arm64: Implement reliable stack trace Message-ID: <20201015212931.mh4a5jt7pxqlzxsg@treble> References: <20201012172605.10715-1-broonie@kernel.org> <20201015141612.GC50416@C02TD0UTHF1T.local> <20201015154951.GD4390@sirena.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201015154951.GD4390@sirena.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_172943_015585_E80BD98B X-CRM114-Status: GOOD ( 31.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Miroslav Benes , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org I can't see the original patch. Can the original poster (Mark B?) add me to Cc on the next version? It's also good practice to add lkml as well. That way, those of us not copied can at least find the patch in the archives. live-patching@vger.kernel.org would also be a good idea for this one. On Thu, Oct 15, 2020 at 04:49:51PM +0100, Mark Brown wrote: > On Thu, Oct 15, 2020 at 03:16:12PM +0100, Mark Rutland wrote: > > On Thu, Oct 15, 2020 at 03:39:37PM +0200, Miroslav Benes wrote: > > > > I'll just copy an excerpt from my notes about the required guarantees. > > > Written by Josh (CCed, he has better idea about the problem than me > > > anyway). > > > > It also needs to: > > > - detect preemption / page fault frames and return an error > > > - only return success if it reaches the end of the task stack; for user > > > tasks, that means the syscall barrier; for kthreads/idle tasks, that > > > means finding a defined thread entry point > > > - make sure it can't get into a recursive loop > > > - make sure each return address is a valid text address > > > - properly detect generated code hacks like function graph tracing and > > > kretprobes > > > " > > > It would be great if we could put something like the above into the > > kernel tree, either under Documentation/ or in a comment somewhere for > > the reliable stacktrace functions. > > Yes, please - the expecations are quite hard to follow at the minute, > implementing it involves quite a bit of guesswork and cargo culting to > figure out what the APIs are supposed to do. Documentation is indeed long overdue. I suppose everyone's looking at me. I can do that, but my bandwidth's limited for at least a few weeks. [ Currently in week 4 of traveling cross-country with a camper ("caravan" in British-speak?), National Lampoon vacation style. ] If by cargo culting, you mean reverse engineering the requirements due to lack of documentation, that's fair. Otherwise, if you see anything that doesn't make sense or that can be improved, let me know. > > AFAICT, existing architectures don't always handle all of the above in > > arch_stack_walk_reliable(). For example, it looks like x86 assumes > > unwiding through exceptions is reliable for !CONFIG_FRAME_POINTER, but I > > think this might not always be true. Why not? What else are the existing arches missing from the above list? > I certainly wouldn't have inferred the list from what's there :/ Fair, presumably because of missing documentation. > The searching for a defined thread entry point for example isn't > entirely visible in the implementations. For now I'll speak only of x86, because I don't quite remember how powerpc does it. For thread entry points, aka the "end" of the stack: - For ORC, the end of the stack is either pt_regs, or -- when unwinding from kthreads, idle tasks, or irqs/exceptions in entry code -- UNWIND_HINT_EMPTY (found by the unwinder's check for orc->end. [ Admittedly the implementation needs to be cleaned up a bit. EMPTY is too broad and needs to be split into UNDEFINED and ENTRY. ] - For frame pointers, by convention, the end of the stack for all tasks is a defined stack offset: end of stack page - sizeof(pt_regs). And yes, all that needs to be documented. -- Josh _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel