Received: by 10.223.185.116 with SMTP id b49csp5887171wrg; Tue, 27 Feb 2018 23:54:00 -0800 (PST) X-Google-Smtp-Source: AH8x224WR8lrKweFih4XK2ENh3AVhpKWSGc2ZaukWfZ5Xf9I/fqN35sbcaCUC6okbU2HXn9CzPj+ X-Received: by 2002:a17:902:44:: with SMTP id 62-v6mr16629169pla.193.1519804440119; Tue, 27 Feb 2018 23:54:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519804440; cv=none; d=google.com; s=arc-20160816; b=amD9dGxNqz3i1F/COxlDqB6SkpuGar1398Uys6V8uCKdj8y2mz3yMn/N3b6JjefJ1m 0E5CDtx2VYKjKDKvxjB1P1AIhoGtT0pM7gbKorxqpuYiqpiI26pNpocx5+qIRQGWfMZU C4raD1EpT9dfI/st+Gz6OB9QE4lyeXs8HQ7P8DE4qyIjA20TolG+AkWRSaun9QE6I4Ul miOPSUNo+Fj0lt3u66Bib4QKQOW5dAn1be40X/VdXBLJ3VZD+aRwU3e0VnzwJvx3lOZ/ 1NdpoK5e9S7AYECQZMcH6TniuiBylzw9TDKfJwH4pqX9EJti8L/y1cL9fiDIe2epc0Jr tdXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=pFdNKWxebhod3KD1UHaxagtZVn1AmCRKicJjLjSW4jY=; b=H8REiRLxV9rJw5cAXaHdTePX+IT5vrc7pHm54anRTXfsU01VETNJwVnZhvPJI+/GCx wmO1Vz9AVAF1PuiEPWQC+LUt9sQ2US71Ev0tBZ42VCoH5PaB7hvvJCxIc2xbqwJv9Wkw LQH1WBmTMRGNyhZmTJNmQ7bQYdTXLiZOMA8PDXgqV/qS1mUE9pk2yJI9A/GYM0BrSdtD vsXns/BX3BbzvQMAvpfJ4rWkj1AOVS6ocB4CoBtmQwSk+gu5JNfkV9bQiGGqGk2fEl9s Z8NGuZNhSGK3AefbXzfVFXVqBzJai8TQ7LjyszMCXXSp+CLlI0HWQrW7WDWA5HpuRQvt 2Q+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5-v6si857951ply.668.2018.02.27.23.53.44; Tue, 27 Feb 2018 23:54:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752160AbeB1Hv6 (ORCPT + 99 others); Wed, 28 Feb 2018 02:51:58 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38856 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751080AbeB1Hvz (ORCPT ); Wed, 28 Feb 2018 02:51:55 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1S7nfo0000930 for ; Wed, 28 Feb 2018 02:51:54 -0500 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gdkp6h161-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 28 Feb 2018 02:51:54 -0500 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 28 Feb 2018 07:51:52 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 28 Feb 2018 07:51:48 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1S7plGr55574708; Wed, 28 Feb 2018 07:51:47 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 715EBA4059; Wed, 28 Feb 2018 07:44:51 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 315C5A404D; Wed, 28 Feb 2018 07:44:49 +0000 (GMT) Received: from bangoria.in.ibm.com (unknown [9.124.31.161]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 28 Feb 2018 07:44:49 +0000 (GMT) From: Ravi Bangoria To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, ananth@linux.vnet.ibm.com, naveen.n.rao@linux.vnet.ibm.com, srikar@linux.vnet.ibm.com, oleg@redhat.com Cc: Ravi Bangoria Subject: [RFC 2/4] Uprobe: Export few functions / data structures Date: Wed, 28 Feb 2018 13:23:43 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180228075345.674-1-ravi.bangoria@linux.vnet.ibm.com> References: <20180228075345.674-1-ravi.bangoria@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18022807-0008-0000-0000-000004D55D20 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022807-0009-0000-0000-00001E68804A Message-Id: <20180228075345.674-3-ravi.bangoria@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-28_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802280094 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These functions and data structures will be used by other files in later patches. Signed-off-by: Ravi Bangoria --- include/linux/uprobes.h | 23 +++++++++++++++++++++++ kernel/events/uprobes.c | 20 ++++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h index 0a294e9..06c169e 100644 --- a/include/linux/uprobes.h +++ b/include/linux/uprobes.h @@ -115,6 +115,12 @@ struct uprobes_state { struct xol_area *xol_area; }; +struct uprobe_map_info { + struct uprobe_map_info *next; + struct mm_struct *mm; + unsigned long vaddr; +}; + extern int set_swbp(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr); extern int set_orig_insn(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long vaddr); extern bool is_swbp_insn(uprobe_opcode_t *insn); @@ -149,6 +155,11 @@ struct uprobes_state { extern bool arch_uprobe_ignore(struct arch_uprobe *aup, struct pt_regs *regs); extern void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr, void *src, unsigned long len); +unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset); +void copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len); +void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len); +struct uprobe_map_info *free_uprobe_map_info(struct uprobe_map_info *info); + #else /* !CONFIG_UPROBES */ struct uprobes_state { }; @@ -203,5 +214,17 @@ static inline void uprobe_copy_process(struct task_struct *t, unsigned long flag static inline void uprobe_clear_state(struct mm_struct *mm) { } +unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset) +{ +} +void copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len) +{ +} +void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len) +{ +} +struct uprobe_map_info *free_uprobe_map_info(struct uprobe_map_info *info) +{ +} #endif /* !CONFIG_UPROBES */ #endif /* _LINUX_UPROBES_H */ diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index fcce25dd..56dd7af 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -130,7 +130,7 @@ static bool valid_vma(struct vm_area_struct *vma, bool is_register) return vma->vm_file && (vma->vm_flags & flags) == VM_MAYEXEC; } -static unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset) +unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset) { return vma->vm_start + offset - ((loff_t)vma->vm_pgoff << PAGE_SHIFT); } @@ -240,14 +240,14 @@ bool __weak is_trap_insn(uprobe_opcode_t *insn) return is_swbp_insn(insn); } -static void copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len) +void copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len) { void *kaddr = kmap_atomic(page); memcpy(dst, kaddr + (vaddr & ~PAGE_MASK), len); kunmap_atomic(kaddr); } -static void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len) +void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len) { void *kaddr = kmap_atomic(page); memcpy(kaddr + (vaddr & ~PAGE_MASK), src, len); @@ -705,23 +705,15 @@ static void delete_uprobe(struct uprobe *uprobe) put_uprobe(uprobe); } -struct uprobe_map_info { - struct uprobe_map_info *next; - struct mm_struct *mm; - unsigned long vaddr; -}; - -static inline struct uprobe_map_info * -free_uprobe_map_info(struct uprobe_map_info *info) +struct uprobe_map_info *free_uprobe_map_info(struct uprobe_map_info *info) { struct uprobe_map_info *next = info->next; kfree(info); return next; } -static struct uprobe_map_info * -build_uprobe_map_info(struct address_space *mapping, loff_t offset, - bool is_register) +struct uprobe_map_info *build_uprobe_map_info(struct address_space *mapping, + loff_t offset, bool is_register) { unsigned long pgoff = offset >> PAGE_SHIFT; struct vm_area_struct *vma; -- 1.8.3.1