Re: [PATCH 04/21] mm: free_area_init: use maximal zone PFNs rather than zone sizes

2020-06-15 Thread Greg Ungerer

Hi Mike,

On 15/6/20 4:22 pm, Mike Rapoport wrote:

On Mon, Jun 15, 2020 at 01:53:42PM +1000, Greg Ungerer wrote:

From: Mike Rapoport 

Currently, architectures that use free_area_init() to initialize memory map
and node and zone structures need to calculate zone and hole sizes. We can
use free_area_init_nodes() instead and let it detect the zone boundaries
while the architectures will only have to supply the possible limits for
the zones.

Signed-off-by: Mike Rapoport 


This is causing some new warnings for me on boot on at least one non-MMU m68k 
target:


There were a couple of changes that cause this. The free_area_init()
now relies on memblock data and architectural limits for zone sizes
rather than on explisit pfns calculated by the arch code. I've update
motorola variant and missed coldfire. Angelo sent a fix for mcfmmu.c
[1] and I've updated it to include nommu as well

[1] 
https://lore.kernel.org/linux-m68k/20200614225119.02-1-angelo.dureghe...@timesys.com


From 55b8523df2a5c4565b132c0691990f0821040fec Mon Sep 17 00:00:00 2001

From: Angelo Dureghello 
Date: Mon, 15 Jun 2020 00:51:19 +0200
Subject: [PATCH] m68k: fix registration of memory regions with memblock

Commit 3f08a302f533 ("mm: remove CONFIG_HAVE_MEMBLOCK_NODE_MAP option")
introduced assumption that UMA systems have their memory at node 0 and
updated most of them, but it forgot nommu and coldfire variants of m68k.

The later change in free area initialization in commit fa3354e4ea39 ("mm:
free_area_init: use maximal zone PFNs rather than zone sizes") exposed that
and caused a lot of "BUG: Bad page state in process swapper" reports.


Even with this patch applied I am still seeing the same messages.

Regards
Greg




Using memblock_add_node() with nid = 0 to register memory banks solves the
problem.

Fixes: 3f08a302f533 ("mm: remove CONFIG_HAVE_MEMBLOCK_NODE_MAP option")
Fixes: fa3354e4ea39 ("mm: free_area_init: use maximal zone PFNs rather than zone 
sizes")
Signed-off-by: Angelo Dureghello 
Co-developed-by: Mike Rapoport 
Signed-off-by: Mike Rapoport 
---
  arch/m68k/kernel/setup_no.c | 2 +-
  arch/m68k/mm/mcfmmu.c   | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c
index e779b19e0193..0c4589a39ba9 100644
--- a/arch/m68k/kernel/setup_no.c
+++ b/arch/m68k/kernel/setup_no.c
@@ -138,7 +138,7 @@ void __init setup_arch(char **cmdline_p)
pr_debug("MEMORY -> ROMFS=0x%p-0x%06lx MEM=0x%06lx-0x%06lx\n ",
 __bss_stop, memory_start, memory_start, memory_end);
  
-	memblock_add(memory_start, memory_end - memory_start);

+   memblock_add_node(memory_start, memory_end - memory_start, 0);
  
  	/* Keep a copy of command line */

*cmdline_p = &command_line[0];
diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c
index 29f47923aa46..7d04210d34f0 100644
--- a/arch/m68k/mm/mcfmmu.c
+++ b/arch/m68k/mm/mcfmmu.c
@@ -174,7 +174,7 @@ void __init cf_bootmem_alloc(void)
m68k_memory[0].addr = _rambase;
m68k_memory[0].size = _ramend - _rambase;
  
-	memblock_add(m68k_memory[0].addr, m68k_memory[0].size);

+   memblock_add_node(m68k_memory[0].addr, m68k_memory[0].size, 0);
  
  	/* compute total pages in system */

num_pages = PFN_DOWN(_ramend - _rambase);



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


Re: [PATCH v2] ieee754/dbl-64: Reduce the scope of temporary storage variables

2020-06-15 Thread Vineet Gupta
On 6/4/20 12:08 PM, Vineet Gupta via Libc-alpha wrote:
> On 6/2/20 1:31 PM, Vineet Gupta via Libc-alpha wrote:
>> On 6/2/20 11:16 AM, Joseph Myers wrote:
>>> On Mon, 1 Jun 2020, Vineet Gupta via Libc-alpha wrote:
>>>
 Also as suggested by Joseph [1] used --strip and compared the libs with
 and w/o patch and their sizes are exactly same (with gcc 9).
>>>
>>> My suggestion was to compare the *contents* of the libraries, not just 
>>> their sizes.  Either they should be byte-for-byte identical, or if there 
>>> are other differences (register allocation, line numbers in assertions, 
>>> etc.) a more detailed investigation will be needed.
>>>
>>
>> Here's my diff of the 2 --strip builds
>>
>> for i in `find . -name libm-2.31.9000.so`; do echo $i; diff $i
>> /SCRATCH/vgupta/gnu2/install/glibcs/$i ; echo $?; done
>>
>> ./aarch64-linux-gnu/lib64/libm-2.31.9000.so
>> 0
>> ./arm-linux-gnueabi/lib/libm-2.31.9000.so
>> 0
>> ./x86_64-linux-gnu/lib64/libm-2.31.9000.so
>> 0
>> ./arm-linux-gnueabihf/lib/libm-2.31.9000.so
>> 0
>> ./riscv64-linux-gnu-rv64imac-lp64/lib64/lp64/libm-2.31.9000.so
>> 0
>> ./riscv64-linux-gnu-rv64imafdc-lp64/lib64/lp64/libm-2.31.9000.so
>> 0
>> ./powerpc-linux-gnu/lib/libm-2.31.9000.so
>> 0
>> ./microblaze-linux-gnu/lib/libm-2.31.9000.so
>> 0
>> ./nios2-linux-gnu/lib/libm-2.31.9000.so
>> 0
>> ./hppa-linux-gnu/lib/libm-2.31.9000.so
>> 0
>> ./s390x-linux-gnu/lib64/libm-2.31.9000.so
>> 0
> 
> Is this sufficient for comparison ?

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


Re: [PATCH v2] ieee754/dbl-64: Reduce the scope of temporary storage variables

2020-06-15 Thread Adhemerval Zanella



On 15/06/2020 16:09, Vineet Gupta via Libc-alpha wrote:
> On 6/4/20 12:08 PM, Vineet Gupta via Libc-alpha wrote:
>> On 6/2/20 1:31 PM, Vineet Gupta via Libc-alpha wrote:
>>> On 6/2/20 11:16 AM, Joseph Myers wrote:
 On Mon, 1 Jun 2020, Vineet Gupta via Libc-alpha wrote:

> Also as suggested by Joseph [1] used --strip and compared the libs with
> and w/o patch and their sizes are exactly same (with gcc 9).

 My suggestion was to compare the *contents* of the libraries, not just 
 their sizes.  Either they should be byte-for-byte identical, or if there 
 are other differences (register allocation, line numbers in assertions, 
 etc.) a more detailed investigation will be needed.

>>>
>>> Here's my diff of the 2 --strip builds
>>>
>>> for i in `find . -name libm-2.31.9000.so`; do echo $i; diff $i
>>> /SCRATCH/vgupta/gnu2/install/glibcs/$i ; echo $?; done
>>>
>>> ./aarch64-linux-gnu/lib64/libm-2.31.9000.so
>>> 0
>>> ./arm-linux-gnueabi/lib/libm-2.31.9000.so
>>> 0
>>> ./x86_64-linux-gnu/lib64/libm-2.31.9000.so
>>> 0
>>> ./arm-linux-gnueabihf/lib/libm-2.31.9000.so
>>> 0
>>> ./riscv64-linux-gnu-rv64imac-lp64/lib64/lp64/libm-2.31.9000.so
>>> 0
>>> ./riscv64-linux-gnu-rv64imafdc-lp64/lib64/lp64/libm-2.31.9000.so
>>> 0
>>> ./powerpc-linux-gnu/lib/libm-2.31.9000.so
>>> 0
>>> ./microblaze-linux-gnu/lib/libm-2.31.9000.so
>>> 0
>>> ./nios2-linux-gnu/lib/libm-2.31.9000.so
>>> 0
>>> ./hppa-linux-gnu/lib/libm-2.31.9000.so
>>> 0
>>> ./s390x-linux-gnu/lib64/libm-2.31.9000.so
>>> 0
>>
>> Is this sufficient for comparison ?
> 
> ping !
> 

This analysis looks good me, although I can't voucher for Joseph.

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


Re: [PATCH v2] ieee754/dbl-64: Reduce the scope of temporary storage variables

2020-06-15 Thread Joseph Myers
On Mon, 15 Jun 2020, Adhemerval Zanella wrote:

> >> Is this sufficient for comparison ?
> > 
> > ping !
> > 
> 
> This analysis looks good me, although I can't voucher for Joseph.

This patch is OK.

-- 
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] ieee754/dbl-64: Reduce the scope of temporary storage variables

2020-06-15 Thread Vineet Gupta
On 6/15/20 12:53 PM, Joseph Myers wrote:
>> This analysis looks good me, although I can't voucher for Joseph.
> This patch is OK.

Pushed. Thx !

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


[PATCH v7 04/13] ARC: Atomics and Locking primitives

2020-06-15 Thread Vineet Gupta
---
 sysdeps/arc/atomic-machine.h | 69 
 1 file changed, 69 insertions(+)
 create mode 100644 sysdeps/arc/atomic-machine.h

diff --git a/sysdeps/arc/atomic-machine.h b/sysdeps/arc/atomic-machine.h
new file mode 100644
index ..1c8638bb44ef
--- /dev/null
+++ b/sysdeps/arc/atomic-machine.h
@@ -0,0 +1,69 @@
+/* Low-level functions for atomic operations. ARC version.
+   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 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 */
-- 
2.20.1


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


[PATCH v7 13/13] Documentation for ARC port

2020-06-15 Thread Vineet Gupta
---
 NEWS| 11 +++
 README  |  1 +
 manual/install.texi |  4 
 3 files changed, 16 insertions(+)

diff --git a/NEWS b/NEWS
index a660fc59a89e..db65fea8b6ec 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,17 @@ Major new features:
 
 * New locale added: ckb_IQ (Kurdish/Sorani spoken in Iraq)
 
+* Support for Synopsys ARC HS cores (ARCv2 ISA) running Linux has been
+  added. This port requires at least binutils-2.32, gcc-8.3 and Linux-5.1.
+  Three ABIs are supported:
+
+ - arc-linux-gnu
+ - arc-linux-gnuhf
+ - arceb-linux-gnu
+
+  The arc* ABI is little-endian while arceb is big-endian. All ABIs use
+  64-bit time (y2038 safe) and 64-bit file offsets (LFS default).
+
 * The GNU C Library now loads audit modules listed in the DT_AUDIT and
   DT_DEPAUDIT dynamic section entries of the main executable.
 
diff --git a/README b/README
index 31c5da0405bd..903f07e4840a 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 c1e49a94fed3..74cb90a91331 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -522,6 +522,8 @@ Library with support for IEEE long double.
 @c powerpc64le performs an autoconf test to verify the compiler compiles with
 @c commands like "$CC -c foo.c -mabi=ibmlongdouble -mlong-double-128".
 
+For ARC architecture builds, GCC 8.3 or higher is needed.
+
 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
@@ -547,6 +549,8 @@ For PowerPC 64-bits little-endian (powerpc64le), 
@command{objcopy} is required
 to support @option{--update-section}.  This option requires binutils 2.26 or
 newer.
 
+ARC architecture needs @code{binutils} 2.32 or higher 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 v7 01/13] ARC: ABI Implementation

2020-06-15 Thread Vineet Gupta
This code deals with the ARC ABI.
---
 sysdeps/arc/__longjmp.S   | 49 
 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.h  | 42 
 sysdeps/arc/dl-sysdep.h   | 25 
 sysdeps/arc/dl-trampoline.S   | 72 +++
 sysdeps/arc/gccframe.h| 21 ++
 sysdeps/arc/jmpbuf-offsets.h  | 22 +++
 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  | 53 ++
 sysdeps/arc/tls-macros.h  | 47 +++
 17 files changed, 547 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.h
 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 ..fcbf1bb6c0e2
--- /dev/null
+++ b/sysdeps/arc/__longjmp.S
@@ -0,0 +1,49 @@
+/* longjmp for ARC.
+   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 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)
+
+   LDR (blink, r0,  0)
+   LDR (sp,r0,  1)
+   LDR (fp,r0,  2)
+   LDR (gp,r0,  3)
+
+   LDR (r13,   r0,  4)
+   LDR (r14,   r0,  5)
+   LDR (r15,   r0,  6)
+   LDR (r16,   r0,  7)
+   LDR (r17,   r0,  8)
+   LDR (r18,   r0,  9)
+   LDR (r19,   r0, 10)
+   LDR (r20,   r0, 11)
+   LDR (r21,   r0, 12)
+   LDR (r22,   r0, 13)
+   LDR (r23,   r0, 14)
+   LDR (r24,   r0, 15)
+
+   mov.f  r0, r1
+   j.d[blink]
+   mov.z  r0, 1/* don't return 0 to setjmp callsite from 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 ..6bba95fafe0f
--- /dev/null
+++ b/sysdeps/arc/bits/setjmp.h
@@ -0,0 +1,26 @@
+/* Define the machine-dependent type `jmp_buf'.  ARC version.
+   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 distribute

[PATCH v7 00/13] glibc port to ARC processors

2020-06-15 Thread Vineet Gupta
Hi,

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

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

v7:
   * Addresses review comments from Adhemerval Zanella and Florian
 Weimer (many thx to you both)
   * Dropped ARC specific semaphore.h (following upstream 1270fbaaeebe)
   * ARC specific dl-runtime.h (following upstream 8dbb7a08ec52)
   * ARC specific math-use-builtins.h and dropped ARC specific sqrt/fma
 routines (math-use-builtins.h will be disintegrated once done upstream)
   * setjmp/longjmp to save GP, no need to save r25 (thread pointer)
   * makecontext/startcontext use r14/r15 (vs. r13/r14)
   * flatten out register file in mcontext_t (remove scratch/callee)
   * Use of 'C' comments in asm code, LDR/STR macros
   * Use of L (..) in asm code
   * Dropped asm global register r25 specification for thread pointer
 and rely on __builtin_thread_pointer
   * NEWS update rewording
   * Sweeping update of Copyright year 2020
v6:
   * Dropped 11/14: merged upstream
   * _FPU_SETS() inline asm reworked
   * Introduce fixup-asm-unistd.h to elide 32-bit time, offset syscalls and
 regenerate arch-syscall.h
   * Fix snafu in updating build-many-glibcs for ARC
   * More code sytle fixes flagged by Joseph
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)

v5: https://sourceware.org/pipermail/libc-alpha/2020-April/112657.html
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:
| 30 FAIL   (-3)
|
| FAIL: csu/test-as-const-tcb-offsets
+ FAIL: elf/tst-audit14
+ FAIL: elf/tst-audit15
+ FAIL: elf/tst-audit16
| 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 (13):
  ARC: ABI Implementation
  ARC: startup and dynamic linking code
  ARC: Thr

[PATCH v7 07/13] ARC: Linux Syscall Interface

2020-06-15 Thread Vineet Gupta
---
 sysdeps/unix/sysv/linux/arc/arch-syscall.h| 303 ++
 sysdeps/unix/sysv/linux/arc/bits/timesize.h   |  21 ++
 sysdeps/unix/sysv/linux/arc/clone.S   |  93 ++
 .../unix/sysv/linux/arc/fixup-asm-unistd.h|  41 +++
 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h  |   6 +
 sysdeps/unix/sysv/linux/arc/kernel-features.h |  27 ++
 sysdeps/unix/sysv/linux/arc/kernel_stat.h |  26 ++
 sysdeps/unix/sysv/linux/arc/mmap_internal.h   |  27 ++
 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/sysdep.c  |  33 ++
 sysdeps/unix/sysv/linux/arc/sysdep.h  | 224 +
 sysdeps/unix/sysv/linux/arc/vfork.S   |  42 +++
 15 files changed, 939 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/fixup-asm-unistd.h
 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/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/unix/sysv/linux/arc/arch-syscall.h 
b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
new file mode 100644
index ..2b017eb5bbaa
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
@@ -0,0 +1,303 @@
+/* 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_adjtime64 405
+#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_fstatfs64 44
+#define __NR_fsync 82
+#define __NR_ftruncate64 46
+#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 __NR_inotify_add_watch 27
+#define __NR_inotify_init1 26
+#define __NR_inotify_rm_watch 28
+#define __NR_io_cancel 3
+#define __NR_io_destroy 1
+#define __NR_io_getevents 4
+#define __NR_io_pgetevents 292
+#define __NR_io_pgetevents_time64 416
+#define __NR_io_setup 0
+#define __NR_io

[PATCH v7 10/13] ARC: ABI lists

2020-06-15 Thread 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  | 2082 +
 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|  213 ++
 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, 4666 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 "cacosh_upward":
+double: 5
+float: 

[PATCH v7 06/13] ARC: hardware floating point support

2020-06-15 Thread Vineet Gupta
---
 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/math-use-builtins.h |  70 ++
 sysdeps/arc/fpu_control.h   | 106 
 sysdeps/arc/get-rounding-mode.h |  38 ++
 sysdeps/arc/math-tests-trap.h   |  27 +++
 sysdeps/arc/tininess.h  |   1 +
 19 files changed, 773 insertions(+)
 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/math-use-builtins.h
 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/fclrexcpt.c b/sysdeps/arc/fpu/fclrexcpt.c
new file mode 100644
index ..7653d99a008c
--- /dev/null
+++ b/sysdeps/arc/fpu/fclrexcpt.c
@@ -0,0 +1,36 @@
+/* Clear given exceptions in current floating-point environment.
+   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 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 
+
+int
+feclearexcept (int excepts)
+{
+  unsigned int fpsr;
+
+  _FPU_GETS (fpsr);
+
+  /* Clear the relevant bits, FWE is preserved.  */
+  fpsr &= ~excepts;
+
+  _FPU_SETS (fpsr);
+
+  return 0;
+}
+libm_hidden_def (feclearexcept)
diff --git a/sysdeps/arc/fpu/fegetenv.c b/sysdeps/arc/fpu/fegetenv.c
new file mode 100644
index ..bbb3b477b423
--- /dev/null
+++ b/sysdeps/arc/fpu/fegetenv.c
@@ -0,0 +1,37 @@
+/* Store current floating-point environment.
+   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 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 
+
+int
+__fegetenv (fenv_t *envp)
+{
+  unsigned int fpcr;
+  unsigned int fpsr;
+
+  _FPU_GETCW (fpcr);
+  _FPU_GETS (fpsr);
+  envp->__fpcr = fpcr;
+  envp->__fpsr = fpsr;
+
+  return 0;
+}
+libm_hidden_def (__fegetenv)
+weak_alias (__fegetenv, fegetenv)
+libm_hidden_weak (fegetenv)
diff --git a/sysdeps/arc/fpu/fegetmode.c b/sysdeps/arc/fpu/fegetmode.c
new file mode 100644
index ..f02c9119f222
--- /dev/null
+++ b/sysdeps/arc/fpu/fegetmode.c
@@ -0,0 +1,31 @@
+/* Store current floating-point control modes.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the 

[PATCH v7 03/13] ARC: Thread Local Storage support

2020-06-15 Thread Vineet Gupta
This includes all 4 TLS addressing models
---
 sysdeps/arc/dl-tls.h |  30 +++
 sysdeps/arc/libc-tls.c   |  27 ++
 sysdeps/arc/nptl/tcb-offsets.sym |  11 +++
 sysdeps/arc/nptl/tls.h   | 148 +++
 sysdeps/arc/stackinfo.h  |  33 +++
 5 files changed, 249 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 ..0f3626d197c9
--- /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) 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 ..234932c29512
--- /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) 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 ..881221e27c1a
--- /dev/null
+++ b/sysdeps/arc/nptl/tls.h
@@ -0,0 +1,148 @@
+/* Definition for thread-local data handling.  NPTL/ARC version.
+   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 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__
+# include 
+# include 
+# include 
+
+#include 
+

[PATCH v7 08/13] ARC: Linux ABI

2020-06-15 Thread 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  | 64 +
 sysdeps/unix/sysv/linux/arc/makecontext.c | 73 ++
 sysdeps/unix/sysv/linux/arc/setcontext.S  | 93 ++
 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h  | 28 ++
 sysdeps/unix/sysv/linux/arc/swapcontext.S | 94 +++
 sysdeps/unix/sysv/linux/arc/sys/cachectl.h| 35 +++
 sysdeps/unix/sysv/linux/arc/sys/ucontext.h| 57 +++
 sysdeps/unix/sysv/linux/arc/sys/user.h| 31 ++
 sysdeps/unix/sysv/linux/arc/ucontext-macros.h | 25 +
 sysdeps/unix/sysv/linux/arc/ucontext_i.sym| 20 
 13 files changed, 599 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 ..5c2b752becad
--- /dev/null
+++ b/sysdeps/arc/nptl/pthreaddef.h
@@ -0,0 +1,32 @@
+/* pthread machine parameter definitions, ARC version.
+   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 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 ..9fabca2c4747
--- /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) 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/unix/sysv/linux/arc/bits/types/__sigset_t.h
new 

[PATCH v7 12/13] build-many-glibcs.py: Enable ARC builds

2020-06-15 Thread Vineet Gupta
---
 scripts/build-many-glibcs.py | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 6c6615b200d9..64f5713530bd 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',
@@ -1224,6 +1233,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 v7 02/13] ARC: startup and dynamic linking code

2020-06-15 Thread Vineet Gupta
Code for C runtime startup and dynamic loading including PLT layout.
---
 sysdeps/arc/bits/link.h   |  52 ++
 sysdeps/arc/dl-machine.h  | 341 ++
 sysdeps/arc/entry.h   |   5 +
 sysdeps/arc/ldsodefs.h|  43 +
 sysdeps/arc/sotruss-lib.c |  50 ++
 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 ..b687250a7a07
--- /dev/null
+++ b/sysdeps/arc/bits/link.h
@@ -0,0 +1,52 @@
+/* Machine-specific declarations for dynamic linker interface, ARC version.
+   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 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 ..82940d8a701e
--- /dev/null
+++ b/sysdeps/arc/dl-machine.h
@@ -0,0 +1,341 @@
+/* Machine-dependent ELF dynamic relocation inline functions.  ARC version.
+   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 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   |  |
+  |  j.d[r12]

[PATCH v7 11/13] ARC: Build Infrastructure

2020-06-15 Thread Vineet Gupta
---
 config.h.in|   3 +
 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 +
 15 files changed, 369 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 831eca2fe14e..2ed684b7d4e4 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/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 ..d5a702e29e58
--- /dev/null
+++ b/sysdeps/arc/Makefile
@@ -0,0 +1,21 @@
+# ARC Makefile
+# 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 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 ..bce7d3c3773d
--- /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
+# 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
+
+
+# For big endian ABI, generate a symbol for selecting right dynamic linker
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long 
lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+for ac_prog in grep ggrep; do
+for ac_exec_ext in '' $ac_executable_extensions; do
+  ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+  as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if 

[PATCH v7 09/13] ARC: Linux Startup and Dynamic Loading

2020-06-15 Thread 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 ..30bcd899d42d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/dl-static.c
@@ -0,0 +1,84 @@
+/* Variable initialization.  ARC version.
+   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 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 ..204a0ff8946c
--- /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) 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 v7 05/13] ARC: math soft float support

2020-06-15 Thread Vineet Gupta
---
 sysdeps/arc/bits/fenv.h   | 78 +++
 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 | 70 
 5 files changed, 203 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 ..b375641e6248
--- /dev/null
+++ b/sysdeps/arc/bits/fenv.h
@@ -0,0 +1,78 @@
+/* Floating point environment.  ARC version.
+   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 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 ..b2a712c8c254
--- /dev/null
+++ b/sysdeps/arc/nofpu/math-tests-exceptions.h
@@ -0,0 +1,27 @@
+/* Configuration for math tests.  Exceptions support ARC version.
+   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 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 ..2f67483db20d
--- /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) 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/o

[PATCH 04/25] mm/arc: Use mm_fault_accounting()

2020-06-15 Thread Peter Xu
Use the new mm_fault_accounting() helper for page fault accounting.

The functional change here is that now we take the whole page fault as a major
fault as long as any of the retried page fault is a major fault.  Previously we
only considered the last fault.

CC: Vineet Gupta 
CC: linux-snps-arc@lists.infradead.org
Signed-off-by: Peter Xu 
---
 arch/arc/mm/fault.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index 92b339c7adba..bc89d4b9c59d 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -72,6 +72,7 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
int sig, si_code = SEGV_MAPERR;
unsigned int write = 0, exec = 0, mask;
vm_fault_t fault = VM_FAULT_SIGSEGV;/* handle_mm_fault() output */
+   vm_fault_t major = 0;
unsigned int flags; /* handle_mm_fault() input */
 
/*
@@ -132,6 +133,7 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
}
 
fault = handle_mm_fault(vma, address, flags);
+   major |= fault & VM_FAULT_MAJOR;
 
/* Quick path to respond to signals */
if (fault_signal_pending(fault, regs)) {
@@ -156,20 +158,9 @@ void do_page_fault(unsigned long address, struct pt_regs 
*regs)
 * Major/minor page fault accounting
 * (in case of retry we only land here once)
 */
-   perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
-
if (likely(!(fault & VM_FAULT_ERROR))) {
-   if (fault & VM_FAULT_MAJOR) {
-   tsk->maj_flt++;
-   perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1,
- regs, address);
-   } else {
-   tsk->min_flt++;
-   perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1,
- regs, address);
-   }
-
/* Normal return path: fault Handled Gracefully */
+   mm_fault_accounting(tsk, regs, address, major);
return;
}
 
-- 
2.26.2


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