[PATCH v3 03/17] ARC: ABI Implementation

2020-03-06 Thread Vineet Gupta
This code deals with the ARC ABI.

Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/__longjmp.S   | 50 ++
 sysdeps/arc/abort-instr.h |  2 +
 sysdeps/arc/bits/endianness.h | 15 +++
 sysdeps/arc/bits/setjmp.h | 26 
 sysdeps/arc/bsd-_setjmp.S |  1 +
 sysdeps/arc/bsd-setjmp.S  |  1 +
 sysdeps/arc/dl-runtime.c  | 39 +
 sysdeps/arc/dl-sysdep.h   | 25 +++
 sysdeps/arc/dl-trampoline.S   | 80 +++
 sysdeps/arc/gccframe.h| 21 +
 sysdeps/arc/gmp-mparam.h  | 23 ++
 sysdeps/arc/jmpbuf-offsets.h  | 47 
 sysdeps/arc/jmpbuf-unwind.h   | 47 
 sysdeps/arc/machine-gmon.h| 35 +++
 sysdeps/arc/memusage.h| 23 ++
 sysdeps/arc/setjmp.S  | 66 +
 sysdeps/arc/sysdep.h  | 48 +
 sysdeps/arc/tls-macros.h  | 47 
 18 files changed, 596 insertions(+)
 create mode 100644 sysdeps/arc/__longjmp.S
 create mode 100644 sysdeps/arc/abort-instr.h
 create mode 100644 sysdeps/arc/bits/endianness.h
 create mode 100644 sysdeps/arc/bits/setjmp.h
 create mode 100644 sysdeps/arc/bsd-_setjmp.S
 create mode 100644 sysdeps/arc/bsd-setjmp.S
 create mode 100644 sysdeps/arc/dl-runtime.c
 create mode 100644 sysdeps/arc/dl-sysdep.h
 create mode 100644 sysdeps/arc/dl-trampoline.S
 create mode 100644 sysdeps/arc/gccframe.h
 create mode 100644 sysdeps/arc/gmp-mparam.h
 create mode 100644 sysdeps/arc/jmpbuf-offsets.h
 create mode 100644 sysdeps/arc/jmpbuf-unwind.h
 create mode 100644 sysdeps/arc/machine-gmon.h
 create mode 100644 sysdeps/arc/memusage.h
 create mode 100644 sysdeps/arc/setjmp.S
 create mode 100644 sysdeps/arc/sysdep.h
 create mode 100644 sysdeps/arc/tls-macros.h

diff --git a/sysdeps/arc/__longjmp.S b/sysdeps/arc/__longjmp.S
new file mode 100644
index ..ffc3daa7de72
--- /dev/null
+++ b/sysdeps/arc/__longjmp.S
@@ -0,0 +1,50 @@
+/* longjmp for ARC.
+   Copyright (C) 2017-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#include 
+#include 
+
+;@ r0 = jump buffer from which regs will be restored
+;@ r1 = value that setjmp( ) will return due to this longjmp
+
+ENTRY (__longjmp)
+
+   ld_s r13,   [r0]
+   ld_s r14,   [r0,4]
+   ld   r15,   [r0,8]
+   ld   r16,   [r0,12]
+   ld   r17,   [r0,16]
+   ld   r18,   [r0,20]
+   ld   r19,   [r0,24]
+   ld   r20,   [r0,28]
+   ld   r21,   [r0,32]
+   ld   r22,   [r0,36]
+   ld   r23,   [r0,40]
+   ld   r24,   [r0,44]
+   ld   r25,   [r0,48]
+
+   ld   blink, [r0,60]
+   ld   fp,[r0,52]
+   ld   sp,[r0,56]
+
+   mov.f  r0, r1   ; get the setjmp return value(due to longjmp) in place
+
+   j.d[blink]  ; to caller of setjmp location, right after the call
+   mov.z  r0, 1; can't let setjmp return 0 when it is due to longjmp
+
+END (__longjmp)
diff --git a/sysdeps/arc/abort-instr.h b/sysdeps/arc/abort-instr.h
new file mode 100644
index ..49f33613c404
--- /dev/null
+++ b/sysdeps/arc/abort-instr.h
@@ -0,0 +1,2 @@
+/* FLAG 1 is privilege mode only instruction, hence will crash any program.  */
+#define ABORT_INSTRUCTION asm ("flag 1")
diff --git a/sysdeps/arc/bits/endianness.h b/sysdeps/arc/bits/endianness.h
new file mode 100644
index ..8f17ca84b485
--- /dev/null
+++ b/sysdeps/arc/bits/endianness.h
@@ -0,0 +1,15 @@
+#ifndef _BITS_ENDIANNESS_H
+#define _BITS_ENDIANNESS_H 1
+
+#ifndef _BITS_ENDIAN_H
+# error "Never use  directly; include  instead."
+#endif
+
+/* ARC has selectable endianness.  */
+#ifdef __BIG_ENDIAN__
+# define __BYTE_ORDER __BIG_ENDIAN
+#else
+# define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+#endif /* bits/endianness.h */
diff --git a/sysdeps/arc/bits/setjmp.h b/sysdeps/arc/bits/setjmp.h
new file mode 100644
index ..333e5cce3bea
--- /dev/null
+++ b/sysdeps/arc/bits/setjmp.h
@@ -0,0 +1,26 @@
+/* Define the machine-dependent type `jmp_buf'.  ARC version.
+   Copyright (C) 1992-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the

[PATCH v3 16/17] NEWS: mention ARC port

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 NEWS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/NEWS b/NEWS
index 58ab5a89e894..923dd18d1478 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,12 @@ Major new features:
 - rv32imafdc ilp32
 - rv32imafdc ilp32d
 
+* Support for ARC HS cores running Linux has been contributed by Synopsys.
+  Port requires atleast
+- binutils-2.31 (binutils-2_31-branch: commit 6ce881c15fc4, 2018-10-04)
+- gcc 8.2 (gcc-8-stable: commit 0d5ba57508c5, 2019-01-29)
+- Linux kernel 5.1+
+
 Deprecated and removed features, and other changes affecting compatibility:
 
   [Add deprecations, removals and changes affecting compatibility here]
-- 
2.20.1


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


[PATCH v3 08/17] ARC: hardware floating point support

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/bits/fenv.h |9 +-
 sysdeps/arc/fpu/e_sqrt.c|   27 +
 sysdeps/arc/fpu/e_sqrtf.c   |   27 +
 sysdeps/arc/fpu/fclrexcpt.c |   36 +
 sysdeps/arc/fpu/fegetenv.c  |   37 +
 sysdeps/arc/fpu/fegetmode.c |   31 +
 sysdeps/arc/fpu/fegetround.c|   32 +
 sysdeps/arc/fpu/feholdexcpt.c   |   43 +
 sysdeps/arc/fpu/fesetenv.c  |   48 +
 sysdeps/arc/fpu/fesetexcept.c   |   32 +
 sysdeps/arc/fpu/fesetmode.c |   41 +
 sysdeps/arc/fpu/fesetround.c|   39 +
 sysdeps/arc/fpu/feupdateenv.c   |   46 +
 sysdeps/arc/fpu/fgetexcptflg.c  |   31 +
 sysdeps/arc/fpu/fraiseexcpt.c   |   39 +
 sysdeps/arc/fpu/fsetexcptflg.c  |   38 +
 sysdeps/arc/fpu/ftestexcept.c   |   33 +
 sysdeps/arc/fpu/libm-test-ulps  | 1703 +++
 sysdeps/arc/fpu/libm-test-ulps-name |1 +
 sysdeps/arc/fpu/s_fma.c |   28 +
 sysdeps/arc/fpu/s_fmaf.c|   28 +
 sysdeps/arc/fpu_control.h   |  101 ++
 sysdeps/arc/get-rounding-mode.h |   38 +
 sysdeps/arc/math-tests-trap.h   |   27 +
 sysdeps/arc/tininess.h  |1 +
 25 files changed, 2514 insertions(+), 2 deletions(-)
 create mode 100644 sysdeps/arc/fpu/e_sqrt.c
 create mode 100644 sysdeps/arc/fpu/e_sqrtf.c
 create mode 100644 sysdeps/arc/fpu/fclrexcpt.c
 create mode 100644 sysdeps/arc/fpu/fegetenv.c
 create mode 100644 sysdeps/arc/fpu/fegetmode.c
 create mode 100644 sysdeps/arc/fpu/fegetround.c
 create mode 100644 sysdeps/arc/fpu/feholdexcpt.c
 create mode 100644 sysdeps/arc/fpu/fesetenv.c
 create mode 100644 sysdeps/arc/fpu/fesetexcept.c
 create mode 100644 sysdeps/arc/fpu/fesetmode.c
 create mode 100644 sysdeps/arc/fpu/fesetround.c
 create mode 100644 sysdeps/arc/fpu/feupdateenv.c
 create mode 100644 sysdeps/arc/fpu/fgetexcptflg.c
 create mode 100644 sysdeps/arc/fpu/fraiseexcpt.c
 create mode 100644 sysdeps/arc/fpu/fsetexcptflg.c
 create mode 100644 sysdeps/arc/fpu/ftestexcept.c
 create mode 100644 sysdeps/arc/fpu/libm-test-ulps
 create mode 100644 sysdeps/arc/fpu/libm-test-ulps-name
 create mode 100644 sysdeps/arc/fpu/s_fma.c
 create mode 100644 sysdeps/arc/fpu/s_fmaf.c
 create mode 100644 sysdeps/arc/fpu_control.h
 create mode 100644 sysdeps/arc/get-rounding-mode.h
 create mode 100644 sysdeps/arc/math-tests-trap.h
 create mode 100644 sysdeps/arc/tininess.h

diff --git a/sysdeps/arc/bits/fenv.h b/sysdeps/arc/bits/fenv.h
index 547f0103a53d..80afa50db9c6 100644
--- a/sysdeps/arc/bits/fenv.h
+++ b/sysdeps/arc/bits/fenv.h
@@ -47,7 +47,7 @@ enum
 # define FE_TOWARDZERO (0x0)
   FE_TOWARDZERO,
 FE_TONEAREST  =
-# define FE_TONEAREST  (0x1)
+# define FE_TONEAREST  (0x1)   /* default */
   FE_TONEAREST,
 FE_UPWARD =
 # define FE_UPWARD (0x2)
@@ -58,7 +58,12 @@ enum
   };
 
 typedef unsigned int fexcept_t;
-typedef unsigned int fenv_t;
+
+typedef struct
+{
+  unsigned int __fpcr;
+  unsigned int __fpsr;
+} fenv_t;
 
 /* If the default argument is used we use this value.  */
 #define FE_DFL_ENV ((const fenv_t *) -1)
diff --git a/sysdeps/arc/fpu/e_sqrt.c b/sysdeps/arc/fpu/e_sqrt.c
new file mode 100644
index ..abb67ef7b061
--- /dev/null
+++ b/sysdeps/arc/fpu/e_sqrt.c
@@ -0,0 +1,27 @@
+/* Square root of floating point number.
+   Copyright (C) 2015-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#include 
+#include 
+
+double
+__ieee754_sqrt (double d)
+{
+  return __builtin_sqrt (d);
+}
+libm_alias_finite (__ieee754_sqrt, __sqrt)
diff --git a/sysdeps/arc/fpu/e_sqrtf.c b/sysdeps/arc/fpu/e_sqrtf.c
new file mode 100644
index ..13008a4f45d6
--- /dev/null
+++ b/sysdeps/arc/fpu/e_sqrtf.c
@@ -0,0 +1,27 @@
+/* Single-precision floating point square root.
+   Copyright (C) 2015-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRAN

[PATCH v3 15/17] build-many-glibcs.py: Enable ARC builds

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 scripts/build-many-glibcs.py | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 0f6c4a5e3a08..011a30494e1a 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -162,6 +162,12 @@ class Context(object):
'cfg': ['--disable-multi-arch']}])
 self.add_config(arch='aarch64_be',
 os_name='linux-gnu')
+self.add_config(arch='arc',
+os_name='linux-gnu',
+gcc_cfg=['--disable-multilib', '--with-cpu=hs38'])
+self.add_config(arch='arc',
+os_name='linux-gnuhf',
+gcc_cfg=['--disable-multilib', 
'--with-cpu=hs38_linux'])
 self.add_config(arch='alpha',
 os_name='linux-gnu')
 self.add_config(arch='arm',
@@ -1239,6 +1245,7 @@ def install_linux_headers(policy, cmdlist):
 """Install Linux kernel headers."""
 arch_map = {'aarch64': 'arm64',
 'alpha': 'alpha',
+'arc': 'arc',
 'arm': 'arm',
 'csky': 'csky',
 'hppa': 'parisc',
-- 
2.20.1


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


[PATCH v3 10/17] ARC: Linux ABI

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/nptl/pthreaddef.h | 32 +++
 sysdeps/unix/sysv/linux/arc/bits/procfs.h | 35 +++
 .../sysv/linux/arc/bits/types/__sigset_t.h| 12 +++
 sysdeps/unix/sysv/linux/arc/getcontext.S  | 63 +
 sysdeps/unix/sysv/linux/arc/makecontext.c | 75 +++
 sysdeps/unix/sysv/linux/arc/setcontext.S  | 92 +++
 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h  | 28 ++
 sysdeps/unix/sysv/linux/arc/swapcontext.S | 92 +++
 sysdeps/unix/sysv/linux/arc/sys/cachectl.h| 36 
 sysdeps/unix/sysv/linux/arc/sys/ucontext.h| 63 +
 sysdeps/unix/sysv/linux/arc/sys/user.h| 31 +++
 sysdeps/unix/sysv/linux/arc/ucontext-macros.h | 29 ++
 sysdeps/unix/sysv/linux/arc/ucontext_i.sym| 20 
 13 files changed, 608 insertions(+)
 create mode 100644 sysdeps/arc/nptl/pthreaddef.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/procfs.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/types/__sigset_t.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/getcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/makecontext.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/setcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/swapcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/cachectl.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/ucontext.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/user.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ucontext-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ucontext_i.sym

diff --git a/sysdeps/arc/nptl/pthreaddef.h b/sysdeps/arc/nptl/pthreaddef.h
new file mode 100644
index ..b265bf1a052c
--- /dev/null
+++ b/sysdeps/arc/nptl/pthreaddef.h
@@ -0,0 +1,32 @@
+/* pthread machine parameter definitions, ARC version.
+   Copyright (C) 2002-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+/* Default stack size.  */
+#define ARCH_STACK_DEFAULT_SIZE(2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning.  */
+#define STACK_ALIGN4
+
+/* Minimal stack size after allocating thread descriptor and guard size.  */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB.  */
+#define TCB_ALIGNMENT  4
+
+/* Location of current stack frame.  */
+#define CURRENT_STACK_FRAME__builtin_frame_address (0)
diff --git a/sysdeps/unix/sysv/linux/arc/bits/procfs.h 
b/sysdeps/unix/sysv/linux/arc/bits/procfs.h
new file mode 100644
index ..e217e94eb6c0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/bits/procfs.h
@@ -0,0 +1,35 @@
+/* Types for registers for sys/procfs.h.  ARC version.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef _SYS_PROCFS_H
+# error "Never include  directly; use  instead."
+#endif
+
+#include 
+
+/* And the whole bunch of them.  We could have used `struct
+   user_regs' directly in the typedef, but tradition says that
+   the register set is an array, which does have some peculiar
+   semantics, so leave it that way.  */
+#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
+
+typedef unsigned long int elf_greg_t;
+typedef unsigned long int elf_gregset_t[ELF_NGREG];
+
+/* There's no seperate floating point reg file in ARCv2.  */
+typedef struct { } elf_fpregset_t;
diff --git a/sysdeps/unix/sysv/linux/arc/bits/types/__sigset_t.h 
b/sysdeps/uni

[PATCH v3 01/17] gcc PR 88409: miscompilation due to missing cc clobber in longlong.h macros

2020-03-06 Thread Vineet Gupta
simple test such as below was failing.

| void main(int argc, char *argv[])
| {
|size_t total_time = 115424;   // expected 115.424
|double secs = (double)total_time/(double)1000;
|printf("%s %d %lf\n", "secs", total_time, secs);  // prints 113.504
|printf("%d\n", (size_t)secs);
| }

The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem()
which uses the __arc__ specific inline asm macros from longlong.h which
were causing miscompilation.

include/
2019-03-28  Vineet Gupta 

PR 89877

* longlong.h [__arc__] (add_ss): Add cc clobber
(sub_ddmmss): Likewise.

Signed-off-by: Vineet Gupta 
---
 stdlib/longlong.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/stdlib/longlong.h b/stdlib/longlong.h
index ee4aac1bb5a0..638b7894d48c 100644
--- a/stdlib/longlong.h
+++ b/stdlib/longlong.h
@@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, 
UDItype);
   : "%r" ((USItype) (ah)), \
 "rICal" ((USItype) (bh)),  \
 "%r" ((USItype) (al)), \
-"rICal" ((USItype) (bl)))
+"rICal" ((USItype) (bl))   \
+  : "cc")
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
   __asm__ ("sub.f  %1, %4, %5\n\tsbc   %0, %2, %3" \
   : "=r" ((USItype) (sh)), \
@@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, 
UDItype);
   : "r" ((USItype) (ah)),  \
 "rICal" ((USItype) (bh)),  \
 "r" ((USItype) (al)),  \
-"rICal" ((USItype) (bl)))
+"rICal" ((USItype) (bl))   \
+  : "cc")
 
 #define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
 #ifdef __ARC_NORM__
-- 
2.20.1


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


[PATCH v3 07/17] ARC: math soft float support

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/bits/fenv.h   | 72 ++
 sysdeps/arc/nofpu/Implies |  1 +
 sysdeps/arc/nofpu/math-tests-exceptions.h | 27 +
 sysdeps/arc/nofpu/math-tests-rounding.h   | 27 +
 sysdeps/arc/sfp-machine.h | 73 +++
 5 files changed, 200 insertions(+)
 create mode 100644 sysdeps/arc/bits/fenv.h
 create mode 100644 sysdeps/arc/nofpu/Implies
 create mode 100644 sysdeps/arc/nofpu/math-tests-exceptions.h
 create mode 100644 sysdeps/arc/nofpu/math-tests-rounding.h
 create mode 100644 sysdeps/arc/sfp-machine.h

diff --git a/sysdeps/arc/bits/fenv.h b/sysdeps/arc/bits/fenv.h
new file mode 100644
index ..547f0103a53d
--- /dev/null
+++ b/sysdeps/arc/bits/fenv.h
@@ -0,0 +1,72 @@
+/* Copyright (C) 2012-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef _FENV_H
+# error "Never use  directly; include  instead."
+#endif
+
+enum
+  {
+FE_INVALID   =
+# define FE_INVALID(0x01)
+  FE_INVALID,
+FE_DIVBYZERO =
+# define FE_DIVBYZERO  (0x02)
+  FE_DIVBYZERO,
+FE_OVERFLOW  =
+# define FE_OVERFLOW   (0x04)
+  FE_OVERFLOW,
+FE_UNDERFLOW =
+# define FE_UNDERFLOW  (0x08)
+  FE_UNDERFLOW,
+FE_INEXACT   =
+# define FE_INEXACT(0x10)
+  FE_INEXACT
+  };
+
+# define FE_ALL_EXCEPT \
+   (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
+
+enum
+  {
+FE_TOWARDZERO =
+# define FE_TOWARDZERO (0x0)
+  FE_TOWARDZERO,
+FE_TONEAREST  =
+# define FE_TONEAREST  (0x1)
+  FE_TONEAREST,
+FE_UPWARD =
+# define FE_UPWARD (0x2)
+  FE_UPWARD,
+FE_DOWNWARD   =
+# define FE_DOWNWARD   (0x3)
+  FE_DOWNWARD
+  };
+
+typedef unsigned int fexcept_t;
+typedef unsigned int fenv_t;
+
+/* If the default argument is used we use this value.  */
+#define FE_DFL_ENV ((const fenv_t *) -1)
+
+#if __GLIBC_USE (IEC_60559_BFP_EXT)
+/* Type representing floating-point control modes.  */
+typedef unsigned int femode_t;
+
+/* Default floating-point control modes.  */
+# define FE_DFL_MODE   ((const femode_t *) -1L)
+#endif
diff --git a/sysdeps/arc/nofpu/Implies b/sysdeps/arc/nofpu/Implies
new file mode 100644
index ..abcbadb25f22
--- /dev/null
+++ b/sysdeps/arc/nofpu/Implies
@@ -0,0 +1 @@
+ieee754/soft-fp
diff --git a/sysdeps/arc/nofpu/math-tests-exceptions.h 
b/sysdeps/arc/nofpu/math-tests-exceptions.h
new file mode 100644
index ..7d74720db94b
--- /dev/null
+++ b/sysdeps/arc/nofpu/math-tests-exceptions.h
@@ -0,0 +1,27 @@
+/* Configuration for math tests. exceptions support ARC version.
+   Copyright (C) 2017-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#ifndef ARC_NOFPU_MATH_TESTS_EXCEPTIONS_H
+#define ARC_NOFPU_MATH_TESTS_EXCEPTIONS_H 1
+
+/* Soft-float doesnot support exceptions.  */
+#define EXCEPTION_TESTS_float  0
+#define EXCEPTION_TESTS_double 0
+#define EXCEPTION_TESTS_long_double0
+
+#endif
diff --git a/sysdeps/arc/nofpu/math-tests-rounding.h 
b/sysdeps/arc/nofpu/math-tests-rounding.h
new file mode 100644
index ..6e5376cb35b5
--- /dev/null
+++ b/sysdeps/arc/nofpu/math-tests-rounding.h
@@ -0,0 +1,27 @@
+/* Configuration for math tests: rounding mode support.  ARC version.
+   Copyright (C) 2017-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+

[PATCH v3 00/17] glibc port to ARC processors

2020-03-06 Thread Vineet Gupta
Hi,

This patchset implements glibc port to ARC HS48x processor from Synopsys.

It is based on 64-time time and offset work by Alistair and others.
Thank you guys for all the hard-work.

Code
-

g...@github.com:foss-for-synopsys-dwc-arc-processors/glibc.git  
#arc-glibc-next-64-bit-time

Changes since v2:

   * Support for Hardware Floating Point

   * 64-bit time and offsets ABI (although all such changes are confined
 to a single patch)


Documentation:
--

(a) ABI doc:
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/wiki/files/ARCv2_ABI.pdf

(b) Programmer's Reference Manual (PRM) : needs a download request to be filled
https://www.synopsys.com/dw/ipdir.php?ds=arc-hs44-hs46-hs48
https://www.synopsys.com/dw/doc.php/ds/cc/programmers-reference-manual-ARC-HS.pdf

Test Results:
--
(a) build-many-glibcs.py

| Summary of test results:
|   1251 PASS
| 15 XFAIL

(b) Full testsuite ran in a cross compile setup using buildroot on HSDK 
development
platform. Bulk of failures come from cross testing setup and I
intend to improve things with native testing going forward.

| Summary of test results:
| 30 FAIL
|
| FAIL: elf/tst-dlopen-self-container   # Cannot create testroot lock.
| FAIL: elf/tst-dlopen-tlsmodid-container#   ditto
| FAIL: elf/tst-ldconfig-bad-aux-cache  #ditto
| FAIL: elf/tst-ldconfig-ld_so_conf-update # ditto
| FAIL: elf/tst-pldd#ditto
| FAIL: iconv/test-iconvconfig  # Needs gconv installed
| FAIL: io/ftwtest  # Requires execution by non-root
| FAIL: io/tst-lockf
| FAIL: libio/tst-wfile-sync
| FAIL: nptl/test-cond-printers # needs Python3 and target GDB on target
| FAIL: nptl/test-condattr-printers #ditto
| FAIL: nptl/test-mutex-printers#ditto
| FAIL: nptl/test-mutexattr-printers#ditto
| FAIL: nptl/test-rwlock-printers   #ditto
| FAIL: nptl/test-rwlockattr-printers   #ditto
| FAIL: nptl/tst-pthread-getattr# Cannot create testroot lock.
| FAIL: nptl/tst-umask1 # passes if run natively on target (NFS 
ACLv3 support needed)
| FAIL: nss/bug-erange
| FAIL: nss/tst-nss-db-endgrent # Cannot create testroot lock.
| FAIL: nss/tst-nss-db-endpwent #ditto
| FAIL: nss/tst-nss-files-hosts-long#ditto
| FAIL: nss/tst-nss-test3   #ditto
| FAIL: nss/tst-nss-files-hosts-getent  # Timed out
| FAIL: nss/tst-nss-files-hosts-multi   # Timed out
| FAIL: posix/bug-ga2   # DNS issue: google DNS vs. SNPS
| FAIL: posix/globtest  # require same user on target and host
| FAIL: posix/tst-getaddrinfo5  # passes outside corporate network
| FAIL: stdio-common/bug22  # Needs more RAM: 2 GB memory
| FAIL: sunrpc/bug20790 # missing cpp on target
| FAIL: timezone/tst-tzset  # passes outside corporate network


kindly review.

Thx,
-Vineet

Vineet Gupta (17):
  gcc PR 88409: miscompilation due to missing cc clobber in longlong.h
macros
  ARC: add definitions to elf/elf.h
  ARC: ABI Implementation
  ARC: startup and dynamic linking code
  ARC: Thread Local Storage support
  ARC: Atomics and Locking primitives
  ARC: math soft float support
  ARC: hardware floating point support
  ARC: Linux Syscall Interface
  ARC: Linux ABI
  ARC: Linux Startup and Dynamic Loading
  ARC: ABI lists
  ARC: Update syscall-names.list for ARC specific syscalls
  ARC: Build Infrastructure
  build-many-glibcs.py: Enable ARC builds
  NEWS: mention ARC port
  ARC: changes to enable 64-bit time_t, off_t, ino_t etc

 NEWS  |6 +
 elf/elf.h |   70 +-
 scripts/build-many-glibcs.py  |7 +
 stdlib/longlong.h |6 +-
 sysdeps/arc/Implies   |3 +
 sysdeps/arc/Makefile  |   25 +
 sysdeps/arc/Versions  |6 +
 sysdeps/arc/__longjmp.S   |   50 +
 sysdeps/arc/abort-instr.h |2 +
 sysdeps/arc/atomic-machine.h  |   73 +
 sysdeps/arc/bits/endianness.h |   15 +
 sysdeps/arc/bits/fenv.h   |   77 +
 sysdeps/arc/bits/link.h   |   52 +
 sysdeps/arc/bits/setjmp.h |   26 +
 sysdeps/arc/bsd-_setjmp.S |1 +
 sysdeps/arc/bsd-setjmp.S  |1 +
 sysdeps/arc/configure |   14 +
 sysdeps/arc/configure.ac  |   11 +
 sysdeps/arc/dl-machine.h  |  340 +++
 sysdeps/arc/dl-runtime.c  |   39 +
 sysdeps/arc/dl-sysdep.h   |   25 +
 sysdeps/arc/dl-tls.h  |   30 +
 sysdeps/arc/dl-trampoline.S   |   80 +
 sysdeps/arc/entry.h   |5 +
 sysdeps/ar

[PATCH v3 06/17] ARC: Atomics and Locking primitives

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/atomic-machine.h  | 73 +++
 sysdeps/arc/nptl/bits/semaphore.h | 32 ++
 2 files changed, 105 insertions(+)
 create mode 100644 sysdeps/arc/atomic-machine.h
 create mode 100644 sysdeps/arc/nptl/bits/semaphore.h

diff --git a/sysdeps/arc/atomic-machine.h b/sysdeps/arc/atomic-machine.h
new file mode 100644
index ..ae16c607dcc4
--- /dev/null
+++ b/sysdeps/arc/atomic-machine.h
@@ -0,0 +1,73 @@
+/* Low-level functions for atomic operations. ARC version.
+   Copyright (C) 2012-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef _ARC_BITS_ATOMIC_H
+#define _ARC_BITS_ATOMIC_H 1
+
+#include 
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+#define __HAVE_64B_ATOMICS 0
+#define USE_ATOMIC_COMPILER_BUILTINS 1
+
+/* ARC does have legacy atomic EX reg, [mem] instruction but the micro-arch
+   is not as optimal as LLOCK/SCOND specially for SMP.  */
+#define ATOMIC_EXCHANGE_USES_CAS 1
+
+#define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval)\
+  (abort (), 0)
+#define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval)   \
+  (abort (), 0)
+#define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval)   \
+  (abort (), 0)
+
+#define __arch_compare_and_exchange_val_8_int(mem, newval, oldval, model)  
\
+  (abort (), (__typeof (*mem)) 0)
+#define __arch_compare_and_exchange_val_16_int(mem, newval, oldval, model) 
\
+  (abort (), (__typeof (*mem)) 0)
+#define __arch_compare_and_exchange_val_64_int(mem, newval, oldval, model) 
\
+  (abort (), (__typeof (*mem)) 0)
+
+#define __arch_compare_and_exchange_val_32_int(mem, newval, oldval, model) 
\
+  ({   
\
+typeof (*mem) __oldval = (oldval); 
\
+__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,   
\
+ model, __ATOMIC_RELAXED); 
\
+__oldval;  
\
+  })
+
+#define atomic_compare_and_exchange_val_acq(mem, new, old) \
+  __atomic_val_bysize (__arch_compare_and_exchange_val, int,   \
+  mem, new, old, __ATOMIC_ACQUIRE)
+
+#ifdef __ARC700__
+#define atomic_full_barrier()  ({ asm volatile ("sync":::"memory"); })
+#else
+#define atomic_full_barrier()  ({ asm volatile ("dmb 3":::"memory"); })
+#endif
+
+#endif /* _ARC_BITS_ATOMIC_H */
diff --git a/sysdeps/arc/nptl/bits/semaphore.h 
b/sysdeps/arc/nptl/bits/semaphore.h
new file mode 100644
index ..772dc4cb9b01
--- /dev/null
+++ b/sysdeps/arc/nptl/bits/semaphore.h
@@ -0,0 +1,32 @@
+/* Machine-specific POSIX semaphore type layouts.  ARC version.
+   Copyright (C) 2002-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#ifndef _SEMAPHORE_H
+# error "Never use  directly; include  instead."
+#endif
+
+#define __SIZEOF_SEM_T 16
+
+/* Value returned if `sem_open' failed.  */
+#define SEM_FAILED  ((sem_t *) 0)
+
+typedef union
+{
+  char __size[__SIZEOF_SEM_T];
+  long int __align;
+} sem_t;
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http

[PATCH v3 17/17] ARC: changes to enable 64-bit time_t, off_t, ino_t etc

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 .../sysv/linux/arc/bits/socket-constants.h|  4 +--
 sysdeps/unix/sysv/linux/arc/bits/timesize.h   | 21 +++
 sysdeps/unix/sysv/linux/arc/c++-types.data| 16 ++--
 sysdeps/unix/sysv/linux/arc/configure |  2 +-
 sysdeps/unix/sysv/linux/arc/configure.ac  |  2 +-
 sysdeps/unix/sysv/linux/arc/kernel_stat.h | 26 +++
 sysdeps/unix/sysv/linux/arc/libc.abilist  |  6 ++---
 sysdeps/unix/sysv/linux/arc/sysdep.h  | 12 +
 8 files changed, 74 insertions(+), 15 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/timesize.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/kernel_stat.h

diff --git a/sysdeps/unix/sysv/linux/arc/bits/socket-constants.h 
b/sysdeps/unix/sysv/linux/arc/bits/socket-constants.h
index 053b5cee399a..74b0c06edb36 100644
--- a/sysdeps/unix/sysv/linux/arc/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/arc/bits/socket-constants.h
@@ -30,9 +30,9 @@
 #define SO_OOBINLINE 10
 #define SO_RCVBUF 8
 #define SO_RCVLOWAT 18
-#define SO_RCVTIMEO 20
+#define SO_RCVTIMEO 66
 #define SO_REUSEADDR 2
 #define SO_SNDBUF 7
 #define SO_SNDLOWAT 19
-# define SO_SNDTIMEO 21
+# define SO_SNDTIMEO 67
 #define SO_TYPE 3
diff --git a/sysdeps/unix/sysv/linux/arc/bits/timesize.h 
b/sysdeps/unix/sysv/linux/arc/bits/timesize.h
new file mode 100644
index ..1259077c6412
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/bits/timesize.h
@@ -0,0 +1,21 @@
+/* Bit size of the time_t type at glibc build time, general case.
+   Copyright (C) 2019-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#include 
+
+#define __TIMESIZE 64
diff --git a/sysdeps/unix/sysv/linux/arc/c++-types.data 
b/sysdeps/unix/sysv/linux/arc/c++-types.data
index 303f4570c8ee..0fb0143ae746 100644
--- a/sysdeps/unix/sysv/linux/arc/c++-types.data
+++ b/sysdeps/unix/sysv/linux/arc/c++-types.data
@@ -1,5 +1,5 @@
 blkcnt64_t:x
-blkcnt_t:l
+blkcnt_t:x
 blksize_t:i
 caddr_t:Pc
 clockid_t:i
@@ -8,14 +8,14 @@ daddr_t:i
 dev_t:y
 fd_mask:l
 fsblkcnt64_t:y
-fsblkcnt_t:m
+fsblkcnt_t:y
 fsfilcnt64_t:y
-fsfilcnt_t:m
+fsfilcnt_t:y
 fsid_t:8__fsid_t
 gid_t:j
 id_t:j
 ino64_t:y
-ino_t:m
+ino_t:y
 int16_t:s
 int32_t:i
 int64_t:x
@@ -26,7 +26,7 @@ loff_t:x
 mode_t:j
 nlink_t:j
 off64_t:x
-off_t:l
+off_t:x
 pid_t:i
 pthread_attr_t:14pthread_attr_t
 pthread_barrier_t:17pthread_barrier_t
@@ -44,13 +44,13 @@ pthread_t:m
 quad_t:x
 register_t:i
 rlim64_t:y
-rlim_t:m
+rlim_t:y
 sigset_t:10__sigset_t
 size_t:j
 socklen_t:j
 ssize_t:i
-suseconds_t:l
-time_t:l
+suseconds_t:x
+time_t:x
 u_char:h
 uid_t:j
 uint:j
diff --git a/sysdeps/unix/sysv/linux/arc/configure 
b/sysdeps/unix/sysv/linux/arc/configure
index f74fa7cb0259..56ec14357507 100644
--- a/sysdeps/unix/sysv/linux/arc/configure
+++ b/sysdeps/unix/sysv/linux/arc/configure
@@ -1,4 +1,4 @@
 # This file is generated from configure.in by Autoconf.  DO NOT EDIT!
  # Local configure fragment for sysdeps/unix/sysv/linux/arc.
 
-arch_minimum_kernel=3.9.0
+arch_minimum_kernel=5.1.0
diff --git a/sysdeps/unix/sysv/linux/arc/configure.ac 
b/sysdeps/unix/sysv/linux/arc/configure.ac
index a9528032d32a..8af5a12cc248 100644
--- a/sysdeps/unix/sysv/linux/arc/configure.ac
+++ b/sysdeps/unix/sysv/linux/arc/configure.ac
@@ -1,4 +1,4 @@
 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # Local configure fragment for sysdeps/unix/sysv/linux/arc.
 
-arch_minimum_kernel=3.9.0
+arch_minimum_kernel=5.1.0
diff --git a/sysdeps/unix/sysv/linux/arc/kernel_stat.h 
b/sysdeps/unix/sysv/linux/arc/kernel_stat.h
new file mode 100644
index ..8fdd86b9e843
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/kernel_stat.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICU

[PATCH v3 11/17] ARC: Linux Startup and Dynamic Loading

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/start.S | 15 +++--
 sysdeps/unix/sysv/linux/arc/dl-static.c | 84 +
 sysdeps/unix/sysv/linux/arc/ldsodefs.h  | 32 ++
 3 files changed, 125 insertions(+), 6 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/arc/dl-static.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/ldsodefs.h

diff --git a/sysdeps/arc/start.S b/sysdeps/arc/start.S
index e006453dcd1f..25e43d71da9e 100644
--- a/sysdeps/arc/start.S
+++ b/sysdeps/arc/start.S
@@ -18,6 +18,8 @@
 
 #define __ASSEMBLY__ 1
 #include 
+#include 
+
 #ifndef ENTRY_POINT
 # error ENTRY_POINT needs to be defined for ARC
 #endif
@@ -31,11 +33,12 @@
 env[0...N]  environment variables (pointers)
 NULL.  */
 
-   .text
-   .align 4
-   .global __start
-   .type __start,@function
-__start:
+ENTRY (ENTRY_POINT)
+
+   /* Needed to make gdb backtraces stop here.  */
+   .cfi_label .Ldummy
+   cfi_undefined (blink)
+
mov fp, 0
ld_sr1, [sp]; argc
 
@@ -60,7 +63,7 @@ __start:
 
/* Should never get here.  */
flag1
-   .size  __start,.-__start
+END (ENTRY_POINT)
 
 /* Define a symbol for the first piece of initialized data.  */
.data
diff --git a/sysdeps/unix/sysv/linux/arc/dl-static.c 
b/sysdeps/unix/sysv/linux/arc/dl-static.c
new file mode 100644
index ..24c31b27fc11
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/dl-static.c
@@ -0,0 +1,84 @@
+/* Variable initialization.  ARC version.
+   Copyright (C) 2001-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#include 
+
+#ifdef SHARED
+
+void
+_dl_var_init (void *array[])
+{
+  /* It has to match "variables" below. */
+  enum
+{
+  DL_PAGESIZE = 0
+};
+
+  GLRO(dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
+}
+
+#else
+
+static void *variables[] =
+{
+  &GLRO(dl_pagesize)
+};
+
+static void
+_dl_unprotect_relro (struct link_map *l)
+{
+  ElfW(Addr) start = ((l->l_addr + l->l_relro_addr)
+ & ~(GLRO(dl_pagesize) - 1));
+  ElfW(Addr) end = ((l->l_addr + l->l_relro_addr + l->l_relro_size)
+   & ~(GLRO(dl_pagesize) - 1));
+
+  if (start != end)
+__mprotect ((void *) start, end - start, PROT_READ | PROT_WRITE);
+}
+
+void
+_dl_static_init (struct link_map *l)
+{
+  struct link_map *rtld_map = l;
+  struct r_scope_elem **scope;
+  const ElfW(Sym) *ref = NULL;
+  lookup_t loadbase;
+  void (*f) (void *[]);
+  size_t i;
+
+  loadbase = _dl_lookup_symbol_x ("_dl_var_init", l, &ref, l->l_local_scope,
+ NULL, 0, 1, NULL);
+
+  for (scope = l->l_local_scope; *scope != NULL; scope++)
+for (i = 0; i < (*scope)->r_nlist; i++)
+  if ((*scope)->r_list[i] == loadbase)
+   {
+ rtld_map = (*scope)->r_list[i];
+ break;
+   }
+
+  if (ref != NULL)
+{
+  f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
+  _dl_unprotect_relro (rtld_map);
+  f (variables);
+  _dl_protect_relro (rtld_map);
+}
+}
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/arc/ldsodefs.h 
b/sysdeps/unix/sysv/linux/arc/ldsodefs.h
new file mode 100644
index ..9eef836168be
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/ldsodefs.h
@@ -0,0 +1,32 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects. ARC
+   Copyright (C) 2001-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#ifndef_LDSODEFS_H
+
+/* Get the real definitions.  */
+

[PATCH v3 05/17] ARC: Thread Local Storage support

2020-03-06 Thread Vineet Gupta
This includes all 4 TLS addressing models

Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/dl-tls.h |  30 +++
 sysdeps/arc/libc-tls.c   |  27 ++
 sysdeps/arc/nptl/tcb-offsets.sym |  11 +++
 sysdeps/arc/nptl/tls.h   | 150 +++
 sysdeps/arc/stackinfo.h  |  33 +++
 5 files changed, 251 insertions(+)
 create mode 100644 sysdeps/arc/dl-tls.h
 create mode 100644 sysdeps/arc/libc-tls.c
 create mode 100644 sysdeps/arc/nptl/tcb-offsets.sym
 create mode 100644 sysdeps/arc/nptl/tls.h
 create mode 100644 sysdeps/arc/stackinfo.h

diff --git a/sysdeps/arc/dl-tls.h b/sysdeps/arc/dl-tls.h
new file mode 100644
index ..2269ac6c3daa
--- /dev/null
+++ b/sysdeps/arc/dl-tls.h
@@ -0,0 +1,30 @@
+/* Thread-local storage handling in the ELF dynamic linker.  ARC version.
+   Copyright (C) 2012-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+
+/* Type used for the representation of TLS information in the GOT.  */
+typedef struct
+{
+  unsigned long int ti_module;
+  unsigned long int ti_offset;
+} tls_index;
+
+extern void *__tls_get_addr (tls_index *ti);
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED((void *) -1l)
diff --git a/sysdeps/arc/libc-tls.c b/sysdeps/arc/libc-tls.c
new file mode 100644
index ..ec88282de60e
--- /dev/null
+++ b/sysdeps/arc/libc-tls.c
@@ -0,0 +1,27 @@
+/* Thread-local storage handling in the ELF dynamic linker.  ARC version.
+   Copyright (C) 2005-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#include 
+#include 
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+  dtv_t *dtv = THREAD_DTV ();
+  return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
diff --git a/sysdeps/arc/nptl/tcb-offsets.sym b/sysdeps/arc/nptl/tcb-offsets.sym
new file mode 100644
index ..56950e0676ed
--- /dev/null
+++ b/sysdeps/arc/nptl/tcb-offsets.sym
@@ -0,0 +1,11 @@
+#include 
+#include 
+
+-- Derive offsets relative to the thread register.
+#define thread_offsetof(mem)   (long)(offsetof(struct pthread, mem) - 
sizeof(struct pthread))
+
+MULTIPLE_THREADS_OFFSEToffsetof (struct pthread, 
header.multiple_threads)
+TLS_PRE_TCB_SIZE   sizeof (struct pthread)
+TLS_TCB_SIZE   sizeof(tcbhead_t)
+
+PTHREAD_TIDoffsetof(struct pthread, tid)
diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h
new file mode 100644
index ..d6b166c1f92b
--- /dev/null
+++ b/sysdeps/arc/nptl/tls.h
@@ -0,0 +1,150 @@
+/* Definition for thread-local data handling.  NPTL/ARC version.
+   Copyright (C) 2012-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef _ARC_NPTL_TLS_H
+#define _ARC_NPTL_TLS_H1
+
+#include 
+
+#ifndef __ASSEMBLER__
+# includ

[PATCH v3 14/17] ARC: Build Infrastructure

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/Implies|  3 +++
 sysdeps/arc/Makefile   | 25 ++
 sysdeps/arc/Versions   |  6 ++
 sysdeps/arc/configure  | 14 
 sysdeps/arc/configure.ac   | 11 ++
 sysdeps/arc/nptl/Makefile  | 22 +++
 sysdeps/arc/preconfigure   | 15 +
 sysdeps/unix/sysv/linux/arc/Implies|  3 +++
 sysdeps/unix/sysv/linux/arc/Makefile   | 20 +
 sysdeps/unix/sysv/linux/arc/Versions   | 16 ++
 sysdeps/unix/sysv/linux/arc/configure  |  4 
 sysdeps/unix/sysv/linux/arc/configure.ac   |  4 
 sysdeps/unix/sysv/linux/arc/shlib-versions |  2 ++
 13 files changed, 145 insertions(+)
 create mode 100644 sysdeps/arc/Implies
 create mode 100644 sysdeps/arc/Makefile
 create mode 100644 sysdeps/arc/Versions
 create mode 100644 sysdeps/arc/configure
 create mode 100644 sysdeps/arc/configure.ac
 create mode 100644 sysdeps/arc/nptl/Makefile
 create mode 100644 sysdeps/arc/preconfigure
 create mode 100644 sysdeps/unix/sysv/linux/arc/Implies
 create mode 100644 sysdeps/unix/sysv/linux/arc/Makefile
 create mode 100644 sysdeps/unix/sysv/linux/arc/Versions
 create mode 100644 sysdeps/unix/sysv/linux/arc/configure
 create mode 100644 sysdeps/unix/sysv/linux/arc/configure.ac
 create mode 100644 sysdeps/unix/sysv/linux/arc/shlib-versions

diff --git a/sysdeps/arc/Implies b/sysdeps/arc/Implies
new file mode 100644
index ..780c4e246769
--- /dev/null
+++ b/sysdeps/arc/Implies
@@ -0,0 +1,3 @@
+wordsize-32
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/sysdeps/arc/Makefile b/sysdeps/arc/Makefile
new file mode 100644
index ..92f90798355b
--- /dev/null
+++ b/sysdeps/arc/Makefile
@@ -0,0 +1,25 @@
+# ARC Makefile
+# Copyright (C) 1993-2020 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library.  If not, see
+# .
+
+# We don't support long doubles as a distinct type.  We don't need to set
+# this variable; it's here mostly for documentational purposes.
+long-double-fcts = no
+
+ifeq ($(subdir),debug)
+CFLAGS-backtrace.c += -funwind-tables
+endif
diff --git a/sysdeps/arc/Versions b/sysdeps/arc/Versions
new file mode 100644
index ..2d0f534b2aba
--- /dev/null
+++ b/sysdeps/arc/Versions
@@ -0,0 +1,6 @@
+libc {
+  GLIBC_2.32 {
+__syscall_error;
+__mcount;
+  }
+}
diff --git a/sysdeps/arc/configure b/sysdeps/arc/configure
new file mode 100644
index ..52e286da2ebb
--- /dev/null
+++ b/sysdeps/arc/configure
@@ -0,0 +1,14 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/arc.
+
+$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
+
+libc_cv_have_sdata_section=no
+
+# For ARC, historically ; was used for comments and not newline
+# Later # also got added to comment list, but ; couldn't be switched to
+# canonical newline as there's lots of code out there which will break
+libc_cv_asm_line_sep='`'
+cat >>confdefs.h <<_ACEOF
+#define ASM_LINE_SEP $libc_cv_asm_line_sep
+_ACEOF
diff --git a/sysdeps/arc/configure.ac b/sysdeps/arc/configure.ac
new file mode 100644
index ..1074d312f033
--- /dev/null
+++ b/sysdeps/arc/configure.ac
@@ -0,0 +1,11 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/arc.
+
+AC_DEFINE(PI_STATIC_AND_HIDDEN)
+libc_cv_have_sdata_section=no
+
+# For ARC, historically ; was used for comments and not newline
+# Later # also got added to comment list, but ; couldn't be switched to
+# canonical newline as there's lots of code out there which will break
+libc_cv_asm_line_sep='`'
+AC_DEFINE_UNQUOTED(ASM_LINE_SEP, $libc_cv_asm_line_sep)
diff --git a/sysdeps/arc/nptl/Makefile b/sysdeps/arc/nptl/Makefile
new file mode 100644
index ..6f387c53905d
--- /dev/null
+++ b/sysdeps/arc/nptl/Makefile
@@ -0,0 +1,22 @@
+# NPTL makefile fragment for ARC.
+# Copyright (C) 2005-2020 Free Software Foundation, Inc.
+#
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by 

[PATCH v3 02/17] ARC: add definitions to elf/elf.h

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 elf/elf.h | 70 ++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/elf/elf.h b/elf/elf.h
index ab8930463c67..51e9968405ff 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -330,7 +330,7 @@ typedef struct
 #define EM_CLOUDSHIELD 192 /* CloudShield */
 #define EM_COREA_1ST   193 /* KIPO-KAIST Core-A 1st gen. */
 #define EM_COREA_2ND   194 /* KIPO-KAIST Core-A 2nd gen. */
-#define EM_ARC_COMPACT2195 /* Synopsys ARCompact V2 */
+#define EM_ARCV2   195 /* Synopsys ARCv2 ISA.  */
 #define EM_OPEN8   196 /* Open8 RISC */
 #define EM_RL78197 /* Renesas RL78 */
 #define EM_VIDEOCORE5  198 /* Broadcom VideoCore V */
@@ -4028,6 +4028,74 @@ enum
 #define R_NDS32_TLS_TPOFF  102
 #define R_NDS32_TLS_DESC   119
 
+/* ARCompact/ARCv2 specific relocs.  */
+#define R_ARC_NONE 0x0
+#define R_ARC_80x1
+#define R_ARC_16   0x2
+#define R_ARC_24   0x3
+#define R_ARC_32   0x4
+#define R_ARC_B26  0x5
+#define R_ARC_B22_PCREL0x6
+#define R_ARC_H30  0x7
+#define R_ARC_N8   0x8
+#define R_ARC_N16  0x9
+#define R_ARC_N24  0xA
+#define R_ARC_N32  0xB
+#define R_ARC_SDA  0xC
+#define R_ARC_SECTOFF  0xD
+#define R_ARC_S21H_PCREL   0xE
+#define R_ARC_S21W_PCREL   0xF
+#define R_ARC_S25H_PCREL   0x10
+#define R_ARC_S25W_PCREL   0x11
+#define R_ARC_SDA320x12
+#define R_ARC_SDA_LDST 0x13
+#define R_ARC_SDA_LDST10x14
+#define R_ARC_SDA_LDST20x15
+#define R_ARC_SDA16_LD 0x16
+#define R_ARC_SDA16_LD10x17
+#define R_ARC_SDA16_LD20x18
+#define R_ARC_S13_PCREL0x19
+#define R_ARC_W0x1A
+#define R_ARC_32_ME0x1B
+#define R_ARC_N32_ME   0x1C
+#define R_ARC_SECTOFF_ME   0x1D
+#define R_ARC_SDA32_ME 0x1E
+#define R_ARC_W_ME 0x1F
+#define R_ARC_H30_ME   0x20
+#define R_ARC_SECTOFF_U8   0x21
+#define R_ARC_SECTOFF_S9   0x22
+#define R_AC_SECTOFF_U80x23
+#define R_AC_SECTOFF_U8_1  0x24
+#define R_AC_SECTOFF_U8_2  0x25
+#define R_AC_SECTOFF_S90x26
+#define R_AC_SECTOFF_S9_1  0x27
+#define R_AC_SECTOFF_S9_2  0x28
+#define R_ARC_SECTOFF_ME_1 0x29
+#define R_ARC_SECTOFF_ME_2 0x2A
+#define R_ARC_SECTOFF_10x2B
+#define R_ARC_SECTOFF_20x2C
+#define R_ARC_PC32 0x32
+#define R_ARC_GOTPC32  0x33
+#define R_ARC_PLT320x34
+#define R_ARC_COPY 0x35
+#define R_ARC_GLOB_DAT 0x36
+#define R_ARC_JUMP_SLOT0x37
+#define R_ARC_RELATIVE 0x38
+#define R_ARC_GOTOFF   0x39
+#define R_ARC_GOTPC0x3A
+#define R_ARC_GOT320x3B
+
+#define R_ARC_TLS_DTPMOD   0x42
+#define R_ARC_TLS_DTPOFF   0x43
+#define R_ARC_TLS_TPOFF0x44
+#define R_ARC_TLS_GD_GOT   0x45
+#define R_ARC_TLS_GD_LD0x46
+#define R_ARC_TLS_GD_CALL  0x47
+#define R_ARC_TLS_IE_GOT   0x48
+#define R_ARC_TLS_DTPOFF_S90x4a
+#define R_ARC_TLS_LE_S90x4a
+#define R_ARC_TLS_LE_320x4b
+
 __END_DECLS
 
 #endif /* elf.h */
-- 
2.20.1


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


[PATCH v3 12/17] ARC: ABI lists

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/nofpu/libm-test-ulps  |  390 +++
 sysdeps/arc/nofpu/libm-test-ulps-name |1 +
 sysdeps/unix/sysv/linux/arc/c++-types.data|   67 +
 sysdeps/unix/sysv/linux/arc/ld.abilist|5 +
 .../sysv/linux/arc/libBrokenLocale.abilist|1 +
 sysdeps/unix/sysv/linux/arc/libanl.abilist|4 +
 sysdeps/unix/sysv/linux/arc/libc.abilist  | 2083 +
 sysdeps/unix/sysv/linux/arc/libcrypt.abilist  |2 +
 sysdeps/unix/sysv/linux/arc/libdl.abilist |9 +
 sysdeps/unix/sysv/linux/arc/libm.abilist  |  699 ++
 .../unix/sysv/linux/arc/libpthread.abilist|  217 ++
 sysdeps/unix/sysv/linux/arc/libresolv.abilist |   79 +
 sysdeps/unix/sysv/linux/arc/librt.abilist |   35 +
 .../unix/sysv/linux/arc/libthread_db.abilist  |   40 +
 sysdeps/unix/sysv/linux/arc/libutil.abilist   |6 +
 sysdeps/unix/sysv/linux/arc/localplt.data |   12 +
 16 files changed, 3650 insertions(+)
 create mode 100644 sysdeps/arc/nofpu/libm-test-ulps
 create mode 100644 sysdeps/arc/nofpu/libm-test-ulps-name
 create mode 100644 sysdeps/unix/sysv/linux/arc/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/arc/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libcrypt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libdl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libthread_db.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libutil.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/localplt.data

diff --git a/sysdeps/arc/nofpu/libm-test-ulps b/sysdeps/arc/nofpu/libm-test-ulps
new file mode 100644
index ..0e8ef313fa94
--- /dev/null
+++ b/sysdeps/arc/nofpu/libm-test-ulps
@@ -0,0 +1,390 @@
+# Begin of automatic generation
+
+# Maximal error of functions:
+Function: "acos":
+float: 1
+ifloat: 1
+
+Function: "acosh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "asin":
+float: 1
+ifloat: 1
+
+Function: "asinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "atan":
+float: 1
+ifloat: 1
+
+Function: "atan2":
+float: 1
+ifloat: 1
+
+Function: "atanh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "cabs":
+double: 1
+idouble: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "cacos":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "cacosh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "carg":
+float: 1
+ifloat: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "casin":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "casinh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Imaginary part of "casinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "catanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "cbrt":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "clog":
+double: 3
+float: 3
+idouble: 3
+ifloat: 3
+
+Function: Imaginary part of "clog":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog10":
+double: 3
+float: 4
+idouble: 3
+ifloat: 4
+
+Function: Imaginary part of "clog10":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "cos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "cosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 5
+idouble: 2
+ifloat: 5
+
+Function: Imaginary part of "cpow":
+float: 2
+ifloat: 2
+
+Function: Real part of "csin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":

[PATCH v3 04/17] ARC: startup and dynamic linking code

2020-03-06 Thread Vineet Gupta
Code for C runtime startup and dynamic loading including PLT layout.

Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/bits/link.h   |  52 ++
 sysdeps/arc/dl-machine.h  | 340 ++
 sysdeps/arc/entry.h   |   5 +
 sysdeps/arc/ldsodefs.h|  43 +
 sysdeps/arc/sotruss-lib.c |  51 ++
 sysdeps/arc/start.S   |  71 
 sysdeps/arc/tst-audit.h   |  23 +++
 7 files changed, 585 insertions(+)
 create mode 100644 sysdeps/arc/bits/link.h
 create mode 100644 sysdeps/arc/dl-machine.h
 create mode 100644 sysdeps/arc/entry.h
 create mode 100644 sysdeps/arc/ldsodefs.h
 create mode 100644 sysdeps/arc/sotruss-lib.c
 create mode 100644 sysdeps/arc/start.S
 create mode 100644 sysdeps/arc/tst-audit.h

diff --git a/sysdeps/arc/bits/link.h b/sysdeps/arc/bits/link.h
new file mode 100644
index ..0acbc1349e08
--- /dev/null
+++ b/sysdeps/arc/bits/link.h
@@ -0,0 +1,52 @@
+/* Machine-specific declarations for dynamic linker interface, ARC version.
+   Copyright (C) 2009-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef_LINK_H
+# error "Never include  directly; use  instead."
+#endif
+
+/* Registers for entry into PLT on ARC.  */
+typedef struct La_arc_regs
+{
+  uint32_t lr_reg[8]; /* r0 through r7 (upto 8 args).  */
+} La_arc_regs;
+
+/* Return values for calls from PLT on ARC.  */
+typedef struct La_arc_retval
+{
+  /* For ARCv2, a 64-bit integer return value can use 2 regs.  */
+  uint32_t lrv_reg[2];
+} La_arc_retval;
+
+__BEGIN_DECLS
+
+extern ElfW(Addr) la_arc_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx,
+uintptr_t *__refcook,
+uintptr_t *__defcook,
+La_arc_regs *__regs,
+unsigned int *__flags,
+const char *__symname,
+long int *__framesizep);
+extern unsigned int la_arc_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ const La_arc_regs *__inregs,
+ La_arc_retval *__outregs,
+ const char *symname);
+
+__END_DECLS
diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h
new file mode 100644
index ..610401f8336d
--- /dev/null
+++ b/sysdeps/arc/dl-machine.h
@@ -0,0 +1,340 @@
+/* Machine-dependent ELF dynamic relocation inline functions.  ARC version.
+   Copyright (C) 1995-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "arc"
+
+#include 
+
+#ifndef ENTRY_POINT
+# error ENTRY_POINT needs to be defined for ARC
+#endif
+
+#include 
+#include 
+#include 
+
+/* Dynamic Linking ABI for ARCv2 ISA.
+
+PLT
+   < DT_PLTGOT
+  |  ld r11, [pcl, off-to-GOT[1] |  0
+  |  |  4
+   plt0   |  ld r10, [pcl, off-to-GOT[2] |  8
+  |  | 12
+  |  j [r10] | 16
+  
+  |Base address of GOT   | 20
+  
+  |  ld r12, [pcl, off-to-GOT[3] | 24
+   plt1   |   

[PATCH v3 09/17] ARC: Linux Syscall Interface

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/nptl/tls.h|  14 +-
 sysdeps/unix/sysv/linux/arc/arch-syscall.h| 317 ++
 .../sysv/linux/arc/bits/socket-constants.h|  38 +++
 sysdeps/unix/sysv/linux/arc/clone.S   |  98 ++
 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h  |   6 +
 sysdeps/unix/sysv/linux/arc/kernel-features.h |  28 ++
 sysdeps/unix/sysv/linux/arc/mmap_internal.h   |  27 ++
 sysdeps/unix/sysv/linux/arc/pt-vfork.S|   1 +
 sysdeps/unix/sysv/linux/arc/sigaction.c   |  31 ++
 sysdeps/unix/sysv/linux/arc/sigrestorer.S |  29 ++
 sysdeps/unix/sysv/linux/arc/syscall.S |  38 +++
 sysdeps/unix/sysv/linux/arc/syscalls.list |   3 +
 sysdeps/unix/sysv/linux/arc/sysdep.c  |  33 ++
 sysdeps/unix/sysv/linux/arc/sysdep.h  | 207 
 sysdeps/unix/sysv/linux/arc/vfork.S   |  42 +++
 15 files changed, 905 insertions(+), 7 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/arc/arch-syscall.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/socket-constants.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/clone.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/kernel-features.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/mmap_internal.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/pt-vfork.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigaction.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigrestorer.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/syscall.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/syscalls.list
 create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/vfork.S

diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h
index d6b166c1f92b..10c7117527ff 100644
--- a/sysdeps/arc/nptl/tls.h
+++ b/sysdeps/arc/nptl/tls.h
@@ -77,13 +77,13 @@ register struct pthread *__thread_self __asm__("r25");
   (((tcbhead_t *) (tcbp))->dtv)
 
 /* Code to initially initialize the thread pointer.  */
-# define TLS_INIT_TP(tcbp) \
-  ({\
-   long result_var;\
-   __builtin_set_thread_pointer(tcbp); \
-   result_var = INTERNAL_SYSCALL (arc_settls, err, 1, (tcbp)); \
-   INTERNAL_SYSCALL_ERROR_P (result_var, err)  \
-   ? "unknown error" : NULL;   \
+# define TLS_INIT_TP(tcbp) \
+  ({   \
+   long result_var;\
+   __builtin_set_thread_pointer(tcbp); \
+   result_var = INTERNAL_SYSCALL (arc_settls, 1, (tcbp));  \
+   INTERNAL_SYSCALL_ERROR_P (result_var)   \
+   ? "settls syscall error" : NULL;\
})
 
 /* Value passed to 'clone' for initialization of the thread register.  */
diff --git a/sysdeps/unix/sysv/linux/arc/arch-syscall.h 
b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
new file mode 100644
index ..db25a17ad077
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
@@ -0,0 +1,317 @@
+/* AUTOGENERATED by update-syscall-lists.py.  */
+#define __NR_accept 202
+#define __NR_accept4 242
+#define __NR_acct 89
+#define __NR_add_key 217
+#define __NR_adjtimex 171
+#define __NR_arc_gettls 246
+#define __NR_arc_settls 245
+#define __NR_arc_usr_cmpxchg 248
+#define __NR_bind 200
+#define __NR_bpf 280
+#define __NR_brk 214
+#define __NR_cacheflush 244
+#define __NR_capget 90
+#define __NR_capset 91
+#define __NR_chdir 49
+#define __NR_chroot 51
+#define __NR_clock_adjtime 266
+#define __NR_clock_adjtime64 405
+#define __NR_clock_getres 114
+#define __NR_clock_getres_time64 406
+#define __NR_clock_gettime 113
+#define __NR_clock_gettime64 403
+#define __NR_clock_nanosleep 115
+#define __NR_clock_nanosleep_time64 407
+#define __NR_clock_settime 112
+#define __NR_clock_settime64 404
+#define __NR_clone 220
+#define __NR_clone3 435
+#define __NR_close 57
+#define __NR_connect 203
+#define __NR_copy_file_range 285
+#define __NR_delete_module 106
+#define __NR_dup 23
+#define __NR_dup3 24
+#define __NR_epoll_create1 20
+#define __NR_epoll_ctl 21
+#define __NR_epoll_pwait 22
+#define __NR_eventfd2 19
+#define __NR_execve 221
+#define __NR_execveat 281
+#define __NR_exit 93
+#define __NR_exit_group 94
+#define __NR_faccessat 48
+#define __NR_fadvise64_64 223
+#define __NR_fallocate 47
+#define __NR_fanotify_init 262
+#define __NR_fanotify_mark 263
+#define __NR_fchdir 50
+#define __NR_fchmod 52
+#define __NR_fchmodat 53
+#define __NR_fchown 55
+#define __NR_fchownat 54
+#define __NR_fcntl64 25
+#define __NR_fdatasync 83
+#define __NR_fgetxattr 10
+#define __NR_finit_module 273
+#define __NR_flistxattr 13
+#define __NR_flock 32
+#define __NR_fremov

[PATCH v3 13/17] ARC: Update syscall-names.list for ARC specific syscalls

2020-03-06 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/unix/sysv/linux/syscall-names.list | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/syscall-names.list 
b/sysdeps/unix/sysv/linux/syscall-names.list
index 3d89814003a2..758b50164103 100644
--- a/sysdeps/unix/sysv/linux/syscall-names.list
+++ b/sysdeps/unix/sysv/linux/syscall-names.list
@@ -41,6 +41,9 @@ adjtimex
 afs_syscall
 alarm
 alloc_hugepages
+arc_gettls
+arc_settls
+arc_usr_cmpxchg
 arch_prctl
 arm_fadvise64_64
 arm_sync_file_range
-- 
2.20.1


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


Re: [PATCH V15] mm/debug: Add tests validating architecture page table helpers

2020-03-06 Thread Qian Cai
On Fri, 2020-03-06 at 05:27 +0530, Anshuman Khandual wrote:
> This adds tests which will validate architecture page table helpers and
> other accessors in their compliance with expected generic MM semantics.
> This will help various architectures in validating changes to existing
> page table helpers or addition of new ones.
> 
> This test covers basic page table entry transformations including but not
> limited to old, young, dirty, clean, write, write protect etc at various
> level along with populating intermediate entries with next page table page
> and validating them.
> 
> Test page table pages are allocated from system memory with required size
> and alignments. The mapped pfns at page table levels are derived from a
> real pfn representing a valid kernel text symbol. This test gets called
> inside kernel_init() right after async_synchronize_full().
> 
> This test gets built and run when CONFIG_DEBUG_VM_PGTABLE is selected. Any
> architecture, which is willing to subscribe this test will need to select
> ARCH_HAS_DEBUG_VM_PGTABLE. For now this is limited to arc, arm64, x86, s390
> and ppc32 platforms where the test is known to build and run successfully.
> Going forward, other architectures too can subscribe the test after fixing
> any build or runtime problems with their page table helpers. Meanwhile for
> better platform coverage, the test can also be enabled with CONFIG_EXPERT
> even without ARCH_HAS_DEBUG_VM_PGTABLE.
> 
> Folks interested in making sure that a given platform's page table helpers
> conform to expected generic MM semantics should enable the above config
> which will just trigger this test during boot. Any non conformity here will
> be reported as an warning which would need to be fixed. This test will help
> catch any changes to the agreed upon semantics expected from generic MM and
> enable platforms to accommodate it thereafter.

OK, I get this working on powerpc hash MMU as well, so this?

diff --git a/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
b/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
index 64d0f9b15c49..c527d05c0459 100644
--- a/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
+++ b/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
@@ -22,8 +22,7 @@
 |   nios2: | TODO |
 |openrisc: | TODO |
 |  parisc: | TODO |
-|  powerpc/32: |  ok  |
-|  powerpc/64: | TODO |
+| powerpc: |  ok  |
 |   riscv: | TODO |
 |s390: |  ok  |
 |  sh: | TODO |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 2e7eee523ba1..176930f40e07 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -116,7 +116,7 @@ config PPC
    #
    select ARCH_32BIT_OFF_T if PPC32
    select ARCH_HAS_DEBUG_VIRTUAL
-   select ARCH_HAS_DEBUG_VM_PGTABLE if PPC32
+   select ARCH_HAS_DEBUG_VM_PGTABLE
    select ARCH_HAS_DEVMEM_IS_ALLOWED
    select ARCH_HAS_ELF_RANDOMIZE
    select ARCH_HAS_FORTIFY_SOURCE
diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
index 96a91bda3a85..98990a515268 100644
--- a/mm/debug_vm_pgtable.c
+++ b/mm/debug_vm_pgtable.c
@@ -256,7 +256,8 @@ static void __init pte_clear_tests(struct mm_struct *mm,
pte_t *ptep,
    pte_t pte = READ_ONCE(*ptep);
 
    pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
-   WRITE_ONCE(*ptep, pte);
+   set_pte_at(mm, vaddr, ptep, pte);
+   barrier();
    pte_clear(mm, vaddr, ptep);
    pte = READ_ONCE(*ptep);
    WARN_ON(!pte_none(pte));

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


Re: [PATCH v2 1/4] ARC: add helpers to sanitize config options

2020-03-06 Thread Vineet Gupta
On 3/5/20 12:02 PM, Eugeniy Paltsev wrote:
> We'll use this macro in coming patches extensively.
> 
> Signed-off-by: Eugeniy Paltsev 

LGTM !

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


Re: [PATCH V15] mm/debug: Add tests validating architecture page table helpers

2020-03-06 Thread Anshuman Khandual


On 03/07/2020 02:14 AM, Qian Cai wrote:
> On Fri, 2020-03-06 at 05:27 +0530, Anshuman Khandual wrote:
>> This adds tests which will validate architecture page table helpers and
>> other accessors in their compliance with expected generic MM semantics.
>> This will help various architectures in validating changes to existing
>> page table helpers or addition of new ones.
>>
>> This test covers basic page table entry transformations including but not
>> limited to old, young, dirty, clean, write, write protect etc at various
>> level along with populating intermediate entries with next page table page
>> and validating them.
>>
>> Test page table pages are allocated from system memory with required size
>> and alignments. The mapped pfns at page table levels are derived from a
>> real pfn representing a valid kernel text symbol. This test gets called
>> inside kernel_init() right after async_synchronize_full().
>>
>> This test gets built and run when CONFIG_DEBUG_VM_PGTABLE is selected. Any
>> architecture, which is willing to subscribe this test will need to select
>> ARCH_HAS_DEBUG_VM_PGTABLE. For now this is limited to arc, arm64, x86, s390
>> and ppc32 platforms where the test is known to build and run successfully.
>> Going forward, other architectures too can subscribe the test after fixing
>> any build or runtime problems with their page table helpers. Meanwhile for
>> better platform coverage, the test can also be enabled with CONFIG_EXPERT
>> even without ARCH_HAS_DEBUG_VM_PGTABLE.
>>
>> Folks interested in making sure that a given platform's page table helpers
>> conform to expected generic MM semantics should enable the above config
>> which will just trigger this test during boot. Any non conformity here will
>> be reported as an warning which would need to be fixed. This test will help
>> catch any changes to the agreed upon semantics expected from generic MM and
>> enable platforms to accommodate it thereafter.
> 
> OK, I get this working on powerpc hash MMU as well, so this?
> 
> diff --git a/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
> b/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
> index 64d0f9b15c49..c527d05c0459 100644
> --- a/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
> +++ b/Documentation/features/debug/debug-vm-pgtable/arch-support.txt
> @@ -22,8 +22,7 @@
>  |   nios2: | TODO |
>  |openrisc: | TODO |
>  |  parisc: | TODO |
> -|  powerpc/32: |  ok  |
> -|  powerpc/64: | TODO |
> +| powerpc: |  ok  |
>  |   riscv: | TODO |
>  |s390: |  ok  |
>  |  sh: | TODO |
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 2e7eee523ba1..176930f40e07 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -116,7 +116,7 @@ config PPC
>   #
>   select ARCH_32BIT_OFF_T if PPC32
>   select ARCH_HAS_DEBUG_VIRTUAL
> - select ARCH_HAS_DEBUG_VM_PGTABLE if PPC32
> + select ARCH_HAS_DEBUG_VM_PGTABLE
>   select ARCH_HAS_DEVMEM_IS_ALLOWED
>   select ARCH_HAS_ELF_RANDOMIZE
>   select ARCH_HAS_FORTIFY_SOURCE
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index 96a91bda3a85..98990a515268 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -256,7 +256,8 @@ static void __init pte_clear_tests(struct mm_struct *mm,
> pte_t *ptep,
>   pte_t pte = READ_ONCE(*ptep);
>  
>   pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
> - WRITE_ONCE(*ptep, pte);
> + set_pte_at(mm, vaddr, ptep, pte);

Hmm, set_pte_at() function is not preferred here for these tests. The idea
is to avoid or atleast minimize TLB/cache flushes triggered from these sort
of 'static' tests. set_pte_at() is platform provided and could/might trigger
these flushes or some other platform specific synchronization stuff. Just
wondering is there specific reason with respect to the soft lock up problem
making it necessary to use set_pte_at() rather than a simple WRITE_ONCE() ?

> + barrier();
>   pte_clear(mm, vaddr, ptep);
>   pte = READ_ONCE(*ptep);
>   WARN_ON(!pte_none(pte));
> 

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


Re: [PATCH v3 01/17] gcc PR 88409: miscompilation due to missing cc clobber in longlong.h macros

2020-03-06 Thread Joseph Myers
If this gets longlong.h back in sync with changes made in the GCC version, 
then please commit.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH v2 2/4] ARC: handle DSP presence in HW

2020-03-06 Thread Vineet Gupta
On 3/5/20 12:02 PM, Eugeniy Paltsev wrote:
> In case of DSP extension presence in HW some instructions
> (related to integer multiply, multiply-accumulate, and divide
> operation) executes on this DSP execution unit. So their
> execution will depend on dsp configuration register (DSP_CTRL)
> 
> As we want these instructions to execute the same way regardless
> of DSP presence we need to set DSP_CTRL properly. However this
> register can be modified bu any usersace app therefore any
> usersace may break kernel execution.
> 
> Fix that by configure DSP_CTRL in CPU early code and in IRQs
> entries.

How about below 

"When DSP extensions are present, some of the regular integer instructions such 
as
DIV, MACD etc are executed in the DSP unit with semantics alterable by flags in
DSP_CTRL aux register. This register is writable by userspace and thus can
potentially affect corresponding instructions in kernel code, intentionally or
otherwise. So safegaurd kernel by effectively disabling DSP_CTRL upon bootup and
every entry to kernel.

Do note that for this config we simply zero out the DSP_CTRL reg assuming
userspace doesn't really care about DSP. The next patch caters to the DSP aware
userspace which this actually saved/restored upon kernel entry."



> 
> Signed-off-by: Eugeniy Paltsev 
> ---
>  arch/arc/Kconfig   | 29 +++-
>  arch/arc/include/asm/arcregs.h | 12 +++
>  arch/arc/include/asm/dsp-impl.h| 54 ++
>  arch/arc/include/asm/entry-arcv2.h |  3 ++
>  arch/arc/kernel/head.S |  4 +++
>  arch/arc/kernel/setup.c|  3 ++
>  6 files changed, 104 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arc/include/asm/dsp-impl.h
> 
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index 7124ab82dfa3..55432a8fc20d 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -401,13 +401,40 @@ config ARC_HAS_DIV_REM
>   default y
>  
>  config ARC_HAS_ACCL_REGS
> - bool "Reg Pair ACCL:ACCH (FPU and/or MPY > 6)"
> + bool "Reg Pair ACCL:ACCH (FPU and/or MPY > 6 and/or DSP)"
>   default y
>   help
> Depending on the configuration, CPU can contain accumulator reg-pair
> (also referred to as r58:r59). These can also be used by gcc as GPR so
> kernel needs to save/restore per process
>  
> +config ARC_DSP_HANDLED
> + def_bool n
> +
> +choice
> + prompt "DSP support"
> + default ARC_DSP_NONE
> + help
> +   Depending on the configuration, CPU can contain DSP registers
> +   (ACC0_GLO, ACC0_GHI, DSP_BFLY0, DSP_CTRL, DSP_FFT_CTRL).
> +   Bellow is options describing how to handle these registers in

typo: Below

Looks good otherwise. No need to respin just for this.

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


Re: [PATCH v3 16/17] NEWS: mention ARC port

2020-03-06 Thread Joseph Myers
On Fri, 6 Mar 2020, Vineet Gupta wrote:

> +* Support for ARC HS cores running Linux has been contributed by Synopsys.
> +  Port requires atleast
> +- binutils-2.31 (binutils-2_31-branch: commit 6ce881c15fc4, 2018-10-04)
> +- gcc 8.2 (gcc-8-stable: commit 0d5ba57508c5, 2019-01-29)
> +- Linux kernel 5.1+

You need to update the list of supported configurations in README.

Any architecture with a higher minimum compiler / binutils version than 
normal needs it documented in install.texi, with the INSTALL file 
regenerated.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH v3 14/17] ARC: Build Infrastructure

2020-03-06 Thread Joseph Myers
On Fri, 6 Mar 2020, Vineet Gupta wrote:

> diff --git a/sysdeps/unix/sysv/linux/arc/configure.ac 
> b/sysdeps/unix/sysv/linux/arc/configure.ac
> new file mode 100644
> index ..a9528032d32a
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/arc/configure.ac
> @@ -0,0 +1,4 @@
> +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
> +# Local configure fragment for sysdeps/unix/sysv/linux/arc.
> +
> +arch_minimum_kernel=3.9.0

Surely you mean 5.1.0, at least until the glibc support for falling back 
to 32-bit time syscalls from 64-bit time interfaces is completed?

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH v3 17/17] ARC: changes to enable 64-bit time_t, off_t, ino_t etc

2020-03-06 Thread Joseph Myers
On Fri, 6 Mar 2020, Vineet Gupta wrote:

> Signed-off-by: Vineet Gupta 
> ---
>  .../sysv/linux/arc/bits/socket-constants.h|  4 +--

There is a general principle for patch series: you should not have later 
patches fixing up things that were wrong with earlier patches.  Each patch 
should add files in the form desired to be reviewed, not in a form that 
gets fixed up later.

(Sometimes a patch series might change a file that was correct in an 
earlier patch in the series, as part of adding additional features, if the 
first M patches add feature X and the next N add feature Y on top of it.  
But that's not the case here - such later patches should not make 
incompatible changes to earlier ones.)

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH v3 00/17] glibc port to ARC processors

2020-03-06 Thread Joseph Myers
Please give details of what the entries would be for 
 and 
 for this port that you 
intend to add once the port is in.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH v3 01/17] gcc PR 88409: miscompilation due to missing cc clobber in longlong.h macros

2020-03-06 Thread Vineet Gupta
On 3/6/20 4:12 PM, Joseph Myers wrote:
> If this gets longlong.h back in sync with changes made in the GCC version, 
> then please commit.

Yes it does. The only differences now are in the initial licensing header due to
glibc's variant bumping year and the http -> https.

BTW, I don't think I asked for commit access before. I just rechecked 
MAINTAINERS
wiki page and seems like someone needs to grant me that.

Thx for taking a look.

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


Re: [PATCH v3 14/17] ARC: Build Infrastructure

2020-03-06 Thread Vineet Gupta
On 3/6/20 4:16 PM, Joseph Myers wrote:
> On Fri, 6 Mar 2020, Vineet Gupta wrote:
>> +
>> +arch_minimum_kernel=3.9.0
>
> Surely you mean 5.1.0, at least until the glibc support for falling back 
> to 32-bit time syscalls from 64-bit time interfaces is completed?

Indeed patch 17/17 does that as that accumulates all changes for the 64-bit time
and offset interfaces.
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH V15] mm/debug: Add tests validating architecture page table helpers

2020-03-06 Thread Qian Cai



> On Mar 6, 2020, at 7:03 PM, Anshuman Khandual  
> wrote:
> 
> Hmm, set_pte_at() function is not preferred here for these tests. The idea
> is to avoid or atleast minimize TLB/cache flushes triggered from these sort
> of 'static' tests. set_pte_at() is platform provided and could/might trigger
> these flushes or some other platform specific synchronization stuff. Just

Why is that important for this debugging option?

> wondering is there specific reason with respect to the soft lock up problem
> making it necessary to use set_pte_at() rather than a simple WRITE_ONCE() ?

Looks at the s390 version of set_pte_at(), it has this comment,
vmaddr);

/*
 * Certain architectures need to do special things when PTEs
 * within a page table are directly modified.  Thus, the following
 * hook is made available.
 */

I can only guess that powerpc  could be the same here.
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v3 17/17] ARC: changes to enable 64-bit time_t, off_t, ino_t etc

2020-03-06 Thread Vineet Gupta
On 3/6/20 4:19 PM, Joseph Myers wrote:
> On Fri, 6 Mar 2020, Vineet Gupta wrote:
> 
>> Signed-off-by: Vineet Gupta 
>> ---
>>  .../sysv/linux/arc/bits/socket-constants.h|  4 +--
> 
> There is a general principle for patch series: you should not have later 
> patches fixing up things that were wrong with earlier patches.  Each patch 
> should add files in the form desired to be reviewed, not in a form that 
> gets fixed up later.
> 
> (Sometimes a patch series might change a file that was correct in an 
> earlier patch in the series, as part of adding additional features, if the 
> first M patches add feature X and the next N add feature Y on top of it.  
> But that's not the case here - such later patches should not make 
> incompatible changes to earlier ones.)

I agree and you've mentioned this fact before as well. The only reason I carved 
it
this way was to ease my testing. The 64-bit time code was based on RV32 which in
turn was based on bleeding edge upstream some of which needed additional work 
for
ARC but ininitial days of 64-bit work, it was hard to know if the fix was needed
for 64-bit or for upstream tracking. And that's exactly what I got bitten by -
when I missed the fixup for init constructor invocation from Florian, wasting 3
days [1]

Anyhow that's just to give you the context. I can split them up and add to
respective sections for next iteration. If we end up not doing another iteration
- hypothetically speaking :-) the whole port is anyhow committed as 1 patch so 
it
doesn't matter.

[1] 
http://lists.infradead.org/pipermail/linux-snps-arc/2020-February/006974.html

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


Re: [PATCH v3 16/17] NEWS: mention ARC port

2020-03-06 Thread Vineet Gupta
On 3/6/20 4:14 PM, Joseph Myers wrote:
> On Fri, 6 Mar 2020, Vineet Gupta wrote:
> 
>> +* Support for ARC HS cores running Linux has been contributed by Synopsys.
>> +  Port requires atleast
>> +- binutils-2.31 (binutils-2_31-branch: commit 6ce881c15fc4, 2018-10-04)
>> +- gcc 8.2 (gcc-8-stable: commit 0d5ba57508c5, 2019-01-29)
>> +- Linux kernel 5.1+
> 
> You need to update the list of supported configurations in README.

Ok did that now. Is it not supposed to also cover the hf (hard-float) configs 
for
architectures in general ?

> 
> Any architecture with a higher minimum compiler / binutils version than 
> normal needs it documented in install.texi, with the INSTALL file 
> regenerated.

"normal" would the ones mentioned in build-many-glibcs ? The min versions for 
ARC
are over year old already so I don't think it needs mentioning.


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


Re: [PATCH v3 00/17] glibc port to ARC processors

2020-03-06 Thread Vineet Gupta
On 3/6/20 4:21 PM, Joseph Myers wrote:
> Please give details of what the entries would be for 
>  and 

ARC
   * 32-bit, hard-float, LE: /lib/ld-linux-arc.so.2
   * 32-bit, soft-float, LE: /lib/ld-linux-arc.so.2

(soft-float ABI is compatible with hardware-float builds in terms of calling
convention, register-file etc)

>  for this port that you 
> intend to add once the port is in.

Last time I checked, static-pie doesn't work for ARC either ATM. There's nothing
else ARC specific, which needs calling out there.


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


Re: [PATCH V15] mm/debug: Add tests validating architecture page table helpers

2020-03-06 Thread Anshuman Khandual



On 03/07/2020 06:04 AM, Qian Cai wrote:
> 
> 
>> On Mar 6, 2020, at 7:03 PM, Anshuman Khandual  
>> wrote:
>>
>> Hmm, set_pte_at() function is not preferred here for these tests. The idea
>> is to avoid or atleast minimize TLB/cache flushes triggered from these sort
>> of 'static' tests. set_pte_at() is platform provided and could/might trigger
>> these flushes or some other platform specific synchronization stuff. Just
> 
> Why is that important for this debugging option?

Primarily reason is to avoid TLB/cache flush instructions on the system
during these tests that only involve transforming different page table
level entries through helpers. Unless really necessary, why should it
emit any TLB/cache flush instructions ?

> 
>> wondering is there specific reason with respect to the soft lock up problem
>> making it necessary to use set_pte_at() rather than a simple WRITE_ONCE() ?
> 
> Looks at the s390 version of set_pte_at(), it has this comment,
> vmaddr);
> 
> /*
>  * Certain architectures need to do special things when PTEs
>  * within a page table are directly modified.  Thus, the following
>  * hook is made available.
>  */
> 
> I can only guess that powerpc  could be the same here.

This comment is present in multiple platforms while defining set_pte_at().
Is not 'barrier()' here alone good enough ? Else what exactly set_pte_at()
does as compared to WRITE_ONCE() that avoids the soft lock up, just trying
to understand.

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


Re: [PATCH v3 16/17] NEWS: mention ARC port

2020-03-06 Thread Joseph Myers
On Sat, 7 Mar 2020, Vineet Gupta wrote:

> On 3/6/20 4:14 PM, Joseph Myers wrote:
> > On Fri, 6 Mar 2020, Vineet Gupta wrote:
> > 
> >> +* Support for ARC HS cores running Linux has been contributed by Synopsys.
> >> +  Port requires atleast
> >> +- binutils-2.31 (binutils-2_31-branch: commit 6ce881c15fc4, 
> >> 2018-10-04)
> >> +- gcc 8.2 (gcc-8-stable: commit 0d5ba57508c5, 2019-01-29)
> >> +- Linux kernel 5.1+
> > 
> > You need to update the list of supported configurations in README.
> 
> Ok did that now. Is it not supposed to also cover the hf (hard-float) 
> configs for architectures in general ?

README has a high-level summary, not full details of every supported ABI 
variant.

> > Any architecture with a higher minimum compiler / binutils version than 
> > normal needs it documented in install.texi, with the INSTALL file 
> > regenerated.
> 
> "normal" would the ones mentioned in build-many-glibcs ? The min versions for 
> ARC
> are over year old already so I don't think it needs mentioning.

"normal" means "the versions documented in install.texi, node Tools for 
Compilation, as the minimum for building glibc on most architectures".

That node should give comprehensive information on what tool versions are 
needed to build glibc.  If an architecture requires GCC more recent than 
6.2, or binutils more recent than 2.25, that needs to be documented there 
(unless the minimum versions for that architecture are the minimum 
binutils / GCC versions that supported that architecture at all).

An alternative in some cases is increasing the global minimum.  Typically 
the global minimum is a version from a few years ago; if it's been a year 
since the minimum major GCC version for building glibc was last updated, 
it may well be reasonable to propose an architecture-independent increase 
of that version to the next major GCC release, for example.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH v3 00/17] glibc port to ARC processors

2020-03-06 Thread Joseph Myers
On Sat, 7 Mar 2020, Vineet Gupta wrote:

> On 3/6/20 4:21 PM, Joseph Myers wrote:
> > Please give details of what the entries would be for 
> >  and 
> 
> ARC
>* 32-bit, hard-float, LE: /lib/ld-linux-arc.so.2
>* 32-bit, soft-float, LE: /lib/ld-linux-arc.so.2
> 
> (soft-float ABI is compatible with hardware-float builds in terms of calling
> convention, register-file etc)

So that should actually be one bullet-point entry for soft-float ABI, 
rather than two entries, because it's a single ABI, with a clarifying note 
following like those for some other architectures.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH V15] mm/debug: Add tests validating architecture page table helpers

2020-03-06 Thread Qian Cai



> On Mar 6, 2020, at 7:56 PM, Anshuman Khandual  
> wrote:
> 
> 
> 
> On 03/07/2020 06:04 AM, Qian Cai wrote:
>> 
>> 
>>> On Mar 6, 2020, at 7:03 PM, Anshuman Khandual  
>>> wrote:
>>> 
>>> Hmm, set_pte_at() function is not preferred here for these tests. The idea
>>> is to avoid or atleast minimize TLB/cache flushes triggered from these sort
>>> of 'static' tests. set_pte_at() is platform provided and could/might trigger
>>> these flushes or some other platform specific synchronization stuff. Just
>> 
>> Why is that important for this debugging option?
> 
> Primarily reason is to avoid TLB/cache flush instructions on the system
> during these tests that only involve transforming different page table
> level entries through helpers. Unless really necessary, why should it
> emit any TLB/cache flush instructions ?
> 
>> 
>>> wondering is there specific reason with respect to the soft lock up problem
>>> making it necessary to use set_pte_at() rather than a simple WRITE_ONCE() ?
>> 
>> Looks at the s390 version of set_pte_at(), it has this comment,
>> vmaddr);
>> 
>> /*
>> * Certain architectures need to do special things when PTEs
>> * within a page table are directly modified.  Thus, the following
>> * hook is made available.
>> */
>> 
>> I can only guess that powerpc  could be the same here.
> 
> This comment is present in multiple platforms while defining set_pte_at().
> Is not 'barrier()' here alone good enough ? Else what exactly set_pte_at()

No, barrier() is not enough.

> does as compared to WRITE_ONCE() that avoids the soft lock up, just trying
> to understand.

I surely can spend hours to figure which exact things in set_pte_at() is 
necessary for
pte_clear() not to stuck, and then propose a solution and possible need to 
retest on
multiple arches. I am not sure if that is a good use of my time just to saving
a few TLB/cache flush on a debug kernel?
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v3 16/17] NEWS: mention ARC port

2020-03-06 Thread Vineet Gupta
On 3/6/20 5:08 PM, Joseph Myers wrote:

> "normal" means "the versions documented in install.texi, node Tools for 
> Compilation, as the minimum for building glibc on most architectures".
> 
> That node should give comprehensive information on what tool versions are 
> needed to build glibc.  If an architecture requires GCC more recent than 
> 6.2, or binutils more recent than 2.25, that needs to be documented there 
> (unless the minimum versions for that architecture are the minimum 
> binutils / GCC versions that supported that architecture at all).

Something along the lines...

-   * GCC 6.2 or newer
+   * GCC 6.2 or newer  (For some architectures specific later versions needed)

- GCC 6.2 or higher is required.  In general it is recommended to use
- the newest version of the compiler that is known to work for
+ GCC 6.2 or higher is required. ARC architecture needs gcc 8.2 or later.
+ In general it is recommended to use the newest version of the compiler



> 
> An alternative in some cases is increasing the global minimum.  Typically 
> the global minimum is a version from a few years ago; if it's been a year 
> since the minimum major GCC version for building glibc was last updated, 
> it may well be reasonable to propose an architecture-independent increase 
> of that version to the next major GCC release, for example.
> 

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


Re: [PATCH v3 16/17] NEWS: mention ARC port

2020-03-06 Thread Joseph Myers
On Sat, 7 Mar 2020, Vineet Gupta wrote:

> On 3/6/20 5:08 PM, Joseph Myers wrote:
> 
> > "normal" means "the versions documented in install.texi, node Tools for 
> > Compilation, as the minimum for building glibc on most architectures".
> > 
> > That node should give comprehensive information on what tool versions are 
> > needed to build glibc.  If an architecture requires GCC more recent than 
> > 6.2, or binutils more recent than 2.25, that needs to be documented there 
> > (unless the minimum versions for that architecture are the minimum 
> > binutils / GCC versions that supported that architecture at all).
> 
> Something along the lines...

Yes, that sort of thing.  For a while there was a higher version required 
for powerpc64le, and there will be again soon, so that's an example.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH V15] mm/debug: Add tests validating architecture page table helpers

2020-03-06 Thread Christophe Leroy



Le 07/03/2020 à 01:56, Anshuman Khandual a écrit :



On 03/07/2020 06:04 AM, Qian Cai wrote:




On Mar 6, 2020, at 7:03 PM, Anshuman Khandual  wrote:

Hmm, set_pte_at() function is not preferred here for these tests. The idea
is to avoid or atleast minimize TLB/cache flushes triggered from these sort
of 'static' tests. set_pte_at() is platform provided and could/might trigger
these flushes or some other platform specific synchronization stuff. Just


Why is that important for this debugging option?


Primarily reason is to avoid TLB/cache flush instructions on the system
during these tests that only involve transforming different page table
level entries through helpers. Unless really necessary, why should it
emit any TLB/cache flush instructions ?


What's the problem with thoses flushes ?






wondering is there specific reason with respect to the soft lock up problem
making it necessary to use set_pte_at() rather than a simple WRITE_ONCE() ?


Looks at the s390 version of set_pte_at(), it has this comment,
vmaddr);

/*
  * Certain architectures need to do special things when PTEs
  * within a page table are directly modified.  Thus, the following
  * hook is made available.
  */

I can only guess that powerpc  could be the same here.


This comment is present in multiple platforms while defining set_pte_at().
Is not 'barrier()' here alone good enough ? Else what exactly set_pte_at()
does as compared to WRITE_ONCE() that avoids the soft lock up, just trying
to understand.




Argh ! I didn't realise that you were writing directly into the page 
tables. When it works, that's only by chance I guess.


To properly set the page table entries, set_pte_at() has to be used:
- On powerpc 8xx, with 16k pages, the page table entry must be copied 
four times. set_pte_at() does it, WRITE_ONCE() doesn't.
- On powerpc book3s/32 (hash MMU), the flag _PAGE_HASHPTE must be 
preserved among writes. set_pte_at() preserves it, WRITE_ONCE() doesn't.


set_pte_at() also does a few other mandatory things, like calling 
pte_mkpte()


So, the WRITE_ONCE() must definitely become a set_pte_at()

Christophe

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