arm: vdso: inline assembler operations to compiler.h
PATCH v3 3/12 arm: vdso: inline assembler operations to compiler.h
Move compiler-specific code to a local compiler.h file. CONFIG_AEABI dependency check. System call fallback functions standardized into a DEFINE_FALLBACK macro. Accept that __arch_counter_get_cntvct() is the API for aarch64. Deal with unresolved references emitted by GCC. Optimize handling of fallback calls. Most notably add unlikely nullptr checking to __vdso_gettimeofday, if tv null no need to proceed to fallback, as vdso is capable of filling in the tv values. For time functions that always return success, do not waste time checking return value for switch to fallback.
v2:
- split first CL into 3 of 7 pieces
v3:
- rebase (unchanged)
--- arch/arm/vdso/compiler.h | 69 ++++++++++++++++++++++++++ arch/arm/vdso/vgettimeofday.c | 109 +++++++++++------------------------------- 2 files changed, 96 insertions(+), 82 deletions(-) create mode 100644 arch/arm/vdso/compiler.h
arch/arm/vdso/compiler.h new file +69 -0
@@ -0,0 +1,69 @@ +/* +* Userspace implementations of fallback calls +* +* Copyright (C) 2017 Cavium, Inc. +* Copyright (C) 2012 ARM Limited +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +* Author: Will Deacon <[email protected]> +* Rewriten into C by: Andrew Pinski <[email protected]> +*/ + +#ifndef __VDSO_COMPILER_H +#define __VDSO_COMPILER_H + +#include <asm/arch_timer.h> +#include <asm/processor.h> +#include <asm/unistd.h> +#include <linux/compiler.h> + +#ifndef CONFIG_AEABI +#error This code depends on AEABI system call conventions +#endif + +#define DEFINE_FALLBACK (name, type_arg1, name_arg1, type_arg2, name_arg2) \ +static notrace long name##_fallback(type_arg1 _##name_arg1, \ + type_arg2 _##name_arg2) \ +{ \ + register type_arg1 name_arg1 asm("r0") = _##name_arg1; \ + register type_arg2 name_arg2 asm("r1") = _##name_arg2; \ + register long ret asm ("r0"); \ + register long nr asm("r7") = __NR_##name; \ + \ + asm volatile( \ + " swi #0\n" \ + : "=r" (ret) \ + : "r" (name_arg1), "r" (name_arg2), "r" (nr) \ + : "memory"); \ + \ + return ret; \ +} + +#define __arch_counter_get_cntvct () arch_counter_get_cntvct() + +/* Avoid unresolved references emitted by GCC */ + +void __aeabi_unwind_cpp_pr0 (void ) +{ +} + +void __aeabi_unwind_cpp_pr1 (void ) +{ +} + +void __aeabi_unwind_cpp_pr2 (void ) +{ +} + +#endif /* __VDSO_COMPILER_H */
arch/arm/vdso/vgettimeofday.c +27 -82
163 lines not on this page · raw message
Signature · 1 line
2.15.0.rc2.357.g7e34df9404-goog
Hi,
Quoted 4 lines · Mark Salyzyn
Move compiler-specific code to a local
compiler.hfile.CONFIG_AEABIdependency check. System call fallback functions standardized into aDEFINE_FALLBACKmacro. Accept that__arch_counter_get_cntvct()is the API for aarch64.
This reads like a stream-of-conciousness, and it's difficult to figure out which bits are intent and which bits are simply a summary of the diff.
It would be really helpful to have a sentence or two at the start explaining the high level idea, and why things must change.
For instance, it's really not clear to me what you mean by:
Accept that __arch_counter_get_cntvct() is the API for aarch64.
... and whether using a #define for this is the best approach.
Quoted 1 line
From a scan of v4.14-rc7, there is no
__arch_counter_get_cntvct()in the
tree, so I'm very confused here.
[...]
arch/arm/vdso/compiler.h static notrace u64 get_ns(const struct vdso_data *vd) · line 108
Quoted 8 lines
arch/arm/vdso/compiler.h new file +2
-1+#define __arch_counter_get_cntvct () arch_counter_get_cntvct()@@ -127,7 +105,7 @@ static notrace u64 get_ns(const struct vdso_data *vd)u64 cycle_now;u64 nsec; - cycle_now =arch_counter_get_cntvct (); + cycle_now =__arch_counter_get_cntvct ();
... and it's difficult to see what the point of these changes is.
Thanks,
Mark.