Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp547364rdb; Thu, 22 Feb 2024 11:29:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX3nyWXNaEHBfcBOHkmHYHCrPOlEYAxPdNN5K/XKgVlyu1Ss8yhFs56RklG71Jx3mFj7ox6h3JMqvuR2EVy8hy8vRfrluGx+MyzNeViow== X-Google-Smtp-Source: AGHT+IFhjrw5BowFbm0/ZDbHXobm8uyIdf1cJvKK21xxy9EnUWq07o0vIe9KJkMd+4QjbBvPiSBL X-Received: by 2002:aa7:c38d:0:b0:565:63d6:40d7 with SMTP id k13-20020aa7c38d000000b0056563d640d7mr73815edq.5.1708630152466; Thu, 22 Feb 2024 11:29:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708630152; cv=pass; d=google.com; s=arc-20160816; b=iWiQS5vypsKVzxqowChoE2FdqiWbhA65KdQBqGXJ2sfUjEEoTmSMXv0Sbzd7Vk3p0E mxpifhRNvE7Tgjd5Q7Tlrl7Ru623S+r2FssyZSO5G3AQ9Sco07nfp9isE+dbAwJiK4Ui ajGQsFaUmmIETjUUa5rOWCpRrm6Wri31WFvg+x0tIlVD19KIY5l8RSjMN7+rJr+0SSDc hNud3K26gpPnu3IjB/LU5Jx50keuh1regFFRs8RX4kxUUO8AveUP4yeYToXi9aQhSgEa hac/mAMiX2zG6v5tzewZbe8hIIiI9jHK9bNXdbGYOLvMWGB7vy4JB53lEg90drcIOoqn 7pWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=/DieCKtMkL6OFsdBEIJ0q7mzZHfNZJTSMtas63Wl/Fw=; fh=WJQ7Ofwp5Wweu2KSQruhdjFc/DcUZulXyroZvrIKAms=; b=pkFGA67jg3FBGJ5XSMWGYPwtxu6ttdxn0P4Das7mFF5UEZsEWRGNgzw6m2cRWpvUDL tOsZoLl0G80R2/g6AoQZmoLlXPnT3K4TdbwYJlMDE6mtfWYQsccYmrXlQMLX5INXkoI6 MFJ4efGNDRyVfDjhkoHEieyMBklUtjRNDbNPBh5U99ZQtfxntvsxPKYx/6mIHAWmR0Fo xlpn26epTWaG7W2TTiox1AS+u1NPrmpjZmjGdDVW2utrTa43fzBFu3lvT6yAAYvXpzeQ 89TnJjmVCXkQ2opsg14OPLIpdVDBdCD/0dT8KsYCI5oNPqEK1SCc79raVzamEkhCb+av z/Sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-77261-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77261-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q15-20020aa7cc0f000000b00564098c4c23si5290775edt.541.2024.02.22.11.29.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 11:29:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77261-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-77261-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77261-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 732651F272EA for ; Thu, 22 Feb 2024 19:28:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E5656AF94; Thu, 22 Feb 2024 19:28:20 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC3E554912; Thu, 22 Feb 2024 19:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708630099; cv=none; b=urs+YfaUkWgJRwI8/rVwMl/FsyK9mCs24C7TcT8bywJ7ZtjDhJz/zWvmivkvYcaAPCd8JWVOr1tkp1ehcSwVbk6qVtplCotJlAgx0cjuzQeJ3FTtVWMurGQAds3bmSMW2D4gXh80GVKwuFkGC0c15xQphHxCMPLbLwOCuscJxIw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708630099; c=relaxed/simple; bh=9b8XTulk2QF1sfxc4c5foOvPMIs5CgMKk2ts2maQPYw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kQR1C7UQY1M2lvucGvWJFo+mCqpYHncDCzecNmRFB6Ej5XNCnLMuQsFZa9JrqdfQ6EJOnR+36UXh/Ji+UWG4oGjF0l4ouGKzYXMgKADgTL+cjfSk9T8PhqRSVmZvy3lMF1QY2aKY+iqScvrk/yGUY3fBwR03VHm+MwWrGGKg+sY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B10F9C433F1; Thu, 22 Feb 2024 19:28:15 +0000 (UTC) Date: Thu, 22 Feb 2024 19:28:13 +0000 From: Catalin Marinas To: Puranjay Mohan Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Zi Shen Lim , Will Deacon , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kumar Kartikeya Dwivedi Subject: Re: [PATCH bpf-next v3 1/2] arm64: stacktrace: Implement arch_bpf_stack_walk() for the BPF JIT Message-ID: References: <20240201125225.72796-1-puranjay12@gmail.com> <20240201125225.72796-2-puranjay12@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240201125225.72796-2-puranjay12@gmail.com> On Thu, Feb 01, 2024 at 12:52:24PM +0000, Puranjay Mohan wrote: > This will be used by bpf_throw() to unwind till the program marked as > exception boundary and run the callback with the stack of the main > program. > > This is required for supporting BPF exceptions on ARM64. > > Signed-off-by: Puranjay Mohan > --- > arch/arm64/kernel/stacktrace.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c > index 7f88028a00c0..66cffc5fc0be 100644 > --- a/arch/arm64/kernel/stacktrace.c > +++ b/arch/arm64/kernel/stacktrace.c > @@ -7,6 +7,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -266,6 +267,31 @@ noinline noinstr void arch_stack_walk(stack_trace_consume_fn consume_entry, > kunwind_stack_walk(arch_kunwind_consume_entry, &data, task, regs); > } > > +struct bpf_unwind_consume_entry_data { > + bool (*consume_entry)(void *cookie, u64 ip, u64 sp, u64 fp); > + void *cookie; > +}; > + > +static bool > +arch_bpf_unwind_consume_entry(const struct kunwind_state *state, void *cookie) > +{ > + struct bpf_unwind_consume_entry_data *data = cookie; > + > + return data->consume_entry(data->cookie, state->common.pc, 0, > + state->common.fp); > +} > + > +noinline noinstr void arch_bpf_stack_walk(bool (*consume_entry)(void *cookie, u64 ip, u64 sp, > + u64 fp), void *cookie) > +{ > + struct bpf_unwind_consume_entry_data data = { > + .consume_entry = consume_entry, > + .cookie = cookie, > + }; > + > + kunwind_stack_walk(arch_bpf_unwind_consume_entry, &data, current, NULL); > +} Too many "cookies", I found reading this confusing. If you ever respin, please use some different "cookie" names. I guess you want this to be merged via the bpf tree? Acked-by: Catalin Marinas