Skip to content

Commit 99101dd

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Make build-time check of RES0/RES1 bits optional
In order to ease the transition towards a state of absolute paranoia where all RES0/RES1 bits gets checked against what KVM know of them, make the checks optional and guarded by a config symbol (CONFIG_KVM_ARM64_RES_BITS_PARANOIA) default to n. Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/kvm/[email protected]/ Signed-off-by: Oliver Upton <[email protected]>
1 parent 8917665 commit 99101dd

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

arch/arm64/kvm/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,15 @@ config PROTECTED_NVHE_STACKTRACE
6767

6868
If unsure, or not using protected nVHE (pKVM), say N.
6969

70+
config KVM_ARM64_RES_BITS_PARANOIA
71+
bool "Build-time check of RES0/RES1 bits"
72+
depends on KVM
73+
default n
74+
help
75+
Say Y here to validate that KVM's knowledge of most system
76+
registers' RES0/RES1 bits matches when the rest of the kernel
77+
defines. Expect the build to fail badly if you enable this.
78+
79+
Just say N.
80+
7081
endif # VIRTUALIZATION

arch/arm64/kvm/check-res-bits.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
static inline void check_res_bits(void)
2323
{
24+
#ifdef CONFIG_KVM_ARM64_RES_BITS_PARANOIA
25+
2426
BUILD_BUG_ON(OSDTRRX_EL1_RES0 != (GENMASK_ULL(63, 32)));
2527
BUILD_BUG_ON(MDCCINT_EL1_RES0 != (GENMASK_ULL(63, 31) | GENMASK_ULL(28, 0)));
2628
BUILD_BUG_ON(MDSCR_EL1_RES0 != (GENMASK_ULL(63, 36) | GENMASK_ULL(28, 28) | GENMASK_ULL(25, 24) | GENMASK_ULL(20, 20) | GENMASK_ULL(18, 16) | GENMASK_ULL(11, 7) | GENMASK_ULL(5, 1)));
@@ -118,4 +120,6 @@ static inline void check_res_bits(void)
118120
BUILD_BUG_ON(TRBMAR_EL1_RES0 != (GENMASK_ULL(63, 12)));
119121
BUILD_BUG_ON(TRBTRG_EL1_RES0 != (GENMASK_ULL(63, 32)));
120122
BUILD_BUG_ON(TRBIDR_EL1_RES0 != (GENMASK_ULL(63, 12) | GENMASK_ULL(7, 6)));
123+
124+
#endif
121125
}

0 commit comments

Comments
 (0)