SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
Nested	
  VMM	
  とはなんぞや	

  カーネル/VM探検隊	
  @つくば	
  
      @syu_cream
Nested	
  VMMについて	
•  Nested	
  VMMとは	
  
   –  読んで字のごとく、VMMをネストする	
  
•  Nested	
  VMMの例	
  
   –  KVM	
  on	
  KVM	
  
   –  BHyVe	
  on	
  VMWare	
  
   –  BitVisor	
  on	
  VMWare	
  
Nested	
  VMMの構成例図	


         L2	
  ゲストOS	


       L1	
  ゲストVMM	


        L0	
  ホストVMM	



        ハードウェア
Nested	
  VMM	
  して何が嬉しい?	
•  VMMを動かすのに実マシンを用意せず済む	
  
•  VMMのデバッグが楽になる	
  
  –  GDBとか使ってサクッとVMMデバッグできる	
  
  –  当研究室は主に実マシンで動作確認してて辛い	
  
    •  VMMと共に僕らの眼の輝きも死んでゆく	
  
•  @m_bird	
  さん「Nested	
  VMMで飯が美味い」
 
	
  
(	
  ˘⊖˘)	
  。o(待てよ……どうすればVMMをネストで
きるんだ……?)	
  
Nested	
  VMM	
  の設計のお話	
•  どうすればVMMをネスト出来るか?	
  

•  The	
  Turtles	
  Project[OSDI’10]やXen	
  Summit	
  の
   Nested	
  VMMについての記述をまとめてみた
Intel	
  VT解説(VMXその1)	
•  ハードでVMを動かす為のモードを提供	
  
 –  x86ではセンシティブ命令の扱いが面倒	
  
 –  VM専用モード(VMX	
  non-­‐root	
  mode)を用意	
  
    •  トラップすべき命令が実行されたらVMX	
  root	
  mode	
  へ遷移
       (VMExit)	
  
    •  適切なエミュレーションをしてVMX	
  non-­‐root	
  modeに戻る
       (VMEntry)	
  

          VMX	
  root	
  mode	
               VMX	
  non-­‐root	
  mode	
                                  VMExit	

                                  VMEntry	


                              VMX命令で制御
Intel	
  VT解説(VMXその2)	
•  VMCS(Virtual	
  Machine	
  Control	
  Structure)	
  
   –  VMX命令の為に設定情報とマシンの状態を保存	
  
   –  保持するデータは大まかに三種類	
  
      •  ホストマシンの状態	
  
      •  ゲストマシンの状態	
  
      •  VMExit	
  の条件など制御情報
Intel	
  VT解説(EPT)	
•  仮想化においてページングの扱いが面倒	
  
    –  物理アドレスを引くのに二重の変換を要する	
  
    –  一発で引けるよう自前でページテーブル用意する	
  
        •  shadow	
  page	
  table	
  
•  EPT(Extended	
  Page	
  Table)	
  
    –  VMMがやらなきゃならない煩雑なアドレス変換をハード
       がやってくれる	
  
    –  仮想化のオーバーヘッド低減
Nested	
  VMM設計	
•  ネストする上で以下をどうにかする	
  
 –  VMXの仮想化	
  
 –  メモリアクセスの仮想化	
  
 –  I/Oの扱い	
  
VMX命令のトラップとエミュレーション	
•  L1ではVMX命令を実行できない	
  
   –  L1	
  はVMX	
  non-­‐root	
  mode	
  で動いてる	
  
   –  →	
  L0	
  に仕事を投げる!	
  
•  L1	
  のVMX命令実行時の処理	
  
   1.  L1-­‐>L0	
  へVMExit	
  	
  
                                        L2	
  ゲストOS	
   2.  L0でエミュレーション	
  
                                      Virtual	
  VMEntry	
   3.  L0-­‐>L1	
  へVMEntry	
  
                                        L1	
  ゲストVMM	
                          2.	
  VMEntry	
•  L1-­‐>L2へのVMEntry	
  
                                             1.	
  VMExit	
   2.	
  VMEntry	
   1.  L1-­‐>L0	
  へVMExit	
  
                                        L0	
  ホストVMM	
   2.  L0-­‐>L2	
  へVMEntry	
  	
                                        ハードウェア
VMCS	
  shadowing	
•  VMXをネストする上でVMCSも複数用意	
  
 1.  L0,	
  L1制御用のVMCS0,1	
  
 2.  L1,	
  L2制御用のVMCS1,2	
  
 3.  L0,	
  L2制御用のVMCS0,2	
  
                                   L2	
  ゲストOS	
    •  VMCS1,2	
  をshadowing	
  
    •  L0<-­‐>L2遷移を可能に	
                            VMCS1,2	
  
                                   L1	
  ゲストVMM	
                                                                  shadowing	

                                   L0	
  ホストVMM	
   VMCS0,1	
     VMCS0,2	
  


                                   ハードウェア
VMEntry/VMExit	
  のエミュレーション	
•  L2関連のVMEntry/VMExitをうまくエミュレー
   ションする必要がある	
  
 –  L0絡みのイベント処理	
  
 –  L1絡みのイベント処理	
  
L0絡みのイベント処理	
•  L0で処理すべきイベント	
  
  •  VMCS0,2	
  に記述されていてVMCS1,2	
  に記述されていない処理	
  
  •  外部割り込み,NMIなど	
  
•  L0でイベントをハンドリングして,L2をレジューム	
  

     L2	
  ゲストOS	

                                                  1.	
  VMExit	
      3.	
  VMEntry	
     L1	
  ゲストVMM	
   VMCS1,2	
  
                                    shadowing	


     L0	
  ホストVMM	
   VMCS0,1	
          VMCS0,2	
           2.	
  イベント処理	


     ハードウェア
L1絡みのイベント処理	
•  VMCS1,2	
  に記述されているイベントの処理	
  
•  L0からL1にイベントをフォワード	
  
  –  VMCS1,2のExit	
  Reason	
  を更新しL2からExit	
  したように見せる	
  
•  L1をレジュームし,イベント処理後L0を経由しL2をレジューム	
  

     L2	
  ゲストOS	
                                  Virtual	
  	
  
                                                    VMEntry/VMExit	
                                      1.	
  VMExit	
                                                                  4.	
  イベント
     L1	
  ゲストVMM	
 VMCS1,2	
                                           処理	
             6.	
  VMEntry	
                                  shadowing	
    3.	
  VMEntry	
                                                                        5.	
  VMExit	
                                                 2.	
  VMCS	
  
     L0	
  ホストVMM	
 VMCS0,1	
      VMCS0,2	
  
                                                   更新	

     ハードウェア
Nested	
  VMMにおけるメモリ管理	
•  Nested	
  VMMは三段階アドレス変換を要する	
  
 –  L2論理→L2物理→L1物理→L0物理	
  
 –  二段階変換ならハードウェアサポートが有るが…	
  
   •  EPT,	
  NPT	
  
   •  増えた1回分のアドレス変換処理をどう扱うか?	
  
Shadow	
  Page	
  Table	
  で頑張る方針	
•  Shadow-­‐on-­‐shadow	
  
    –  L0,L1	
  でそれぞれshadow	
  page	
  table	
  を持つ	
  
    –  L0物理アドレスのアクセスはL0のSPT02で一気に変換	
  
•  Shadow-­‐on-­‐EPT	
  
    –  L0	
  でEPTを使用し,L1でshadow	
  page	
  nested MMU virtualization models.
                                     ent
                                           table	
  を持つ	
  
    –  オーバーヘッド大	
  
        •  L2でpage	
  fault	
  する度,L0へVMExit	
  
        	
  	
  	
  	
  した後L1	
  でSPT更新する必要有…	
  




                                                    Figure 4: MMU alternatives for neste
Mulc-­‐dimensional	
  Paging	
•  一つのEPTでL2物理→L0物理変換を可能にする	
  
 –  二つのEPTを合成したEPT02を持つ	
  
    •  L0のEPT01,	
  L1のEPT12	
  
 –  ページフォルトによるVMExit	
  が減少しオーバーヘッド低減	
  
               ent nested MMU virtualization models.                              a
 –  L1のEPT12への更新を検出しEPT02に反映する必要有り	
  
                                                                                  e
    •  L1におけるEPT12の更新とINVEPTをトラップする	
                                             p
                                                                                  a
                                                                                  c
                                                                                  f
                                                                                  c
                                                                                  i
                                                                                  t
                                                                                  o
                                                                                  t
                           Figure 4: MMU alternatives for nested virtualization
Nested	
  VMMにおけるI/Oの扱い	
•  仮想化環境においてI/Oの扱いは3種の方針が有る	
  
  –  エミュレーション	
  
  –  準仮想化	
  
  –  パススルー	
  
•  Nested	
  VMMならL0,	
  L1で3*3=9	
  通りの組合せが存在
参考資料	
•  The	
  Turtles	
  Project[OSDI’10]の論文	
  
   –  hgp://stacc.usenix.org/events/osdi10/tech/
      full_papers/Ben-­‐Yehuda.pdf	
  
•  kvm	
  の実装	
  
   –  arch/x86/kvm/vmx.c	
  

Más contenido relacionado

Destacado

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Destacado (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

2012/09/22 カーネル/VM探検隊@つくば 発表資料「Nested VMMとはなんぞや」

  • 1. Nested  VMM  とはなんぞや カーネル/VM探検隊  @つくば   @syu_cream
  • 2. Nested  VMMについて •  Nested  VMMとは   –  読んで字のごとく、VMMをネストする   •  Nested  VMMの例   –  KVM  on  KVM   –  BHyVe  on  VMWare   –  BitVisor  on  VMWare  
  • 3. Nested  VMMの構成例図 L2  ゲストOS L1  ゲストVMM L0  ホストVMM ハードウェア
  • 4. Nested  VMM  して何が嬉しい? •  VMMを動かすのに実マシンを用意せず済む   •  VMMのデバッグが楽になる   –  GDBとか使ってサクッとVMMデバッグできる   –  当研究室は主に実マシンで動作確認してて辛い   •  VMMと共に僕らの眼の輝きも死んでゆく   •  @m_bird  さん「Nested  VMMで飯が美味い」
  • 5.     (  ˘⊖˘)  。o(待てよ……どうすればVMMをネストで きるんだ……?)  
  • 6. Nested  VMM  の設計のお話 •  どうすればVMMをネスト出来るか?   •  The  Turtles  Project[OSDI’10]やXen  Summit  の Nested  VMMについての記述をまとめてみた
  • 7. Intel  VT解説(VMXその1) •  ハードでVMを動かす為のモードを提供   –  x86ではセンシティブ命令の扱いが面倒   –  VM専用モード(VMX  non-­‐root  mode)を用意   •  トラップすべき命令が実行されたらVMX  root  mode  へ遷移 (VMExit)   •  適切なエミュレーションをしてVMX  non-­‐root  modeに戻る (VMEntry)   VMX  root  mode VMX  non-­‐root  mode VMExit VMEntry VMX命令で制御
  • 8. Intel  VT解説(VMXその2) •  VMCS(Virtual  Machine  Control  Structure)   –  VMX命令の為に設定情報とマシンの状態を保存   –  保持するデータは大まかに三種類   •  ホストマシンの状態   •  ゲストマシンの状態   •  VMExit  の条件など制御情報
  • 9. Intel  VT解説(EPT) •  仮想化においてページングの扱いが面倒   –  物理アドレスを引くのに二重の変換を要する   –  一発で引けるよう自前でページテーブル用意する   •  shadow  page  table   •  EPT(Extended  Page  Table)   –  VMMがやらなきゃならない煩雑なアドレス変換をハード がやってくれる   –  仮想化のオーバーヘッド低減
  • 10. Nested  VMM設計 •  ネストする上で以下をどうにかする   –  VMXの仮想化   –  メモリアクセスの仮想化   –  I/Oの扱い  
  • 11. VMX命令のトラップとエミュレーション •  L1ではVMX命令を実行できない   –  L1  はVMX  non-­‐root  mode  で動いてる   –  →  L0  に仕事を投げる!   •  L1  のVMX命令実行時の処理   1.  L1-­‐>L0  へVMExit     L2  ゲストOS 2.  L0でエミュレーション   Virtual  VMEntry 3.  L0-­‐>L1  へVMEntry   L1  ゲストVMM 2.  VMEntry •  L1-­‐>L2へのVMEntry   1.  VMExit 2.  VMEntry 1.  L1-­‐>L0  へVMExit   L0  ホストVMM 2.  L0-­‐>L2  へVMEntry   ハードウェア
  • 12. VMCS  shadowing •  VMXをネストする上でVMCSも複数用意   1.  L0,  L1制御用のVMCS0,1   2.  L1,  L2制御用のVMCS1,2   3.  L0,  L2制御用のVMCS0,2   L2  ゲストOS •  VMCS1,2  をshadowing   •  L0<-­‐>L2遷移を可能に   VMCS1,2   L1  ゲストVMM shadowing L0  ホストVMM VMCS0,1   VMCS0,2   ハードウェア
  • 13. VMEntry/VMExit  のエミュレーション •  L2関連のVMEntry/VMExitをうまくエミュレー ションする必要がある   –  L0絡みのイベント処理   –  L1絡みのイベント処理  
  • 14. L0絡みのイベント処理 •  L0で処理すべきイベント   •  VMCS0,2  に記述されていてVMCS1,2  に記述されていない処理   •  外部割り込み,NMIなど   •  L0でイベントをハンドリングして,L2をレジューム   L2  ゲストOS 1.  VMExit 3.  VMEntry L1  ゲストVMM VMCS1,2   shadowing L0  ホストVMM VMCS0,1   VMCS0,2   2.  イベント処理 ハードウェア
  • 15. L1絡みのイベント処理 •  VMCS1,2  に記述されているイベントの処理   •  L0からL1にイベントをフォワード   –  VMCS1,2のExit  Reason  を更新しL2からExit  したように見せる   •  L1をレジュームし,イベント処理後L0を経由しL2をレジューム   L2  ゲストOS Virtual     VMEntry/VMExit 1.  VMExit 4.  イベント L1  ゲストVMM VMCS1,2   処理 6.  VMEntry shadowing 3.  VMEntry 5.  VMExit 2.  VMCS   L0  ホストVMM VMCS0,1   VMCS0,2   更新 ハードウェア
  • 16. Nested  VMMにおけるメモリ管理 •  Nested  VMMは三段階アドレス変換を要する   –  L2論理→L2物理→L1物理→L0物理   –  二段階変換ならハードウェアサポートが有るが…   •  EPT,  NPT   •  増えた1回分のアドレス変換処理をどう扱うか?  
  • 17. Shadow  Page  Table  で頑張る方針 •  Shadow-­‐on-­‐shadow   –  L0,L1  でそれぞれshadow  page  table  を持つ   –  L0物理アドレスのアクセスはL0のSPT02で一気に変換   •  Shadow-­‐on-­‐EPT   –  L0  でEPTを使用し,L1でshadow  page  nested MMU virtualization models. ent table  を持つ   –  オーバーヘッド大   •  L2でpage  fault  する度,L0へVMExit          した後L1  でSPT更新する必要有…   Figure 4: MMU alternatives for neste
  • 18. Mulc-­‐dimensional  Paging •  一つのEPTでL2物理→L0物理変換を可能にする   –  二つのEPTを合成したEPT02を持つ   •  L0のEPT01,  L1のEPT12   –  ページフォルトによるVMExit  が減少しオーバーヘッド低減   ent nested MMU virtualization models. a –  L1のEPT12への更新を検出しEPT02に反映する必要有り   e •  L1におけるEPT12の更新とINVEPTをトラップする   p a c f c i t o t Figure 4: MMU alternatives for nested virtualization
  • 19. Nested  VMMにおけるI/Oの扱い •  仮想化環境においてI/Oの扱いは3種の方針が有る   –  エミュレーション   –  準仮想化   –  パススルー   •  Nested  VMMならL0,  L1で3*3=9  通りの組合せが存在
  • 20. 参考資料 •  The  Turtles  Project[OSDI’10]の論文   –  hgp://stacc.usenix.org/events/osdi10/tech/ full_papers/Ben-­‐Yehuda.pdf   •  kvm  の実装   –  arch/x86/kvm/vmx.c