Re: [PATCH] mm: Define ARCH_HAS_FIRST_USER_ADDRESS

2021-04-14 Thread Anshuman Khandual
On 4/14/21 11:40 AM, Christophe Leroy wrote:
> 
> 
> Le 14/04/2021 à 07:59, Anshuman Khandual a écrit :
>>
>>
>> On 4/14/21 10:52 AM, Christophe Leroy wrote:
>>>
>>>
>>> Le 14/04/2021 à 04:54, Anshuman Khandual a écrit :
 Currently most platforms define FIRST_USER_ADDRESS as 0UL duplicating the
 same code all over. Instead define a new option ARCH_HAS_FIRST_USER_ADDRESS
 for those platforms which would override generic default FIRST_USER_ADDRESS
 value 0UL. This makes it much cleaner with reduced code.

 Cc: linux-al...@vger.kernel.org
 Cc: linux-snps-arc@lists.infradead.org
 Cc: linux-arm-ker...@lists.infradead.org
 Cc: linux-c...@vger.kernel.org
 Cc: linux-hexa...@vger.kernel.org
 Cc: linux-i...@vger.kernel.org
 Cc: linux-m...@lists.linux-m68k.org
 Cc: linux-m...@vger.kernel.org
 Cc: openr...@lists.librecores.org
 Cc: linux-par...@vger.kernel.org
 Cc: linuxppc-...@lists.ozlabs.org
 Cc: linux-ri...@lists.infradead.org
 Cc: linux-s...@vger.kernel.org
 Cc: linux...@vger.kernel.org
 Cc: sparcli...@vger.kernel.org
 Cc: linux...@lists.infradead.org
 Cc: linux-xte...@linux-xtensa.org
 Cc: x...@kernel.org
 Cc: linux...@kvack.org
 Cc: linux-ker...@vger.kernel.org
 Signed-off-by: Anshuman Khandual 
 ---
    arch/alpha/include/asm/pgtable.h | 1 -
    arch/arc/include/asm/pgtable.h   | 6 --
    arch/arm/Kconfig | 1 +
    arch/arm64/include/asm/pgtable.h | 2 --
    arch/csky/include/asm/pgtable.h  | 1 -
    arch/hexagon/include/asm/pgtable.h   | 3 ---
    arch/ia64/include/asm/pgtable.h  | 1 -
    arch/m68k/include/asm/pgtable_mm.h   | 1 -
    arch/microblaze/include/asm/pgtable.h    | 2 --
    arch/mips/include/asm/pgtable-32.h   | 1 -
    arch/mips/include/asm/pgtable-64.h   | 1 -
    arch/nds32/Kconfig   | 1 +
    arch/nios2/include/asm/pgtable.h | 2 --
    arch/openrisc/include/asm/pgtable.h  | 1 -
    arch/parisc/include/asm/pgtable.h    | 2 --
    arch/powerpc/include/asm/book3s/pgtable.h    | 1 -
    arch/powerpc/include/asm/nohash/32/pgtable.h | 1 -
    arch/powerpc/include/asm/nohash/64/pgtable.h | 2 --
    arch/riscv/include/asm/pgtable.h | 2 --
    arch/s390/include/asm/pgtable.h  | 2 --
    arch/sh/include/asm/pgtable.h    | 2 --
    arch/sparc/include/asm/pgtable_32.h  | 1 -
    arch/sparc/include/asm/pgtable_64.h  | 3 ---
    arch/um/include/asm/pgtable-2level.h | 1 -
    arch/um/include/asm/pgtable-3level.h | 1 -
    arch/x86/include/asm/pgtable_types.h | 2 --
    arch/xtensa/include/asm/pgtable.h    | 1 -
    include/linux/mm.h   | 4 
    mm/Kconfig   | 4 
    29 files changed, 10 insertions(+), 43 deletions(-)

 diff --git a/include/linux/mm.h b/include/linux/mm.h
 index 8ba434287387..47098ccd715e 100644
 --- a/include/linux/mm.h
 +++ b/include/linux/mm.h
 @@ -46,6 +46,10 @@ extern int sysctl_page_lock_unfairness;
      void init_mm_internals(void);
    +#ifndef ARCH_HAS_FIRST_USER_ADDRESS
>>>
>>> I guess you didn't test it . :)
>>
>> In fact I did :) Though just booted it on arm64 and cross compiled on
>> multiple others platforms.

I guess for all platforms, ARCH_HAS_FIRST_USER_ADDRESS would have just
evaluated to be false hence falling back on the generic definition. So
this never complained during build any where or during boot on arm64.

>>
>>>
>>> should be #ifndef CONFIG_ARCH_HAS_FIRST_USER_ADDRESS
>>
>> Right, meant that instead.
>>
>>>
 +#define FIRST_USER_ADDRESS    0UL
 +#endif
>>>
>>> But why do we need a config option at all for that ?
>>>
>>> Why not just:
>>>
>>> #ifndef FIRST_USER_ADDRESS
>>> #define FIRST_USER_ADDRESS    0UL
>>> #endif
>>
>> This sounds simpler. But just wondering, would not there be any possibility
>> of build problems due to compilation sequence between arch and generic code ?
>>
> 
> For sure it has to be addresses carefully, but there are already a lot of 
> stuff like that around pgtables.h
> 
> For instance, pte_offset_kernel() has a generic definition in 
> linux/pgtables.h based on whether it is already defined or not.
> 
> Taking into account that FIRST_USER_ADDRESS is today in the architectures's 
> asm/pgtables.h, I think putting the fallback definition in linux/pgtable.h 
> would do the trick.

Agreed,  includes  at the beginning and
if the arch defines FIRST_USER_ADDRESS, the generic one afterwards would
be skipped. The following change builds on multiple platforms.

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ad086e6d7155..5da96f5df48f 100644
--- 

[committed] ARC: Update ulps

2021-04-14 Thread Vineet Gupta
Needed after 43576de04afc6

Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/fpu/libm-test-ulps   | 40 
 sysdeps/arc/nofpu/libm-test-ulps | 14 +++
 2 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/sysdeps/arc/fpu/libm-test-ulps b/sysdeps/arc/fpu/libm-test-ulps
index 1a7cd54b39d2..56ff9149cbb6 100644
--- a/sysdeps/arc/fpu/libm-test-ulps
+++ b/sysdeps/arc/fpu/libm-test-ulps
@@ -46,7 +46,7 @@ double: 1
 float: 1
 
 Function: "asin_upward":
-double: 1
+double: 2
 float: 1
 
 Function: "asinh":
@@ -861,35 +861,35 @@ float: 1
 
 Function: "j0":
 double: 4
-float: 6
+float: 9
 
 Function: "j0_downward":
-double: 2
-float: 4
+double: 6
+float: 8
 
 Function: "j0_towardzero":
 double: 4
-float: 5
+float: 9
 
 Function: "j0_upward":
-double: 3
-float: 5
+double: 4
+float: 9
 
 Function: "j1":
 double: 5
 float: 9
 
 Function: "j1_downward":
-double: 4
-float: 6
+double: 9
+float: 8
 
 Function: "j1_towardzero":
-double: 4
-float: 3
+double: 5
+float: 8
 
 Function: "j1_upward":
 double: 5
-float: 5
+float: 7
 
 Function: "jn":
 double: 9
@@ -1093,35 +1093,35 @@ float: 9
 
 Function: "y0":
 double: 3
-float: 6
+float: 8
 
 Function: "y0_downward":
 double: 3
-float: 4
+float: 8
 
 Function: "y0_towardzero":
 double: 3
-float: 4
+float: 8
 
 Function: "y0_upward":
 double: 4
-float: 5
+float: 8
 
 Function: "y1":
 double: 7
-float: 6
+float: 9
 
 Function: "y1_downward":
 double: 6
-float: 6
+float: 8
 
 Function: "y1_towardzero":
 double: 7
-float: 7
+float: 9
 
 Function: "y1_upward":
 double: 7
-float: 7
+float: 9
 
 Function: "yn":
 double: 9
diff --git a/sysdeps/arc/nofpu/libm-test-ulps b/sysdeps/arc/nofpu/libm-test-ulps
index 15449dd55a9c..6ac2830b2594 100644
--- a/sysdeps/arc/nofpu/libm-test-ulps
+++ b/sysdeps/arc/nofpu/libm-test-ulps
@@ -2,6 +2,7 @@
 
 # Maximal error of functions:
 Function: "acos":
+double: 1
 float: 1
 
 Function: "acosh":
@@ -9,6 +10,7 @@ double: 2
 float: 2
 
 Function: "asin":
+double: 1
 float: 1
 
 Function: "asinh":
@@ -16,10 +18,11 @@ double: 2
 float: 2
 
 Function: "atan":
+double: 1
 float: 1
 
 Function: "atan2":
-float: 1
+float: 2
 
 Function: "atanh":
 double: 2
@@ -112,6 +115,7 @@ double: 3
 float: 3
 
 Function: Imaginary part of "clog":
+double: 1
 float: 1
 
 Function: Real part of "clog10":
@@ -204,10 +208,10 @@ double: 1
 
 Function: "j0":
 double: 2
-float: 8
+float: 9
 
 Function: "j1":
-double: 2
+double: 4
 float: 9
 
 Function: "jn":
@@ -258,11 +262,11 @@ float: 8
 
 Function: "y0":
 double: 3
-float: 8
+float: 9
 
 Function: "y1":
 double: 3
-float: 2
+float: 9
 
 Function: "yn":
 double: 3
-- 
2.25.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v2] init: consolidate trap_init()

2021-04-14 Thread Jisheng Zhang
Many architectures implement the trap_init() as NOP, since there is
no such default for trap_init(), this empty stub is duplicated among
these architectures. Provide a generic but weak NOP implementation
to drop the empty stubs of trap_init() in these architectures.

The alpha, microblaze and sparc32 have real trap_init() implementation
but the __init marker is missing, so add it to these three platforms.

Signed-off-by: Jisheng Zhang 
---
Since v1:
 - add __init marker to trap_init() for alpha, microblaze and sparc32
 - adjust the generic weak NOP trap_init() location to make it sits with
   other NOP implementations together

 arch/alpha/kernel/traps.c  |  2 +-
 arch/arc/kernel/traps.c|  5 -
 arch/arm/kernel/traps.c|  5 -
 arch/h8300/kernel/traps.c  | 13 -
 arch/hexagon/kernel/traps.c|  4 
 arch/microblaze/kernel/traps.c |  2 +-
 arch/nds32/kernel/traps.c  |  5 -
 arch/nios2/kernel/traps.c  |  5 -
 arch/openrisc/kernel/traps.c   |  5 -
 arch/parisc/kernel/traps.c |  4 
 arch/powerpc/kernel/traps.c|  5 -
 arch/riscv/kernel/traps.c  |  5 -
 arch/sparc/kernel/traps_32.c   |  2 +-
 arch/um/kernel/trap.c  |  4 
 init/main.c|  2 ++
 15 files changed, 5 insertions(+), 63 deletions(-)

diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
index 921d4b6e4d95..96b203199c6c 100644
--- a/arch/alpha/kernel/traps.c
+++ b/arch/alpha/kernel/traps.c
@@ -973,7 +973,7 @@ do_entUnaUser(void __user * va, unsigned long opcode,
return;
 }
 
-void
+void __init
 trap_init(void)
 {
/* Tell PAL-code what global pointer we want in the kernel.  */
diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c
index 57235e5c0cea..6b83e3f2b41c 100644
--- a/arch/arc/kernel/traps.c
+++ b/arch/arc/kernel/traps.c
@@ -20,11 +20,6 @@
 #include 
 #include 
 
-void __init trap_init(void)
-{
-   return;
-}
-
 void die(const char *str, struct pt_regs *regs, unsigned long address)
 {
show_kernel_fault_diag(str, regs, address);
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 17d5a785df28..9baccef20392 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -780,11 +780,6 @@ void abort(void)
panic("Oops failed to kill thread");
 }
 
-void __init trap_init(void)
-{
-   return;
-}
-
 #ifdef CONFIG_KUSER_HELPERS
 static void __init kuser_init(void *vectors)
 {
diff --git a/arch/h8300/kernel/traps.c b/arch/h8300/kernel/traps.c
index 5d8b969cd8f3..c3a3ebf77fbb 100644
--- a/arch/h8300/kernel/traps.c
+++ b/arch/h8300/kernel/traps.c
@@ -30,19 +30,6 @@
 
 static DEFINE_SPINLOCK(die_lock);
 
-/*
- * this must be called very early as the kernel might
- * use some instruction that are emulated on the 060
- */
-
-void __init base_trap_init(void)
-{
-}
-
-void __init trap_init(void)
-{
-}
-
 asmlinkage void set_esp0(unsigned long ssp)
 {
current->thread.esp0 = ssp;
diff --git a/arch/hexagon/kernel/traps.c b/arch/hexagon/kernel/traps.c
index 904134b37232..edfc35dafeb1 100644
--- a/arch/hexagon/kernel/traps.c
+++ b/arch/hexagon/kernel/traps.c
@@ -28,10 +28,6 @@
 #define TRAP_SYSCALL   1
 #define TRAP_DEBUG 0xdb
 
-void __init trap_init(void)
-{
-}
-
 #ifdef CONFIG_GENERIC_BUG
 /* Maybe should resemble arch/sh/kernel/traps.c ?? */
 int is_valid_bugaddr(unsigned long addr)
diff --git a/arch/microblaze/kernel/traps.c b/arch/microblaze/kernel/traps.c
index 94b6fe93147d..7c15704fe56e 100644
--- a/arch/microblaze/kernel/traps.c
+++ b/arch/microblaze/kernel/traps.c
@@ -18,7 +18,7 @@
 #include 
 #include 
 
-void trap_init(void)
+void __init trap_init(void)
 {
__enable_hw_exceptions();
 }
diff --git a/arch/nds32/kernel/traps.c b/arch/nds32/kernel/traps.c
index ee0d9ae192a5..f06421c645af 100644
--- a/arch/nds32/kernel/traps.c
+++ b/arch/nds32/kernel/traps.c
@@ -183,11 +183,6 @@ void __pgd_error(const char *file, int line, unsigned long 
val)
 }
 
 extern char *exception_vector, *exception_vector_end;
-void __init trap_init(void)
-{
-   return;
-}
-
 void __init early_trap_init(void)
 {
unsigned long ivb = 0;
diff --git a/arch/nios2/kernel/traps.c b/arch/nios2/kernel/traps.c
index b172da4eb1a9..596986a74a26 100644
--- a/arch/nios2/kernel/traps.c
+++ b/arch/nios2/kernel/traps.c
@@ -105,11 +105,6 @@ void show_stack(struct task_struct *task, unsigned long 
*stack,
printk("%s\n", loglvl);
 }
 
-void __init trap_init(void)
-{
-   /* Nothing to do here */
-}
-
 /* Breakpoint handler */
 asmlinkage void breakpoint_c(struct pt_regs *fp)
 {
diff --git a/arch/openrisc/kernel/traps.c b/arch/openrisc/kernel/traps.c
index 4d61333c2623..aa1e709405ac 100644
--- a/arch/openrisc/kernel/traps.c
+++ b/arch/openrisc/kernel/traps.c
@@ -231,11 +231,6 @@ void unhandled_exception(struct pt_regs *regs, int ea, int 
vector)
die("Oops", regs, 9);
 }
 
-void __init trap_init(void)
-{
-   /* Nothing needs to be done */
-}
-
 

Re: [PATCH] init: consolidate trap_init()

2021-04-14 Thread Jisheng Zhang
On Wed, 14 Apr 2021 17:27:57 +0800
Jisheng Zhang  wrote:

> CAUTION: Email originated externally, do not click links or open attachments 
> unless you recognize the sender and know the content is safe.
> 
> 
> On Wed, 14 Apr 2021 11:10:42 +0200
> Christophe Leroy  wrote:
> 
> >
> > Le 14/04/2021 à 10:58, Jisheng Zhang a écrit :  
> > > Many architectures implement the trap_init() as NOP, since there is
> > > no such default for trap_init(), this empty stub is duplicated among
> > > these architectures. Provide a generic but weak NOP implementation
> > > to drop the empty stubs of trap_init() in these architectures.  
> >
> > You define the weak function in the __init section.
> >
> > Most but not all architectures had it in __init section.
> >
> > And the remaining ones may not be defined in __init section. For instance 
> > look at the one in alpha
> > architecture.
> >
> > Have you checked that it is not a problem ? It would be good to say 
> > something about it in the commit
> > description.  
> 
> For those non-nop platforms, I can only test x86/arm64/, but both has
> __init mark. I'm not sure whether this is a problem for alpha etc. Maybe
> I can check which section the trap_init() sits. Or to avoid any possible
> regression, I can add __init mark to those remaining ones without it in
> preparation patches.
> 

Hi,

I found only three platforms don't have the __init marker for trap_init(), I
will add the __init marker in three preparation patches in new version.

thanks

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] init: consolidate trap_init()

2021-04-14 Thread Jisheng Zhang
On Wed, 14 Apr 2021 11:10:42 +0200
Christophe Leroy  wrote:

> 
> Le 14/04/2021 à 10:58, Jisheng Zhang a écrit :
> > Many architectures implement the trap_init() as NOP, since there is
> > no such default for trap_init(), this empty stub is duplicated among
> > these architectures. Provide a generic but weak NOP implementation
> > to drop the empty stubs of trap_init() in these architectures.  
> 
> You define the weak function in the __init section.
> 
> Most but not all architectures had it in __init section.
> 
> And the remaining ones may not be defined in __init section. For instance 
> look at the one in alpha
> architecture.
> 
> Have you checked that it is not a problem ? It would be good to say something 
> about it in the commit
> description.

For those non-nop platforms, I can only test x86/arm64/, but both has
__init mark. I'm not sure whether this is a problem for alpha etc. Maybe
I can check which section the trap_init() sits. Or to avoid any possible
regression, I can add __init mark to those remaining ones without it in
preparation patches.

> 
> 
> >
> > Signed-off-by: Jisheng Zhang 
> > ---
> >   arch/arc/kernel/traps.c  |  5 -
> >   arch/arm/kernel/traps.c  |  5 -
> >   arch/h8300/kernel/traps.c| 13 -
> >   arch/hexagon/kernel/traps.c  |  4 
> >   arch/nds32/kernel/traps.c|  5 -
> >   arch/nios2/kernel/traps.c|  5 -
> >   arch/openrisc/kernel/traps.c |  5 -
> >   arch/parisc/kernel/traps.c   |  4 
> >   arch/powerpc/kernel/traps.c  |  5 -
> >   arch/riscv/kernel/traps.c|  5 -
> >   arch/um/kernel/trap.c|  4 
> >   init/main.c  |  2 ++
> >   12 files changed, 2 insertions(+), 60 deletions(-)
> >
> > diff --git a/init/main.c b/init/main.c
> > index 53b278845b88..4bdbe2928530 100644
> > --- a/init/main.c
> > +++ b/init/main.c
> > @@ -790,6 +790,8 @@ static inline void initcall_debug_enable(void)
> >   }
> >   #endif
> >
> > +void __init __weak trap_init(void) { }
> > +  
> 
> I think in a C file we don't try to save space as much as in a header file.
> 

This is to follow most weak NOP implementations in init/main.c to make
the style unified in the same file. I'm not sure which is better.

> I would prefer something like:
> 
> 
> void __init __weak trap_init(void)
> {
> }
> 
> 
> >   /* Report memory auto-initialization states for this boot. */
> >   static void __init report_meminit(void)
> >   {
> >  


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] init: consolidate trap_init()

2021-04-14 Thread Christophe Leroy



Le 14/04/2021 à 10:58, Jisheng Zhang a écrit :

Many architectures implement the trap_init() as NOP, since there is
no such default for trap_init(), this empty stub is duplicated among
these architectures. Provide a generic but weak NOP implementation
to drop the empty stubs of trap_init() in these architectures.


You define the weak function in the __init section.

Most but not all architectures had it in __init section.

And the remaining ones may not be defined in __init section. For instance look at the one in alpha 
architecture.


Have you checked that it is not a problem ? It would be good to say something about it in the commit 
description.





Signed-off-by: Jisheng Zhang 
---
  arch/arc/kernel/traps.c  |  5 -
  arch/arm/kernel/traps.c  |  5 -
  arch/h8300/kernel/traps.c| 13 -
  arch/hexagon/kernel/traps.c  |  4 
  arch/nds32/kernel/traps.c|  5 -
  arch/nios2/kernel/traps.c|  5 -
  arch/openrisc/kernel/traps.c |  5 -
  arch/parisc/kernel/traps.c   |  4 
  arch/powerpc/kernel/traps.c  |  5 -
  arch/riscv/kernel/traps.c|  5 -
  arch/um/kernel/trap.c|  4 
  init/main.c  |  2 ++
  12 files changed, 2 insertions(+), 60 deletions(-)

diff --git a/init/main.c b/init/main.c
index 53b278845b88..4bdbe2928530 100644
--- a/init/main.c
+++ b/init/main.c
@@ -790,6 +790,8 @@ static inline void initcall_debug_enable(void)
  }
  #endif
  
+void __init __weak trap_init(void) { }

+


I think in a C file we don't try to save space as much as in a header file.

I would prefer something like:


void __init __weak trap_init(void)
{
}



  /* Report memory auto-initialization states for this boot. */
  static void __init report_meminit(void)
  {



___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] init: consolidate trap_init()

2021-04-14 Thread Jisheng Zhang
Many architectures implement the trap_init() as NOP, since there is
no such default for trap_init(), this empty stub is duplicated among
these architectures. Provide a generic but weak NOP implementation
to drop the empty stubs of trap_init() in these architectures.

Signed-off-by: Jisheng Zhang 
---
 arch/arc/kernel/traps.c  |  5 -
 arch/arm/kernel/traps.c  |  5 -
 arch/h8300/kernel/traps.c| 13 -
 arch/hexagon/kernel/traps.c  |  4 
 arch/nds32/kernel/traps.c|  5 -
 arch/nios2/kernel/traps.c|  5 -
 arch/openrisc/kernel/traps.c |  5 -
 arch/parisc/kernel/traps.c   |  4 
 arch/powerpc/kernel/traps.c  |  5 -
 arch/riscv/kernel/traps.c|  5 -
 arch/um/kernel/trap.c|  4 
 init/main.c  |  2 ++
 12 files changed, 2 insertions(+), 60 deletions(-)

diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c
index 57235e5c0cea..6b83e3f2b41c 100644
--- a/arch/arc/kernel/traps.c
+++ b/arch/arc/kernel/traps.c
@@ -20,11 +20,6 @@
 #include 
 #include 
 
-void __init trap_init(void)
-{
-   return;
-}
-
 void die(const char *str, struct pt_regs *regs, unsigned long address)
 {
show_kernel_fault_diag(str, regs, address);
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 17d5a785df28..9baccef20392 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -780,11 +780,6 @@ void abort(void)
panic("Oops failed to kill thread");
 }
 
-void __init trap_init(void)
-{
-   return;
-}
-
 #ifdef CONFIG_KUSER_HELPERS
 static void __init kuser_init(void *vectors)
 {
diff --git a/arch/h8300/kernel/traps.c b/arch/h8300/kernel/traps.c
index 5d8b969cd8f3..c3a3ebf77fbb 100644
--- a/arch/h8300/kernel/traps.c
+++ b/arch/h8300/kernel/traps.c
@@ -30,19 +30,6 @@
 
 static DEFINE_SPINLOCK(die_lock);
 
-/*
- * this must be called very early as the kernel might
- * use some instruction that are emulated on the 060
- */
-
-void __init base_trap_init(void)
-{
-}
-
-void __init trap_init(void)
-{
-}
-
 asmlinkage void set_esp0(unsigned long ssp)
 {
current->thread.esp0 = ssp;
diff --git a/arch/hexagon/kernel/traps.c b/arch/hexagon/kernel/traps.c
index 904134b37232..edfc35dafeb1 100644
--- a/arch/hexagon/kernel/traps.c
+++ b/arch/hexagon/kernel/traps.c
@@ -28,10 +28,6 @@
 #define TRAP_SYSCALL   1
 #define TRAP_DEBUG 0xdb
 
-void __init trap_init(void)
-{
-}
-
 #ifdef CONFIG_GENERIC_BUG
 /* Maybe should resemble arch/sh/kernel/traps.c ?? */
 int is_valid_bugaddr(unsigned long addr)
diff --git a/arch/nds32/kernel/traps.c b/arch/nds32/kernel/traps.c
index ee0d9ae192a5..f06421c645af 100644
--- a/arch/nds32/kernel/traps.c
+++ b/arch/nds32/kernel/traps.c
@@ -183,11 +183,6 @@ void __pgd_error(const char *file, int line, unsigned long 
val)
 }
 
 extern char *exception_vector, *exception_vector_end;
-void __init trap_init(void)
-{
-   return;
-}
-
 void __init early_trap_init(void)
 {
unsigned long ivb = 0;
diff --git a/arch/nios2/kernel/traps.c b/arch/nios2/kernel/traps.c
index b172da4eb1a9..596986a74a26 100644
--- a/arch/nios2/kernel/traps.c
+++ b/arch/nios2/kernel/traps.c
@@ -105,11 +105,6 @@ void show_stack(struct task_struct *task, unsigned long 
*stack,
printk("%s\n", loglvl);
 }
 
-void __init trap_init(void)
-{
-   /* Nothing to do here */
-}
-
 /* Breakpoint handler */
 asmlinkage void breakpoint_c(struct pt_regs *fp)
 {
diff --git a/arch/openrisc/kernel/traps.c b/arch/openrisc/kernel/traps.c
index 4d61333c2623..aa1e709405ac 100644
--- a/arch/openrisc/kernel/traps.c
+++ b/arch/openrisc/kernel/traps.c
@@ -231,11 +231,6 @@ void unhandled_exception(struct pt_regs *regs, int ea, int 
vector)
die("Oops", regs, 9);
 }
 
-void __init trap_init(void)
-{
-   /* Nothing needs to be done */
-}
-
 asmlinkage void do_trap(struct pt_regs *regs, unsigned long address)
 {
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc);
diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
index 8d8441d4562a..747c328fb886 100644
--- a/arch/parisc/kernel/traps.c
+++ b/arch/parisc/kernel/traps.c
@@ -859,7 +859,3 @@ void  __init early_trap_init(void)
 
initialize_ivt(_vector_20);
 }
-
-void __init trap_init(void)
-{
-}
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index a44a30b0688c..e952bee89684 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -2207,11 +2207,6 @@ DEFINE_INTERRUPT_HANDLER(kernel_bad_stack)
die("Bad kernel stack pointer", regs, SIGABRT);
 }
 
-void __init trap_init(void)
-{
-}
-
-
 #ifdef CONFIG_PPC_EMULATED_STATS
 
 #define WARN_EMULATED_SETUP(type)  .type = { .name = #type }
diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index 0879b5df11b9..b3f3d84de779 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -194,8 +194,3 @@ int is_valid_bugaddr(unsigned long pc)
return ((insn & __COMPRESSED_INSN_MASK) == 

Re: [PATCH] mm: Define ARCH_HAS_FIRST_USER_ADDRESS

2021-04-14 Thread Christophe Leroy



Le 14/04/2021 à 07:59, Anshuman Khandual a écrit :



On 4/14/21 10:52 AM, Christophe Leroy wrote:



Le 14/04/2021 à 04:54, Anshuman Khandual a écrit :

Currently most platforms define FIRST_USER_ADDRESS as 0UL duplicating the
same code all over. Instead define a new option ARCH_HAS_FIRST_USER_ADDRESS
for those platforms which would override generic default FIRST_USER_ADDRESS
value 0UL. This makes it much cleaner with reduced code.

Cc: linux-al...@vger.kernel.org
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-c...@vger.kernel.org
Cc: linux-hexa...@vger.kernel.org
Cc: linux-i...@vger.kernel.org
Cc: linux-m...@lists.linux-m68k.org
Cc: linux-m...@vger.kernel.org
Cc: openr...@lists.librecores.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-ri...@lists.infradead.org
Cc: linux-s...@vger.kernel.org
Cc: linux...@vger.kernel.org
Cc: sparcli...@vger.kernel.org
Cc: linux...@lists.infradead.org
Cc: linux-xte...@linux-xtensa.org
Cc: x...@kernel.org
Cc: linux...@kvack.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Anshuman Khandual 
---
   arch/alpha/include/asm/pgtable.h | 1 -
   arch/arc/include/asm/pgtable.h   | 6 --
   arch/arm/Kconfig | 1 +
   arch/arm64/include/asm/pgtable.h | 2 --
   arch/csky/include/asm/pgtable.h  | 1 -
   arch/hexagon/include/asm/pgtable.h   | 3 ---
   arch/ia64/include/asm/pgtable.h  | 1 -
   arch/m68k/include/asm/pgtable_mm.h   | 1 -
   arch/microblaze/include/asm/pgtable.h    | 2 --
   arch/mips/include/asm/pgtable-32.h   | 1 -
   arch/mips/include/asm/pgtable-64.h   | 1 -
   arch/nds32/Kconfig   | 1 +
   arch/nios2/include/asm/pgtable.h | 2 --
   arch/openrisc/include/asm/pgtable.h  | 1 -
   arch/parisc/include/asm/pgtable.h    | 2 --
   arch/powerpc/include/asm/book3s/pgtable.h    | 1 -
   arch/powerpc/include/asm/nohash/32/pgtable.h | 1 -
   arch/powerpc/include/asm/nohash/64/pgtable.h | 2 --
   arch/riscv/include/asm/pgtable.h | 2 --
   arch/s390/include/asm/pgtable.h  | 2 --
   arch/sh/include/asm/pgtable.h    | 2 --
   arch/sparc/include/asm/pgtable_32.h  | 1 -
   arch/sparc/include/asm/pgtable_64.h  | 3 ---
   arch/um/include/asm/pgtable-2level.h | 1 -
   arch/um/include/asm/pgtable-3level.h | 1 -
   arch/x86/include/asm/pgtable_types.h | 2 --
   arch/xtensa/include/asm/pgtable.h    | 1 -
   include/linux/mm.h   | 4 
   mm/Kconfig   | 4 
   29 files changed, 10 insertions(+), 43 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 8ba434287387..47098ccd715e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -46,6 +46,10 @@ extern int sysctl_page_lock_unfairness;
     void init_mm_internals(void);
   +#ifndef ARCH_HAS_FIRST_USER_ADDRESS


I guess you didn't test it . :)


In fact I did :) Though just booted it on arm64 and cross compiled on
multiple others platforms.



should be #ifndef CONFIG_ARCH_HAS_FIRST_USER_ADDRESS


Right, meant that instead.




+#define FIRST_USER_ADDRESS    0UL
+#endif


But why do we need a config option at all for that ?

Why not just:

#ifndef FIRST_USER_ADDRESS
#define FIRST_USER_ADDRESS    0UL
#endif


This sounds simpler. But just wondering, would not there be any possibility
of build problems due to compilation sequence between arch and generic code ?



For sure it has to be addresses carefully, but there are already a lot of stuff like that around 
pgtables.h


For instance, pte_offset_kernel() has a generic definition in linux/pgtables.h based on whether it 
is already defined or not.


Taking into account that FIRST_USER_ADDRESS is today in the architectures's asm/pgtables.h, I think 
putting the fallback definition in linux/pgtable.h would do the trick.


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc