Skip to content

Lock Validation Layout Types

include/sync/lock_chk_types.h View source View on GitHub
struct lock_chk_map (3 fields) source
§ const struct lock_chk_class *class
§ struct lock_chk_class instance_class
§ atomic(struct lock_chk_node *) base_node
struct lock_chk_lock (8 fields) source
§ struct lock_chk_map map
§ void *instance
§ enum lock_chk_type type : 4
§ enum lock_chk_flags flags : 4
§ bool initialized : 1
§ bool manages_irql : 1
§ bool raw_operation : 1
struct lock_chk_id (3 fields) source
§ void *instance
§ enum lock_chk_type type
§ enum lock_chk_flags flags
struct lock_chk_held (10 fields) source
§ struct lock_chk_node *node
§ struct lock_chk_id lock
§ const struct lock_chk_site *acquire_site
§ uint64_t acquire_tsc
§ enum irql prev_irql
§ uint16_t cpu
TODO

We use this to represent CPU due to size, cpu_id_t is a size_t

§ enum lock_chk_mode mode
§ enum lock_subclass subclass
§ bool trylock
§ bool raw_operation
struct lock_chk_thread_data (4 fields) source
§ struct lock_chk_held held[LOCK_CHK_MAX_HELD_LOCKS]
§ uint8_t depth
§ uint8_t thread_checked_depth
§ uint8_t thread_checked_spin_depth
struct lock_chk_acq_req (10 fields) source
§ struct lock_chk_map *map
§ struct lock_chk_id lock
§ const struct lock_chk_site *site
§ enum lock_chk_mode mode
§ enum irql prev_irql
§ enum lock_subclass subclass
§ enum lock_op_flags op_flags
§ bool irqs_enabled : 1
§ bool in_irq : 1
§ bool in_nmi : 1
struct lock_chk_acq_token (5 fields) source
§ struct lock_chk_node *node
§ struct lock_chk_node *context_node
§ const struct lock_chk_acq_req *request
§ struct lock_chk_thread_data *thread_data
§ bool active
struct lock_chk_rel_req (4 fields) source
§ struct lock_chk_map *map
§ struct lock_chk_id lock
§ const struct lock_chk_site *site
§ enum lock_chk_mode mode
struct lock_chk_rel_token (4 fields) source
§ struct lock_chk_thread_data *thread_data
§ void *instance
§ uint8_t held_index
§ bool active
enum lock_chk_context_bits : uint8_t (4 variants) source
§ LOCK_CHK_CTX_IRQ = 1 << 0
§ LOCK_CHK_CTX_SPIN_DISPATCH = 1 << 1
§ LOCK_CHK_CTX_SPIN_HIGH = 1 << 2
§ LOCK_CHK_CTX_RAW_OPERATION = 1 << 3
struct lock_chk_id lock_chk_id_of(const struct lock_chk_lock *lock)
source
void lock_chk_before_acq(
    struct lock_chk_acq_token *token,
    const struct lock_chk_acq_req *request
)
source
void lock_chk_acqd(struct lock_chk_acq_token *token)
source
void lock_chk_cancel(struct lock_chk_acq_token *token)
source
void lock_chk_before_rel(
    struct lock_chk_rel_token *token,
    const struct lock_chk_rel_req *request
)
source
void lock_chk_reld(struct lock_chk_rel_token *token)
source
bool lock_chk_assert_held_deep(
    struct lock_chk_lock *lock,
    enum lock_chk_mode mode,
    bool want_held,
    const struct lock_chk_site *site
)
source

LOCK_CHK_ASSERT_HELD/NOT_HELD and whatnot use this, which returns true if the engine could evaluate the assertion, and otherwise will return false, and panic if a violation is found

void lock_chk_map_runtime_init(
    struct lock_chk_map *map,
    const struct lock_chk_class *class
)
source
struct lock_chk_acq_req lock_chk_acq_req_make(
    struct lock_chk_lock *lock,
    const struct lock_chk_site *site,
    enum lock_chk_mode mode,
    enum lock_subclass subclass,
    enum lock_op_flags flags
)
source
struct lock_chk_rel_req lock_chk_rel_req_make(
    struct lock_chk_lock *lock,
    const struct lock_chk_site *site,
    enum lock_chk_mode mode
)
source
#define LOCK_CHK_MAX_NODES 1024
source
#define LOCK_CHK_MAX_EDGES 8192
source
#define LOCK_CHK_HASH_BUCKETS 1024
source
#define LOCK_CHK_MAX_HELD_LOCKS 32
source
#define LOCK_CHK_MAX_SPIN_DEPTH 32
source
#define LOCK_CHK_MAX_SUBCLASSES 8
source
#define LOCK_CHK_MODE_STATE_COUNT (LOCK_CHK_MAX_NODES * 2)
source
#define LOCK_CHK_MAP_VALUE_INIT(class_)
source
Expansion
#define LOCK_CHK_MAP_VALUE_INIT(class_) \
    ((struct lock_chk_map) { \
        .class = (class_), \
        .instance_class = \
            { \
                .name = "<instance>", \
                .file = __RELFILE__, \
                .line = __LINE__, \
            }, \
        .base_node = ATOMIC_VAR_INIT(NULL), \
    })
#define LOCK_CHK_LOCK_VALUE_INIT(class_, flags_)
source
Expansion
#define LOCK_CHK_LOCK_VALUE_INIT(class_, flags_) \
    ((struct lock_chk_lock) { \
        .flags = (flags_), \
        .initialized = true, \
        .used = ATOMIC_VAR_INIT(false), \
        .map = LOCK_CHK_MAP_VALUE_INIT(class_), \
    })