Message ID | 20120606091950.GB6745@in.ibm.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
On Wed, 2012-06-06 at 14:49 +0530, Ananth N Mavinakayanahalli wrote:
> +int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, loff_t vaddr)
Don't we traditionally use unsigned long to pass vaddrs?
On Wed, Jun 06, 2012 at 11:23:52AM +0200, Peter Zijlstra wrote: > On Wed, 2012-06-06 at 14:49 +0530, Ananth N Mavinakayanahalli wrote: > > +int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, loff_t vaddr) > > Don't we traditionally use unsigned long to pass vaddrs? Right. But the vaddr we pass here is vma_info->vaddr which is loff_t. I guess I should've made that clear in the patch description. Ananth
* Ananth N Mavinakayanahalli <ananth@in.ibm.com> wrote: > On Wed, Jun 06, 2012 at 11:23:52AM +0200, Peter Zijlstra wrote: > > On Wed, 2012-06-06 at 14:49 +0530, Ananth N Mavinakayanahalli wrote: > > > +int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, loff_t vaddr) > > > > Don't we traditionally use unsigned long to pass vaddrs? > > Right. But the vaddr we pass here is vma_info->vaddr which is loff_t. > I guess I should've made that clear in the patch description. Why not fix struct vma_info's vaddr type? Thanks, Ingo
On Wed, Jun 06, 2012 at 11:40:15AM +0200, Ingo Molnar wrote: > > * Ananth N Mavinakayanahalli <ananth@in.ibm.com> wrote: > > > On Wed, Jun 06, 2012 at 11:23:52AM +0200, Peter Zijlstra wrote: > > > On Wed, 2012-06-06 at 14:49 +0530, Ananth N Mavinakayanahalli wrote: > > > > +int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, loff_t vaddr) > > > > > > Don't we traditionally use unsigned long to pass vaddrs? > > > > Right. But the vaddr we pass here is vma_info->vaddr which is loff_t. > > I guess I should've made that clear in the patch description. > > Why not fix struct vma_info's vaddr type? Agreed. Will fix and send v2. Ananth
* Ingo Molnar <mingo@kernel.org> [2012-06-06 11:40:15]: > > * Ananth N Mavinakayanahalli <ananth@in.ibm.com> wrote: > > > On Wed, Jun 06, 2012 at 11:23:52AM +0200, Peter Zijlstra wrote: > > > On Wed, 2012-06-06 at 14:49 +0530, Ananth N Mavinakayanahalli wrote: > > > > +int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, loff_t vaddr) > > > > > > Don't we traditionally use unsigned long to pass vaddrs? > > > > Right. But the vaddr we pass here is vma_info->vaddr which is loff_t. > > I guess I should've made that clear in the patch description. > > Why not fix struct vma_info's vaddr type? > Calculating and comparing vaddr results either uses variables of type loff_t. To avoid typecasting and avoid overflow at each of these places, we used loff_t. Ananth, install_breakpoint() already has a variable of type addr of type unsigned long. Why dont you use addr instead of vaddr.
On 06/06, Ananth N Mavinakayanahalli wrote: > > From: Ananth N Mavinakayanahalli <ananth@in.ibm.com> > > On RISC architectures like powerpc, instructions are fixed size. > Instruction analysis on such platforms is just a matter of (insn % 4). > Pass the vaddr at which the uprobe is to be inserted so that > arch_uprobe_analyze_insn() can flag misaligned registration requests. And the next patch checks "vaddr & 0x03". But why do you need this new arg? arch_uprobe_analyze_insn() could check "container_of(auprobe, struct uprobe, arch)->offset & 0x3" with the same effect, no? vm_start/vm_pgoff are obviously page-aligned. Oleg.
* Oleg Nesterov <oleg@redhat.com> [2012-06-06 17:08:48]: > On 06/06, Ananth N Mavinakayanahalli wrote: > > > > From: Ananth N Mavinakayanahalli <ananth@in.ibm.com> > > > > On RISC architectures like powerpc, instructions are fixed size. > > Instruction analysis on such platforms is just a matter of (insn % 4). > > Pass the vaddr at which the uprobe is to be inserted so that > > arch_uprobe_analyze_insn() can flag misaligned registration requests. > > And the next patch checks "vaddr & 0x03". > > But why do you need this new arg? arch_uprobe_analyze_insn() could > check "container_of(auprobe, struct uprobe, arch)->offset & 0x3" with > the same effect, no? vm_start/vm_pgoff are obviously page-aligned. > We cant use container_of because we moved the definition for struct uprobe to kernel/events/uprobe.c. This was possible before when struct uprobe definition was in include/uprobes.h
On Wed, Jun 06, 2012 at 05:14:23PM +0530, Srikar Dronamraju wrote: > * Ingo Molnar <mingo@kernel.org> [2012-06-06 11:40:15]: > > > > > * Ananth N Mavinakayanahalli <ananth@in.ibm.com> wrote: > > > > > On Wed, Jun 06, 2012 at 11:23:52AM +0200, Peter Zijlstra wrote: > > > > On Wed, 2012-06-06 at 14:49 +0530, Ananth N Mavinakayanahalli wrote: > > > > > +int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, loff_t vaddr) > > > > > > > > Don't we traditionally use unsigned long to pass vaddrs? > > > > > > Right. But the vaddr we pass here is vma_info->vaddr which is loff_t. > > > I guess I should've made that clear in the patch description. > > > > Why not fix struct vma_info's vaddr type? > > > > Calculating and comparing vaddr results either uses variables of type loff_t. > To avoid typecasting and avoid overflow at each of these places, we used > loff_t. > > Ananth, install_breakpoint() already has a variable of type addr of type > unsigned long. Why dont you use addr instead of vaddr. Ok, makes sense. I'll change it in v2. Ananth
Index: uprobes-24may/arch/x86/include/asm/uprobes.h =================================================================== --- uprobes-24may.orig/arch/x86/include/asm/uprobes.h +++ uprobes-24may/arch/x86/include/asm/uprobes.h @@ -48,7 +48,7 @@ struct arch_uprobe_task { #endif }; -extern int arch_uprobe_analyze_insn(struct arch_uprobe *aup, struct mm_struct *mm); +extern int arch_uprobe_analyze_insn(struct arch_uprobe *aup, struct mm_struct *mm, loff_t vaddr); extern int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs); extern int arch_uprobe_post_xol(struct arch_uprobe *aup, struct pt_regs *regs); extern bool arch_uprobe_xol_was_trapped(struct task_struct *tsk); Index: uprobes-24may/arch/x86/kernel/uprobes.c =================================================================== --- uprobes-24may.orig/arch/x86/kernel/uprobes.c +++ uprobes-24may/arch/x86/kernel/uprobes.c @@ -409,9 +409,10 @@ static int validate_insn_bits(struct arc * arch_uprobe_analyze_insn - instruction analysis including validity and fixups. * @mm: the probed address space. * @arch_uprobe: the probepoint information. + * @vaddr: virtual address at which to install the probepoint * Return 0 on success or a -ve number on error. */ -int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm) +int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, loff_t vaddr) { int ret; struct insn insn; Index: uprobes-24may/kernel/events/uprobes.c =================================================================== --- uprobes-24may.orig/kernel/events/uprobes.c +++ uprobes-24may/kernel/events/uprobes.c @@ -697,7 +697,7 @@ install_breakpoint(struct uprobe *uprobe if (is_swbp_insn((uprobe_opcode_t *)uprobe->arch.insn)) return -EEXIST; - ret = arch_uprobe_analyze_insn(&uprobe->arch, mm); + ret = arch_uprobe_analyze_insn(&uprobe->arch, mm, vaddr); if (ret) return ret;