Received: by 10.213.65.68 with SMTP id h4csp470240imn; Wed, 4 Apr 2018 01:32:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx48qfvb0p2MPUWCwu8JcJAQYETgvXdawglQwMIBIYDq88Z0dCkEtWuTfvhE4VzqZUrtgPfCR X-Received: by 10.98.217.139 with SMTP id b11mr13244554pfl.113.1522830756787; Wed, 04 Apr 2018 01:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522830756; cv=none; d=google.com; s=arc-20160816; b=EqCrQJMBaIbfMKpmH0np5iCNHSW2xV5x6kYvPnQZKAP9est6HJ8oZ/x5RPDG4xppYm bXa9JW+X3ghA9RBFBQd1rTrpOw3fXfXlzhH7ltshz+si4UrCcYLIYmAHpr/zdbzugE4p DRG7DcpYq24GEQuniwVYZC+Z/dQgYzU3N8Bx9RW8rkEji8waMwwMeSntzwsm5UA1J5xx SQMQ/rE0ViBSD5ffqdUsnwdi+IzfkBVqxpXsxPc5n9B+hh2dhFZhwF/iPSYuVKy4Vvtg zf2B0FyCnxq483RudmwxZnPtHvSnWhzTnx6ZoyK1dDSRoGU1s1KqABfHAnl0H+rMHW7b HrPg== 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=+cRQjl+/r6TXFBo2vqVkRjv6ShpRbS/A+e5hgTSkek4=; b=zC93VevTlWRq7yzmgcHAvZGabv/7taQsCa/Hnbjb+1OPQXsqGteAs3WNbmB/+SETyS 19bAbd+yA78KbZtcAFCCBDV9TAtuSB7OeGD58wNfUtwc7vSDEJ4J/dArbB2yOlnhTCsK XwKCxaCgio1CVjaSm3h5eRhXD3C7V9yL5sMu8EzNThOzKLtB3qMbadax7zM0pgJ5TGKM 11NfBxK+NayTu8yg0GkkJYwdupwUI+XdLOnfWnYiXgwJ6jpA2XiQ9GnwQEsUdbENBiy6 Sf/u8CxeuYZ2+gv7KsIUKRlCuY7ay8Xd2VYEsAiJ0jy3AI6JZajinjYy15d4Lt3/hG3h EsKA== 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 r3-v6si2485552plb.666.2018.04.04.01.32.23; Wed, 04 Apr 2018 01:32:36 -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 S1751900AbeDDI3w (ORCPT + 99 others); Wed, 4 Apr 2018 04:29:52 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60402 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751772AbeDDI3t (ORCPT ); Wed, 4 Apr 2018 04:29:49 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w348TnCZ040199 for ; Wed, 4 Apr 2018 04:29:49 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 2h4tv4ryw0-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 04 Apr 2018 04:28:48 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Apr 2018 09:28:46 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Apr 2018 09:28:39 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w348ScrX51642402; Wed, 4 Apr 2018 08:28:38 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DF6D111C058; Wed, 4 Apr 2018 09:20:53 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5B19B11C04A; Wed, 4 Apr 2018 09:20:49 +0100 (BST) Received: from bangoria.in.ibm.com (unknown [9.124.31.24]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 Apr 2018 09:20:49 +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 v2 1/9] Uprobe: Export vaddr <-> offset conversion functions Date: Wed, 4 Apr 2018 14:01:02 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180404083110.18647-1-ravi.bangoria@linux.vnet.ibm.com> References: <20180404083110.18647-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: 18040408-0044-0000-0000-000005434462 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040408-0045-0000-0000-0000288359D9 Message-Id: <20180404083110.18647-2-ravi.bangoria@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-04-04_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-1804040090 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ad06d42..95909f2 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2274,6 +2274,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