Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1289583ybj; Tue, 5 May 2020 17:17:37 -0700 (PDT) X-Google-Smtp-Source: APiQypLktqBuHdadQqJwj32BHbvrIPL4UP6Y5pNpXYvmcK5RTkFg8XcfOQOJC1Stbos8z+nqiTTK X-Received: by 2002:a50:cd55:: with SMTP id d21mr3087780edj.115.1588724257463; Tue, 05 May 2020 17:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588724257; cv=none; d=google.com; s=arc-20160816; b=H5ZYn4Hq3Nqb03/tV6XV1E5TEiLr2eAZcWNmQtMifwMyRcVbK8y4z2u0m1mBhaWF4E ZLBdX2KdwkYx3Jec/8kujE0A2vUQuL22py1lpIYDCHwmaGiQ2KJiPu3D/uimq895wqFl BU0WFqtxZIP0IrRHYV0x10lFpqPyjPiy12gnIhHqDWHfhEN+IT6j0Qu1541Lf/qQ+V5n eKS6ppYpzxnGHXzDmTU2U8E+TGA+52/C72ofZcxKkxGvm5snZ3pOAN6H5v7uK/9VJmKd VXEOiAwIZZfZjd97D8TvtyjCP+5vJUHuB3s3jIrU2UAct6b+xL1NwxipT7T4bVu8mJYV dk+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=c2hLm6+zbJEAyEVfAYowpOyewzOW+kIv+YTbZQ2i84M=; b=cRW84ILDnhoa2tjyXWLEcF/U4wGCHtIavf45uShR8UiG7ZJfvSA7A3jSdZH2aoLcUo GUSe31rrpxsX3cbJGm/3t/s2M+CG0g6dicsD1/XqPy9h9YM5zg8+dZ+KnTmTA1p6SPty OeEUMQ/n3OOfpE6P9hCkUm1vRcOukVDlvZSidV8SGraP2qBoUtYd1JU9QPP5TCJg6DiD YyQN2nutuGWE+PklQbGyDVxMw55K5H60laKhvB6dAg/wwHvGsxidcif9eM0LlnxoCoTN CYr0PPwUekWi9v8Rb5Oc+lILHn2Gg/qHM4J2PDz0kvENcVcPcA48DAfr0kUAn1z9PqUY GugQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=Wnv9h8DF; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce18si152844ejc.54.2020.05.05.17.17.14; Tue, 05 May 2020 17:17:37 -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=@atishpatra.org header.s=google header.b=Wnv9h8DF; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729346AbgEFAPw (ORCPT + 99 others); Tue, 5 May 2020 20:15:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728642AbgEFAPv (ORCPT ); Tue, 5 May 2020 20:15:51 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E739C061A0F for ; Tue, 5 May 2020 17:15:51 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id f13so50867wrm.13 for ; Tue, 05 May 2020 17:15:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atishpatra.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c2hLm6+zbJEAyEVfAYowpOyewzOW+kIv+YTbZQ2i84M=; b=Wnv9h8DFu6J1kDi8bq3i9rgHlErQOSO5b2nOTXCK2bc54VFNTOkk5Kd/ClmcCuHm4Q VwfRWOEr1NhchIQ8XeAqwgX4bGh1orWeSO4dAmSha799JFEOKbletI8XUJ7QmZdDatsG kqU09jDULZN8sx1sg/VAu8E3+7D6iQ374zGLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=c2hLm6+zbJEAyEVfAYowpOyewzOW+kIv+YTbZQ2i84M=; b=B7+XOwWcfRcLiCAnSijMTAUqgDH+LsmP3IN2mXflxZ+kex7awXg0iKbIQEYGKMAllk Fo2CKiR/Ogmu8D6dLZL7DM2Th7Bdke0URdzhTzMuh9dAAj1D19IjEVLDes9odTouyF0m O7vpw/WRzkrS7SH49zEtUsnhy7wTrXqUA8CnfCOaahG9FFOyS7onQQBAMWOIyIA8JB0W eAE/4j9NQpS+ZW+JikuFWOwp4AbIuKszwnYhCyMnkm9owreyjLAZ+c1gCYcwmRvLTqJ4 q2e1wyU6AnqY8OviaLi/jP20wJolzPJEaLqqaYLcaXgGe0SzNL9kCFEXAy6i3xsDPCr4 5Zrg== X-Gm-Message-State: AGi0Pub3EQB0HNB4hHUOdGlReQGEfUIS9pzkkoWKyX2p1x505ri/QEg0 yPDqd/jVLLxZAAFmu8WouU5Ewuu2DCAfN1ONvNb/ X-Received: by 2002:a5d:5703:: with SMTP id a3mr6910168wrv.53.1588724150121; Tue, 05 May 2020 17:15:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Atish Patra Date: Tue, 5 May 2020 17:15:38 -0700 Message-ID: Subject: Re: [PATCH] RISC-V: Remove unused code from STRICT_KERNEL_RWX To: Palmer Dabbelt , Nick Kossifidis Cc: Atish Patra , Albert Ou , Anup Patel , "linux-kernel@vger.kernel.org List" , Zong Li , Paul Walmsley , linux-riscv Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 5, 2020 at 5:03 PM Palmer Dabbelt wrote: > > On Tue, 05 May 2020 17:00:05 PDT (-0700), atishp@atishpatra.org wrote: > > On Tue, May 5, 2020 at 4:55 PM Palmer Dabbelt wrote: > >> > >> On Sun, 03 May 2020 21:03:19 PDT (-0700), Atish Patra wrote: > >> > This patch removes the unused functions set_kernel_text_rw/ro. > >> > Currently, it is not being invoked from anywhere and no other architecture > >> > (except arm) uses this code. Even in ARM, these functions are not invoked > >> > from anywhere currently. > >> > > >> > Fixes: d27c3c90817e ("riscv: add STRICT_KERNEL_RWX support") > >> > > >> > Signed-off-by: Atish Patra > >> > --- > >> > arch/riscv/mm/init.c | 16 ---------------- > >> > 1 file changed, 16 deletions(-) > >> > > >> > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > >> > index b55be44ff9bd..ba60a581e9b6 100644 > >> > --- a/arch/riscv/mm/init.c > >> > +++ b/arch/riscv/mm/init.c > >> > @@ -501,22 +501,6 @@ static inline void setup_vm_final(void) > >> > #endif /* CONFIG_MMU */ > >> > > >> > #ifdef CONFIG_STRICT_KERNEL_RWX > >> > -void set_kernel_text_rw(void) > >> > -{ > >> > - unsigned long text_start = (unsigned long)_text; > >> > - unsigned long text_end = (unsigned long)_etext; > >> > - > >> > - set_memory_rw(text_start, (text_end - text_start) >> PAGE_SHIFT); > >> > -} > >> > - > >> > -void set_kernel_text_ro(void) > >> > -{ > >> > - unsigned long text_start = (unsigned long)_text; > >> > - unsigned long text_end = (unsigned long)_etext; > >> > - > >> > - set_memory_ro(text_start, (text_end - text_start) >> PAGE_SHIFT); > >> > -} > >> > - > >> > void mark_rodata_ro(void) > >> > { > >> > unsigned long text_start = (unsigned long)_text; > >> > >> Thanks, this is on fixes. Are you going to remove the ARM code as well? > >> > > > > Yeah and also I realized that I forgot to remove the declarations from > > the header file. > > My bad. I will send out a v2. Please drop this one and take v2. > > I just fixed it up > Thanks. I was going over the code again and found one usage for set_kernel_text_rw for ARM. It is used in kexec while set_kernel_text_ro is not invoked anywhere. I am not sure if it is required for kexec implementation for RISC-V. @nick: Can you please comment ? > commit 73cb8e2a5863ccc5215660f5123db621bd57dff7 > gpg: Signature made Tue 05 May 2020 05:02:17 PM PDT > gpg: using RSA key 2B3C3747446843B24A943A7A2E1319F35FBB1889 > gpg: issuer "palmer@dabbelt.com" > gpg: Good signature from "Palmer Dabbelt " [ultimate] > gpg: aka "Palmer Dabbelt " [ultimate] > Author: Atish Patra > Date: Sun May 3 21:03:19 2020 -0700 > > RISC-V: Remove unused code from STRICT_KERNEL_RWX > > This patch removes the unused functions set_kernel_text_rw/ro. > Currently, it is not being invoked from anywhere and no other architecture > (except arm) uses this code. Even in ARM, these functions are not invoked > from anywhere currently. > > Fixes: d27c3c90817e ("riscv: add STRICT_KERNEL_RWX support") > Signed-off-by: Atish Patra > Reviewed-by: Zong Li > Signed-off-by: Palmer Dabbelt > > diff --git a/arch/riscv/include/asm/set_memory.h b/arch/riscv/include/asm/set_memory.h > index c38df4771c09..4c5bae7ca01c 100644 > --- a/arch/riscv/include/asm/set_memory.h > +++ b/arch/riscv/include/asm/set_memory.h > @@ -22,14 +22,6 @@ static inline int set_memory_x(unsigned long addr, int numpages) { return 0; } > static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; } > #endif > > -#ifdef CONFIG_STRICT_KERNEL_RWX > -void set_kernel_text_ro(void); > -void set_kernel_text_rw(void); > -#else > -static inline void set_kernel_text_ro(void) { } > -static inline void set_kernel_text_rw(void) { } > -#endif > - > int set_direct_map_invalid_noflush(struct page *page); > int set_direct_map_default_noflush(struct page *page); > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index 5b813532db59..27a334106708 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -502,22 +502,6 @@ static inline void setup_vm_final(void) > #endif /* CONFIG_MMU */ > > #ifdef CONFIG_STRICT_KERNEL_RWX > -void set_kernel_text_rw(void) > -{ > - unsigned long text_start = (unsigned long)_text; > - unsigned long text_end = (unsigned long)_etext; > - > - set_memory_rw(text_start, (text_end - text_start) >> PAGE_SHIFT); > -} > - > -void set_kernel_text_ro(void) > -{ > - unsigned long text_start = (unsigned long)_text; > - unsigned long text_end = (unsigned long)_etext; > - > - set_memory_ro(text_start, (text_end - text_start) >> PAGE_SHIFT); > -} > - > void mark_rodata_ro(void) > { > unsigned long text_start = (unsigned long)_text; > -- Regards, Atish