17.01.2014 Views

The holy bible of SWEB - Institute of Applied Information Processing ...

The holy bible of SWEB - Institute of Applied Information Processing ...

The holy bible of SWEB - Institute of Applied Information Processing ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.6. <strong>SWEB</strong> TASK SEPARATION AND PROTECTION<br />

CHAPTER 3. VM, PROTECTION AND PAGING<br />

3.6 Sweb Task Separation and Protection<br />

3.6.1 Segment Descriptor Privilege Level / Task Privilege Level<br />

As shown in Table 3.8, Sweb uses only privilege level 0 for kernel code and 3 for user<br />

code. User threads running user code start with CS and DS set to 4 and 5 respectively.<br />

Refer to low level task switching and syscalls on when privilege levels are changed.<br />

3.6.2 User- / Supervisor- Page<br />

Paging <strong>of</strong>fers an additional mechanism concerning code privileges in form <strong>of</strong> the user/supervisoraccess<br />

flag in the Page-Directory. Pages where the user_access flag is not set may only<br />

be accessed by code with privilege level 0 i.e. the kernel. In Sweb the user_access flag<br />

is set only on mappings below 2GiB.<br />

3.6.3 LoadPageOnDemand<br />

Instead <strong>of</strong> loading a new process complete into memory on process launch, only the<br />

pages needed can be loaded one a time. In Sweb, on start <strong>of</strong> an new user process, all<br />

virtual pages are non-present. <strong>The</strong> first time each user page is accessed, a page fault<br />

happens and the Page-Fault-Handler is called. On deciding that the page is in the user<br />

threads linear address space below 2GiB, the user processes instance <strong>of</strong> class Loader<br />

is called. Loader then checks the ELF-Header and loads the code and data from the<br />

executable, that match the missing page’s linear address range.<br />

It is further possible to remember if a page has never changed since it was loaded<br />

on demand. <strong>The</strong>n, instead <strong>of</strong> swapping it out, it could simply be free’d because it<br />

can be reload from the executable. This approach however introduces some issues in<br />

conjunction with shared pages which are detailed in section 3.7.6.<br />

3.6.4 UserThread Termination<br />

On termination <strong>of</strong> a user process, ArchMemory::freePageDirectory(..) is called. <strong>The</strong><br />

function recursively frees all mapped pages below 2GiB.<br />

3.7 Extending Sweb<br />

3.7.1 Using 4MiB Pages<br />

In various operating systems, pages <strong>of</strong> 4MiB size are used to map kernel code because<br />

the IA32 maintains different TLBs for 4KiB and 4MiB pages. <strong>The</strong> advantage would<br />

be that the kernel has its own page cache that would remain unchanged on a task<br />

switch. In the beginning Sweb used one 4MiB kernel page. Later, it was more important<br />

to prevent and catch errors by marking parts (

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!