diff mbox series

RISC-V: Remove unused code from STRICT_KERNEL_RWX

Message ID 20200504040319.31423-1-atish.patra@wdc.com (mailing list archive)
State New, archived
Headers show
Series RISC-V: Remove unused code from STRICT_KERNEL_RWX | expand

Commit Message

Atish Patra May 4, 2020, 4:03 a.m. UTC
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 <atish.patra@wdc.com>
---
 arch/riscv/mm/init.c | 16 ----------------
 1 file changed, 16 deletions(-)

Comments

Zong Li May 4, 2020, 5:36 a.m. UTC | #1
On Mon, May 4, 2020 at 12:04 PM Atish Patra <atish.patra@wdc.com> 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 <atish.patra@wdc.com>
> ---
>  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;
> --
> 2.26.2
>

Looks good to me. Thanks.
Reviewed-by: Zong Li <zong.li@sifive.com>
Palmer Dabbelt May 5, 2020, 11:55 p.m. UTC | #2
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 <atish.patra@wdc.com>
> ---
>  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?
Atish Patra May 6, 2020, midnight UTC | #3
On Tue, May 5, 2020 at 4:55 PM Palmer Dabbelt <palmer@dabbelt.com> 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 <atish.patra@wdc.com>
> > ---
> >  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.
Palmer Dabbelt May 6, 2020, 12:03 a.m. UTC | #4
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 <palmer@dabbelt.com> 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 <atish.patra@wdc.com>
>> > ---
>> >  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

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 <palmer@dabbelt.com>" [ultimate]
gpg:                 aka "Palmer Dabbelt <palmerdabbelt@google.com>" [ultimate]
Author: Atish Patra <atish.patra@wdc.com>
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 <atish.patra@wdc.com>
    Reviewed-by: Zong Li <zong.li@sifive.com>
    Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>

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;
Atish Patra May 6, 2020, 12:15 a.m. UTC | #5
On Tue, May 5, 2020 at 5:03 PM Palmer Dabbelt <palmer@dabbelt.com> 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 <palmer@dabbelt.com> 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 <atish.patra@wdc.com>
> >> > ---
> >> >  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 <palmer@dabbelt.com>" [ultimate]
> gpg:                 aka "Palmer Dabbelt <palmerdabbelt@google.com>" [ultimate]
> Author: Atish Patra <atish.patra@wdc.com>
> 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 <atish.patra@wdc.com>
>     Reviewed-by: Zong Li <zong.li@sifive.com>
>     Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
>
> 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;
>
diff mbox series

Patch

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;