Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Unikernelで始める自作OS/OS Development with Unikernel
Search
Akira Moroo
October 06, 2019
Technology
1
510
Unikernelで始める自作OS/OS Development with Unikernel
Unikernelの設計/実装を使って自作OSができるのではないかという話です.
Akira Moroo
October 06, 2019
Tweet
Share
More Decks by Akira Moroo
See All by Akira Moroo
Exploring x86 MSR Space
retrage
0
1.1k
LLMでバイナリ解析支援
retrage
0
150
GitHub ActionsでDevSecOpsごっこ
retrage
0
34
Practical Rust (Hypervisor) Firmware
retrage
3
1.5k
Bypassing UEFI Secure Boot with Thin-Hypervisor
retrage
0
1.1k
Porting Linux to Nabla Containers
retrage
0
1.1k
Network Boot from Bell Labs
retrage
2
1.5k
LLVM Backend Development for EFI Byte Code
retrage
2
870
EFI Byte Code Virtual Machine for Fun and Profit
retrage
2
2k
Other Decks in Technology
See All in Technology
ユーザーストーリーマッピングから始めるアジャイルチームと並走するQA / Starting QA with User Story Mapping
katawara
0
200
技術負債の「予兆検知」と「状況異変」のススメ / Technology Dept
i35_267
1
1.1k
飲食店予約台帳を支えるインタラクティブ UI 設計と実装
siropaca
7
1.8k
開発スピードは上がっている…品質はどうする? スピードと品質を両立させるためのプロダクト開発の進め方とは #DevSumi #DevSumiB / Agile And Quality
nihonbuson
2
2.9k
『衛星データ利用の方々にとって近いようで触れる機会のなさそうな小話 ~ 衛星搭載ソフトウェアと衛星運用ソフトウェア (実物) を動かしながらわいわいする編 ~』 @日本衛星データコミニティ勉強会
meltingrabbit
0
140
白金鉱業Meetup Vol.17_あるデータサイエンティストのデータマネジメントとの向き合い方
brainpadpr
5
740
Data-centric AI入門第6章:Data-centric AIの実践例
x_ttyszk
1
400
N=1から解き明かすAWS ソリューションアーキテクトの魅力
kiiwami
0
130
2.5Dモデルのすべて
yu4u
2
860
現場の種を事業の芽にする - エンジニア主導のイノベーションを事業戦略に装着する方法 -
kzkmaeda
2
2.1k
CZII - CryoET Object Identification 参加振り返り・解法共有
tattaka
0
360
Goで作って学ぶWebSocket
ryuichi1208
0
160
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Measuring & Analyzing Core Web Vitals
bluesmoon
6
240
Building a Scalable Design System with Sketch
lauravandoore
461
33k
Building Applications with DynamoDB
mza
93
6.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
Docker and Python
trallard
44
3.3k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.4k
Done Done
chrislema
182
16k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Transcript
Unikernelで 始める⾃作OS October 6, 2019 第17回 ⾃作OSもくもく会 @retrage
Q: なぜOS⾃作? 1
A: 楽しいから 2
A: 学習のため • こういう⼈もいるはず • コンピュータアーキテクチャやOSを知る • 書籍や資料を読んだり • 既存OSの実装を読んだり
• 実際に⼿を動かしてみることで理解が深まる 3
学習のためのOS⾃作 • 1. ゼロから全部実装 • 全てを⾃分で実装したコードで制御できる • 関⼼のある部分の実装にたどり着くまでが⼤変 • 2.
既存OSの改造 • 関⼼のある部分の実装にすぐ着⼿できる • 既存OSの実装を理解している必要がある • Linuxのような⼤規模なOSの場合かなり⼤変 4
OS⾃作の障壁 • x86プラットフォームは⽐較的複雑 • 歴史的経緯による • 煩雑な起動プロセス • 多種多様なデバイスへの対応 •
学習⽤途であれば仮想環境で⼗分では? • デバイス: virtio, シリアルコンソール • OSの起動: -kernel os.img • => Unikernelが使えそう 5
Unikernel: 概要 • OSの形態の1つ (Library OS) • 仮想環境で動作す ることを前提 •
空間の分離なし • シングルプロセス • ハイパーバイザで 隔離性を担保 • 実装は多数 6
Unikernel: ⾃作OSの観点 • 簡易化したOSとみなせる • 1. ゼロからの実装: • マルチプロセスの実装が不要 •
実装すべきデバイスドライバは少数 • 2. 既存OSの改造: • コード量が⽐較的少ない • 例: Unikraft 108,523⾏ 7
Unikernels as Processes • Unikernelをホスト上のプロセスとして動かす • 隔離はOS上のプロセスで⼗分 • Unikernelに対する制約 •
システムコールを直接発⾏できない 8
ハイパーコール 9
Unikernels as Processes: ⾃作OSの観点 • 抽象化されたデバイス • デバイスドライバを書く必要がない • ハイパーコールを発⾏するだけで利⽤可能
• デバッグが⽐較的容易 • ただのユーザ空間のプロセスのため • エミュレータも不要 • => ⾼レイヤーな部分を作るのに最適 10
課題点 • 学習を⽬的に設計実装されていない • コードが不親切だったり • コードの説明がなかったり • 汎⽤OSでは必須な機能の実装がない •
マルチタスク • ユーザ空間とカーネル空間の分離 • =>どこに興味があるかに依存 11
実例 12
Unikraft 13
Linux Kernel Library 14 • vanillaなLinux Kernelがユーザ空 間で動作 • ホスト固有の
コードは綺麗に 分離 • mutex/semaphore /thread/block rw etc. • arch/lkl
LKL on Unikraft 15 uk-host.o lkl.o LKL App unikraft_linuxu_x86_64 liblkl
LK mutex.o thread.o timer.o
LKL on Unikraftデモ 16 $ ./build/boot_linuxu-x86_64 Welcome to _ __
_____ __ _____ (_) /__ _______ _/ _/ /_ / // / _ \/ / '_// __/ _ `/ _/ __/ \_,_/_//_/_/_/\_\/_/ \_,_/_/ \__/ Titan 0.2~51691ea /* snip */ [ 0.000000] Linux version 4.17.0+ (
[email protected]
) (gcc version 8.1.1 20180712 (Red Hat 8.1.1-5) (GCC)) #1 Thu Jan 10 14:04:16 JST 2019 /* snip */ [ 0.000000] This architecture does not have kernel memory protection. lkl_start_kernel(&lkl_host_ops, "mem=16M loglevel=8") = 0 /* snip */