From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932357AbcDTBaP (ORCPT ); Tue, 19 Apr 2016 21:30:15 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:43734 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932084AbcDTBaM (ORCPT ); Tue, 19 Apr 2016 21:30:12 -0400 Subject: Re: [PATCH v11 5/9] arm64: Kprobes with single stepping support To: David Long , Catalin Marinas , Will Deacon , Sandeepa Prabhu , William Cohen , "Pratyush Anand" , Steve Capper , , , Marc Zyngier References: <1457501543-24197-1-git-send-email-dave.long@linaro.org> <1457501543-24197-6-git-send-email-dave.long@linaro.org> CC: Mark Rutland , Petr Mladek , Viresh Kumar , John Blackwood , Feng Kan , Zi Shen Lim , Dave P Martin , Yang Shi , Vladimir Murzin , Kees Cook , "Suzuki K. Poulose" , "Mark Brown" , =?UTF-8?Q?Alex_Benn=c3=a9e?= , Ard Biesheuvel , "Greg Kroah-Hartman" , Mark Salyzyn , James Morse , Christoffer Dall , Andrew Morton , Robin Murphy , Jens Wiklander , Balamurugan Shanmugam , Hanjun Guo , Ding Tianhong , From: Li Bin Message-ID: <5716DB78.2010109@huawei.com> Date: Wed, 20 Apr 2016 09:29:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1457501543-24197-6-git-send-email-dave.long@linaro.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.23.78] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.5716DB88.0015,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 39ce1250fc935d2560b2abc29c11d61c Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, on 2016/3/9 13:32, David Long wrote: > +int __kprobes arch_prepare_kprobe(struct kprobe *p) > +{ > + unsigned long probe_addr = (unsigned long)p->addr; Here should verify the addr alignment: if (probe_addr & 0x3) return -EINVAL; Thanks, Li Bin > + > + /* copy instruction */ > + p->opcode = le32_to_cpu(*p->addr); > + > + if (in_exception_text(probe_addr)) > + return -EINVAL; > + > + /* decode instruction */ > + switch (arm_kprobe_decode_insn(p->addr, &p->ainsn)) { > + case INSN_REJECTED: /* insn not supported */ > + return -EINVAL; > + > + case INSN_GOOD_NO_SLOT: /* insn need simulation */ > + return -EINVAL; > + > + case INSN_GOOD: /* instruction uses slot */ > + p->ainsn.insn = get_insn_slot(); > + if (!p->ainsn.insn) > + return -ENOMEM; > + break; > + }; > + > + /* prepare the instruction */ > + arch_prepare_ss_slot(p); > + > + return 0; > +} > + From mboxrd@z Thu Jan 1 00:00:00 1970 From: huawei.libin@huawei.com (Li Bin) Date: Wed, 20 Apr 2016 09:29:28 +0800 Subject: [PATCH v11 5/9] arm64: Kprobes with single stepping support In-Reply-To: <1457501543-24197-6-git-send-email-dave.long@linaro.org> References: <1457501543-24197-1-git-send-email-dave.long@linaro.org> <1457501543-24197-6-git-send-email-dave.long@linaro.org> Message-ID: <5716DB78.2010109@huawei.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi David, on 2016/3/9 13:32, David Long wrote: > +int __kprobes arch_prepare_kprobe(struct kprobe *p) > +{ > + unsigned long probe_addr = (unsigned long)p->addr; Here should verify the addr alignment: if (probe_addr & 0x3) return -EINVAL; Thanks, Li Bin > + > + /* copy instruction */ > + p->opcode = le32_to_cpu(*p->addr); > + > + if (in_exception_text(probe_addr)) > + return -EINVAL; > + > + /* decode instruction */ > + switch (arm_kprobe_decode_insn(p->addr, &p->ainsn)) { > + case INSN_REJECTED: /* insn not supported */ > + return -EINVAL; > + > + case INSN_GOOD_NO_SLOT: /* insn need simulation */ > + return -EINVAL; > + > + case INSN_GOOD: /* instruction uses slot */ > + p->ainsn.insn = get_insn_slot(); > + if (!p->ainsn.insn) > + return -ENOMEM; > + break; > + }; > + > + /* prepare the instruction */ > + arch_prepare_ss_slot(p); > + > + return 0; > +} > +