Skip to content

Commit 69bb058

Browse files
mrutland-armwilldeacon
authored andcommitted
arm64: insn: avoid circular include dependency
Nathan reports that when building with CONFIG_LTO_CLANG_THIN=y, the build fails due to BUILD_BUG_ON() not being defined before its uss in <asm/insn.h>. The problem is that with LTO, we patch READ_ONCE(), and <asm/rwonce.h> includes <asm/insn.h>, creating a circular include chain: <linux/build_bug.h> <linux/compiler.h> <asm/rwonce.h> <asm/alternative-macros.h> <asm/insn.h> <linux/build-bug.h> ... and so when <asm/insn.h> includes <linux/build_bug.h>, none of the BUILD_BUG* definitions have happened yet. To avoid this, let's move AARCH64_INSN_SIZE into a header without any dependencies, such that it can always be safely included. At the same time, avoid including <asm/alternative.h> in <asm/insn.h>, which should no longer be necessary (and doesn't make sense when insn.h is consumed by userspace). Reported-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20210621080830.GA37068@C02TD0UTHF1T.local Fixes: 3e00e39 ("arm64: insn: move AARCH64_INSN_SIZE into <asm/insn.h>") Signed-off-by: Will Deacon <will@kernel.org>
1 parent 3e00e39 commit 69bb058

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

arch/arm64/include/asm/alternative-macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define __ASM_ALTERNATIVE_MACROS_H
44

55
#include <asm/cpucaps.h>
6-
#include <asm/insn.h>
6+
#include <asm/insn-def.h>
77

88
#define ARM64_CB_PATCH ARM64_NCAPS
99

arch/arm64/include/asm/insn-def.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
3+
#ifndef __ASM_INSN_DEF_H
4+
#define __ASM_INSN_DEF_H
5+
6+
/* A64 instructions are always 32 bits. */
7+
#define AARCH64_INSN_SIZE 4
8+
9+
#endif /* __ASM_INSN_DEF_H */

arch/arm64/include/asm/insn.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
#include <linux/build_bug.h>
1111
#include <linux/types.h>
1212

13-
#include <asm/alternative.h>
14-
15-
/* A64 instructions are always 32 bits. */
16-
#define AARCH64_INSN_SIZE 4
13+
#include <asm/insn-def.h>
1714

1815
#ifndef __ASSEMBLY__
1916
/*

0 commit comments

Comments
 (0)