1 #include <linux/list.h>
3 #include "ksplice-patch.h"
12 LIST_HEAD(shadow_list
);
13 DEFINE_SPINLOCK(shadow_lock
);
15 int init_shadow_field_type(int *shadow_key
, typeof(GFP_KERNEL
) gfp_flags
)
20 void *init_shadow_field(int *shadow_key
, void *obj
, int size
,
21 typeof(GFP_KERNEL
) gfp_flags
)
23 struct shadow_field
*shadow
= kmalloc(sizeof(*shadow
), gfp_flags
);
27 shadow
->key
= shadow_key
;
28 shadow
->data
= kmalloc(size
, gfp_flags
);
29 if (shadow
->data
== NULL
) {
33 spin_lock(&shadow_lock
);
34 list_add(&shadow
->list
, &shadow_list
);
35 spin_unlock(&shadow_lock
);
39 void cleanup_shadow_field(int *shadow_key
, void *obj
)
41 struct shadow_field
*shadow
;
42 spin_lock(&shadow_lock
);
43 list_for_each_entry(shadow
, &shadow_list
, list
) {
44 if (shadow
->obj
== obj
&& shadow
->key
== shadow_key
) {
45 list_del(&shadow
->list
);
52 spin_unlock(&shadow_lock
);
55 void *get_shadow_field(int *shadow_key
, void *obj
)
57 struct shadow_field
*shadow
;
59 spin_lock(&shadow_lock
);
60 list_for_each_entry(shadow
, &shadow_list
, list
) {
61 if (shadow
->obj
== obj
&& shadow
->key
== shadow_key
) {
67 spin_unlock(&shadow_lock
);
71 void cleanup_shadow_field_type(int *shadow_key
)
73 struct shadow_field
*shadow
, *n
;
74 spin_lock(&shadow_lock
);
75 list_for_each_entry_safe(shadow
, n
, &shadow_list
, list
) {
76 if (shadow
->key
== shadow_key
) {
77 list_del(&shadow
->list
);
82 spin_unlock(&shadow_lock
);