The K Project VGA SBRK Conclusion LSE Team EPITA May 06, 2019 - - PowerPoint PPT Presentation

the k project
SMART_READER_LITE
LIVE PREVIEW

The K Project VGA SBRK Conclusion LSE Team EPITA May 06, 2019 - - PowerPoint PPT Presentation

The K Project LSE Team Memory layout Syscall handler The K Project VGA SBRK Conclusion LSE Team EPITA May 06, 2019 LSE Team (EPITA) The K Project May 06, 2019 1 / 13 User memory layout The K Project LSE Team Memory layout


slide-1
SLIDE 1

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

The K Project

LSE Team

EPITA

May 06, 2019

LSE Team (EPITA) The K Project May 06, 2019 1 / 13

slide-2
SLIDE 2

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

User memory layout

Needed segments Code Data Optional segments Stack

LSE Team (EPITA) The K Project May 06, 2019 2 / 13

slide-3
SLIDE 3

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

Sane memory layout

memory reserved address

User Code User Data User Stack User Head Kernel Code/Data

User Data Segment rw- User Code Segment r-x

phdr .p_memsz + phdr .p_vaddr brk 0xFFFFFFFFFF 0x00000000

Figure: “Simple” example

LSE Team (EPITA) The K Project May 06, 2019 3 / 13

slide-4
SLIDE 4

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

What is needed

For every segments Find enough space using the given memory allocator Should not overlap with each other For the stack segment Should expand down

LSE Team (EPITA) The K Project May 06, 2019 4 / 13

slide-5
SLIDE 5

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

Sane memory layout (again)

memory reserved address

User Code User Data User Stack User Head Kernel Code/Data

User Data Segment rw- User Code Segment r-x

phdr .p_memsz + phdr .p_vaddr brk 0xFFFFFFFFFF 0x00000000

Figure: “Simple” example

LSE Team (EPITA) The K Project May 06, 2019 5 / 13

slide-6
SLIDE 6

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

Syscall

Kernel­Land

Generic Syscall Handler Specific Syscall Handler Push arguments Call Generic Handler Put arguments in Registers Put syscall # in Register Trap to kernel Return to caller

Userland

Table of handlers

Figure: Syscall Processing

LSE Team (EPITA) The K Project May 06, 2019 6 / 13

slide-7
SLIDE 7

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

Syscall Gate

A unique syscall gate (0x80)

int 0x80

eax: Syscall number ebx, ecx, edx: Syscall parameters

LSE Team (EPITA) The K Project May 06, 2019 7 / 13

slide-8
SLIDE 8

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

Implementation advices

Jump table Do not forget to translate the user addresses Check for invalid user pointers

LSE Team (EPITA) The K Project May 06, 2019 8 / 13

slide-9
SLIDE 9

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

VGA Syscalls

setvideo Swich between VGA text (3h) and graphic mode (13h) swap frontbuffer Loads the user buffer into the graphic framebuffer

LSE Team (EPITA) The K Project May 06, 2019 9 / 13

slide-10
SLIDE 10

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

Syscall SBRK

Implementations advices man 2 sbrk Find some unused memory in the user data segment

LSE Team (EPITA) The K Project May 06, 2019 10 / 13

slide-11
SLIDE 11

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

Address space advices

You can load and exec any ROM in “flat” mode. You can exec any ROM in kernel land GDB will not understand non-zero base address

LSE Team (EPITA) The K Project May 06, 2019 11 / 13

slide-12
SLIDE 12

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

Summary

Implement the syscall handler Wrap and enable each syscall Implement the VGA syscalls Implement sbrk Notes All of these will be needed in order to run the ROMs.

LSE Team (EPITA) The K Project May 06, 2019 12 / 13

slide-13
SLIDE 13

The K Project LSE Team Memory layout Syscall handler VGA SBRK Conclusion

Contact

k[at]lse.epita.fr labos.lse with [K] tag #k (irc.rezosup.org) guillaume.pagnoux[at]lse.epita.fr tom.decrette[at]lse.epita.fr

LSE Team (EPITA) The K Project May 06, 2019 13 / 13