ARC fixes/updates
cover ARC fixes/updates
Hi,
A couple of updates for ARC.
Thx,
-Vineet
Vineet Gupta (2):
ARC: fp: (micro)optimize FPU_STATUS read by eliding FWE bit clearing
ARC: elf: make type safe
sysdeps/arc/dl-machine.h | 23 ++++++++++------------- sysdeps/arc/fpu_control.h | 15 +++++++-------- 2 files changed, 17 insertions(+), 21 deletions(-)
Signature · 7 lines
2.25.1 _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
PATCH 1/2 ARC: fp: (micro)optimize FPU_STATUS read by eliding FWE bit clearing
Any FPU_STATUS write needs setting the FWE bit (31) whcih just provides a "control signal" to enable explicit write (vs. the side-effect of FPU instructions). However this bit is RAZ and write-only, thus effectively never stored in FPU_STATUS register. Thus when reading the register there is no need to clear it. This shaves off a BCLR instruction from the fe*exceptino family of functions and while no big deal still makes sense to do.
This came up when debugging a race in math/test-fenv-tls [1]
[1]: https://github.com/foss-for-synopsys-dwc-arc-processors/linux/issues/54
--- sysdeps/arc/fpu_control.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
sysdeps/arc/fpu_control.h +7 -8
@@ -81,21 +81,20 @@ typedef unsigned int fpu_control_t;# define _FPU_SETCW (cw) __asm__ volatile ("sr %0, [0x300]" : : "r" (cw))/* Macros for accessing the hardware status word. -FWE bit is special as it controls if actual status bits could be wrritten -explicitly (other than FPU instructions). We handle it here to keep the -callers agnostic of it: -- clear it out when reporting status bits -- always set it when changing status bits. */ +Writing to FPU_STATUS requires a "control" bit FWE to be able to set the +exception flags directly (as opposed to side-effects of FP instructions). +That is done in the macro here to keeps callers agnostic of this detail. +And given FWE is write-only and RAZ, no need to "clear" it in _FPU_GETS +macro. */ # define _FPU_GETS (cw) \ __asm__ volatile ("lr %0, [0x301] \r\n" \ - "bclr %0, %0, 31 \r\n" \ : "=r" (cw))# define _FPU_SETS (cw) \ do { \ - unsigned int __tmp = 0x80000000 | (cw); \ + unsigned int __fwe = 0x80000000 | (cw); \ __asm__ volatile ("sr %0, [0x301] \r\n" \ - : : "r" (__tmp)); \ + : : "r" (__fwe)); \ } while (0)/* Default control word set at startup. */
Signature · 7 lines
2.25.1 _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH 1/2] ARC: fp: (micro)optimize FPU_STATUS read by eliding FWE bit clearing
Quoted 8 lines · Vineet Gupta via Libc-alpha
Any
FPU_STATUSwrite needs setting the FWE bit (31) whcih just provides a "control signal" to enable explicit write (vs. the side-effect of FPU instructions). However this bit is RAZ and write-only, thus effectively never stored inFPU_STATUSregister. Thus when reading the register there is no need to clear it. This shaves off a BCLR instruction from the fe*exceptino family of functions and while no big deal still makes sense to do.
Quoted 5 lines
This came up when debugging a race in math/test-fenv-tls [1]
[1]: https://github.com/foss-for-synopsys-dwc-arc-processors/linux/issues/54
Signed-off-by Vineet Gupta <[email protected]>
Committed !
Quoted 28 lines
--- sysdeps/arc/fpu_control.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)sysdeps/arc/fpu_control.h +5
-6@@ -81,21 +81,20 @@ typedef unsigned int fpu_control_t;# define _FPU_SETCW (cw) __asm__ volatile ("sr %0, [0x300]" : : "r" (cw))/* Macros for accessing the hardware status word. -FWE bit is special as it controls if actual status bits could be wrritten -explicitly (other than FPU instructions). We handle it here to keep the -callers agnostic of it: -- clear it out when reporting status bits -- always set it when changing status bits. */ +Writing to FPU_STATUS requires a "control" bit FWE to be able to set the +exception flags directly (as opposed to side-effects of FP instructions). +That is done in the macro here to keeps callers agnostic of this detail. +And given FWE is write-only and RAZ, no need to "clear" it in _FPU_GETS +macro. */ # define _FPU_GETS (cw) \ __asm__ volatile ("lr %0, [0x301] \r\n" \ - "bclr %0, %0, 31 \r\n" \ : "=r" (cw))
sysdeps/arc/fpu_control.h typedef unsigned int fpu_control_t; · line 100
Quoted 10 lines
sysdeps/arc/fpu_control.h +2
-2# define _FPU_SETS (cw) \ do { \ - unsigned int __tmp = 0x80000000 | (cw); \ + unsigned int __fwe = 0x80000000 | (cw); \ __asm__ volatile ("sr %0, [0x301] \r\n" \ - : : "r" (__tmp)); \ + : : "r" (__fwe)); \ } while (0)/* Default control word set at startup. */
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
PATCH 2/2 ARC: elf: make type safe
In reply to Vineet Gupta--- sysdeps/arc/dl-machine.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
sysdeps/arc/dl-machine.h +10 -13
@@ -86,7 +86,7 @@/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (const Elf32_Ehdr *ehdr) +elf_machine_matches_host (const ElfW (Ehdr) *ehdr) {return (ehdr->e_machine ==EM_ARCV2 /* ARC HS. */ || ehdr->e_machine ==EM_ARC_COMPACT );/* ARC 700. */
@@ -124,7 +124,7 @@ static inline int __attribute__ ((always_inline)) elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) { - extern void _dl_runtime_resolve (Elf32_Word); + extern void _dl_runtime_resolve (void);if (l->l_info[DT_JMPREL ] && lazy) {
@@ -202,7 +202,7 @@ __start: \n\/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ #define ELF_MACHINE_JMP_SLOT R_ARC_JUMP_SLOT -/* ARC uses Elf32_Rela relocations. */ +/* ARC uses Rela relocations. */ #define ELF_MACHINE_NO_REL 1#define ELF_MACHINE_NO_RELA 0
@@ -211,19 +211,14 @@ __start: \n\static inline ElfW (Addr)elf_machine_fixup_plt (struct link_map *map,lookup_t t,const ElfW (Sym) *refsym,const ElfW (Sym) *sym, -const Elf32_Rela *reloc, +const ElfW (Rela) *reloc,ElfW (Addr) *reloc_addr,ElfW (Addr) value) {return *reloc_addr = value; }/* Return the final value of a plt relocation. */ -static inline ElfW (Addr) -elf_machine_plt_value (struct link_map *map,const Elf32_Rela *reloc, -ElfW (Addr) value) -{ -return value; -} +#define elf_machine_plt_value (map, reloc, value) (value)/* Names of the architecture-specific auditing callback functions. */ #define ARCH_LA_PLTENTER arc_gnu_pltenter
@@ -239,8 +234,9 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, const ElfW(Sym) *sym, const struct r_found_version *version, void *const reloc_addr_arg, int skip_ifunc) { +ElfW (Addr ) r_info = reloc->r_info; +const unsigned long int r_type =ELFW (R_TYPE ) (r_info);ElfW (Addr) *const reloc_addr = reloc_addr_arg; -const unsigned int r_type =ELF32_R_TYPE (reloc->r_info);if (__glibc_unlikely (r_type ==R_ARC_RELATIVE )) *reloc_addr += map->l_addr;
@@ -334,11 +330,12 @@ elf_machine_lazy_rel (struct link_map *map, ElfW(Addr) l_addr, const ElfW(Rela) *reloc, int skip_ifunc) { ElfW(Addr) *const reloc_addr = (void *) (l_addr + reloc->r_offset); +const unsigned int r_type =ELFW (R_TYPE ) (reloc->r_info); -if (ELF32_R_TYPE (reloc->r_info) ==R_ARC_JUMP_SLOT ) +if (r_type ==R_ARC_JUMP_SLOT ) *reloc_addr += l_addr;else -_dl_reloc_bad_type (map,ELF32_R_TYPE (reloc->r_info),1 ); +_dl_reloc_bad_type (map, r_type,1 ); }#endif /* RESOLVE_MAP */
Signature · 7 lines
2.25.1 _______________________________________________ linux-snps-arc mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH 2/2] ARC: elf: make type safe
Quoted 1 line · Vineet Gupta via Libc-alpha
Signed-off-by Vineet Gupta <[email protected]>
Committed !
Quoted 74 lines
--- sysdeps/arc/dl-machine.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)sysdeps/arc/dl-machine.h +8
-11@@ -86,7 +86,7 @@/* Return nonzero iff ELF header is compatible with the running host. */ static inline int -elf_machine_matches_host (const Elf32_Ehdr *ehdr) +elf_machine_matches_host (const ElfW (Ehdr) *ehdr) {return (ehdr->e_machine ==EM_ARCV2 /* ARC HS. */ || ehdr->e_machine ==EM_ARC_COMPACT );/* ARC 700. */ @@ -124,7 +124,7 @@ static inline int __attribute__ ((always_inline)) elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) { - extern void _dl_runtime_resolve (Elf32_Word); + extern void _dl_runtime_resolve (void);if (l->l_info[DT_JMPREL ] && lazy) {@@ -202,7 +202,7 @@ __start: \n\/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ #define ELF_MACHINE_JMP_SLOT R_ARC_JUMP_SLOT -/* ARC uses Elf32_Rela relocations. */ +/* ARC uses Rela relocations. */ #define ELF_MACHINE_NO_REL 1#define ELF_MACHINE_NO_RELA 0@@ -211,19 +211,14 @@ __start: \n\static inline ElfW (Addr)elf_machine_fixup_plt (struct link_map *map,lookup_t t,const ElfW (Sym) *refsym,const ElfW (Sym) *sym, -const Elf32_Rela *reloc, +const ElfW (Rela) *reloc,ElfW (Addr) *reloc_addr,ElfW (Addr) value) {return *reloc_addr = value; }/* Return the final value of a plt relocation. */ -static inline ElfW (Addr) -elf_machine_plt_value (struct link_map *map,const Elf32_Rela *reloc, -ElfW (Addr) value) -{ -return value; -} +#define elf_machine_plt_value (map, reloc, value) (value)/* Names of the architecture-specific auditing callback functions. */ #define ARCH_LA_PLTENTER arc_gnu_pltenter@@ -239,8 +234,9 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, const ElfW(Sym) *sym, const struct r_found_version *version, void *const reloc_addr_arg, int skip_ifunc) { +ElfW (Addr ) r_info = reloc->r_info; +const unsigned long int r_type =ELFW (R_TYPE ) (r_info);ElfW (Addr) *const reloc_addr = reloc_addr_arg; -const unsigned int r_type =ELF32_R_TYPE (reloc->r_info);if (__glibc_unlikely (r_type ==R_ARC_RELATIVE )) *reloc_addr += map->l_addr;@@ -334,11 +330,12 @@ elf_machine_lazy_rel (struct link_map *map, ElfW(Addr) l_addr, const ElfW(Rela) *reloc, int skip_ifunc) { ElfW(Addr) *const reloc_addr = (void *) (l_addr + reloc->r_offset); +const unsigned int r_type =ELFW (R_TYPE ) (reloc->r_info);
sysdeps/arc/dl-machine.h elf_machine_lazy_rel (struct link_map *map, ElfW(Addr) l_addr, · line 341
Quoted 10 lines
sysdeps/arc/dl-machine.h +2
-2-if (ELF32_R_TYPE (reloc->r_info) ==R_ARC_JUMP_SLOT ) +if (r_type ==R_ARC_JUMP_SLOT ) *reloc_addr += l_addr;else - _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1); + _dl_reloc_bad_type (map, r_type, 1); }#endif /* RESOLVE_MAP */
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc