Received: by 10.192.165.156 with SMTP id m28csp1412615imm; Mon, 16 Apr 2018 21:37:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ePzpUoKZjSB6ZsgK1UzQrnSe23iqwCleqiKkIgsjO0ifcFYF43LUjw9FdDvn+ulNUn8LM X-Received: by 2002:a17:902:6ecd:: with SMTP id l13-v6mr608646pln.113.1523939852185; Mon, 16 Apr 2018 21:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523939852; cv=none; d=google.com; s=arc-20160816; b=G6ipRHwo0j+YyJ5FIfwBeACLyd/jQgrpQAiG0dkyv8tZDEdjeWK8Eugjthb2icUc3u SKGSBDwO2H0VvptotCIF8ccaqHJUQqXE2VZxA/dJDIwr8SjMei6DkLz1mHrW1+Vsnc6v Om1er2TQnsVZt3D2OtnPdGjtr143uoZhQk4mKtE2H6sAgfwT4xsso6oWxjd6DOwUzcdA MJBlcnQy6ijlQNgOBfIQy+U78WOJoPIR7kRz+g0IrnEeIGsskmmu7EgloNiV/Vqw6Skk 8fc1hZclniygZSyM6cZtTsaEf2/+mkkuHDRvCyflFs3n05rvzjTRsK7WMcF9DidMkOIW phQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from :arc-authentication-results; bh=Qx4/M3DPAxpEahd5Pg7CiKM45Dh+NF/OrSStv9Ksxzo=; b=FC3ATKtzuCo4K1X+YDqKZ6pdCKQVxQ4m/6pgabKGJcIy780geYAnCp5XE4K/VVKgb3 KxeZR7a8w7SNGVrRjBdW4Eub91aoAiEvyvHHPDikXtp33B23r+nsJniyMLcZwrUl0to4 muDAoenCe8Y17mHrfXdGKe3zArvIE6bTJ2Ex+uvfAoQFbDJrnmnSar+f00Y9qwdB7dsX 5McTDDbpNNPlrLCeSDHzFvgapVcXfnUa7TLkiFMN3jxFq0bbl8Gd0f/NbTWyea+bBuZb MSZSC71ZO2kUu48eEcunLGPYUPMNRMxjr/I8iNqkSszEX8KUeJsUVDfCbJS+70ltxLtJ 9qnA== 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 p11-v6si5599412plo.276.2018.04.16.21.37.18; Mon, 16 Apr 2018 21:37:32 -0700 (PDT) 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 S1751358AbeDQEda (ORCPT + 99 others); Tue, 17 Apr 2018 00:33:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36250 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750738AbeDQEd1 (ORCPT ); Tue, 17 Apr 2018 00:33:27 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3H4T1lB040338 for ; Tue, 17 Apr 2018 00:33:26 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hd6e5fr29-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 17 Apr 2018 00:33:26 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Apr 2018 05:33:24 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 17 Apr 2018 05:33:18 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3H4XHAc57016356; Tue, 17 Apr 2018 04:33:17 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4FE0FAE045; Tue, 17 Apr 2018 05:23:08 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B94D7AE04D; Tue, 17 Apr 2018 05:23:03 +0100 (BST) Received: from bangoria.in.ibm.com (unknown [9.124.31.151]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 17 Apr 2018 05:23:03 +0100 (BST) From: Ravi Bangoria To: mhiramat@kernel.org, oleg@redhat.com, peterz@infradead.org, srikar@linux.vnet.ibm.com, rostedt@goodmis.org Cc: acme@kernel.org, ananth@linux.vnet.ibm.com, akpm@linux-foundation.org, alexander.shishkin@linux.intel.com, alexis.berlemont@gmail.com, corbet@lwn.net, dan.j.williams@intel.com, jolsa@redhat.com, kan.liang@intel.com, kjlx@templeofstupid.com, kstewart@linuxfoundation.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, milian.wolff@kdab.com, mingo@redhat.com, namhyung@kernel.org, naveen.n.rao@linux.vnet.ibm.com, pc@us.ibm.com, tglx@linutronix.de, yao.jin@linux.intel.com, fengguang.wu@intel.com, jglisse@redhat.com, Ravi Bangoria Subject: [PATCH v3 1/9] Uprobe: Export vaddr <-> offset conversion functions Date: Tue, 17 Apr 2018 10:02:36 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180417043244.7501-1-ravi.bangoria@linux.vnet.ibm.com> References: <20180417043244.7501-1-ravi.bangoria@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 18041704-0044-0000-0000-0000054900B4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041704-0045-0000-0000-000028890C02 Message-Id: <20180417043244.7501-2-ravi.bangoria@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-17_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1804170041 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ravi Bangoria These are generic functions which operates on file offset and virtual address. Make these functions available outside of uprobe code so that other can use it as well. Signed-off-by: Ravi Bangoria Reviewed-by: Jérôme Glisse --- include/linux/mm.h | 12 ++++++++++++ kernel/events/uprobes.c | 10 ---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index ccac106..de0cc08 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2272,6 +2272,18 @@ struct vm_unmapped_area_info { return unmapped_area(info); } +static inline 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); +} + +static inline loff_t +vaddr_to_offset(struct vm_area_struct *vma, unsigned long vaddr) +{ + return ((loff_t)vma->vm_pgoff << PAGE_SHIFT) + (vaddr - vma->vm_start); +} + /* truncate.c */ extern void truncate_inode_pages(struct address_space *, loff_t); extern void truncate_inode_pages_range(struct address_space *, diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index ce6848e..bd6f230 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -130,16 +130,6 @@ 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) -{ - return vma->vm_start + offset - ((loff_t)vma->vm_pgoff << PAGE_SHIFT); -} - -static loff_t vaddr_to_offset(struct vm_area_struct *vma, unsigned long vaddr) -{ - return ((loff_t)vma->vm_pgoff << PAGE_SHIFT) + (vaddr - vma->vm_start); -} - /** * __replace_page - replace page in vma by new page. * based on replace_page in mm/ksm.c -- 1.8.3.1