From ebdb6f237772df251378d2c08350d345135bcb9e Mon Sep 17 00:00:00 2001 From: Richard Earnshaw Date: Thu, 23 Aug 2018 09:47:34 +0000 Subject: PR target/86951 arm - Handle speculation barriers on pre-armv7 CPUs The AArch32 instruction sets prior to Armv7 do not define the ISB and DSB instructions that are needed to form a speculation barrier. While I do not know of any instances of cores based on those instruction sets being vulnerable to speculative side channel attacks it is possible to run code built for those ISAs on more recent hardware where they would become vulnerable. This patch works around this by using a library call added to libgcc. That code can then take any platform-specific actions necessary to ensure safety. For the moment I've only handled two cases: the library code being built for armv7 or later anyway and running on Linux. On Linux we can handle this by calling the kernel function that will flush a small amount of cache. Such a sequence ends with a ISB+DSB sequence if running on an Armv7 or later CPU. gcc: PR target/86951 * config/arm/arm-protos.h (arm_emit_speculation_barrier): New prototype. * config/arm/arm.c (speculation_barrier_libfunc): New static variable. (arm_init_libfuncs): Initialize it. (arm_emit_speculation_barrier): New function. * config/arm/arm.md (speculation_barrier): Call arm_emit_speculation_barrier for architectures that do not have DSB or ISB. (speculation_barrier_insn): Only match on Armv7 or later. libgcc: PR target/86951 * config/arm/lib1funcs.asm (speculation_barrier): New function. * config/arm/t-arm (LIB1ASMFUNCS): Add it to list of functions to build. From-SVN: r263806 --- libgcc/ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libgcc/ChangeLog') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index d003fd54c6e..280bd102868 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,10 @@ +2018-08-23 Richard Earnshaw + + PR target/86951 + * config/arm/lib1funcs.asm (speculation_barrier): New function. + * config/arm/t-arm (LIB1ASMFUNCS): Add it to list of functions + to build. + 2018-08-22 Iain Sandoe * config/unwind-dw2-fde-darwin.c -- cgit v1.2.3