Skip to content

Commit a78d156

Browse files
author
Russell King
committed
ARM: spectre-v1: add speculation barrier (csdb) macros
Add assembly and C macros for the new CSDB instruction. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Acked-by: Mark Rutland <mark.rutland@arm.com> Boot-tested-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Tony Lindgren <tony@atomide.com>
1 parent add5609 commit a78d156

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎arch/arm/include/asm/assembler.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,14 @@ THUMB( orr \reg , \reg , #PSR_T_BIT )
447447
.size \name , . - \name
448448
.endm
449449

450+
.macro csdb
451+
#ifdef CONFIG_THUMB2_KERNEL
452+
.inst.w 0xf3af8014
453+
#else
454+
.inst 0xe320f014
455+
#endif
456+
.endm
457+
450458
.macro check_uaccess, addr:req, size:req, limit:req, tmp:req, bad:req
451459
#ifndef CONFIG_CPU_USE_DOMAINS
452460
adds \tmp, \addr, #\size - 1

‎arch/arm/include/asm/barrier.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
#define isb(option) __asm__ __volatile__ ("isb " #option : : : "memory")
1818
#define dsb(option) __asm__ __volatile__ ("dsb " #option : : : "memory")
1919
#define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
20+
#ifdef CONFIG_THUMB2_KERNEL
21+
#define CSDB ".inst.w 0xf3af8014"
22+
#else
23+
#define CSDB ".inst 0xe320f014"
24+
#endif
25+
#define csdb() __asm__ __volatile__(CSDB : : : "memory")
2026
#elif defined(CONFIG_CPU_XSC3) || __LINUX_ARM_ARCH__ == 6
2127
#define isb(x) __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
2228
: : "r" (0) : "memory")
@@ -37,6 +43,13 @@
3743
#define dmb(x) __asm__ __volatile__ ("" : : : "memory")
3844
#endif
3945

46+
#ifndef CSDB
47+
#define CSDB
48+
#endif
49+
#ifndef csdb
50+
#define csdb()
51+
#endif
52+
4053
#ifdef CONFIG_ARM_HEAVY_MB
4154
extern void (*soc_mb)(void);
4255
extern void arm_heavy_mb(void);

0 commit comments

Comments
 (0)