Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3221290pxj; Mon, 7 Jun 2021 05:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmtzP2TrobpE+U+rpM7h2iB26o1U4rb274qGGWnXGbMRnQSJDCgfJqWYzkxsEHU4YB5E5H X-Received: by 2002:a17:906:85d5:: with SMTP id i21mr15831221ejy.360.1623069225921; Mon, 07 Jun 2021 05:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623069225; cv=none; d=google.com; s=arc-20160816; b=BhY4XrD1+UOCYQZTftpPnQUQruY6HBt0iZ5Y8rV7TqUmfkaMeBOPDoU9EHzohN1elK KCoLq+siOtwKGD249d8+4vOZ9bTzpMJU4pZr/7QqxsE4BMjnIjnDGC5aqERm2KSBuCix qnUoNuyabQ7pHpTq5ssDL4ga03a6kGVCS/B9B8MMe9oj5oHzViX24fUkoOSku5LTm0Uk jUdKFoL9xj+85fLnMXZpjNG/iI0R81j3i3er/N4Sb6YSTSRvba7R4k0GFx/X224H+ntk aUdN/tg8vB9D/3Yu0yQi6EdzOo1DwM+FcYdpnsKnEITOdT9H9gs9vc8oQZ7sFmoygSzN tDkg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=AI3/1hcKOIjpdMTDfHD31HFLLc+y/VQVWoJxGVNJcIM=; b=QQZUewcujyqg3joPt30wxx8e855mMWymvMBfSrK5JqVG37usYGPx1OqhbYlFW9309o zKbWsBizFKadXrf04OuFGcEJSWHiaPBwG6jBfJZ6YsTaBiVp2MKchrJUys9TnYvTy8w8 120rEynJ9mqquZlS0T/BMQdVmDcNpSUyGMDdal+WnEOtE5Jy+666fzEzaJKrJYu2t1hE xC2g8YWE8XLPRJ+gvT3RIBlF9hPHuUu+XFhy3ayKtGmIf3wLCO/rP67YvDn0DOIWMgdf ptXq2GkxgYXkI5tLVaLNpLpZlFtgb0nu9RTWFgUg2/XXh1Mr6kxcFtS1PxbJtToscEfO a+tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FTJjQLzF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si13802913edw.282.2021.06.07.05.33.21; Mon, 07 Jun 2021 05:33: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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FTJjQLzF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbhFGMeG (ORCPT + 99 others); Mon, 7 Jun 2021 08:34:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:52846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbhFGMeE (ORCPT ); Mon, 7 Jun 2021 08:34:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 87DF3610E7; Mon, 7 Jun 2021 12:32:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623069133; bh=T4Z14wIFK7gWUQjB62xSZCX/tmsIcTCzew9mUok/E2c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=FTJjQLzFbWiOTBIXQdtOhHbpc4nwI6xdVDWxdGul9Uc3onX/+qQHoaGwVCf/QGJJD L6jg7CAj2Wu6GCL5FbehCdmGRxATzPVdGfAJmdmQ1SbFMARhaUXUZ6/mbB+LJWZflC K0m5jW82PSxt8QVEVHHLYDE9XBNs2bZstM2ZAZia56XywdOWzyhT5JbJ00sSZdKSWi 6DRPScorVyEgCsM+8R6Qjx926ZcHnTq3ET4ZTclKgNOZ51AvGSX/ShVc+nNJNLco0Z 9c4MVnP5Wj+7TL2d3DaTGtHbDQBUNUgT6RpbWYM86b3BVSsUKNGr+/LRe6jNStVzsZ UcDQtAFhhkrMw== Date: Mon, 7 Jun 2021 21:32:08 +0900 From: Masami Hiramatsu To: Barry Song Cc: , , , , , , , , , , , , , , Christoph Hellwig Subject: Re: [PATCH v2] kprobes: remove duplicated strong free_insn_page in x86 and s390 Message-Id: <20210607213208.b6d4bbda578a1f3aea93a9cb@kernel.org> In-Reply-To: <20210607091854.31580-1-song.bao.hua@hisilicon.com> References: <20210607091854.31580-1-song.bao.hua@hisilicon.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 7 Jun 2021 21:18:54 +1200 Barry Song wrote: > 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. Hm, OK. Actually riscv and arm64 uses __vmalloc() but anyway since module_memfree() calls vfree(). So it has no problem. Acked-by: Masami Hiramatsu Thank you, > > 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 > -- Masami Hiramatsu