*/
#include <linux/kasan.h>
+#include <linux/mm.h>
#include <linux/scs.h>
#include <linux/slab.h>
+#include <linux/vmstat.h>
#include <asm/scs.h>
static struct kmem_cache *scs_cache;
scs_cache = kmem_cache_create("scs_cache", SCS_SIZE, 0, 0, NULL);
}
+static struct page *__scs_page(struct task_struct *tsk)
+{
+ return virt_to_page(task_scs(tsk));
+}
+
+static void scs_account(struct task_struct *tsk, int account)
+{
+ mod_zone_page_state(page_zone(__scs_page(tsk)), NR_KERNEL_SCS_KB,
+ account * (SCS_SIZE / 1024));
+}
+
int scs_prepare(struct task_struct *tsk, int node)
{
void *s = scs_alloc(node);
task_scs(tsk) = s;
task_scs_offset(tsk) = 0;
+ scs_account(tsk, 1);
return 0;
}
return;
WARN(scs_corrupted(tsk), "corrupted shadow stack detected when freeing task\n");
+ scs_account(tsk, -1);
scs_free(s);
}