[PATCH v5 11/14] ARC: Update syscall-names.list for ARC specific syscalls

2020-04-08 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


[PATCH v5 12/14] ARC: Build Infrastructure

2020-04-08 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 config.h.in|   3 +
 scripts/build-many-glibcs.py   |   9 +
 sysdeps/arc/Implies|   3 +
 sysdeps/arc/Makefile   |  21 +++
 sysdeps/arc/Versions   |   8 +
 sysdeps/arc/configure  | 182 +
 sysdeps/arc/configure.ac   |  26 +++
 sysdeps/arc/nptl/Makefile  |  22 +++
 sysdeps/arc/preconfigure   |  14 ++
 sysdeps/unix/sysv/linux/arc/Implies|   3 +
 sysdeps/unix/sysv/linux/arc/Makefile   |  29 
 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/ldconfig.h |  27 +++
 sysdeps/unix/sysv/linux/arc/shlib-versions |   7 +
 16 files changed, 378 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/ldconfig.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/shlib-versions

diff --git a/config.h.in b/config.h.in
index dea43df438f6..08962dfed075 100644
--- a/config.h.in
+++ b/config.h.in
@@ -109,6 +109,9 @@
 /* AArch64 big endian ABI */
 #undef HAVE_AARCH64_BE
 
+/* ARC big endian ABI */
+#undef HAVE_ARC_BE
+
 /* C-SKY ABI version.  */
 #undef CSKYABI
 
diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 942a2227806a..64a836c52ea9 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -162,6 +162,15 @@ 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='arceb',
+os_name='linux-gnu',
+gcc_cfg=['--disable-multilib', '--with-cpu=hs38'])
 self.add_config(arch='alpha',
 os_name='linux-gnu')
 self.add_config(arch='arm',
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 ..56ac503bfe43
--- /dev/null
+++ b/sysdeps/arc/Makefile
@@ -0,0 +1,21 @@
+# 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
diff --git a/sysdeps/arc/Versions b/sysdeps/arc/Versions
new file mode 100644
index ..6ac7b8e49505
--- /dev/null
+++ b/sysdeps/arc/Versions
@@ -0,0 +1,8 @@
+libc {
+  GLIBC_2.32 {
+__mcount;
+  }
+  GLIBC_PRIVATE {
+__syscall_error;
+  }
+}
diff --git a/sysdeps/arc/configure b/sysdeps/arc/configure
new file mode 100644
index ..5820017d6505
--- /dev/null
+++ b/sysdeps/arc/configure
@@ -0,0 +1,182 @@
+# 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
+# 

[PATCH v5 08/14] ARC: Linux ABI

2020-04-08 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 | 73 +++
 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| 61 
 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, 604 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 ..465c40c71bbd
--- /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 

[PATCH v5 02/14] ARC: startup and dynamic linking code

2020-04-08 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   |  74 +
 sysdeps/arc/tst-audit.h   |  23 +++
 7 files changed, 588 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 ..70fe4bb01809
--- /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 v5 06/14] ARC: hardware floating point support

2020-04-08 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 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 |  40 +
 sysdeps/arc/fpu/fesetround.c|  40 +
 sysdeps/arc/fpu/feupdateenv.c   |  51 
 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/s_fma.c |  28 +
 sysdeps/arc/fpu/s_fmaf.c|  28 +
 sysdeps/arc/fpu_control.h   | 102 
 sysdeps/arc/get-rounding-mode.h |  38 
 sysdeps/arc/math-tests-trap.h   |  27 +
 sysdeps/arc/tininess.h  |   1 +
 22 files changed, 809 insertions(+)
 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/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/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 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 
+
+float
+__ieee754_sqrtf (float s)
+{
+  return __builtin_sqrtf (s);
+}
+libm_alias_finite (__ieee754_sqrtf, __sqrtf)
diff --git a/sysdeps/arc/fpu/fclrexcpt.c b/sysdeps/arc/fpu/fclrexcpt.c
new file mode 100644
index ..549968dcd465
--- /dev/null
+++ b/sysdeps/arc/fpu/fclrexcpt.c
@@ -0,0 +1,36 @@
+/* Clear given exceptions in current floating-point environment.
+   Copyright (C) 2018-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C 

[PATCH v5 04/14] ARC: Atomics and Locking primitives

2020-04-08 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/atomic-machine.h  | 69 +++
 sysdeps/arc/nptl/bits/semaphore.h | 32 ++
 2 files changed, 101 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 ..6cf128dc7fa8
--- /dev/null
+++ b/sysdeps/arc/atomic-machine.h
@@ -0,0 +1,69 @@
+/* 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)
+
+#define atomic_full_barrier()  ({ asm volatile ("dmb 3":::"memory"); })
+
+#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://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v5 09/14] ARC: Linux Startup and Dynamic Loading

2020-04-08 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/unix/sysv/linux/arc/dl-static.c | 84 +
 sysdeps/unix/sysv/linux/arc/ldsodefs.h  | 32 ++
 2 files changed, 116 insertions(+)
 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/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[] =
+{
+  (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, , 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.  */
+#include_next 
+
+/* Now define our stuff.  */
+
+/* We need special support to initialize DSO loaded for statically linked
+   binaries.  */
+extern void _dl_static_init (struct link_map *map);
+#undef DL_STATIC_INIT
+#define DL_STATIC_INIT(map) _dl_static_init (map)
+
+#endif /* ldsodefs.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 v5 07/14] ARC: Linux Syscall Interface

2020-04-08 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/unix/sysv/linux/arc/arch-syscall.h| 317 ++
 sysdeps/unix/sysv/linux/arc/bits/timesize.h   |  21 ++
 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/kernel_stat.h |  26 ++
 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 |  33 ++
 sysdeps/unix/sysv/linux/arc/syscalls.list |   3 +
 sysdeps/unix/sysv/linux/arc/sysctl.mk |   1 +
 sysdeps/unix/sysv/linux/arc/sysdep.c  |  33 ++
 sysdeps/unix/sysv/linux/arc/sysdep.h  | 219 
 sysdeps/unix/sysv/linux/arc/vfork.S   |  42 +++
 16 files changed, 915 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/arc/arch-syscall.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/timesize.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/kernel_stat.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/sysctl.mk
 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/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_fremovexattr 16
+#define __NR_fsconfig 431
+#define __NR_fsetxattr 7
+#define __NR_fsmount 432
+#define __NR_fsopen 430
+#define __NR_fspick 433
+#define __NR_fstat64 80
+#define __NR_fstatat64 79
+#define __NR_fstatfs64 44
+#define __NR_fsync 82
+#define __NR_ftruncate64 46
+#define __NR_futex 98
+#define __NR_futex_time64 422
+#define __NR_get_mempolicy 236
+#define __NR_get_robust_list 100
+#define __NR_getcpu 168
+#define __NR_getcwd 17
+#define __NR_getdents64 61
+#define __NR_getegid 177
+#define __NR_geteuid 175
+#define __NR_getgid 176
+#define __NR_getgroups 158
+#define __NR_getitimer 102
+#define __NR_getpeername 205
+#define __NR_getpgid 155
+#define __NR_getpid 172
+#define __NR_getppid 173
+#define __NR_getpriority 141
+#define __NR_getrandom 278
+#define __NR_getresgid 150
+#define __NR_getresuid 148
+#define __NR_getrlimit 163
+#define __NR_getrusage 165
+#define __NR_getsid 156
+#define __NR_getsockname 204
+#define __NR_getsockopt 209
+#define __NR_gettid 178
+#define __NR_gettimeofday 169
+#define __NR_getuid 174
+#define __NR_getxattr 8
+#define __NR_init_module 105
+#define 

[PATCH v5 01/14] ARC: ABI Implementation

2020-04-08 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  | 33 +++
 sysdeps/arc/dl-sysdep.h   | 25 +++
 sysdeps/arc/dl-trampoline.S   | 80 +++
 sysdeps/arc/gccframe.h| 21 +
 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 
 17 files changed, 567 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/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 terms of the GNU Lesser General Public
+   License as published by the Free Software 

[PATCH v5 03/14] ARC: Thread Local Storage support

2020-04-08 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 ..64c432c22e76
--- /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 ..10c7117527ff
--- /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__
+# 

[PATCH v5 05/14] ARC: math soft float support

2020-04-08 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/bits/fenv.h   | 77 +++
 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, 205 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 ..80afa50db9c6
--- /dev/null
+++ b/sysdeps/arc/bits/fenv.h
@@ -0,0 +1,77 @@
+/* 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)   /* default */
+  FE_TONEAREST,
+FE_UPWARD =
+# define FE_UPWARD (0x2)
+  FE_UPWARD,
+FE_DOWNWARD   =
+# define FE_DOWNWARD   (0x3)
+  FE_DOWNWARD
+  };
+
+typedef unsigned int fexcept_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)
+
+#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 ..2ec58e088ebf
--- /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 does not 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

[PATCH v5 13/14] build-many-glibcs.py: Enable ARC builds

2020-04-08 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 scripts/build-many-glibcs.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 64a836c52ea9..77b686d34cea 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -1248,6 +1248,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 v5 14/14] Documentation for ARC port

2020-04-08 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 NEWS| 9 +
 README  | 1 +
 manual/install.texi | 5 +
 3 files changed, 15 insertions(+)

diff --git a/NEWS b/NEWS
index 14fd59a16a2d..6d17b6a0a087 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,15 @@ Major new features:
 - rv32imafdc ilp32
 - rv32imafdc ilp32d
 
+* Support for Synpsys ARC HS cores (ARCv2 ISA) running Linux.
+
+  Port requires atleast
+- binutils-2.32 (binutils-2_31-branch: commit 6ce881c15fc4, 2018-10-04)
+- gcc 8.3 (gcc-8-stable: commit 0d5ba57508c5, 2019-01-29)
+- Linux kernel 5.1+ (64-bit time and offsets)
+
+  Both Little and Big-Endian supported
+
 Deprecated and removed features, and other changes affecting compatibility:
 
   [Add deprecations, removals and changes affecting compatibility here]
diff --git a/README b/README
index cee86ab178cf..d0f0edb3930a 100644
--- a/README
+++ b/README
@@ -24,6 +24,7 @@ The GNU C Library supports these configurations for using 
Linux kernels:
 
aarch64*-*-linux-gnu
alpha*-*-linux-gnu
+   arc*-*-linux-gnu
arm-*-linux-gnueabi
csky-*-linux-gnuabiv2
hppa-*-linux-gnu
diff --git a/manual/install.texi b/manual/install.texi
index 71bf47cac659..c4b11e4e7973 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -507,6 +507,9 @@ the newest version of the compiler that is known to work 
for building
 release time, GCC 9.2.1 is the newest compiler verified to work to build
 @theglibc{}.
 
+For ARC architecture builds, GCC 8.3 is needed which has the necessary
+fixes to support @theglibc{}.
+
 For multi-arch support it is recommended to use a GCC which has been built with
 support for GNU indirect functions.  This ensures that correct debugging
 information is generated for functions selected by IFUNC resolvers.  This
@@ -528,6 +531,8 @@ No other assembler or linker has the necessary 
functionality at the
 moment. As of release time, GNU @code{binutils} 2.32 is the newest
 verified to work to build @theglibc{}.
 
+ARC architecture needs @code{binutils} 2.32 for TLS related fixes.
+
 @item
 GNU @code{texinfo} 4.7 or later
 
-- 
2.20.1


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


[PATCH v5 00/14] glibc port to ARC processors

2020-04-08 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 at

g...@github.com:foss-for-synopsys-dwc-arc-processors/glibc.git  
arc-glibc-post-v5

v5:
   * Big Endian formally supported as multi-ABI
   * Removed code for ARC700 processors
   * Hard-float code updates: fegetmode, fesetround, feupdateenv
   * socket-constant.h update for 64-bit ABI spun off as standalone patch
   * __syscall_error made glibc_private
   * math ulps regen
   * gmp-mparam.h removed
   * lint fixes as flagged by Joseph
v4:
   * Dropped 1/17: Merged upstream
   * Dropped 17/17:
   - 64-bit time/offset code chunked up into respective patches
   * sysctl removed
   * Updated README for arc gnu triplet
   * Updated install files for ARC gcc/binutils requirements
   * Updated NEWS with brief ISA/ABI info

v3:
   * Support for Hardware Floating Point
   * 64-bit time and offsets ABI (although all such changes are confined
 to a single patch)

v4: https://sourceware.org/pipermail/libc-alpha/2020-March/111855.html
v3: https://sourceware.org/legacy-ml/libc-alpha/2020-03/msg00167.html
v2: https://sourceware.org/legacy-ml/libc-alpha/2019-01/msg00681.html
v1: https://sourceware.org/legacy-ml/libc-alpha/2018-12/msg00678.html

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:
| 33 FAIL
|
| FAIL: csu/test-as-const-tcb-offsets
| FAIL: elf/tst-ldconfig-ld_so_conf-update # not true: dlopen
| FAIL: iconv/test-iconvconfig  # Needs gconv installed
| FAIL: iconv/tst-gconv-init-failure
| FAIL: io/ftwtest  # Requires execution by non-root
| FAIL: io/tst-futimesat
| FAIL: io/tst-lockf
| FAIL: libio/tst-wfile-sync
| FAIL: locale/tst-C-locale
| FAIL: locale/tst-duplocale
| FAIL: locale/tst-locale-locpath
| FAIL: locale/tst-locname
| FAIL: localedata/sort-test
| 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-umask1 # passes if run natively on target (NFS 
ACLv3 support needed)
| FAIL: nss/bug-erange
| 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: resolv/tst-resolv-basic
| FAIL: resolv/tst-resolv-edns
| FAIL: resolv/tst-resolv-rotate
| FAIL: resolv/tst-resolv-search
| 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 (14):
  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
  Documentation for ARC port

 NEWS  |9 +
 README|1 +
 config.h.in   |3 +
 manual/install.texi   |5 +
 scripts/build-many-glibcs.py  |   10 +
 sysdeps/arc/Implies   |3 +
 sysdeps/arc/Makefile  |   21 +
 sysdeps/arc/Versions  |8 +
 sysdeps/arc/__longjmp.S   |   50 +
 sysdeps/arc/abort-instr.h |2 +
 sysdeps/arc/atomic-machine.h  |   69 +
 sysdeps/arc/bits/endianness.h |   15 +
 sysdeps/arc/bits/fenv.h   |   77 +
 sysdeps/arc/bits/link.h   

[PATCH v5 10/14] ARC: ABI lists

2020-04-08 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/fpu/libm-test-ulps| 1140 +
 sysdeps/arc/fpu/libm-test-ulps-name   |1 +
 sysdeps/arc/nofpu/libm-test-ulps  |  270 +++
 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  | 2081 +
 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 +
 18 files changed, 4669 insertions(+)
 create mode 100644 sysdeps/arc/fpu/libm-test-ulps
 create mode 100644 sysdeps/arc/fpu/libm-test-ulps-name
 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/fpu/libm-test-ulps b/sysdeps/arc/fpu/libm-test-ulps
new file mode 100644
index ..00262925b75b
--- /dev/null
+++ b/sysdeps/arc/fpu/libm-test-ulps
@@ -0,0 +1,1140 @@
+# Begin of automatic generation
+
+# Maximal error of functions:
+Function: "acos":
+double: 1
+float: 1
+
+Function: "acos_downward":
+double: 1
+float: 1
+
+Function: "acos_towardzero":
+double: 1
+float: 1
+
+Function: "acos_upward":
+double: 1
+float: 1
+
+Function: "acosh":
+double: 3
+float: 2
+
+Function: "acosh_downward":
+double: 2
+float: 2
+
+Function: "acosh_towardzero":
+double: 2
+float: 2
+
+Function: "acosh_upward":
+double: 3
+float: 3
+
+Function: "asin":
+double: 1
+float: 1
+
+Function: "asin_downward":
+double: 1
+float: 1
+
+Function: "asin_towardzero":
+double: 1
+float: 1
+
+Function: "asin_upward":
+double: 1
+float: 1
+
+Function: "asinh":
+double: 3
+float: 2
+
+Function: "asinh_downward":
+double: 3
+float: 3
+
+Function: "asinh_towardzero":
+double: 2
+float: 2
+
+Function: "asinh_upward":
+double: 3
+float: 3
+
+Function: "atan":
+double: 1
+float: 1
+
+Function: "atan2":
+double: 7
+float: 2
+
+Function: "atan2_downward":
+double: 5
+float: 2
+
+Function: "atan2_towardzero":
+double: 5
+float: 2
+
+Function: "atan2_upward":
+double: 8
+float: 2
+
+Function: "atan_downward":
+double: 1
+float: 2
+
+Function: "atan_towardzero":
+double: 1
+float: 1
+
+Function: "atan_upward":
+double: 2
+float: 2
+
+Function: "atanh":
+double: 2
+float: 2
+
+Function: "atanh_downward":
+double: 3
+float: 3
+
+Function: "atanh_towardzero":
+double: 2
+float: 2
+
+Function: "atanh_upward":
+double: 3
+float: 3
+
+Function: "cabs":
+double: 1
+float: 1
+
+Function: "cabs_downward":
+double: 1
+
+Function: "cabs_towardzero":
+double: 1
+
+Function: "cabs_upward":
+double: 2
+float: 1
+
+Function: Real part of "cacos":
+double: 2
+float: 2
+
+Function: Imaginary part of "cacos":
+double: 5
+float: 3
+
+Function: Real part of "cacos_downward":
+double: 3
+float: 2
+
+Function: Imaginary part of "cacos_downward":
+double: 5
+float: 3
+
+Function: Real part of "cacos_towardzero":
+double: 3
+float: 2
+
+Function: Imaginary part of "cacos_towardzero":
+double: 4
+float: 2
+
+Function: Real part of "cacos_upward":
+double: 2
+float: 3
+
+Function: Imaginary part of "cacos_upward":
+double: 5
+float: 5
+
+Function: Real part of "cacosh":
+double: 5
+float: 4
+
+Function: Imaginary part of "cacosh":
+double: 2
+float: 2
+
+Function: Real part of "cacosh_downward":
+double: 4
+float: 2
+
+Function: Imaginary part of "cacosh_downward":
+double: 3
+float: 3
+
+Function: Real part of "cacosh_towardzero":
+double: 4
+float: 2
+
+Function: Imaginary part of "cacosh_towardzero":
+double: 3
+float: 2
+
+Function: Real part of 

Re: [PATCH V2 0/3] mm/debug: Add more arch page table helper tests

2020-04-08 Thread Anshuman Khandual


On 04/08/2020 05:45 PM, Gerald Schaefer wrote:
> On Wed, 8 Apr 2020 12:41:51 +0530
> Anshuman Khandual  wrote:
> 
> [...]
>>>   

 Some thing like this instead.

 pte_t pte = READ_ONCE(*ptep);
 pte = pte_mkhuge(__pte((pte_val(pte) | RANDOM_ORVALUE) & PMD_MASK));

 We cannot use mk_pte_phys() as it is defined only on some platforms
 without any generic fallback for others.  
>>>
>>> Oh, didn't know that, sorry. What about using mk_pte() instead, at least
>>> it would result in a present pte:
>>>
>>> pte = pte_mkhuge(mk_pte(phys_to_page(RANDOM_ORVALUE & PMD_MASK), prot));  
>>
>> Lets use mk_pte() here but can we do this instead
>>
>> paddr = (__pfn_to_phys(pfn) | RANDOM_ORVALUE) & PMD_MASK;
>> pte = pte_mkhuge(mk_pte(phys_to_page(paddr), prot));
>>
> 
> Sure, that will also work.
> 
> BTW, this RANDOM_ORVALUE is not really very random, the way it is
> defined. For s390 we already changed it to mask out some arch bits,
> but I guess there are other archs and bits that would always be
> set with this "not so random" value, and I wonder if/how that would
> affect all the tests using this value, see also below.

RANDOM_ORVALUE is a constant which was added in order to make sure
that the page table entries should have some non-zero value before
getting called with pxx_clear() and followed by a pxx_none() check.
This is currently used only in pxx_clear_tests() tests. Hence there
is no impact for the existing tests.

> 
>>>
>>> And if you also want to do some with the existing value, which seems
>>> to be an empty pte, then maybe just check if writing and reading that
>>> value with set_huge_pte_at() / huge_ptep_get() returns the same,
>>> i.e. initially w/o RANDOM_ORVALUE.
>>>
>>> So, in combination, like this (BTW, why is the barrier() needed, it
>>> is not used for the other set_huge_pte_at() calls later?):  
>>
>> Ahh missed, will add them. Earlier we faced problem without it after
>> set_pte_at() for a test on powerpc (64) platform. Hence just added it
>> here to be extra careful.
>>
>>>
>>> @@ -733,24 +733,28 @@ static void __init hugetlb_advanced_test
>>> struct page *page = pfn_to_page(pfn);
>>> pte_t pte = READ_ONCE(*ptep);
>>>  
>>> -   pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
>>> +   set_huge_pte_at(mm, vaddr, ptep, pte);
>>> +   WARN_ON(!pte_same(pte, huge_ptep_get(ptep)));
>>> +
>>> +   pte = pte_mkhuge(mk_pte(phys_to_page(RANDOM_ORVALUE & PMD_MASK), 
>>> prot));
>>> set_huge_pte_at(mm, vaddr, ptep, pte);
>>> barrier();
>>> WARN_ON(!pte_same(pte, huge_ptep_get(ptep)));
>>>
>>> This would actually add a new test "write empty pte with
>>> set_huge_pte_at(), then verify with huge_ptep_get()", which happens
>>> to trigger a warning on s390 :-)  
>>
>> On arm64 as well which checks for pte_present() in set_huge_pte_at().
>> But PTE present check is not really present in each set_huge_pte_at()
>> implementation especially without __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT.
>> Hence wondering if we should add this new test here which will keep
>> giving warnings on s390 and arm64 (at the least).
> 
> Hmm, interesting. I forgot about huge swap / migration, which is not
> (and probably cannot be) supported on s390. The pte_present() check
> on arm64 seems to check for such huge swap / migration entries,
> according to the comment.
> 
> The new test "write empty pte with set_huge_pte_at(), then verify
> with huge_ptep_get()" would then probably trigger the
> WARN_ON(!pte_present(pte)) in arm64 code. So I guess "writing empty
> ptes with set_huge_pte_at()" is not really a valid use case in practice,
> or else you would have seen this warning before. In that case, it
> might not be a good idea to add this test.

Got it.

> 
> I also do wonder now, why the original test with
> "pte = __pte(pte_val(pte) | RANDOM_ORVALUE);"
> did not also trigger that warning on arm64. On s390 this test failed
> exactly because the constructed pte was not present (initially empty,
> or'ing RANDOM_ORVALUE does not make it present for s390). I guess this
> just worked by chance on arm64, because the bits from RANDOM_ORVALUE
> also happened to mark the pte present for arm64.

That is correct. RANDOM_ORVALUE has got PTE_PROT_NONE bit set that makes
the PTE test for pte_present().

On arm64 platform,

#define pte_present(pte)  (!!(pte_val(pte) & (PTE_VALID | PTE_PROT_NONE)))

> 
> This brings us back to the question above, regarding the "randomness"
> of RANDOM_ORVALUE. Not really sure what the intention behind that was,
> but maybe it would make sense to restrict this RANDOM_ORVALUE to
> non-arch-specific bits, i.e. only bits that would be part of the
> address value within a page table entry? Or was it intentionally
> chosen to also mess with other bits?

As mentioned before, RANDOM_ORVALUE just helped make a given page table
entry contain non-zero values before getting cleared. AFAICS we should
not need RANDOM_ORVALUE for HugeTLB test here. I believe 

Re: [PATCH] [ARC] Allow more ABIs in GLIBC_DYNAMIC_LINKER

2020-04-08 Thread Vineet Gupta
Hi Claudiu,

For glibc needs can this be backported to gcc-9 please !

Thx,
-Vineet

On 3/31/20 3:06 AM, Claudiu Zissulescu Ianculescu wrote:
> Pushed.
>
> Thank you,
> Claudiu
>
> On Sun, Mar 29, 2020 at 2:05 AM Vineet Gupta via Gcc-patches
>  wrote:
>> Enable big-endian suffixed dynamic linker per glibc multi-abi support.
>>
>> And to avoid a future churn and version pairingi hassles, also allow
>> arc700 although glibc for ARC currently doesn't support it.
>>
>> gcc/
>> -xx-xx  Vineet Gupta 
>> +
>> +   * config/arc/linux.h: GLIBC_DYNAMIC_LINKER support BE/arc700
>>
>> Signed-off-by: Vineet Gupta 
>> ---
>>  gcc/ChangeLog  | 4 
>>  gcc/config/arc/linux.h | 2 +-
>>  2 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
>> index 86ad683a6cb0..c26a748fd51b 100644
>> --- a/gcc/ChangeLog
>> +++ b/gcc/ChangeLog
>> @@ -1,3 +1,7 @@
>> +2020-03-28  Vineet Gupta 
>> +
>> +   * config/arc/linux.h: GLIBC_DYNAMIC_LINKER support BE/arc700
>> +
>>  2020-03-28  Jakub Jelinek  
>>
>> PR c/93573
>> diff --git a/gcc/config/arc/linux.h b/gcc/config/arc/linux.h
>> index 0b99da3fcdaf..1bbeccee7115 100644
>> --- a/gcc/config/arc/linux.h
>> +++ b/gcc/config/arc/linux.h
>> @@ -29,7 +29,7 @@ along with GCC; see the file COPYING3.  If not see
>>  }  \
>>while (0)
>>
>> -#define GLIBC_DYNAMIC_LINKER   "/lib/ld-linux-arc.so.2"
>> +#define GLIBC_DYNAMIC_LINKER   
>> "/lib/ld-linux-arc%{mbig-endian:eb}%{mcpu=arc700:700}.so.2"
>>  #define UCLIBC_DYNAMIC_LINKER  "/lib/ld-uClibc.so.0"
>>
>>  /* Note that the default is to link against dynamic libraries, if they are
>> --
>> 2.20.1
>>
> ___
> linux-snps-arc mailing list
> linux-snps-arc@lists.infradead.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.infradead.org_mailman_listinfo_linux-2Dsnps-2Darc=DwICAg=DPL6_X_6JkXFx7AXWqB0tg=7FgpX6o3vAhwMrMhLh-4ZJey5kjdNUwOL2CWsFwR4T8=MrObyH2ki95_7m_xHpnWX-k9eIMOsxMuSa48qhxYOCY=3ggbGwaiJuSFnFECy0ItuwBBMDAcriwCdSc3GA0UFig=
>  

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


Re: [PATCH V2 0/3] mm/debug: Add more arch page table helper tests

2020-04-08 Thread Gerald Schaefer
On Wed, 8 Apr 2020 12:41:51 +0530
Anshuman Khandual  wrote:

[...]
> >   
> >>
> >> Some thing like this instead.
> >>
> >> pte_t pte = READ_ONCE(*ptep);
> >> pte = pte_mkhuge(__pte((pte_val(pte) | RANDOM_ORVALUE) & PMD_MASK));
> >>
> >> We cannot use mk_pte_phys() as it is defined only on some platforms
> >> without any generic fallback for others.  
> > 
> > Oh, didn't know that, sorry. What about using mk_pte() instead, at least
> > it would result in a present pte:
> > 
> > pte = pte_mkhuge(mk_pte(phys_to_page(RANDOM_ORVALUE & PMD_MASK), prot));  
> 
> Lets use mk_pte() here but can we do this instead
> 
> paddr = (__pfn_to_phys(pfn) | RANDOM_ORVALUE) & PMD_MASK;
> pte = pte_mkhuge(mk_pte(phys_to_page(paddr), prot));
> 

Sure, that will also work.

BTW, this RANDOM_ORVALUE is not really very random, the way it is
defined. For s390 we already changed it to mask out some arch bits,
but I guess there are other archs and bits that would always be
set with this "not so random" value, and I wonder if/how that would
affect all the tests using this value, see also below.

> > 
> > And if you also want to do some with the existing value, which seems
> > to be an empty pte, then maybe just check if writing and reading that
> > value with set_huge_pte_at() / huge_ptep_get() returns the same,
> > i.e. initially w/o RANDOM_ORVALUE.
> > 
> > So, in combination, like this (BTW, why is the barrier() needed, it
> > is not used for the other set_huge_pte_at() calls later?):  
> 
> Ahh missed, will add them. Earlier we faced problem without it after
> set_pte_at() for a test on powerpc (64) platform. Hence just added it
> here to be extra careful.
> 
> > 
> > @@ -733,24 +733,28 @@ static void __init hugetlb_advanced_test
> > struct page *page = pfn_to_page(pfn);
> > pte_t pte = READ_ONCE(*ptep);
> >  
> > -   pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
> > +   set_huge_pte_at(mm, vaddr, ptep, pte);
> > +   WARN_ON(!pte_same(pte, huge_ptep_get(ptep)));
> > +
> > +   pte = pte_mkhuge(mk_pte(phys_to_page(RANDOM_ORVALUE & PMD_MASK), 
> > prot));
> > set_huge_pte_at(mm, vaddr, ptep, pte);
> > barrier();
> > WARN_ON(!pte_same(pte, huge_ptep_get(ptep)));
> > 
> > This would actually add a new test "write empty pte with
> > set_huge_pte_at(), then verify with huge_ptep_get()", which happens
> > to trigger a warning on s390 :-)  
> 
> On arm64 as well which checks for pte_present() in set_huge_pte_at().
> But PTE present check is not really present in each set_huge_pte_at()
> implementation especially without __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT.
> Hence wondering if we should add this new test here which will keep
> giving warnings on s390 and arm64 (at the least).

Hmm, interesting. I forgot about huge swap / migration, which is not
(and probably cannot be) supported on s390. The pte_present() check
on arm64 seems to check for such huge swap / migration entries,
according to the comment.

The new test "write empty pte with set_huge_pte_at(), then verify
with huge_ptep_get()" would then probably trigger the
WARN_ON(!pte_present(pte)) in arm64 code. So I guess "writing empty
ptes with set_huge_pte_at()" is not really a valid use case in practice,
or else you would have seen this warning before. In that case, it
might not be a good idea to add this test.

I also do wonder now, why the original test with
"pte = __pte(pte_val(pte) | RANDOM_ORVALUE);"
did not also trigger that warning on arm64. On s390 this test failed
exactly because the constructed pte was not present (initially empty,
or'ing RANDOM_ORVALUE does not make it present for s390). I guess this
just worked by chance on arm64, because the bits from RANDOM_ORVALUE
also happened to mark the pte present for arm64.

This brings us back to the question above, regarding the "randomness"
of RANDOM_ORVALUE. Not really sure what the intention behind that was,
but maybe it would make sense to restrict this RANDOM_ORVALUE to
non-arch-specific bits, i.e. only bits that would be part of the
address value within a page table entry? Or was it intentionally
chosen to also mess with other bits?

Regards,
Gerald


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


Re: [PATCH V2 0/3] mm/debug: Add more arch page table helper tests

2020-04-08 Thread Anshuman Khandual


On 04/07/2020 09:24 PM, Gerald Schaefer wrote:
> On Sun, 5 Apr 2020 17:58:14 +0530
> Anshuman Khandual  wrote:
> 
> [...]
>>>
>>> Could be fixed like this (the first de-reference is a bit special,
>>> because at that point *ptep does not really point to a large (pmd) entry
>>> yet, it is initially an invalid pte entry, which breaks our huge_ptep_get() 
>>>  
>>
>> There seems to be an inconsistency on s390 platform. Even though it defines
>> a huge_ptep_get() override, it does not subscribe __HAVE_ARCH_HUGE_PTEP_GET
>> which should have forced it fallback on generic huge_ptep_get() but it does
>> not :) Then I realized that __HAVE_ARCH_HUGE_PTEP_GET only makes sense when
>> an arch uses . s390 does not use that and hence gets
>> away with it's own huge_ptep_get() without __HAVE_ARCH_HUGE_PTEP_GET. Sounds
>> confusing ? But I might not have the entire context here.
> 
> Yes, that sounds very confusing. Also a bit ironic, since huge_ptep_get()
> was initially introduced because of s390, and now we don't select
> __HAVE_ARCH_HUGE_PTEP_GET...
> 
> As you realized, I guess this is because we do not use generic hugetlb.h.
> And when __HAVE_ARCH_HUGE_PTEP_GET was introduced with commit 544db7597ad
> ("hugetlb: introduce generic version of huge_ptep_get"), that was probably
> the reason why we did not get our share of __HAVE_ARCH_HUGE_PTEP_GET.

Understood.

> 
> Nothing really wrong with that, but yes, very confusing. Maybe we could
> also select it for s390, even though it wouldn't have any functional
> impact (so far), just for less confusion. Maybe also thinking about
> using the generic hugetlb.h, not sure if the original reasons for not
> doing so would still apply. Now I only need to find the time...

Seems like something worth to explore if we could remove this confusion.

> 
>>
>>> conversion logic. I also added PMD_MASK alignment for RANDOM_ORVALUE,
>>> because we do have some special bits there in our large pmds. It seems
>>> to also work w/o that alignment, but it feels a bit wrong):  
>>
>> Sure, we can accommodate that.
>>
>>>
>>> @@ -731,26 +731,26 @@ static void __init hugetlb_advanced_test
>>>   unsigned long vaddr, pgprot_t 
>>> prot)
>>>  {
>>> struct page *page = pfn_to_page(pfn);
>>> -   pte_t pte = READ_ONCE(*ptep);
>>> +   pte_t pte;
>>>
>>> -   pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
>>> +   pte = pte_mkhuge(mk_pte_phys(RANDOM_ORVALUE & PMD_MASK, prot));  
>>
>> So that keeps the existing value in 'ptep' pointer at bay and instead
>> construct a PTE from scratch. I would rather have READ_ONCE(*ptep) at
>> least provide the seed that can be ORed with RANDOM_ORVALUE before
>> being masked with PMD_MASK. Do you see any problem ?
> 
> Yes, unfortunately. The problem is that the resulting pte is not marked
> as present. The conversion pte -> (huge) pmd, which is done in
> set_huge_pte_at() for s390, will establish an empty pmd for non-present
> ptes, all the RANDOM_ORVALUE stuff is lost. And a subsequent
> huge_ptep_get() will not result in the same original pte value. If you

Ohh.

> want to preserve and check the RANDOM_ORVALUE, it has to be a present
> pte, hence the mk_pte(_phys).

Understood and mk_pte() is also available on all platforms.

> 
>>
>> Some thing like this instead.
>>
>> pte_t pte = READ_ONCE(*ptep);
>> pte = pte_mkhuge(__pte((pte_val(pte) | RANDOM_ORVALUE) & PMD_MASK));
>>
>> We cannot use mk_pte_phys() as it is defined only on some platforms
>> without any generic fallback for others.
> 
> Oh, didn't know that, sorry. What about using mk_pte() instead, at least
> it would result in a present pte:
> 
> pte = pte_mkhuge(mk_pte(phys_to_page(RANDOM_ORVALUE & PMD_MASK), prot));

Lets use mk_pte() here but can we do this instead

paddr = (__pfn_to_phys(pfn) | RANDOM_ORVALUE) & PMD_MASK;
pte = pte_mkhuge(mk_pte(phys_to_page(paddr), prot));

> 
> And if you also want to do some with the existing value, which seems
> to be an empty pte, then maybe just check if writing and reading that
> value with set_huge_pte_at() / huge_ptep_get() returns the same,
> i.e. initially w/o RANDOM_ORVALUE.
> 
> So, in combination, like this (BTW, why is the barrier() needed, it
> is not used for the other set_huge_pte_at() calls later?):

Ahh missed, will add them. Earlier we faced problem without it after
set_pte_at() for a test on powerpc (64) platform. Hence just added it
here to be extra careful.

> 
> @@ -733,24 +733,28 @@ static void __init hugetlb_advanced_test
> struct page *page = pfn_to_page(pfn);
> pte_t pte = READ_ONCE(*ptep);
>  
> -   pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
> +   set_huge_pte_at(mm, vaddr, ptep, pte);
> +   WARN_ON(!pte_same(pte, huge_ptep_get(ptep)));
> +
> +   pte = pte_mkhuge(mk_pte(phys_to_page(RANDOM_ORVALUE & PMD_MASK), 
> prot));
> set_huge_pte_at(mm, vaddr, ptep, pte);
> barrier();
> WARN_ON(!pte_same(pte, huge_ptep_get(ptep)));
> 
>