From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753535AbcGURQq (ORCPT ); Thu, 21 Jul 2016 13:16:46 -0400 Received: from foss.arm.com ([217.140.101.70]:49266 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753300AbcGURQp (ORCPT ); Thu, 21 Jul 2016 13:16:45 -0400 Date: Thu, 21 Jul 2016 18:16:36 +0100 From: Catalin Marinas To: David Long Cc: Marc Zyngier , Huang Shijie , James Morse , Pratyush Anand , Sandeepa Prabhu , Will Deacon , William Cohen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Steve Capper , Masami Hiramatsu , Li Bin , Jisheng Zhang , Mark Rutland , Daniel Thompson , Vladimir Murzin , Petr Mladek , Ard Biesheuvel , Jens Wiklander , Robin Murphy , Mark Brown , Suzuki K Poulose , Dave P Martin , Andrey Ryabinin , yalin wang , Yang Shi , Zi Shen Lim , John Blackwood , Andrew Morton , Alex =?iso-8859-1?Q?Benn=E9e?= , Adam Buchbinder , Christoffer Dall Subject: Re: [PATCH v15 04/10] arm64: Kprobes with single stepping support Message-ID: <20160721171636.GG16666@e104818-lin.cambridge.arm.com> References: <1467995754-32508-1-git-send-email-dave.long@linaro.org> <1467995754-32508-5-git-send-email-dave.long@linaro.org> <578FA238.3050206@arm.com> <5790F960.5050007@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5790F960.5050007@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 21, 2016 at 12:33:36PM -0400, David Long wrote: > On 07/20/2016 12:09 PM, Marc Zyngier wrote: > >On 08/07/16 17:35, David Long wrote: > >>diff --git a/arch/arm64/include/asm/kprobes.h b/arch/arm64/include/asm/kprobes.h > >>new file mode 100644 > >>index 0000000..79c9511 > >>--- /dev/null > >>+++ b/arch/arm64/include/asm/kprobes.h > >>@@ -0,0 +1,60 @@ > >>+/* > >>+ * arch/arm64/include/asm/kprobes.h > >>+ * > >>+ * Copyright (C) 2013 Linaro Limited > >>+ * > >>+ * This program is free software; you can redistribute it and/or modify > >>+ * it under the terms of the GNU General Public License version 2 as > >>+ * published by the Free Software Foundation. > >>+ * > >>+ * This program is distributed in the hope that it will be useful, > >>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of > >>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > >>+ * General Public License for more details. > >>+ */ > >>+ > >>+#ifndef _ARM_KPROBES_H > >>+#define _ARM_KPROBES_H > >>+ > >>+#include > >>+#include > >>+#include > >>+ > >>+#define __ARCH_WANT_KPROBES_INSN_SLOT > >>+#define MAX_INSN_SIZE 1 > >>+#define MAX_STACK_SIZE 128 > > > >Where is that value coming from? Because even on my 6502, I have a 256 > >byte stack. > > Although I don't claim to know the original author's thoughts I would guess > it is based on the seven other existing implementations for kprobes on > various architectures, all of which appear to use either 64 or 128 for > MAX_STACK_SIZE. The code is not trying to duplicate the whole stack. This seems to be some random choice in the hope that arguments passed on the stack cannot exceed MAX_STACK_SIZE. I'll put a patch together which checks the previous stack frame and limit the copying. If the fp information or if the size to be copied exceeds MAX_STACK_SIZE, just skip the probe hook (return 0 in setjmp_pre_handler). -- Catalin