Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3864711pxj; Tue, 8 Jun 2021 00:00:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx98Dhn5n09PrhIblLf5uJhe7DROFUsV9mznw1Dlpp0cLhQa2uD5ul0w1pdHDqwsDxNGZ3A X-Received: by 2002:a05:6402:2317:: with SMTP id l23mr24297091eda.265.1623135623718; Tue, 08 Jun 2021 00:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623135623; cv=none; d=google.com; s=arc-20160816; b=hx00pqlNXUugg82dASFJbcg0qEzfKDkLlrIlqMjcQXruzj9MxNaDzjADnKTHdGjROu P4oXz93zIVUm3ctWIg9C0HUX/Duu4d2IQBul7fTKmd/RE1xDwXAVYYUDSBYz8VzS9g9N dc5GgFqUUSsqrSc1w4nuj08TD24Da8Q6APTHX/4MQz0X79TGIexlNApmPFF6IjESq9Uo 6yT7nUSChPd8/VFmifRcrGepNNVEBlgLuGnWWledXB5H46ikNuh8pfLTZdyJV2eE//L9 N++phZP262l+mmpfllXrZack50JGPNEgVpFORvlq/TST54PlslcdqY+i1LPJuawU0TAX ljzw== 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=x1GgDb5s8hK9kGiyg3W/7Quui14SNg3M3Awp3BxEpQ4=; b=p+YB0Ab8+8yXUXK5egL3edeupI01HEcGp/nO7Co94KJUgXVoyejQIvS/+4EnN8qqJ5 t69OU1vtgEVKNCx1d9s9sRkMUpehxwtmZ50s0n4/qmH4EgvDjYVbxdPqbIkbb3xOfD50 gt5J6SxNxoualbofZw8edCnjZPpsEmgAq9i6vW43twGtj+UlISzuX5ZqQdiom/STcUnx AYw7xbLZ60oGDbhf+pYPcjio3x7vDmyqlcycfiBe/eDg/1q575rROINEJ0eGKdQvtxRC vGXcknnO2tKaV04RFT+YVgOv2Y4HfEPzvxU6BknHV1t88W43D6dIPGvu1/B8TCuFBhxC xudA== 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 6si11632059ejl.599.2021.06.08.00.00.00; Tue, 08 Jun 2021 00:00:23 -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 S230333AbhFHG7k (ORCPT + 99 others); Tue, 8 Jun 2021 02:59:40 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:8073 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbhFHG7i (ORCPT ); Tue, 8 Jun 2021 02:59:38 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FzgwH1DP6zYrm0; Tue, 8 Jun 2021 14:54:55 +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; Tue, 8 Jun 2021 14:57:44 +0800 Received: from SWX921481.china.huawei.com (10.126.203.90) 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; Tue, 8 Jun 2021 14:57:39 +0800 From: Barry Song To: , , , , , , , , , , , , , CC: , , , Barry Song , "Christoph Hellwig" Subject: [PATCH v3] kprobes: remove duplicated strong free_insn_page in x86 and s390 Date: Tue, 8 Jun 2021 18:57:36 +1200 Message-ID: <20210608065736.32656-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.203.90] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 is 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. Acked-by: Masami Hiramatsu Acked-by: Heiko Carstens Cc: Christoph Hellwig Signed-off-by: Barry Song --- -v3: mark free_insn_page as static according to Christoph's comment arch/s390/kernel/kprobes.c | 5 ----- arch/x86/kernel/kprobes/core.c | 6 ------ include/linux/kprobes.h | 1 - kernel/kprobes.c | 2 +- 4 files changed, 1 insertion(+), 13 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/include/linux/kprobes.h b/include/linux/kprobes.h index 1883a4a9f16a..c98a35a75f40 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h @@ -407,7 +407,6 @@ int enable_kprobe(struct kprobe *kp); void dump_kprobe(struct kprobe *kp); void *alloc_insn_page(void); -void free_insn_page(void *page); int kprobe_get_kallsym(unsigned int symnum, unsigned long *value, char *type, char *sym); diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 745f08fdd7a6..e0c4c9d57299 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) +static void free_insn_page(void *page) { module_memfree(page); } -- 2.25.1