gpu on kvm
play

GPU on KVM Gabriel Laskar <gabriel@lse.epita.fr> Introduction - PowerPoint PPT Presentation

GPU on KVM Gabriel Laskar <gabriel@lse.epita.fr> Introduction How can we have 3D acceleration on VMs? Goals: Portability Security and of course Quake ! Outline What is a GPU? How can we bring something to the


  1. GPU on KVM Gabriel Laskar <gabriel@lse.epita.fr>

  2. Introduction ● How can we have 3D acceleration on VMs? ● Goals: ○ Portability ○ Security ○ and of course Quake !

  3. Outline ● What is a GPU? ● How can we bring something to the screen? ● What is a VM? ● A virtualized device? ● How can we bring all this together?

  4. What is a Graphic Card? ● Display ● Video Playback ● 2D & 3D Graphics ● Computation

  5. GPUs are complex Texture Data Vertex Rasterization Vertex Data Pixel Pipeline Framebuffer Pipeline State State Vertex Shader Pixel Shader

  6. GPU API ● Specs unknown ● Every GPU is different ● State is enormous (>1GB size) ● DMA & Computation

  7. Graphic Stack Application Mesa3D libGL State Tracker DRI, Mesa Gallium Classic Mesa HW Driver Classic WinSys libDRM Kernel DRM KMS

  8. Mesa3D ● Provides High Level APIs ○ 3D Acceleration: OpenGL/OpenGLES ○ Video Acceleration: XVMC, VAAPI, VDPAU ● Device dependant ● Divided in 2 parts: Mesa classic & Gallium3D

  9. Gallium3D ● New architecture for graphic devices ● Allows code-sharing between drivers ● Used by radeon, nouveau & others ● Provides software fallback

  10. Gallium API ● Screen: screen access, context & resource creation ● Resource: texture or buffer ● Surface: resource binded as a framebuffer ● Sampler view: resource for shader use ● Context: constant state, resources

  11. Gallium Shaders: TGSI ● Intermediate language for shaders ● Text based ● API not stable yet

  12. TGSI Example VERT DCL IN[0] DCL IN[1] DCL OUT[0], POSITION DCL OUT[1], COLOR IMM FLT32 { 0.2, -0.1, 0.0, 0.0 } ADD OUT[0], IN[0], IMM[0] MOV OUT[1], IN[1] END

  13. EGL/GLX ● Graphics context management ● Surface/buffer binding ● EGL is an interface between OpenGL and the windowing system

  14. DRM ● Low level access to the GPU ● Perform Kernel Mode Setting ● Export GPU Primitives ○ Context allocations ○ Command queues ○ VRAM management with GEM & TTM ○ Buffer sharing with GEM & DMA-buf ● libDRM in userland wraps the interface

  15. KMS ● In kernel API for modsetting ● Allow modesetting without root access ● Glitch-free boot ● Fast VT-Switch ● Kernel crash log ● Better power management

  16. How can we have all of this inside a VM ?

  17. Qemu/KVM ● Linux Hypervisor ● Leverage existing Linux APIs ● Use Qemu for VM Creation & Device Emulation

  18. Qemu/KVM guest guest guest driver driver driver virtual virtual virtual device device device Qemu Qemu Qemu KVM Linux Kernel Virtualization HW Hardware Extensions

  19. Device Virtualization ● Emulated Devices ○ Too Slow ○ GPU are too complex ● Virtualized Devices ○ Hard to do it right ○ What we want to do ● Hardware Passthrough ○ Good performances ○ No sharing

  20. Virtualized OpenGL stack ● API remoting ● Virtual GPU ● HW Sharing: XenGT, Grid

  21. API Remoting Guest Host App App App RPC Endpoint User-Level 3D API Redirector 3D API API API GPU Driver Kernel GPU Hardware

  22. Device Emulation Guest Host GPU Emulator State Management App App App Rendering Backend User-Level 3D API 3D API API API GPU Driver Kernel Virtual GPU Driver Kernel GPU Hardware Virtual GPU Hardware Shared Memory

  23. Virtio Devices ● Standard for virtualized devices ● Already used for net, block & console ● Easy code reuse

  24. Virgl ● Virtio based virtual gpu ● Developed by David Airlie ● 2d and 3d version ● Portability: no need for a specific gpu

  25. Virgl: What’s in it? ● vga device in Qemu ● Renderer Backend in Qemu (for 2D & 3D) ● KMS kernel driver for the guest ● Xorg DDX driver for guest ● Mesa Gallium3D based driver for guest

  26. Virgl: virtio ● Single virtio queue used to send commands to the host ● Protocol is based on Gallium3D ● IRQ for Cursor & Fence IRQ

  27. Current Status ● Error handling ● Capabilities (OpenGL 3.0 for the moment) ● GL versioning ● GLES in guest or host ● Not usable for production yet

  28. Want to try it? http://virgil3d.github.io/ Questions?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend