Towards capabilities in HelenOS Towards capabilities in HelenOS The - - PowerPoint PPT Presentation

towards capabilities in helenos towards capabilities in
SMART_READER_LITE
LIVE PREVIEW

Towards capabilities in HelenOS Towards capabilities in HelenOS The - - PowerPoint PPT Presentation

Towards capabilities in HelenOS Towards capabilities in HelenOS The elephant in the room The elephant in the room http://www.helenos.org http://www.helenos.org Jakub Jerm jakub@jermar.eu HelenOS in a nutshell HelenOS in a nutshell


slide-1
SLIDE 1

Towards capabilities in HelenOS Towards capabilities in HelenOS

The elephant in the room The elephant in the room

Jakub Jermář

jakub@jermar.eu

http://www.helenos.org http://www.helenos.org

slide-2
SLIDE 2 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 2

HelenOS in a nutshell HelenOS in a nutshell

  • Portable microkernel-based multiserver OS
  • Designed and implemented from scratch
  • Not a clone of any existing OS / API
  • Virtually no third-party code
  • Fine-grained userspace components
slide-3
SLIDE 3 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 3

Since last FOSDEM... Since last FOSDEM...

  • HelenOS 0.7.0 (April)
  • HelenOS 0.7.1 (November)
  • HelenOS Camp 2017
  • Fork us on GitHub!
  • CZ.NIC feeds one HelenOS developer
slide-4
SLIDE 4 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 4

Coming soon Coming soon

  • C++14 support
  • USB 3.0 support
slide-5
SLIDE 5 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 5

Google Summer of Code Google Summer of Code

  • Microkernel devroom
  • Organizations Announced on February 12
  • Student Application Period starts on March 12
  • http://gsoc.microkernel.info/
slide-6
SLIDE 6 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 6

Terminology Terminology

Capability:

Task-local name for a reference to a kernel object; userspace uses integer handles to refer to capabilities

Kernel objects:

Reference-counted wrappers for a select group of

  • bjects allocated in and by the kernel that can be

made accessible to userspace in a controlled way via capability handles

slide-7
SLIDE 7 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 7

Motivation Motivation

  • Fix broken mechanisms
  • Reduce number of mechanisms
  • Fix broken interfaces
  • Get rid of global names
  • Modernize the system
slide-8
SLIDE 8 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 8

Example: passing files Example: passing files

  • How to pass an open file which exists in the

VFS server from the parent task to the child?

slide-9
SLIDE 9 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 9

Example: passing files Example: passing files

  • How to pass an open file which exists in the

VFS server from the parent task to the child?

Parent Parent Child Child VFS VFS Kernel Kernel

slide-10
SLIDE 10 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 10

Example: passing files Example: passing files

  • How to pass an open file which exists in the

VFS server from the parent task to the child?

Parent Parent Child Child VFS VFS Kernel Kernel

  • 1. LOADER_SET_FILES
  • 2. IPC_M_STATE_CHANGE_AUTHORIZE
  • 3. EOK
  • 4. EVENT_TASK_STATE_CHANGE

5.

  • 6. VFS_WAIT_IN_HANDLE
  • 7. EOK
  • 8. EOK
slide-11
SLIDE 11 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 11

Example: passing files Example: passing files

  • How to pass an open file which exists in the

VFS server from the parent task to the child? IPC_M_CHANGE_AUTHORIZE

– Two clients of a server can negotiate a change of

their state kept in the server

– All VFS files map to single kernel object – Actively involves the server + kernel notification

slide-12
SLIDE 12 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 12

Example: passing files Example: passing files

  • How to pass an open file which exists in the

VFS server from the parent task to the child?

slide-13
SLIDE 13 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 13

Example: passing files Example: passing files

  • How to pass an open file which exists in the

VFS server from the parent task to the child?

Parent Parent Child Child VFS VFS Kernel Kernel

slide-14
SLIDE 14 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 14

Example: passing files Example: passing files

  • How to pass an open file which exists in the

VFS server from the parent task to the child?

Parent Parent Child Child VFS VFS Kernel Kernel

  • 1. IPC_M_CONNECT_TO_ME(port = 6)
  • 2. EOK
slide-15
SLIDE 15 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 15

Example: passing files Example: passing files

  • How to pass an open file which exists in the

VFS server from the parent task to the child? IPC_M_CONNECT_(TO_ME/ME_TO)

– Mechanism to create (callback) IPC connections – Does not currently accept a port number – VFS not involved – One kernel object per one VFS file

slide-16
SLIDE 16 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 16

Example: IRQ handlers Example: IRQ handlers

  • Device drivers can register an IRQ handler.

How to identify the handler so that it can be unregistered?

slide-17
SLIDE 17 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 17

Example: IRQ handlers Example: IRQ handlers

  • Device drivers can register an IRQ handler.

How to identify the handler so that it can be unregistered? Before HelenOS 0.7.1

g_devno = SYS_DEVICE_ASSIGN_DEVNO() SYS_IPC_IRQ_SUBSCRIBE(irq, g_devno, …) SYS_IPC_IRQ_UNSUBSCRIBE(irq, g_devno)

slide-18
SLIDE 18 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 18

Example: IRQ handlers Example: IRQ handlers

  • Device drivers can register an IRQ handler.

How to identify the handler so that it can be unregistered? Before HelenOS 0.7.1

g_devno = SYS_DEVICE_ASSIGN_DEVNO() SYS_IPC_IRQ_SUBSCRIBE(irq, g_devno, …) SYS_IPC_IRQ_UNSUBSCRIBE(irq, g_devno)

– A microkernel should not assign devno’s – No enforcement to use the devno for registration – Everyone can unregister any IRQ handler

slide-19
SLIDE 19 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 19

Example: IRQ handlers Example: IRQ handlers

  • Device drivers can register an IRQ handler.

How to identify the handler so that it can be unregistered?

slide-20
SLIDE 20 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 20

Example: IRQ handlers Example: IRQ handlers

  • Device drivers can register an IRQ handler.

How to identify the handler so that it can be unregistered? Since HelenOS 0.7.1

handle = SYS_IPC_IRQ_SUBSCRIBE(irq, …) SYS_IPC_IRQ_UNSUBSCRIBE(handle)

– Capability handles are task-local – Need to posses the capability in order to unregister

slide-21
SLIDE 21 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 21

Elephant in the room Elephant in the room

  • Capabilities are great
  • How to introduce them to HelenOS?
slide-22
SLIDE 22 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 22

Elephant in the room Elephant in the room

  • Capabilities are great
  • How to introduce them to HelenOS?
  • We don’t have to (start from scratch)
  • HelenOS already has them (in a limited way)
slide-23
SLIDE 23 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 23

Basic HelenOS RPC Basic HelenOS RPC

Task Task Task Task

Answerbox Answerbox Phones Answerbox Answerbox Phones ipc_call_async_fast(2, method, arg1, arg2, arg3, ...) ipc_wait_for_call_timeout ipc_wait_for_call_timeout ipc_answer_fast(callid, retval, arg1, arg2, arg3, arg4)

slide-24
SLIDE 24 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 24

Call forwarding Call forwarding

Task Task Task Task Task Task

Answerbox Answerbox Answerbox Answerbox Phones Answerbox Answerbox Phones Phones ipc_call_async_fast(2, method, arg1, arg2, arg3, ...) ipc_wait_for_call_timeout ipc_wait_for_call_timeout ipc_answer_fast(callid, retval, arg1, arg2, arg3, arg4) ipc_forward_fast(callid, 5, method, arg1, arg2, ...) ipc_wait_for_call_timeout

slide-25
SLIDE 25 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 25

Creating a new connection Creating a new connection

Task Task Task Task Task Task

Answerbox Answerbox Answerbox Answerbox Phones Answerbox Answerbox Phones Phones ipc_call_async_fast(2, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, ...) ipc_wait_for_call_timeout ipc_wait_for_call_timeout ipc_answer_fast(callid, EOK, arg1, arg2, arg3, arg4) ipc_forward_fast(callid, 5, IPC_M_CONNECT_ME_TO, arg1, arg2, ...) ipc_wait_for_call_timeout

slide-26
SLIDE 26 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 26

Creating a new connection Creating a new connection

Task Task Task Task Task Task

Answerbox Answerbox Answerbox Answerbox Phones Answerbox Answerbox Phones Phones ipc_call_async_fast(2, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, ...) ipc_wait_for_call_timeout ipc_wait_for_call_timeout ipc_answer_fast(callid, EOK, arg1, arg2, arg3, arg4) ipc_forward_fast(callid, 5, IPC_M_CONNECT_TO_ME, arg1, arg2, ...) ipc_wait_for_call_timeout

slide-27
SLIDE 27 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 27

Elephant in the room Elephant in the room

  • HelenOS IPC: a coarse-grained capability system
  • Roughly analogous to Mach IPC
slide-28
SLIDE 28 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 28

Elephant in the room Elephant in the room

Mach HelenOS Unit of IPC communication Message Call IPC communication endpoint Port Answerbox IPC connection Send Right Phone Receive from IPC endpoint Receive Right ipc_wait_for_call_timeout() implicitly receives from task’s answerbox Right to answer Sender includes send-once right to a reply port Implicit via received call Give connection to third- party Reply with send right Forward IPC_M_CONNECT_ME_TO call

slide-29
SLIDE 29 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 29

Elephant in the room Elephant in the room

Capability ↔ Phone Pass capability ↔ Forward connection

slide-30
SLIDE 30 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 30

Limits of IPC as capabilities Limits of IPC as capabilities

  • Phone the only type of capability
  • Can only pass one type of capability
  • Only one answerbox per task
  • Maximum 64 phones per task
  • Kernel addresses as user callid’s

Answerbox Answerbox Phones 3 2 1 Async Ports

~ ~ ~ ~

Answerbox Answerbox Phones (4, 1) (4, 2) (7, 3)

slide-31
SLIDE 31 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 31

Work already done Work already done

  • New capability framework
  • IPC switched to using it
  • Kernel objects: phones, calls and IRQs
  • Arbitrary number of capabilities
  • User refers to calls using capability handles

kobject_t .type = KOBJECT_TYPE_CALL .refcnt = 3 kobject_t .type = KOBJECT_TYPE_CALL .refcnt = 3 call_t call_t cap_t .state = CAP_STATE_PUBLISHED .task = <task A> .handle = 5 cap_t .state = CAP_STATE_PUBLISHED .task = <task A> .handle = 5 cap_t .state = CAP_STATE_PUBLISHED .task = <task A> .handle = 13 cap_t .state = CAP_STATE_PUBLISHED .task = <task A> .handle = 13 Reference from code Answerbox Answerbox 3 2 1 Async Ports

~ ~ ~ ~

Answerbox Answerbox (4, 1) (4, 2) (7, 3) Capabilities 4 4 7 7 c c c c c c c Capabilities p p i IRQ

slide-32
SLIDE 32 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 32

What needs to be done What needs to be done

  • Answerbox as capabilities / kernel objects

– Arbitrary number of answerboxes – Pair with user-level async ports – Where does the answer go to?

  • Tasks and threads as kernel objects

– Get rid of the remaining global IDs – Get rid of existence checks

3 2 1 Async Ports

~ ~ ~ ~

(4) (6) (7) Capabilities 4 4 7 7 6 6 c c c c c c c Capabilities p p i IRQ a a a p ~ t thread task

slide-33
SLIDE 33 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 33

Future Future

  • Resource management

– We removed some arbitrary resource limits

  • 64 phones per task, 4 active calls per phone

– Per-task resource pools to compensate – Service-for-resource trading

  • Capability rights
  • Revoking of capabilities
  • Pass arbitrary capability between tasks
slide-34
SLIDE 34 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 34

Summary Summary

  • Originally HelenOS had capabilities for IPC

endpoints by accident

  • Generalized the IPC subsystem to support
  • ther kernel objects
  • Capabilities used to fix broken APIs
  • Still need to introduce more kernel objects,

especially for answerboxes

  • Things need to settle down
slide-35
SLIDE 35 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 35

Q&A Q&A

http://www.helenos.org https://github.com/HelenOS/helenos @HelenOSOrg @jjermar Thank you!

slide-36
SLIDE 36 BRUSSELS 3 FEBRUARY - 4 F 8000+ hackers 600+ lectures lightning talks devrooms beer

Jakub Jermář, FOSDEM 2018, February 3rd Towards capabilities in HelenOS 36

References References

  • Photo of laptop running HelenOS with USB 3.0

support courtesy of Ondřej Hlavatý