Lines Matching refs:shadow

3  * shadow.c - Shadow Variables
13 * The shadow variable API provides a simple relationship between an
15 * caller to provide any mutual exclusion required of the shadow data.
17 * Once a shadow variable is attached to its parent object via the
19 * call to klp_shadow_get() may then return the shadow variable's data
20 * pointer. Callers of klp_shadow_*alloc() should prepare shadow data
23 * The klp_shadow_*alloc() API calls may allocate memory for new shadow
42 * the shadow variables it references.
47 * struct klp_shadow - shadow variable structure
63 * klp_shadow_match() - verify a shadow variable matches given <obj, id>
64 * @shadow: shadow variable to match
68 * Return: true if the shadow variable matches.
70 static inline bool klp_shadow_match(struct klp_shadow *shadow, void *obj,
73 return shadow->obj == obj && shadow->id == id;
77 * klp_shadow_get() - retrieve a shadow variable data pointer
81 * Return: the shadow variable data element, NULL on failure.
85 struct klp_shadow *shadow;
89 hash_for_each_possible_rcu(klp_shadow_hash, shadow, node,
92 if (klp_shadow_match(shadow, obj, id)) {
94 return shadow->data;
113 /* Check if the shadow variable already exists */
119 * Allocate a new shadow variable. Fill it with zeroes by default.
150 pr_err("Failed to construct shadow variable <%p, %lx> (%d)\n",
165 WARN(1, "Duplicate shadow variable <%p, %lx>\n", obj, id);
173 * klp_shadow_alloc() - allocate and add a new shadow variable
178 * @ctor: custom constructor to initialize the shadow data (optional)
181 * Allocates @size bytes for new shadow variable data using @gfp_flags.
183 * function if it is not NULL. The new shadow variable is then added
186 * If an existing <obj, id> shadow variable can be found, this routine will
193 * Return: the shadow variable data element, NULL on duplicate or
206 * klp_shadow_get_or_alloc() - get existing or allocate a new shadow variable
211 * @ctor: custom constructor to initialize the shadow data (optional)
214 * Returns a pointer to existing shadow data if an <obj, id> shadow
215 * variable is already present. Otherwise, it creates a new shadow
218 * This function guarantees that only one shadow variable exists with the given
223 * Return: the shadow variable data element, NULL on failure.
234 static void klp_shadow_free_struct(struct klp_shadow *shadow,
237 hash_del_rcu(&shadow->node);
239 dtor(shadow->obj, shadow->data);
240 kfree_rcu(shadow, rcu_head);
244 * klp_shadow_free() - detach and free a <obj, id> shadow variable
248 * and/or free data that the shadow variable points to (optional)
250 * This function releases the memory for this <obj, id> shadow variable
255 struct klp_shadow *shadow;
261 hash_for_each_possible(klp_shadow_hash, shadow, node,
264 if (klp_shadow_match(shadow, obj, id)) {
265 klp_shadow_free_struct(shadow, dtor);
275 * klp_shadow_free_all() - detach and free all <_, id> shadow variables
278 * and/or free data that the shadow variable points to (optional)
280 * This function releases the memory for all <_, id> shadow variable
285 struct klp_shadow *shadow;
292 hash_for_each(klp_shadow_hash, i, shadow, node) {
293 if (klp_shadow_match(shadow, shadow->obj, id))
294 klp_shadow_free_struct(shadow, dtor);