Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3105147pxj; Mon, 7 Jun 2021 02:20:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwolLkC2ew4sMR+ZqfiAyzjt94d0BcbSPZ5uKCrybu4cjqVx1Q2iidJacFelMBSjQh4rYbh X-Received: by 2002:aa7:c0d3:: with SMTP id j19mr19081105edp.196.1623057645257; Mon, 07 Jun 2021 02:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623057645; cv=none; d=google.com; s=arc-20160816; b=PeDXNFtgPYeuc2UgZ8ycwD3v7mJyBydYS8HOePBWvzQBWdydoNJKvrlpsFzt3kzguk MJw0jKAe1whrW+mTgG+fOWEAcC40fuAnHFLOA1lO8ENfMAOwq6wlLwx+Xa0qAkrGj+Iw 0amf5O4ajWnAefnSP7fc/jlT5q8cRWtIJG8M2Bk5lV4XiJv7D3EhpL+ZlhYW67x/50gC rxePs9F1jkuDl7wtGuaId1Ek1eq0sdMN9aFvnCfJLjZodShmilKz8o0CWJ8bwFABS3rs tYQ4uMmZ2t+0lBdzXuiLy0Al1aDJHjv0vTQxAk/iZ7xCYZNWjdXDSjmMApO0WoBGqGzJ 6Kng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Yy8Jji1XjP7QnMK53YCYHLdhchHCXj35suglXcmEVSU=; b=Kk0e3XnrXx0eB0inqYUsp9JO/cZiEB0XWl+hqQNbEmcSDnmRo1Zd/sqja4DL+0QZ7d ogOlrvueXNbLr4aYvWfwKFvu3kPHhlmvGvwabSlMBJAfyTj4p6SYiYDQ959JH4+/vxyv rjyZSRQiAtg1JNsUwY7Xs9ZSNzuqp8Ox26XJi8uTVn4kohcTuRczSkrk8P3hS9p6Mx9r OyklYfE8GsxZJsHhlZqZgwxmnV8VfZj3Yd9Rhu+NhP+kRNyyAL63plSQuwoyaCe88PAa 4cMN5jP6+4rYg15kVx6YZDKsrnkiyWSxcizeibfyxVRc5BoKYjRP0eIXXAOp30O+nCUk cgoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b23si7986815ejl.274.2021.06.07.02.20.22; Mon, 07 Jun 2021 02:20:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbhFGJVB (ORCPT + 99 others); Mon, 7 Jun 2021 05:21:01 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:3447 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbhFGJU6 (ORCPT ); Mon, 7 Jun 2021 05:20:58 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Fz75b0byhz6wHk; Mon, 7 Jun 2021 17:16:03 +0800 (CST) Received: from dggemi761-chm.china.huawei.com (10.1.198.147) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Mon, 7 Jun 2021 17:19:05 +0800 Received: from SWX921481.china.huawei.com (10.126.200.77) by dggemi761-chm.china.huawei.com (10.1.198.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 7 Jun 2021 17:18:56 +0800 From: Barry Song To: , , , , , , , , , , , , , CC: , Barry Song , Christoph Hellwig Subject: [PATCH v2] kprobes: remove duplicated strong free_insn_page in x86 and s390 Date: Mon, 7 Jun 2021 21:18:54 +1200 Message-ID: <20210607091854.31580-1-song.bao.hua@hisilicon.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.126.200.77] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggemi761-chm.china.huawei.com (10.1.198.147) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org free_insn_page() in x86 and s390 are same with the common weak function in kernel/kprobes.c. Plus, the comment "Recover page to RW mode before releasing it" in x86 seems insensible to be there since resetting mapping is done by common code in vfree() of module_memfree(). So drop these two duplicated strong functions and related comment, then mark the common one in kernel/kprobes.c strong. Cc: Christoph Hellwig Signed-off-by: Barry Song --- -v2: remove free_insn_page in s390 as well and remove the __weak in common code according to Christoph's comment; arch/s390/kernel/kprobes.c | 5 ----- arch/x86/kernel/kprobes/core.c | 6 ------ kernel/kprobes.c | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c index aae24dc75df6..60cfbd24229b 100644 --- a/arch/s390/kernel/kprobes.c +++ b/arch/s390/kernel/kprobes.c @@ -44,11 +44,6 @@ void *alloc_insn_page(void) return page; } -void free_insn_page(void *page) -{ - module_memfree(page); -} - static void *alloc_s390_insn_page(void) { if (xchg(&insn_page_in_use, 1) == 1) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index d3d65545cb8b..3bce67d3a03c 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -422,12 +422,6 @@ void *alloc_insn_page(void) return page; } -/* Recover page to RW mode before releasing it */ -void free_insn_page(void *page) -{ - module_memfree(page); -} - /* Kprobe x86 instruction emulation - only regs->ip or IF flag modifiers */ static void kprobe_emulate_ifmodifiers(struct kprobe *p, struct pt_regs *regs) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 745f08fdd7a6..ddb643f3879f 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -106,7 +106,7 @@ void __weak *alloc_insn_page(void) return module_alloc(PAGE_SIZE); } -void __weak free_insn_page(void *page) +void free_insn_page(void *page) { module_memfree(page); } -- 2.25.1