• Home
  • Popular Downloads
  • Contact Us
  • Submit

Softpile

Free Downloads

Main Navigation
  • Home
  • Windows
  • Mac OS X
  • Business
  • Desktop
  • Development
  • Education
  • Games
  • Internet
  • Multimedia
  • Utilities
Home » Linux » Cache colouring task_struct and kernel stack

Cache colouring task_struct and kernel stack

April 8, 2008
Cache colouring task_struct and kernel stack is a patch created to cache-colours both task_struct and kernel stack.
Version: 2.5.0-0.5
License: GPL
Operating System: Linux
Homepage: www.xmailserver.org
Developed by: Davide Libenzi
Cache colouring task_struct and kernel stack is a patch created to cache-colours both task_struct and kernel stack using a slab allocator for task_struct and initial stack pointer jittering for kernel stack. An extra structure is defined for task_struct allocations as long as a new init task structure :

[include/linux/sched.h]

#define TSK_TO_KSTACK(p) (((struct full_task_struct *) (p))->stack)
#define TSK_KSTACK_TOP(p) (((struct full_task_struct *) (p))->stack_top)
#define TSK_COUNT(p) (((struct full_task_struct *) (p))->count)

struct full_task_struct {
struct task_struct task;
atomic_t count;
unsigned long stack;
unsigned long stack_top;
};

struct init_task_struct {
unsigned long stack[INIT_TASK_SIZE/sizeof(long)];
struct full_task_struct ftsk;
};

So, each pointer to a task_struct is really a full_task_struct pointer that can be used to access other fields like task stack base, task stack top and task_struct use count. The stack to task_struct iverse lookup is done by storing the pointer of the stack's owner task_struct at the base of the stack :

[arch/??/kernel/process.c]

struct task_struct *alloc_task_struct(void)
{
struct full_task_struct *f = (struct full_task_struct *) kmem_cache_alloc(tsk_cache, GFP_KERNEL);

if (!f)
return NULL;
f->stack = __get_free_pages(GFP_KERNEL, 1);
if (!f->stack) {
kmem_cache_free(tsk_cache, f);
return NULL;
}
atomic_set(&f->count, 1);
*((struct task_struct **) f->stack) = (struct task_struct *) f;
return (struct task_struct *) f;
}

The initial stack frame pointer jittering is done by :

[arch/??/kernel/process.c]

#define STACK_COLOUR_BITS 3
#define STACK_COLOUR_MASK ((1 esp = esp;

p->thread.esp = TSK_KSTACK_TOP(p) = (unsigned long) childregs;
p->thread.esp0 = (unsigned long) (childregs+1);

p->thread.eip = (unsigned long) ret_from_fork;

savesegment(fs,p->thread.fs);
savesegment(gs,p->thread.gs);

unlazy_fpu(current);
struct_cpy(&p->thread.i387, ¤t->thread.i387);

return 0;
}

By using three stack color bits eight colors will be used for initial stack frame pointer jittering that should be enough for most cache architectures. Care has to be taken in increasing too much STACK_COLOUR_BITS because this can lead to kernel stack overflows ( for example a STACK_COLOUR_BITS set to 4 with a cache line size of 128 bytes like P4 will result in a maximum jitter of 2048 bytes by leaving only 6 Kb for the kernel stack ).
cache cache colouring colouring kernel stack task_struct task_struct colouring
Free Download 28K
0
  • Share on:

Cache colouring task_struct and kernel stack User Reviews

Sponsored

Categories

  • Linux

Related Downloads

Drools Helper Integration
Help Drools usage from Java
Fbdo
Fbdo is a small suite of complementary tools for behavioral extensions to ...
pwnsjp
pwnsjp is a console-based frontend to the following some dictionaries.
Ckkern
Ckkern is an utility that lets you check your kernel version number against the ...
ranpwd
ranpwd is a small utility for generating random passwords in a variety of ...
Copyright © 1999-2017 Softpile Free Downloads
  • Contact Us
  • Submit
  • Privacy Policy
  • Disclaimer
  • Terms of Use