Skip to content

Commit af2cd26

Browse files
committed
compiler-capability-analysis: Add infrastructure for Clang's capability analysis
Capability analysis is a C language extension, which enables statically checking that user-definable "capabilities" are acquired and released where required. An obvious application is lock-safety checking for the kernel's various synchronization primitives (each of which represents a "capability"), and checking that locking rules are not violated. Clang originally called the feature "Thread Safety Analysis" [1], with some terminology still using the thread-safety-analysis-only names. This was later changed and the feature became more flexible, gaining the ability to define custom "capabilities". Its foundations can be found in "capability systems", used to specify the permissibility of operations to depend on some capability being held (or not held). [1] https://clang.llvm.org/docs/ThreadSafetyAnalysis.html [2] https://www.cs.cornell.edu/talc/papers/capabilities.pdf Because the feature is not just able to express capabilities related to synchronization primitives, the naming chosen for the kernel departs from Clang's initial "Thread Safety" nomenclature and refers to the feature as "Capability Analysis" to avoid confusion. The implementation still makes references to the older terminology in some places, such as `-Wthread-safety` being the warning enabled option that also still appears in diagnostic messages. See more details in the kernel-doc documentation added in this and the subsequent changes. A Clang version that supports -Wthread-safety-addressof is recommended, but not required: llvm/llvm-project#123063 Signed-off-by: Marco Elver <[email protected]>
1 parent 4d2076f commit af2cd26

File tree

5 files changed

+423
-7
lines changed

5 files changed

+423
-7
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,7 @@ include-$(CONFIG_KCOV) += scripts/Makefile.kcov
10821082
include-$(CONFIG_RANDSTRUCT) += scripts/Makefile.randstruct
10831083
include-$(CONFIG_AUTOFDO_CLANG) += scripts/Makefile.autofdo
10841084
include-$(CONFIG_PROPELLER_CLANG) += scripts/Makefile.propeller
1085+
include-$(CONFIG_WARN_CAPABILITY_ANALYSIS) += scripts/Makefile.capability-analysis
10851086
include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
10861087

10871088
include $(addprefix $(srctree)/, $(include-y))

0 commit comments

Comments
 (0)