Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1170612pxb; Thu, 16 Sep 2021 01:02:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9rvG56IpaeK9PDSbPBt6+nQnbQlRad4MBZ8Drva/GorVA8pJ9qEv21RA3mPXn97XrgyVQ X-Received: by 2002:a6b:8d15:: with SMTP id p21mr3363640iod.194.1631779351478; Thu, 16 Sep 2021 01:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631779351; cv=none; d=google.com; s=arc-20160816; b=pkwl/AbhNiECiYhkFJeklumyDh/VBsl8DV5K+TE8vYYpM7GKLweipWANhfwwPKBzbe KPjG+oKRASZsnPXcU4f3KzxXBRFY0z8JalSz81NGHXT63MOKbTsXkWIiNvbOaajg1v0M f4xpKuxlZvBDv6nb5Thrj95Ab7+PBBVb0HBmPLKMzEyJi0KeDZq9tZJSpWwcN8Pg+crq 5Lz7RPIAXPBPvhgu0BpsH0wxWQj2IBjgbGuKBc3Ijd2aiul2H07K7FgLd4ehcR6kYG7y SxOMflPq2PQQZrBkF6rWRl8vQZSydk9p8yJa7NCte0SeTrKHbc9+1P+zgVMkOU/12toW C7QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/QXwV71Kp89im184T0V/ymrJou00nyhzJ+R4oD+1+9E=; b=aKFZiyFklSq/Dcy53GY2ALhUSgdipTl3nlsrtM+UsxX7sevRKGfsyAQfZuRO53T8R5 lZCc69SIcUHO15qjJxrH0WMJvABsF7ztRmvGzj62TXmF2ztjuOA9k7MmToblSbmN9RbN WRWyHoFs3Zcq948/Mr0Bvj5n9HocQLTPkUP7G0UM3QCtqCYxq5z8kFF3hWgLac3swdCr /jbOsBjs1tZB7aAjFMR2UGU5c060tRkvkYAsRztgB3vHQKGkW7dig9RWJsanCTRPjecs OYmQ2L1i06nIzAsCbZFhRbO4IOemjDfArgYJcUC+BpviVujcZZwguBx7KKg5xXIhJAfa slUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=IkOcVzKq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p20si2105905ilh.62.2021.09.16.01.02.19; Thu, 16 Sep 2021 01:02:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=IkOcVzKq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234987AbhIPIB6 (ORCPT + 99 others); Thu, 16 Sep 2021 04:01:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234882AbhIPIB5 (ORCPT ); Thu, 16 Sep 2021 04:01:57 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B0BC061574; Thu, 16 Sep 2021 01:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=/QXwV71Kp89im184T0V/ymrJou00nyhzJ+R4oD+1+9E=; b=IkOcVzKq4+f8IOOQbzP3FeT1dy G1WF51P7rzx3jxur49KY7W50vga9kSNq3gDNzq5+LEEVlP6/9A2H8BWfO9vE9O3WwiZSXCKqj+cXg JIKU1QHpzZrloTIieHyQxKEd2th7ofkEa6bXEY63k5vDhpEwxvwHy8BvwQNMVo5unSgFZOESHDWdu vhbUn20zbcRXG+dbat4OfdKSVfEEMtSISJKA3CRVWlhuU83d5iir6IVupT1Pe3lKJawvXgvSGzU64 f/NQpxQ4zzZ3UG4Dx3D1JRXhMn+90EGUHCmDeFm6PdMFmsRgPkZyKVI5XsRhFhnKLA3DvqkqokmHv /vuzOSGA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQmJd-003bfD-7X; Thu, 16 Sep 2021 08:00:17 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id EFCD83000A3; Thu, 16 Sep 2021 10:00:15 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A17002CD48C2B; Thu, 16 Sep 2021 10:00:15 +0200 (CEST) Date: Thu, 16 Sep 2021 10:00:15 +0200 From: Peter Zijlstra To: =?utf-8?B?546L6LSH?= Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "open list:PERFORMANCE EVENTS SUBSYSTEM" , "open list:PERFORMANCE EVENTS SUBSYSTEM" , "open list:BPF (Safe dynamic programs and tools)" , "open list:BPF (Safe dynamic programs and tools)" , jroedel@suse.de, x86@kernel.org Subject: Re: [PATCH] x86/dumpstack/64: Add guard pages to stack_info Message-ID: References: <20210910153839.GH4323@worktop.programming.kicks-ass.net> <3fb7c51f-696b-da70-1965-1dda9910cb14@linux.alibaba.com> <3f26f7a2-0a09-056a-3a7a-4795b6723b60@linux.alibaba.com> <76de02b7-4d87-4a3a-e4d4-048829749887@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <76de02b7-4d87-4a3a-e4d4-048829749887@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 16, 2021 at 11:47:49AM +0800, 王贇 wrote: > I did some debug and found the issue, we are missing: > > @@ -122,7 +137,10 @@ static __always_inline bool in_exception_stack(unsigned long *stack, struct stac > info->type = ep->type; > info->begin = (unsigned long *)begin; > info->end = (unsigned long *)end; > - info->next_sp = (unsigned long *)regs->sp; > + > + if (!(ep->type & STACK_TYPE_GUARD)) > + info->next_sp = (unsigned long *)regs->sp; > + > return true; > } > > as the guard page are not working as real stack I guess? Correct, but I thought I put if (type & GUARD) terminators in all paths that ended up caring about ->next_sp. Clearly I seem to have missed one :/ Let me try and figure out where that happens. > With that one things going on correctly, and some trivials below. > > enum stack_type { > > - STACK_TYPE_UNKNOWN, > > + STACK_TYPE_UNKNOWN = 0, > > Is this necessary? No, but it makes it more explicit we care about the value. > > STACK_TYPE_TASK, > > STACK_TYPE_IRQ, > > STACK_TYPE_SOFTIRQ, > > STACK_TYPE_ENTRY, > > STACK_TYPE_EXCEPTION, > > STACK_TYPE_EXCEPTION_LAST = STACK_TYPE_EXCEPTION + N_EXCEPTION_STACKS-1, > > + STACK_TYPE_GUARD = 0x80, Note that this is a flag. > > }; > > > > struct stack_info { > > --- a/arch/x86/kernel/dumpstack_64.c > > +++ b/arch/x86/kernel/dumpstack_64.c > > @@ -32,9 +32,15 @@ const char *stack_type_name(enum stack_t > > { > > BUILD_BUG_ON(N_EXCEPTION_STACKS != 6); > > > > + if (type == STACK_TYPE_TASK) > > + return "TASK"; > > + > > if (type == STACK_TYPE_IRQ) > > return "IRQ"; > > > > + if (type == STACK_TYPE_SOFTIRQ) > > + return "SOFTIRQ"; > > + > > Do we need one for GUARD too? No, GUARD is not a single type but a flag. The caller can trivially do something like: "%s %s", stack_type_name(type & ~GUARD), (type & GUARD) ? "GUARD" : "" > > if (type == STACK_TYPE_ENTRY) { > > /* > > * On 64-bit, we have a generic entry stack that we > > @@ -111,10 +122,11 @@ static __always_inline bool in_exception > > k = (stk - begin) >> PAGE_SHIFT; > > /* Lookup the page descriptor */ > > ep = &estack_pages[k]; > > - /* Guard page? */ > > + /* unknown entry */ > > if (!ep->size) > > return false; > > > > + > > Extra line? Gone now, thanks!