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=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 AD273C433C1 for ; Tue, 23 Mar 2021 21:07:11 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 327DA61994 for ; Tue, 23 Mar 2021 21:07:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 327DA61994 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:References: Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=08IrQqWD+KY+BYa6njGKrXkVXQPNOtCdKwlOcU5WkY0=; b=dkPdQ66Brcpf64c5KRydmo7Lx oyfwsTD/9oGX6TzLCLdJf2avWbypuMmjK2FWxiUZ+ApA4KaWZWsa5f5yBkWhimxqNXUiLCpGMzUcd PkJAVbVC+qREiFW10M59ylvHkrriwMPIQs6RepCYBWN9eNGm62e+ARmdmcQ5cnHWtf8HEV/BYcGs4 /ybfNyFbgnd40BgmTOoztari1lSzyyiKIAZd95OgBr62myPhfPEB06GA2zIYSoXL4wZLFyaMX42oK rNwMrKjWY3U3znlmTy8qESswV+If9D5wlsRM2JEDKpZuB09ox+Yi+oCf4sGwqH8B1E8m1GguIXEMH /MoT5R0Dg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lOoCv-00Fkyj-LG; Tue, 23 Mar 2021 21:04:57 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lOoCn-00FkxS-IX for linux-arm-kernel@lists.infradead.org; Tue, 23 Mar 2021 21:04:53 +0000 Received: from [192.168.254.32] (unknown [47.187.194.202]) by linux.microsoft.com (Postfix) with ESMTPSA id E873920B5680; Tue, 23 Mar 2021 14:04:47 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E873920B5680 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1616533488; bh=OXR8yOga0/h10z0/w8+nlFHgpqAPODs3PDqE1WL4q1A=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=BMkCtQ1v6P65n3C3S1DgHgChYKUAfW4cYWty31O2g0bDdyAg4gD9pHKXgc3W/qPPR whSduVPY89bFxr43JQOEoIh2zIZ3a+YOgBV4hfOe6wRECTEhAz5BZoGFHQBWRBIKu4 GlHbadEgBZjgG9iBRvnhP3sweuceSHCPBimchckk= Subject: Re: [RFC PATCH v2 5/8] arm64: Detect an FTRACE frame and mark a stack trace unreliable From: "Madhavan T. Venkataraman" To: Mark Rutland Cc: broonie@kernel.org, jpoimboe@redhat.com, jthierry@redhat.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210323105118.GE95840@C02TD0UTHF1T.local> <2167f3c5-e7d0-40c8-99e3-ae89ceb2d60e@linux.microsoft.com> <20210323133611.GB98545@C02TD0UTHF1T.local> <20210323145734.GD98545@C02TD0UTHF1T.local> <20210323170236.GF98545@C02TD0UTHF1T.local> <20210323183053.GH98545@C02TD0UTHF1T.local> <8aa50127-3f00-818d-d58c-4b3ff7235c74@linux.microsoft.com> Message-ID: <5f32abc2-5759-5fb9-a626-cce962ac275a@linux.microsoft.com> Date: Tue, 23 Mar 2021 16:04:47 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <8aa50127-3f00-818d-d58c-4b3ff7235c74@linux.microsoft.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210323_210451_931800_1A69575B X-CRM114-Status: GOOD ( 24.41 ) 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: , 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 Thanks for all the input - Mark Rutland and Mark Brown. I will send out the stack termination patch next. Since I am splitting the original series into 3 separate series, I will change the titles and start with version 1 in each case, if there is no objection. Again, Thanks. Madhavan On 3/23/21 3:24 PM, Madhavan T. Venkataraman wrote: > > > On 3/23/21 1:30 PM, Mark Rutland wrote: >> On Tue, Mar 23, 2021 at 12:23:34PM -0500, Madhavan T. Venkataraman wrote: >>> On 3/23/21 12:02 PM, Mark Rutland wrote: >> >> [...] >> >>> I think that I did a bad job of explaining what I wanted to do. It is not >>> for any additional protection at all. >>> >>> So, let us say we create a field in the task structure: >>> >>> u64 unreliable_stack; >>> >>> Whenever an EL1 exception is entered or FTRACE is entered and pt_regs get >>> set up and pt_regs->stackframe gets chained, increment unreliable_stack. >>> On exiting the above, decrement unreliable_stack. >>> >>> In arch_stack_walk_reliable(), simply do this check upfront: >>> >>> if (task->unreliable_stack) >>> return -EINVAL; >>> >>> This way, the function does not even bother unwinding the stack to find >>> exception frames or checking for different return addresses or anything. >>> We also don't have to worry about code being reorganized, functions >>> being renamed, etc. It also may help in debugging to know if a task is >>> experiencing an exception and the level of nesting, etc. >> >> As in my other reply, since this is an optimization that is not >> necessary for functional correctness, I would prefer to avoid this for >> now. We can reconsider that in future if we encounter performance >> problems. >> >> Even with this there will be cases where we have to identify >> non-unwindable functions explicitly (e.g. the patchable-function-entry >> trampolines, where the real return address is in x9), and I'd prefer >> that we use one mechanism consistently. >> >> I suspect that in the future we'll need to unwind across exception >> boundaries using metadata, and we can treat the non-unwindable metadata >> in the same way. >> >> [...] >> >>>> 3. Figure out exception boundary handling. I'm currently working to >>>> simplify the entry assembly down to a uniform set of stubs, and I'd >>>> prefer to get that sorted before we teach the unwinder about >>>> exception boundaries, as it'll be significantly simpler to reason >>>> about and won't end up clashing with the rework. >>> >>> So, here is where I still have a question. Is it necessary for the unwinder >>> to know the exception boundaries? Is it not enough if it knows if there are >>> exceptions present? For instance, using something like num_special_frames >>> I suggested above? >> >> I agree that it would be legitimate to bail out early if we knew there >> was going to be an exception somewhere in the trace. Regardless, I think >> it's simpler overall to identify non-unwindability during the trace, and >> doing that during the trace aligns more closely with the structure that >> we'll need to permit unwinding across these boundaries in future, so I'd >> prefer we do that rather than trying to optimize for early returns >> today. >> > > OK. Fair enough. > > Thanks. > > Madhavan > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel