SlideShare a Scribd company logo
1 of 60
Download to read offline
Faculty of Computer Science Institute for System Architecture, Operating Systems Group




Advanced Components on
Top of A Microkernel
Björn Döbel
What we talked about so far

• Microkernels are cool!

• Fiasco.OC provides fundamental mechanisms:
      – Tasks (address spaces)
         • Container of resources
      – Threads
         • Units of execution
      – Inter-Process Communication
         • Exchange Data
         • Timeouts
         • Mapping of resources


TU Dresden, 2012-07-24    L4Re: Advanced Components   Slide 2 / 54
Lecture Outline

• Building a real system on top of Fiasco.OC

• Reusing legacy libraries
      – POSIX C library

• Device Drivers in user space
      – Accessing hardware resources
      – Reusing Linux device drivers

• OS virtualization on top of L4Re



TU Dresden, 2012-07-24     L4Re: Advanced Components   Slide 3 / 54
Reusing Existing Software

• Often used term: legacy software

• Why?
      – Convenience:
         • Users get their “favorite” application on the
           new OS
      – Effort:
         • Rewriting everything from scratch takes a
           lot of time
         • But: maintaining ported software and
           adaptions also does not come for free


TU Dresden, 2012-07-24    L4Re: Advanced Components   Slide 4 / 54
Reusing Existing Software

• How?
      – Porting:
            • Adapt existing software to use L4Re/Fiasco.OC
              features instead of Linux
            • Efficient execution, large maintenance effort
      – Library-level interception
            • Port convenience libraries to L4Re and link legacy
              applications without modification
                   – POSIX C libraries, libstdc++
      – OS-level interception
            • Wine: implement Windows OS interface on top of new
              OS
      – Hardware-level:
            • Virtual Machines

TU Dresden, 2012-07-24           L4Re: Advanced Components    Slide 5 / 54
Starting Point: Monolithic OS



                   Application         Application         Application     Application
User mode

Kernel
mode
                                                 System-Call Interface


                             File Systems     Networking      Processes       Memory
                                  VFS           Sockets       Scheduling    Management
              Linux       File System Impl.    Protocols         IPC       Page allocation
              Kernel                                                       Address spaces
                                   Device Drivers                            Swapping



                                                     Hardware Access




 TU Dresden, 2012-07-24                 L4Re: Advanced Components                        Slide 6 / 54
Microkernel: Decomposed System



                    Application   Application        Application        Application
User mode



                   File System                                                 TCP/IP
                      Server                                                   Server
                                       Disk                   Network
                                      Driver                   Driver


Kernel
mode
                                     Microkernel




                           COMPLEX!
 TU Dresden, 2012-07-24           L4Re: Advanced Components                           Slide 7 / 54
Idea: Central Server

                   Application      Application        Application        Application
User mode



                  File Descriptor       Socket
                                                                   Linux OS Personality
                   Management         Management




                   File System                                                   TCP/IP
                      Server                                                     Server
                                         Disk                   Network
                                        Driver                   Driver


Kernel
mode
                                       Microkernel




 - Complexity only hidden in OS personality
 - Personality becomes a bottleneck
 TU Dresden, 2012-07-24             L4Re: Advanced Components                           Slide 8 / 54
L4Re: Emulation Libraries

                   Application         Application          Application         Application
User mode
                    C Library           C Library            C Library           C Library
                    VFS     Socket      VFS      Socket      VFS     Socket      VFS     Socket
                  Library   Library   Library    Library   Library   Library   Library   Library




                   File System                                                           TCP/IP
                      Server                                                             Server
                                                 Disk                Network
                                                Driver                Driver


Kernel
mode
                                            Microkernel




 - Applications use common C interface (POSIX)
 - Complexity split across “backend” libraries
 TU Dresden, 2012-07-24                L4Re: Advanced Components                                Slide 9 / 54
POSIX

• Standard: Portable Operating System Interface (for
  UNIX*)
• Interfaces:
   – I/O: files, sockets, TTYs
   – Threads: libpthread
   – ...
• Usually provided by a C library
• Abstractions vs. dependencies:
   – memcpy(), strcpy() → no deps, simply reuse
   – malloc() → depends on mmap() / sbrk()
   – getpwent() → depends on file system, notion of
     users, Posix ACLs ...


TU Dresden, 2012-07-24    L4Re: Advanced Components   Slide 10 / 54
POSIX on L4Re

      Linux                                                     L4Re
   Application                  memcpy()                      Application
                                fopen()
glibC + System               gettimeofday()                     uClibC
 Call Bindings
                                                     L4Re L4Re VFS L4Re
                                  open()             Mem RomFS ExtFS Time
                                  read()              BE   BE   BE    BE Backends
                                  mmap()

    System Call
       Entry
                         L4Re::Env::mem_alloc()                           Ext4FS
  VFS / Memory              L4::L4fs::open()
  Management                                                              Server
                                                     Memory rom/
                                                     Allocator File Sys
  ext4         FAT                                                         Disk       RTC
                                                        Roottask          Driver     Server
  Linux Kernel
                                                            Fiasco.OC Kernel
TU Dresden, 2012-07-24          L4Re: Advanced Components                      Slide 11 / 54
L4Re Backend Example: time()

time_t time(time_t *t)
 time_t time(time_t *t)
                                               Replacement of POSIX'
{
 {                                             time() function
   struct timespec a;
    struct timespec a;
   libc_be_rt_clock_gettime(&a);
    libc_be_rt_clock_gettime(&a);
   if (t)
    if (t)                     uint64_t __libc_l4_rt_clock_offset;
      *t = a.tv_sec;            uint64_t __libc_l4_rt_clock_offset;
       *t = a.tv_sec;
   return a.tv_sec;            int libc_be_rt_clock_gettime(struct timespec *t)
    return a.tv_sec;            int libc_be_rt_clock_gettime(struct timespec *t)
}                              {
 }                              {
                                  uint64_t clock;
                                   uint64_t clock;
                                  clock = l4re_kip()­>clock();
                                   clock = l4re_kip()­>clock();
                                  clock += __libc_l4_rt_clock_offset;
                                   clock += __libc_l4_rt_clock_offset;
   Call L4Re-specific             t­>tv_sec  = clock / 1000000;
   backend function                t­>tv_sec  = clock / 1000000;
                                  t­>tv_nsec = (clock % 1000000) * 1000;
                                   t­>tv_nsec = (clock % 1000000) * 1000;
                                  return 0;
                                   return 0;
                               }
                                }
      TU Dresden, 2012-07-24        L4Re: Advanced Components          Slide 12 / 54
L4Re Backend: mmap

• libC implements memory allocator
• Uses mmap(... MAP_ANONYMOUS …) to allocate
  backing memory
• Can reuse libC's allocator if we provide mmap()

• L4Re VFS library:
      – mmap(MAP_PRIVATE|MAP_ANONYMOUS):
          → use dataspace as backing memory
          → attach DS via L4RM interface




TU Dresden, 2012-07-24   L4Re: Advanced Components   Slide 13 / 54
Summary: Legacy Reuse

• L4Re provides C (and C++) standard library

• OS-specific functionality wrapped by backend
  libraries
      –   Virtual file system
      –   Memory allocation
      –   Time
      –   Signals
      –   Sockets

• POSIX support nearly directly enables a wide
  range of other libraries:
      – libpng, freetype, libcairo, Qt, ...

TU Dresden, 2012-07-24     L4Re: Advanced Components   Slide 14 / 54
Moving on: Device Drivers

• Now that I have a virtual file system, I'd
  actually like to access the disk …
      – … or the network
      – … or my USB webcam.

• Microkernel philosophy: run non-essential
  components in user space

• But: device drivers might need privileged
  hardware access.



TU Dresden, 2012-07-24    L4Re: Advanced Components   Slide 15 / 54
Some statistics

• [Swift03]: Drivers cause 85% of Windows XP crashes.

• [Chou01]:
   – Error rate in Linux drivers is 3x (maximum: 10x)
     higher than for the rest of the kernel
   – Bugs cluster (if you find one bug, you're more likely
     to find another one pretty close)
   – Life expectancy of a bug in the Linux kernel (~2.4):
     1.8 years

• [Rhyzyk09]: Causes for driver bugs
   – 23% programming error
   – 38% mismatch regarding device specification
   – 39% OS-driver-interface misconceptions
TU Dresden, 2012-07-24
Anecdote: Linux e1000 NVRAM bug

• Aug 8th 2008 Bug report: e1000 PCI-X network
    cards rendered broken by Linux 2.6.27-rc
      – overwritten NVRAM on card




TU Dresden, 2012-07-24
Anecdote: Linux e1000 NVRAM bug

• Aug 8th 2008 Bug report: e1000 PCI-X network
    cards rendered broken by Linux 2.6.27-rc
      – overwritten NVRAM on card

• Oct 1st 2008 Intel releases quickfix
      – map NVRAM somewhere else




TU Dresden, 2012-07-24
Anecdote: Linux e1000 NVRAM bug

• Aug 8th 2008 Bug report: e1000 PCI-X network
    cards rendered broken by Linux 2.6.27-rc
      – overwritten NVRAM on card

• Oct 1st 2008 Intel releases quickfix
      – map NVRAM somewhere else

• Oct 15th 2008 Reason found:
      – dynamic ftrace framework tries to patch __init code,
        but .init sections are unmapped after running init code
      – NVRAM got mapped to same location
      – Scary cmpxchg() behavior on I/O memory




TU Dresden, 2012-07-24
Anecdote: Linux e1000 NVRAM bug

• Aug 8th 2008 Bug report: e1000 PCI-X network
    cards rendered broken by Linux 2.6.27-rc
      – overwritten NVRAM on card

• Oct 1st 2008 Intel releases quickfix
      – map NVRAM somewhere else

• Oct 15th 2008 Reason found:
      – dynamic ftrace framework tries to patch __init code,
        but .init sections are unmapped after running init code
      – NVRAM got mapped to same location
      – Scary cmpxchg() behavior on I/O memory

• Nov 2nd 2008 dynamic ftrace reworked for Linux
    2.6.28-rc3
TU Dresden, 2012-07-24
Idea: User-level Drivers

• Isolate components
      – device drivers (disk, network, graphic, USB cruise
        missiles, ...)
      – stacks (TCP/IP, file systems, …)

• Separate address spaces each
   – More robust components

• Problems
      – Overhead
         • HW multiplexing
         • Context switches
      – Need to handle I/O privileges


TU Dresden, 2012-07-24
Hardware Resources: Interrupts

• Signal device state change
• Programmable Interrupt Controller (PIC, APIC)
      – map HW IRQs to CPU's IRQ lines
      – prioritize interrupts
                System                     PCI
                 Bus                       Bus
    CPU                     PIC
          INT
                              INT A
                              INT B              IDE   NET   USB
                              INT C


                         Chipset

                                  Memory
                                   Bus


                          Memory

TU Dresden, 2012-07-24
Hardware Resources: Interrupts (2)

• Handling interrupts involves
      – examine / manipulate device
      – program PIC
         • acknowledge/mask/unmask interrupts
                System                     PCI
                 Bus                       Bus
    CPU                     PIC
          INT
                              INT A
                              INT B              IDE   NET   USB
                              INT C


                         Chipset

                                  Memory
                                   Bus


                          Memory

TU Dresden, 2012-07-24
L4: Interrupt handling

• IRQ kernel object
      – Represents arbitrary async notification
      – Kernel maps hardware IRQs to IRQ objects
• Exactly one waiter per object
      – call l4_irq_attach() before
      – wait using l4_irq_receive()
• Multiple IRQs per waiter
      – attach to multiple objects
      – use l4_ipc_wait()
• IRQ sharing
      – Many IRQ objects may be chain()ed to a master
        IRQ object

TU Dresden, 2012-07-24
Hardware Resources: I/O ports

• x86-specific feature
• I/O ports define own I/O address space
      – Each device uses its own area within this address
        space
• Special instruction to access I/O ports
      – in / out: I/O read / write
      – Example: read byte from serial port
        mov $0x3f8, %edx
        in  (%dx), %al
• Need to restrict I/O port access
      – Allow device drivers access to I/O ports used by its
        device only


TU Dresden, 2012-07-24
I/O Bitmap

• Per task IO privilege level (IOPL)
• If IOPL > current PL, all
  accesses are allowed
  (kernel mode)
• Else: I/O bitmap is checked      #0xfff0   1111111111011011
• 1 bit per I/O port               #0xffe0   1111111111111111
   – 65536 ports -> 8kB                              ...
• Controls port access             #0x0000   1111111111111111
  (0 == ok, 1 == GPF)
• L4: per-task I/O bitmap
                                             I/O Map Base Address
   – Switched during task switch
   – Allows per-task grant/deny of
      I/O port access
                                                     TSS
TU Dresden, 2012-07-24
Fiasco.OC: I/O Flexpages

• Reuse kernel's map/grant mechanism for mapping
  I/O port rights -> I/O flexpages
• Kernel detects type of flexpage and acts
  accordingly
• Task with all I/O ports mapped is raised to IOPL 3

                                             Map/Grant



1111           Base Port            0000 log2#Ports 0
L4.Fiasco I/O flexpage format




TU Dresden, 2012-07-24
Hardware Resources: I/O Memory

• Devices often contain on-chip memory (NICs, graphcis
  cards, ...)
• Instead of accessing through I/O ports, drivers can
  map this memory into their address space just like
  normal RAM
   – no need for special instructions
   – increased flexibility by using underlying virtual
     memory management
                         Driver               Memory


                         Kernel
                         Fiasco Microkernel
       Software

       Hardware
                           CPU                 Chipset   Device
                                                                Memory



TU Dresden, 2012-07-24                         Memoy
Hardware Resources: I/O memory (2)

• Device memory looks just like phys. memory
• Chipset needs to
      – map I/O memory to exclusive address ranges
      – distinguish physical and I/O memory access

                         Driver

                         Kernel
                         Fiasco Microkernel
       Software

       Hardware
                           CPU                Chipset   Device
                                                               Memory



                                              Memory


TU Dresden, 2012-07-24
I/O memory in L4

• Like all memory, I/O memory is owned by sigma0
• Sigma0 implements protocol to request I/O memory
  pages
• Abstraction: Dataspaces containing I/O memory

                         Driver 1             Driver 2


                         Sigma0

                         Kernel
                         Fiasco Microkernel
       Software

       Hardware
                           CPU                  Chipset

                                                          Device 1   Device 2
                                                Memory

TU Dresden, 2012-07-24
Can I trust my driver?

• Scenario: devices attached to a PCI bus
• Driver needs access to PCI configuration space
   – I/O resource discovery
   – Enable/disable device interrupts
• PCI config space access:
   – Write (bus, device, function#) to I/O port 0xCF8
   – Read/write data to/from I/O port 0xCFC
• Problem:
   – Who makes sure that my driver uses the proper
     (bus, device, function) tuple?




TU Dresden, 2012-07-24     L4Re: Advanced Components   Slide 31 / 54
L4Re: Device Management

• Solution: only provide access to those
  devices, a driver is supposed to access
• I/O server + virtual buses

       Network                      Disk                              Sound
        Driver                     Driver                             Driver




                                  I/O server

                                                                                PCI bus
      NIC                Disk 1     Disk 2                     Sound card


TU Dresden, 2012-07-24             L4Re: Advanced Components                   Slide 32 / 54
Summary: Fiasco.OC/L4Re Device Drivers

• Interrupts → Mapped to IPC

• I/O ports → Managed as kernel resource

• I/O memory → Cleanly integrates with L4
  memory management

• PCI bus → Managed by separate I/O server




TU Dresden, 2012-07-24    L4Re: Advanced Components   Slide 33 / 54
Implementing Device Drivers

• Just like in any other OS:
      – Specify a server interface
      – Implement interface, use the access methods
        provided by the runtime environment
•   Highly optimized code possible
•   Hard to maintain
•   Implementation time-consuming
•   Unavailable specifications
•   Why reimplement drivers if there are already
    versions available?
      – Linux, BSD – Open Source
      – Windows – Binary drivers

TU Dresden, 2012-07-24
Reusing Legacy Device Drivers

• NDIS-Wrapper: Linux glue
  library to run Windows WiFi
  drivers on Linux
                                          Windows
                                           Driver
• Idea is simple: provide a                Code

  library mapping Windows API             Glue Code
  to Linux
                                            Linux

• Implementation is a problem.




TU Dresden, 2012-07-24
Reusing Legacy Device Drivers (2)

• Generalize the idea: provide a Linux
  environment to run drivers on L4
      → Device Driver Environment (DDE)




TU Dresden, 2012-07-24
Emulating Linux: DDE/Linux

• Multiple L4 threads provide a Linux environment
      –   Workqueues
      –   SoftIRQs / Bottom Halves
      –   Timers
      –   Jiffies
• Emulate SMP-like system (each L4 thread
  assumed to be one processor)
• Wrap Linux functionality
      – kmalloc() → L4 Slab allocator library
      – Linux spinlock → pthread mutex
• Handle in-kernel accesses (e.g., PCI config space)



TU Dresden, 2012-07-24
Multiple Donator OSes




TU Dresden, 2012-07-24
DDEKit – another abstraction

• Pull common abstractions
  into dedicated library
   – Threads
   – Synchronization
   – Memory
   – IRQ handling
   – I/O port access
     → DDE Construction Kit
        (DDEKit)

• Implement DDEs against the
  DDEKit interface



TU Dresden, 2012-07-24
DDEKit (2)

• Implementation overhead for single DDEs gets
  much smaller
• Performance overhead still reasonable
      – e.g., no visible increase of network latency in user-
        level ethernet driver
• L4-specific parts (sloccount):
      –   standalone DDE Linux 2.4:        ~ 3.000 LoC
      –   DDEKit                           ~ 2.000 LoC
      –   DDEKit-based DDE Linux 2.6:      ~ 1.000 LoC
      –   Standalone Linux VM (DD/OS):     > 500.000 LoC
• Highly customizable: implement DDE base library
  and support libs (net, disk, sound, ...)

TU Dresden, 2012-07-24
DDEKit: portability

• Reversing the DDE idea: port DDEKit to host
  environment → reuse whole Linux support lib

• Has been done for:
      –   L4Env, L4Re
      –   Genode OS Framework
      –   Minix 3
      –   GNU/Hurd
      –   Linux




TU Dresden, 2012-07-24
Device Drivers: Isolation vs. Performance
Full Protection: Isolated              Best performance: all
Address Spaces                         in one address space

          Application
              uClibC
                                              Application
     L4Re Socket Backend
                                                   uClibC
                                  ?      L4Re Socket Backend

        TCP/IP Stack
                                             TCP/IP Library

     Linux       DDE
    Network
     Driver              DDEKit           Linux        DDE
                                         Network
         Network Server                   Driver        DDEKit



      Fiasco.OC Kernel                     Fiasco.OC Kernel
TU Dresden, 2012-07-24
Device Sharing?

• Problem: Devices often            Application            Application
  don't support shared access         uClibC                 uClibC
  from multiple applications        TCP/IP Library         TCP/IP Library




                                                              ?

                                          Linux      DDE
                                         Network
                                          Driver           DDEKit

                                             Network Server




TU Dresden, 2012-07-24
Device Sharing?

• Problem: Devices often            Application          Application
  don't support shared access         uClibC               uClibC
  from multiple applications        TCP/IP Library      TCP/IP Library


• Solution: Introduce
  “virtualized” intermediary
  interfaces

• Networking on L4Re: Ankh                 VNIC          VNIC
  network multiplexer                          Mutiplexing

   – Shared memory NIC for                  Linux     DDE
                                           Network
     each client                            Driver   DDEKit
   – Virtual MAC addresses                   Network Server




TU Dresden, 2012-07-24
Virtual Machines

• Extreme approach to
  reusing existing software:
      – Run application inside the
        real OS
      – Wrap the OS in a virtual      Windows       Linux
        machine
      – Run the Virtual Machine on     VM 1         VM 2
        top of microkernel
• Advantages:                            Virtual Machine
      – Full guest OS interface               Monitor
        supported
      – Runs any binary that has       Microkernel Runtime
        been compiled for the guest
        OS without modification            Microkernel
• Problem: someone needs
  to implement a VMM!

TU Dresden, 2012-07-24
Approaches to Virtualization

• Goal: Make guest OS think it runs on real HW

• Emulation: simulate every instruction
      – Very slow
      – Allows for incompatible guest and host hardware

• Trap&Emulate: when guest and host HW are
  identical
      –   Execute on real processor as long as possible
      –   Privileged instructions lead to processor traps
      –   Handle those traps in VMM
      –   Requires virtualizable instruction set!


TU Dresden, 2012-07-24
Virtualizing Broken Instruction Sets

• Original x86 instruction set is not virtualizable
      – Some instructions behave differently in user and kernel
        mode
      – Not all such instructions cause a trap when executed in
        user mode

• Fix 1: Binary rewriting (VMware products)
   – Transform binary code so that broken instructions lead to
      a trap that can be handled by the VMM

• Fix 2: Correct the instruction set
   – Intel VT / AMD-V




TU Dresden, 2012-07-24
VMM Implementation Choices

Bare-Metal VMM            VMM on OS          Paravirtualization
- no OS overhead          - reuse infra-     - port guest OS to
- complete control           structure         host interface
- high effort             - may have worse   - no VMM overhead
                            performance      - maintenance cost


                             App    App

   App        App             Guest OS
                                                 App    App
     Guest OS                 Virtual HW
                                                  Guest OS
    Virtual HW              User-level VMM

 Host OS == VMM                    Host OS             Host OS

   Physical HW               Physical HW         Physical HW
 TU Dresden, 2012-07-24
Paravirtualizing Linux


                   Application         Application         Application     Application
User mode

Kernel
mode
                                                 System-Call Interface


                             File Systems     Networking      Processes       Memory
                                  VFS           Sockets       Scheduling    Management
              Linux       File System Impl.    Protocols         IPC       Page allocation
              Kernel                                                       Address spaces
                                   Device Drivers                            Swapping



                                                     Hardware Access




                                        Hardware
                                        CPU, Memory, PCI, Devices




 TU Dresden, 2012-07-24
Paravirtualizing Linux
                       Application           Application        Application     Application

                         L4 Task               L4 Task            L4 Task         L4 Task



Adapt to L4 IPC                                       System-Call Interface

                                  File Systems     Networking     Processes       Memory
                                       VFS           Sockets      Scheduling    Management
                               File System Impl.    Protocols        IPC       Page allocation
                                                                               Address spaces
                                        Device Drivers                           Swapping

  L4Re as HW                                             Hardware Access
  architecture
                                                     L4Linux kernel task

                                            L4 Runtime Environment
    User mode


    Kernel
    mode                                           Fiasco.OC

                                         Hardware
                                         CPU, Memory, PCI, Devices
      TU Dresden, 2012-07-24
L4Linux

• L4 as new “hardware” platform in Linux, relay
  tasks to Fiasco.OC
      – Thread switching + state management
      – MMU handling
      – Use Fiasco.OC interrupts

• Linux applications are L4 tasks
      – IPC used for
         • Kernel entry
         • Signal delivery
         • Copying from/to user space



TU Dresden, 2012-07-24
L4Linux: Kernel Entry

• Linux application executes INT 0x80 instruction

• Fiasco.OC receives CPU trap
• Fiasco.OC relays handling to user-level handler
   – Every thread has an exception handler assigned
   – Similar to a page fault, kernel generates exception
     IPC message
       • Contains whole CPU state

• Linux kernel task is exception handler for user
  applications
      • Receives exception IPC
      • Handles system call
      • Replies to let user app continue
TU Dresden, 2012-07-24
Simplifying Exception Handling

• Fiasco.OC extension: vCPU
      – Thread with additional properties:
          • “kernel” task
          • “user” task
      – l4_vcpu_resume() → move thread to user task and
        let it execute
      – Upon CPU exception: move whole thread to kernel
        task and set it to dedicated kernel EIP/ESP
      – Kernel then calls l4_vcpu_resume() again

• Greatly simplifies L4Linux implementation:
   – Same mechanism used for interrupts, page faults,
     system calls, ...

TU Dresden, 2012-07-24
Assignment #3

       Make your encryption server (from assignment
       #2) accessible to an L4Linux user application.

                                   Isolated VM
                                                   L4
         Linux           Linux    Linux
          App             App      App       X   Crypto
                                                 Server




                                 L4Linux




TU Dresden, 2012-07-24
Assignment #3

       Make your encryption server (from assignment
       #2) accessible to an L4Linux user application.

                                   Isolated VM
                                                   L4
         Linux           Linux    Linux
                                                 Crypto
          App             App      App
                                                 Server


          /dev/l4crypt
                             L4Crypt
                              Linux
                              Driver

                                 L4Linux




TU Dresden, 2012-07-24
Step 1: Download and build L4Linux

• Instructions: http://os.inf.tu-dresden.de/L4/LinuxOnL4/
• You will need a bunch of additional L4 packages
      – Route A: the build system complains about missing
        packages → fetch them with “svn up” in l4/pkg directory
      – Route B: this is the list you'll need:
        acpica drivers examples fb-drv input io
        libevent libio-io libirq libvcpu lxfuxlibc
        mag mag-gfx rtc shmc x86emu zlib
• When configuring L4Linux:
      – Leave L4 options as they are (only set proper L4Re build
        directory)
      – Disable as much HW options (PCI, SATA, SCSI,
        Networking, …) as you can
         • Faster builds
         • We don't need hardware right now

TU Dresden, 2012-07-24
Step 2: Running L4Linux

• Example files in l4/conf/examples:
      – l4lx-x86.io → Config file for virtual PCI bus (that will
        contain PS2 input device, frame buffer and any PCI
        devs … but you disabled PCI in step 1, remember?)
      – l4lx-gfx.cfg → Lua init script to launch L4Linux and
        a graphical console

• There's also an entry in l4/conf/modules.lst
  already.

• For a root file system:
      – Download an initrd, e.g., from
        http://os.inf.tu-dresden.de/download/
      – Build your own initrd
TU Dresden, 2012-07-24
Step 3: Implementing the Driver

• Linux side: use a standard chardev for
  communication between driver and
  applications

• L4 side:
      – L4Linux kernel modules are built as any other
        Linux kernel module
      – You may include and use L4 headers as in any
        other L4 application
      – For IPC: no C++ streaming – Linux is C code,
        so write to the UTCB yourself


TU Dresden, 2012-07-24
Happy Hacking!



 Don't perform any L4 system call
   between writing the UTCB and
  sending the IPC message to your
               server!


             Log output (printk, …) is an L4 system call!




TU Dresden, 2012-07-24
Further Reading

• H. Weisbach et al. “Generic User-Level PCI Drivers”
    http://os.inf.tu-dresden.de/papers_ps/rtlws2011-dde.pdf
    Bringing the DDE approach to Linux

• Lackorzynski et al. “Generic Virtualization with Virtual
  Processors”
    http://os.inf.tu-dresden.de/papers_ps/rtlws2010_genericvirt.pdf
    Introducing the L4Linux vCPU model


• Steinberg et al.: “NOVA: A Microhypervisor-based Secure
  Virtualization Architecture”
    http://os.inf.tu-dresden.de/papers_ps/steinberg_eurosys2010.pdf
    A bare-metal microhypervisor

• Singaravelu et al.: “Enforcing Configurable Trust in Client-
  side Software Stacks by Splitting Information Flow”
    http://os.inf.tu-dresden.de/papers_ps/git-cercs-07-11.pdf
    Splitting applications into trusted and untrusted parts
TU Dresden, 2012-07-24       L4Re: Advanced Components                Slide 60 / 54

More Related Content

What's hot

組み込みから HPC まで ARM コアで実現するエコシステム
組み込みから HPC まで ARM コアで実現するエコシステム組み込みから HPC まで ARM コアで実現するエコシステム
組み込みから HPC まで ARM コアで実現するエコシステムShinnosuke Furuya
 
Linux Porting to a Custom Board
Linux Porting to a Custom BoardLinux Porting to a Custom Board
Linux Porting to a Custom BoardPatrick Bellasi
 
Preventing Linux in your car from killing you: The L4Re Open Source Microviso...
Preventing Linux in your car from killing you: The L4Re Open Source Microviso...Preventing Linux in your car from killing you: The L4Re Open Source Microviso...
Preventing Linux in your car from killing you: The L4Re Open Source Microviso...Linaro
 
linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
 
Project meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewProject meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewYu-Hsin Hung
 
EB corbos and the L4Re microhypervisor: Open-source automotive safety
EB corbos and the L4Re microhypervisor: Open-source automotive safetyEB corbos and the L4Re microhypervisor: Open-source automotive safety
EB corbos and the L4Re microhypervisor: Open-source automotive safetyAlexander Much
 
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...ijafrc
 
Android Binder IPC for Linux
Android Binder IPC for LinuxAndroid Binder IPC for Linux
Android Binder IPC for LinuxYu-Hsin Hung
 
Toward dynamic analysis of obfuscated android malware
Toward dynamic analysis of obfuscated android malwareToward dynamic analysis of obfuscated android malware
Toward dynamic analysis of obfuscated android malwareZongXian Shen
 
LCE13: Android Graphics Upstreaming
LCE13: Android Graphics UpstreamingLCE13: Android Graphics Upstreaming
LCE13: Android Graphics UpstreamingLinaro
 
ACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelSUSE Labs Taipei
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateLinaro
 
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...The Linux Foundation
 

What's hot (20)

組み込みから HPC まで ARM コアで実現するエコシステム
組み込みから HPC まで ARM コアで実現するエコシステム組み込みから HPC まで ARM コアで実現するエコシステム
組み込みから HPC まで ARM コアで実現するエコシステム
 
Linux Porting to a Custom Board
Linux Porting to a Custom BoardLinux Porting to a Custom Board
Linux Porting to a Custom Board
 
Preventing Linux in your car from killing you: The L4Re Open Source Microviso...
Preventing Linux in your car from killing you: The L4Re Open Source Microviso...Preventing Linux in your car from killing you: The L4Re Open Source Microviso...
Preventing Linux in your car from killing you: The L4Re Open Source Microviso...
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Improve Android System Component Performance
Improve Android System Component PerformanceImprove Android System Component Performance
Improve Android System Component Performance
 
Project meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewProject meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture Overview
 
EB corbos and the L4Re microhypervisor: Open-source automotive safety
EB corbos and the L4Re microhypervisor: Open-source automotive safetyEB corbos and the L4Re microhypervisor: Open-source automotive safety
EB corbos and the L4Re microhypervisor: Open-source automotive safety
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Android Virtualization: Opportunity and Organization
Android Virtualization: Opportunity and OrganizationAndroid Virtualization: Opportunity and Organization
Android Virtualization: Opportunity and Organization
 
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
 
Embedded Android : System Development - Part I
Embedded Android : System Development - Part IEmbedded Android : System Development - Part I
Embedded Android : System Development - Part I
 
Android Binder IPC for Linux
Android Binder IPC for LinuxAndroid Binder IPC for Linux
Android Binder IPC for Linux
 
Toward dynamic analysis of obfuscated android malware
Toward dynamic analysis of obfuscated android malwareToward dynamic analysis of obfuscated android malware
Toward dynamic analysis of obfuscated android malware
 
LCE13: Android Graphics Upstreaming
LCE13: Android Graphics UpstreamingLCE13: Android Graphics Upstreaming
LCE13: Android Graphics Upstreaming
 
ACPI Debugging from Linux Kernel
ACPI Debugging from Linux KernelACPI Debugging from Linux Kernel
ACPI Debugging from Linux Kernel
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack Update
 
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
 
Understanding open max il
Understanding open max ilUnderstanding open max il
Understanding open max il
 
Embedded Android : System Development - Part IV
Embedded Android : System Development - Part IVEmbedded Android : System Development - Part IV
Embedded Android : System Development - Part IV
 

Similar to Advanced Components on Top of L4Re

Introduction to Microkernels
Introduction to MicrokernelsIntroduction to Microkernels
Introduction to MicrokernelsVasily Sartakov
 
Visual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & VirtualisationVisual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & Virtualisationwangyuanyi
 
Linux Performance Analysis and Tools
Linux Performance Analysis and ToolsLinux Performance Analysis and Tools
Linux Performance Analysis and ToolsBrendan Gregg
 
Enea Linux and LWRT FTF China 2012
Enea Linux and LWRT FTF China 2012Enea Linux and LWRT FTF China 2012
Enea Linux and LWRT FTF China 2012EneaSoftware
 
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copyLinux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copyBoden Russell
 
Linux internal
Linux internalLinux internal
Linux internalmcganesh
 
Linux@assignment ppt
Linux@assignment pptLinux@assignment ppt
Linux@assignment pptRama .
 
Linux architecture
Linux architectureLinux architecture
Linux architecturemcganesh
 
Linux architecture
Linux architectureLinux architecture
Linux architecturemcganesh
 
Dataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and toolsDataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and toolsStefano Salsano
 
RHCE (RED HAT CERTIFIED ENGINEERING)
RHCE (RED HAT CERTIFIED ENGINEERING)RHCE (RED HAT CERTIFIED ENGINEERING)
RHCE (RED HAT CERTIFIED ENGINEERING)Sumant Garg
 
Linux Container Brief for IEEE WG P2302
Linux Container Brief for IEEE WG P2302Linux Container Brief for IEEE WG P2302
Linux Container Brief for IEEE WG P2302Boden Russell
 
How devops exhausts itself, and what will happen next
How devops exhausts itself, and what will happen nextHow devops exhausts itself, and what will happen next
How devops exhausts itself, and what will happen nextKirill Vechera
 
Ch20 OS
Ch20 OSCh20 OS
Ch20 OSC.U
 

Similar to Advanced Components on Top of L4Re (20)

Introduction to Microkernels
Introduction to MicrokernelsIntroduction to Microkernels
Introduction to Microkernels
 
淺談探索 Linux 系統設計之道
淺談探索 Linux 系統設計之道 淺談探索 Linux 系統設計之道
淺談探索 Linux 系統設計之道
 
L4 Microkernel :: Design Overview
L4 Microkernel :: Design OverviewL4 Microkernel :: Design Overview
L4 Microkernel :: Design Overview
 
Visual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & VirtualisationVisual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & Virtualisation
 
Linux Performance Analysis and Tools
Linux Performance Analysis and ToolsLinux Performance Analysis and Tools
Linux Performance Analysis and Tools
 
Enea Linux and LWRT FTF China 2012
Enea Linux and LWRT FTF China 2012Enea Linux and LWRT FTF China 2012
Enea Linux and LWRT FTF China 2012
 
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copyLinux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
Linux containers – next gen virtualization for cloud (atl summit) ar4 3 - copy
 
Linux internal
Linux internalLinux internal
Linux internal
 
Linux@assignment ppt
Linux@assignment pptLinux@assignment ppt
Linux@assignment ppt
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
 
Dataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and toolsDataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and tools
 
RHCE (RED HAT CERTIFIED ENGINEERING)
RHCE (RED HAT CERTIFIED ENGINEERING)RHCE (RED HAT CERTIFIED ENGINEERING)
RHCE (RED HAT CERTIFIED ENGINEERING)
 
Filesystems, RPC and HDFS
Filesystems, RPC and HDFSFilesystems, RPC and HDFS
Filesystems, RPC and HDFS
 
Linux Container Brief for IEEE WG P2302
Linux Container Brief for IEEE WG P2302Linux Container Brief for IEEE WG P2302
Linux Container Brief for IEEE WG P2302
 
How devops exhausts itself, and what will happen next
How devops exhausts itself, and what will happen nextHow devops exhausts itself, and what will happen next
How devops exhausts itself, and what will happen next
 
OS_Ch20
OS_Ch20OS_Ch20
OS_Ch20
 
OSCh20
OSCh20OSCh20
OSCh20
 
Ch20 OS
Ch20 OSCh20 OS
Ch20 OS
 
Linux Driver and Embedded Developer Course Highlights
Linux Driver and  Embedded Developer Course HighlightsLinux Driver and  Embedded Developer Course Highlights
Linux Driver and Embedded Developer Course Highlights
 

More from Vasily Sartakov

Мейнстрим технологии шифрованной памяти
Мейнстрим технологии шифрованной памятиМейнстрим технологии шифрованной памяти
Мейнстрим технологии шифрованной памятиVasily Sartakov
 
RnD Collaborations in Asia-Pacific Region
RnD Collaborations in Asia-Pacific RegionRnD Collaborations in Asia-Pacific Region
RnD Collaborations in Asia-Pacific RegionVasily Sartakov
 
Сетевая подсистема в L4Re и Genode
Сетевая подсистема в L4Re и GenodeСетевая подсистема в L4Re и Genode
Сетевая подсистема в L4Re и GenodeVasily Sartakov
 
Защита памяти при помощи NX-bit в среде L4Re
Защита памяти при помощи NX-bit в среде L4ReЗащита памяти при помощи NX-bit в среде L4Re
Защита памяти при помощи NX-bit в среде L4ReVasily Sartakov
 
Hardware Errors and the OS
Hardware Errors and the OSHardware Errors and the OS
Hardware Errors and the OSVasily Sartakov
 
Operating Systems Meet Fault Tolerance
Operating Systems Meet Fault ToleranceOperating Systems Meet Fault Tolerance
Operating Systems Meet Fault ToleranceVasily Sartakov
 
Operating Systems Hardening
Operating Systems HardeningOperating Systems Hardening
Operating Systems HardeningVasily Sartakov
 
Особенности Национального RnD
Особенности Национального RnDОсобенности Национального RnD
Особенности Национального RnDVasily Sartakov
 
Применение Fiasco.OC
Применение Fiasco.OCПрименение Fiasco.OC
Применение Fiasco.OCVasily Sartakov
 
Прикладная Информатика 6 (36) 2011
Прикладная Информатика 6 (36) 2011Прикладная Информатика 6 (36) 2011
Прикладная Информатика 6 (36) 2011Vasily Sartakov
 
Разработка встраиваемой операционной системы на базе микроядерной архитектуры...
Разработка встраиваемой операционной системы на базе микроядерной архитектуры...Разработка встраиваемой операционной системы на базе микроядерной архитектуры...
Разработка встраиваемой операционной системы на базе микроядерной архитектуры...Vasily Sartakov
 

More from Vasily Sartakov (20)

Мейнстрим технологии шифрованной памяти
Мейнстрим технологии шифрованной памятиМейнстрим технологии шифрованной памяти
Мейнстрим технологии шифрованной памяти
 
RnD Collaborations in Asia-Pacific Region
RnD Collaborations in Asia-Pacific RegionRnD Collaborations in Asia-Pacific Region
RnD Collaborations in Asia-Pacific Region
 
Сетевая подсистема в L4Re и Genode
Сетевая подсистема в L4Re и GenodeСетевая подсистема в L4Re и Genode
Сетевая подсистема в L4Re и Genode
 
Защита памяти при помощи NX-bit в среде L4Re
Защита памяти при помощи NX-bit в среде L4ReЗащита памяти при помощи NX-bit в среде L4Re
Защита памяти при помощи NX-bit в среде L4Re
 
Hardware Errors and the OS
Hardware Errors and the OSHardware Errors and the OS
Hardware Errors and the OS
 
Operating Systems Meet Fault Tolerance
Operating Systems Meet Fault ToleranceOperating Systems Meet Fault Tolerance
Operating Systems Meet Fault Tolerance
 
Intro
IntroIntro
Intro
 
Genode OS Framework
Genode OS FrameworkGenode OS Framework
Genode OS Framework
 
Operating Systems Hardening
Operating Systems HardeningOperating Systems Hardening
Operating Systems Hardening
 
Особенности Национального RnD
Особенности Национального RnDОсобенности Национального RnD
Особенности Национального RnD
 
Genode Architecture
Genode ArchitectureGenode Architecture
Genode Architecture
 
Genode Components
Genode ComponentsGenode Components
Genode Components
 
Genode Programming
Genode ProgrammingGenode Programming
Genode Programming
 
Genode Compositions
Genode CompositionsGenode Compositions
Genode Compositions
 
Trusted Computing Base
Trusted Computing BaseTrusted Computing Base
Trusted Computing Base
 
System Integrity
System IntegritySystem Integrity
System Integrity
 
Intro
IntroIntro
Intro
 
Применение Fiasco.OC
Применение Fiasco.OCПрименение Fiasco.OC
Применение Fiasco.OC
 
Прикладная Информатика 6 (36) 2011
Прикладная Информатика 6 (36) 2011Прикладная Информатика 6 (36) 2011
Прикладная Информатика 6 (36) 2011
 
Разработка встраиваемой операционной системы на базе микроядерной архитектуры...
Разработка встраиваемой операционной системы на базе микроядерной архитектуры...Разработка встраиваемой операционной системы на базе микроядерной архитектуры...
Разработка встраиваемой операционной системы на базе микроядерной архитектуры...
 

Recently uploaded

FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

Advanced Components on Top of L4Re

  • 1. Faculty of Computer Science Institute for System Architecture, Operating Systems Group Advanced Components on Top of A Microkernel Björn Döbel
  • 2. What we talked about so far • Microkernels are cool! • Fiasco.OC provides fundamental mechanisms: – Tasks (address spaces) • Container of resources – Threads • Units of execution – Inter-Process Communication • Exchange Data • Timeouts • Mapping of resources TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 2 / 54
  • 3. Lecture Outline • Building a real system on top of Fiasco.OC • Reusing legacy libraries – POSIX C library • Device Drivers in user space – Accessing hardware resources – Reusing Linux device drivers • OS virtualization on top of L4Re TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 3 / 54
  • 4. Reusing Existing Software • Often used term: legacy software • Why? – Convenience: • Users get their “favorite” application on the new OS – Effort: • Rewriting everything from scratch takes a lot of time • But: maintaining ported software and adaptions also does not come for free TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 4 / 54
  • 5. Reusing Existing Software • How? – Porting: • Adapt existing software to use L4Re/Fiasco.OC features instead of Linux • Efficient execution, large maintenance effort – Library-level interception • Port convenience libraries to L4Re and link legacy applications without modification – POSIX C libraries, libstdc++ – OS-level interception • Wine: implement Windows OS interface on top of new OS – Hardware-level: • Virtual Machines TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 5 / 54
  • 6. Starting Point: Monolithic OS Application Application Application Application User mode Kernel mode System-Call Interface File Systems Networking Processes Memory VFS Sockets Scheduling Management Linux File System Impl. Protocols IPC Page allocation Kernel Address spaces Device Drivers Swapping Hardware Access TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 6 / 54
  • 7. Microkernel: Decomposed System Application Application Application Application User mode File System TCP/IP Server Server Disk Network Driver Driver Kernel mode Microkernel COMPLEX! TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 7 / 54
  • 8. Idea: Central Server Application Application Application Application User mode File Descriptor Socket Linux OS Personality Management Management File System TCP/IP Server Server Disk Network Driver Driver Kernel mode Microkernel - Complexity only hidden in OS personality - Personality becomes a bottleneck TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 8 / 54
  • 9. L4Re: Emulation Libraries Application Application Application Application User mode C Library C Library C Library C Library VFS Socket VFS Socket VFS Socket VFS Socket Library Library Library Library Library Library Library Library File System TCP/IP Server Server Disk Network Driver Driver Kernel mode Microkernel - Applications use common C interface (POSIX) - Complexity split across “backend” libraries TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 9 / 54
  • 10. POSIX • Standard: Portable Operating System Interface (for UNIX*) • Interfaces: – I/O: files, sockets, TTYs – Threads: libpthread – ... • Usually provided by a C library • Abstractions vs. dependencies: – memcpy(), strcpy() → no deps, simply reuse – malloc() → depends on mmap() / sbrk() – getpwent() → depends on file system, notion of users, Posix ACLs ... TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 10 / 54
  • 11. POSIX on L4Re Linux L4Re Application memcpy() Application fopen() glibC + System gettimeofday() uClibC Call Bindings L4Re L4Re VFS L4Re open() Mem RomFS ExtFS Time read() BE BE BE BE Backends mmap() System Call Entry L4Re::Env::mem_alloc() Ext4FS VFS / Memory L4::L4fs::open() Management Server Memory rom/ Allocator File Sys ext4 FAT Disk RTC Roottask Driver Server Linux Kernel Fiasco.OC Kernel TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 11 / 54
  • 12. L4Re Backend Example: time() time_t time(time_t *t) time_t time(time_t *t) Replacement of POSIX' { { time() function    struct timespec a;    struct timespec a;    libc_be_rt_clock_gettime(&a);    libc_be_rt_clock_gettime(&a);    if (t)    if (t) uint64_t __libc_l4_rt_clock_offset;       *t = a.tv_sec; uint64_t __libc_l4_rt_clock_offset;       *t = a.tv_sec;    return a.tv_sec; int libc_be_rt_clock_gettime(struct timespec *t)    return a.tv_sec; int libc_be_rt_clock_gettime(struct timespec *t) } { } {    uint64_t clock;    uint64_t clock;    clock = l4re_kip()­>clock();    clock = l4re_kip()­>clock();    clock += __libc_l4_rt_clock_offset;    clock += __libc_l4_rt_clock_offset; Call L4Re-specific    t­>tv_sec  = clock / 1000000; backend function    t­>tv_sec  = clock / 1000000;    t­>tv_nsec = (clock % 1000000) * 1000;    t­>tv_nsec = (clock % 1000000) * 1000;    return 0;    return 0; } } TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 12 / 54
  • 13. L4Re Backend: mmap • libC implements memory allocator • Uses mmap(... MAP_ANONYMOUS …) to allocate backing memory • Can reuse libC's allocator if we provide mmap() • L4Re VFS library: – mmap(MAP_PRIVATE|MAP_ANONYMOUS): → use dataspace as backing memory → attach DS via L4RM interface TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 13 / 54
  • 14. Summary: Legacy Reuse • L4Re provides C (and C++) standard library • OS-specific functionality wrapped by backend libraries – Virtual file system – Memory allocation – Time – Signals – Sockets • POSIX support nearly directly enables a wide range of other libraries: – libpng, freetype, libcairo, Qt, ... TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 14 / 54
  • 15. Moving on: Device Drivers • Now that I have a virtual file system, I'd actually like to access the disk … – … or the network – … or my USB webcam. • Microkernel philosophy: run non-essential components in user space • But: device drivers might need privileged hardware access. TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 15 / 54
  • 16. Some statistics • [Swift03]: Drivers cause 85% of Windows XP crashes. • [Chou01]: – Error rate in Linux drivers is 3x (maximum: 10x) higher than for the rest of the kernel – Bugs cluster (if you find one bug, you're more likely to find another one pretty close) – Life expectancy of a bug in the Linux kernel (~2.4): 1.8 years • [Rhyzyk09]: Causes for driver bugs – 23% programming error – 38% mismatch regarding device specification – 39% OS-driver-interface misconceptions TU Dresden, 2012-07-24
  • 17. Anecdote: Linux e1000 NVRAM bug • Aug 8th 2008 Bug report: e1000 PCI-X network cards rendered broken by Linux 2.6.27-rc – overwritten NVRAM on card TU Dresden, 2012-07-24
  • 18. Anecdote: Linux e1000 NVRAM bug • Aug 8th 2008 Bug report: e1000 PCI-X network cards rendered broken by Linux 2.6.27-rc – overwritten NVRAM on card • Oct 1st 2008 Intel releases quickfix – map NVRAM somewhere else TU Dresden, 2012-07-24
  • 19. Anecdote: Linux e1000 NVRAM bug • Aug 8th 2008 Bug report: e1000 PCI-X network cards rendered broken by Linux 2.6.27-rc – overwritten NVRAM on card • Oct 1st 2008 Intel releases quickfix – map NVRAM somewhere else • Oct 15th 2008 Reason found: – dynamic ftrace framework tries to patch __init code, but .init sections are unmapped after running init code – NVRAM got mapped to same location – Scary cmpxchg() behavior on I/O memory TU Dresden, 2012-07-24
  • 20. Anecdote: Linux e1000 NVRAM bug • Aug 8th 2008 Bug report: e1000 PCI-X network cards rendered broken by Linux 2.6.27-rc – overwritten NVRAM on card • Oct 1st 2008 Intel releases quickfix – map NVRAM somewhere else • Oct 15th 2008 Reason found: – dynamic ftrace framework tries to patch __init code, but .init sections are unmapped after running init code – NVRAM got mapped to same location – Scary cmpxchg() behavior on I/O memory • Nov 2nd 2008 dynamic ftrace reworked for Linux 2.6.28-rc3 TU Dresden, 2012-07-24
  • 21. Idea: User-level Drivers • Isolate components – device drivers (disk, network, graphic, USB cruise missiles, ...) – stacks (TCP/IP, file systems, …) • Separate address spaces each – More robust components • Problems – Overhead • HW multiplexing • Context switches – Need to handle I/O privileges TU Dresden, 2012-07-24
  • 22. Hardware Resources: Interrupts • Signal device state change • Programmable Interrupt Controller (PIC, APIC) – map HW IRQs to CPU's IRQ lines – prioritize interrupts System PCI Bus Bus CPU PIC INT INT A INT B IDE NET USB INT C Chipset Memory Bus Memory TU Dresden, 2012-07-24
  • 23. Hardware Resources: Interrupts (2) • Handling interrupts involves – examine / manipulate device – program PIC • acknowledge/mask/unmask interrupts System PCI Bus Bus CPU PIC INT INT A INT B IDE NET USB INT C Chipset Memory Bus Memory TU Dresden, 2012-07-24
  • 24. L4: Interrupt handling • IRQ kernel object – Represents arbitrary async notification – Kernel maps hardware IRQs to IRQ objects • Exactly one waiter per object – call l4_irq_attach() before – wait using l4_irq_receive() • Multiple IRQs per waiter – attach to multiple objects – use l4_ipc_wait() • IRQ sharing – Many IRQ objects may be chain()ed to a master IRQ object TU Dresden, 2012-07-24
  • 25. Hardware Resources: I/O ports • x86-specific feature • I/O ports define own I/O address space – Each device uses its own area within this address space • Special instruction to access I/O ports – in / out: I/O read / write – Example: read byte from serial port mov $0x3f8, %edx in  (%dx), %al • Need to restrict I/O port access – Allow device drivers access to I/O ports used by its device only TU Dresden, 2012-07-24
  • 26. I/O Bitmap • Per task IO privilege level (IOPL) • If IOPL > current PL, all accesses are allowed (kernel mode) • Else: I/O bitmap is checked #0xfff0 1111111111011011 • 1 bit per I/O port #0xffe0 1111111111111111 – 65536 ports -> 8kB ... • Controls port access #0x0000 1111111111111111 (0 == ok, 1 == GPF) • L4: per-task I/O bitmap I/O Map Base Address – Switched during task switch – Allows per-task grant/deny of I/O port access TSS TU Dresden, 2012-07-24
  • 27. Fiasco.OC: I/O Flexpages • Reuse kernel's map/grant mechanism for mapping I/O port rights -> I/O flexpages • Kernel detects type of flexpage and acts accordingly • Task with all I/O ports mapped is raised to IOPL 3 Map/Grant 1111 Base Port 0000 log2#Ports 0 L4.Fiasco I/O flexpage format TU Dresden, 2012-07-24
  • 28. Hardware Resources: I/O Memory • Devices often contain on-chip memory (NICs, graphcis cards, ...) • Instead of accessing through I/O ports, drivers can map this memory into their address space just like normal RAM – no need for special instructions – increased flexibility by using underlying virtual memory management Driver Memory Kernel Fiasco Microkernel Software Hardware CPU Chipset Device Memory TU Dresden, 2012-07-24 Memoy
  • 29. Hardware Resources: I/O memory (2) • Device memory looks just like phys. memory • Chipset needs to – map I/O memory to exclusive address ranges – distinguish physical and I/O memory access Driver Kernel Fiasco Microkernel Software Hardware CPU Chipset Device Memory Memory TU Dresden, 2012-07-24
  • 30. I/O memory in L4 • Like all memory, I/O memory is owned by sigma0 • Sigma0 implements protocol to request I/O memory pages • Abstraction: Dataspaces containing I/O memory Driver 1 Driver 2 Sigma0 Kernel Fiasco Microkernel Software Hardware CPU Chipset Device 1 Device 2 Memory TU Dresden, 2012-07-24
  • 31. Can I trust my driver? • Scenario: devices attached to a PCI bus • Driver needs access to PCI configuration space – I/O resource discovery – Enable/disable device interrupts • PCI config space access: – Write (bus, device, function#) to I/O port 0xCF8 – Read/write data to/from I/O port 0xCFC • Problem: – Who makes sure that my driver uses the proper (bus, device, function) tuple? TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 31 / 54
  • 32. L4Re: Device Management • Solution: only provide access to those devices, a driver is supposed to access • I/O server + virtual buses Network Disk Sound Driver Driver Driver I/O server PCI bus NIC Disk 1 Disk 2 Sound card TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 32 / 54
  • 33. Summary: Fiasco.OC/L4Re Device Drivers • Interrupts → Mapped to IPC • I/O ports → Managed as kernel resource • I/O memory → Cleanly integrates with L4 memory management • PCI bus → Managed by separate I/O server TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 33 / 54
  • 34. Implementing Device Drivers • Just like in any other OS: – Specify a server interface – Implement interface, use the access methods provided by the runtime environment • Highly optimized code possible • Hard to maintain • Implementation time-consuming • Unavailable specifications • Why reimplement drivers if there are already versions available? – Linux, BSD – Open Source – Windows – Binary drivers TU Dresden, 2012-07-24
  • 35. Reusing Legacy Device Drivers • NDIS-Wrapper: Linux glue library to run Windows WiFi drivers on Linux Windows Driver • Idea is simple: provide a Code library mapping Windows API Glue Code to Linux Linux • Implementation is a problem. TU Dresden, 2012-07-24
  • 36. Reusing Legacy Device Drivers (2) • Generalize the idea: provide a Linux environment to run drivers on L4 → Device Driver Environment (DDE) TU Dresden, 2012-07-24
  • 37. Emulating Linux: DDE/Linux • Multiple L4 threads provide a Linux environment – Workqueues – SoftIRQs / Bottom Halves – Timers – Jiffies • Emulate SMP-like system (each L4 thread assumed to be one processor) • Wrap Linux functionality – kmalloc() → L4 Slab allocator library – Linux spinlock → pthread mutex • Handle in-kernel accesses (e.g., PCI config space) TU Dresden, 2012-07-24
  • 38. Multiple Donator OSes TU Dresden, 2012-07-24
  • 39. DDEKit – another abstraction • Pull common abstractions into dedicated library – Threads – Synchronization – Memory – IRQ handling – I/O port access → DDE Construction Kit (DDEKit) • Implement DDEs against the DDEKit interface TU Dresden, 2012-07-24
  • 40. DDEKit (2) • Implementation overhead for single DDEs gets much smaller • Performance overhead still reasonable – e.g., no visible increase of network latency in user- level ethernet driver • L4-specific parts (sloccount): – standalone DDE Linux 2.4: ~ 3.000 LoC – DDEKit ~ 2.000 LoC – DDEKit-based DDE Linux 2.6: ~ 1.000 LoC – Standalone Linux VM (DD/OS): > 500.000 LoC • Highly customizable: implement DDE base library and support libs (net, disk, sound, ...) TU Dresden, 2012-07-24
  • 41. DDEKit: portability • Reversing the DDE idea: port DDEKit to host environment → reuse whole Linux support lib • Has been done for: – L4Env, L4Re – Genode OS Framework – Minix 3 – GNU/Hurd – Linux TU Dresden, 2012-07-24
  • 42. Device Drivers: Isolation vs. Performance Full Protection: Isolated Best performance: all Address Spaces in one address space Application uClibC Application L4Re Socket Backend uClibC ? L4Re Socket Backend TCP/IP Stack TCP/IP Library Linux DDE Network Driver DDEKit Linux DDE Network Network Server Driver DDEKit Fiasco.OC Kernel Fiasco.OC Kernel TU Dresden, 2012-07-24
  • 43. Device Sharing? • Problem: Devices often Application Application don't support shared access uClibC uClibC from multiple applications TCP/IP Library TCP/IP Library ? Linux DDE Network Driver DDEKit Network Server TU Dresden, 2012-07-24
  • 44. Device Sharing? • Problem: Devices often Application Application don't support shared access uClibC uClibC from multiple applications TCP/IP Library TCP/IP Library • Solution: Introduce “virtualized” intermediary interfaces • Networking on L4Re: Ankh VNIC VNIC network multiplexer Mutiplexing – Shared memory NIC for Linux DDE Network each client Driver DDEKit – Virtual MAC addresses Network Server TU Dresden, 2012-07-24
  • 45. Virtual Machines • Extreme approach to reusing existing software: – Run application inside the real OS – Wrap the OS in a virtual Windows Linux machine – Run the Virtual Machine on VM 1 VM 2 top of microkernel • Advantages: Virtual Machine – Full guest OS interface Monitor supported – Runs any binary that has Microkernel Runtime been compiled for the guest OS without modification Microkernel • Problem: someone needs to implement a VMM! TU Dresden, 2012-07-24
  • 46. Approaches to Virtualization • Goal: Make guest OS think it runs on real HW • Emulation: simulate every instruction – Very slow – Allows for incompatible guest and host hardware • Trap&Emulate: when guest and host HW are identical – Execute on real processor as long as possible – Privileged instructions lead to processor traps – Handle those traps in VMM – Requires virtualizable instruction set! TU Dresden, 2012-07-24
  • 47. Virtualizing Broken Instruction Sets • Original x86 instruction set is not virtualizable – Some instructions behave differently in user and kernel mode – Not all such instructions cause a trap when executed in user mode • Fix 1: Binary rewriting (VMware products) – Transform binary code so that broken instructions lead to a trap that can be handled by the VMM • Fix 2: Correct the instruction set – Intel VT / AMD-V TU Dresden, 2012-07-24
  • 48. VMM Implementation Choices Bare-Metal VMM VMM on OS Paravirtualization - no OS overhead - reuse infra- - port guest OS to - complete control structure host interface - high effort - may have worse - no VMM overhead performance - maintenance cost App App App App Guest OS App App Guest OS Virtual HW Guest OS Virtual HW User-level VMM Host OS == VMM Host OS Host OS Physical HW Physical HW Physical HW TU Dresden, 2012-07-24
  • 49. Paravirtualizing Linux Application Application Application Application User mode Kernel mode System-Call Interface File Systems Networking Processes Memory VFS Sockets Scheduling Management Linux File System Impl. Protocols IPC Page allocation Kernel Address spaces Device Drivers Swapping Hardware Access Hardware CPU, Memory, PCI, Devices TU Dresden, 2012-07-24
  • 50. Paravirtualizing Linux Application Application Application Application L4 Task L4 Task L4 Task L4 Task Adapt to L4 IPC System-Call Interface File Systems Networking Processes Memory VFS Sockets Scheduling Management File System Impl. Protocols IPC Page allocation Address spaces Device Drivers Swapping L4Re as HW Hardware Access architecture L4Linux kernel task L4 Runtime Environment User mode Kernel mode Fiasco.OC Hardware CPU, Memory, PCI, Devices TU Dresden, 2012-07-24
  • 51. L4Linux • L4 as new “hardware” platform in Linux, relay tasks to Fiasco.OC – Thread switching + state management – MMU handling – Use Fiasco.OC interrupts • Linux applications are L4 tasks – IPC used for • Kernel entry • Signal delivery • Copying from/to user space TU Dresden, 2012-07-24
  • 52. L4Linux: Kernel Entry • Linux application executes INT 0x80 instruction • Fiasco.OC receives CPU trap • Fiasco.OC relays handling to user-level handler – Every thread has an exception handler assigned – Similar to a page fault, kernel generates exception IPC message • Contains whole CPU state • Linux kernel task is exception handler for user applications • Receives exception IPC • Handles system call • Replies to let user app continue TU Dresden, 2012-07-24
  • 53. Simplifying Exception Handling • Fiasco.OC extension: vCPU – Thread with additional properties: • “kernel” task • “user” task – l4_vcpu_resume() → move thread to user task and let it execute – Upon CPU exception: move whole thread to kernel task and set it to dedicated kernel EIP/ESP – Kernel then calls l4_vcpu_resume() again • Greatly simplifies L4Linux implementation: – Same mechanism used for interrupts, page faults, system calls, ... TU Dresden, 2012-07-24
  • 54. Assignment #3 Make your encryption server (from assignment #2) accessible to an L4Linux user application. Isolated VM L4 Linux Linux Linux App App App X Crypto Server L4Linux TU Dresden, 2012-07-24
  • 55. Assignment #3 Make your encryption server (from assignment #2) accessible to an L4Linux user application. Isolated VM L4 Linux Linux Linux Crypto App App App Server /dev/l4crypt L4Crypt Linux Driver L4Linux TU Dresden, 2012-07-24
  • 56. Step 1: Download and build L4Linux • Instructions: http://os.inf.tu-dresden.de/L4/LinuxOnL4/ • You will need a bunch of additional L4 packages – Route A: the build system complains about missing packages → fetch them with “svn up” in l4/pkg directory – Route B: this is the list you'll need: acpica drivers examples fb-drv input io libevent libio-io libirq libvcpu lxfuxlibc mag mag-gfx rtc shmc x86emu zlib • When configuring L4Linux: – Leave L4 options as they are (only set proper L4Re build directory) – Disable as much HW options (PCI, SATA, SCSI, Networking, …) as you can • Faster builds • We don't need hardware right now TU Dresden, 2012-07-24
  • 57. Step 2: Running L4Linux • Example files in l4/conf/examples: – l4lx-x86.io → Config file for virtual PCI bus (that will contain PS2 input device, frame buffer and any PCI devs … but you disabled PCI in step 1, remember?) – l4lx-gfx.cfg → Lua init script to launch L4Linux and a graphical console • There's also an entry in l4/conf/modules.lst already. • For a root file system: – Download an initrd, e.g., from http://os.inf.tu-dresden.de/download/ – Build your own initrd TU Dresden, 2012-07-24
  • 58. Step 3: Implementing the Driver • Linux side: use a standard chardev for communication between driver and applications • L4 side: – L4Linux kernel modules are built as any other Linux kernel module – You may include and use L4 headers as in any other L4 application – For IPC: no C++ streaming – Linux is C code, so write to the UTCB yourself TU Dresden, 2012-07-24
  • 59. Happy Hacking! Don't perform any L4 system call between writing the UTCB and sending the IPC message to your server! Log output (printk, …) is an L4 system call! TU Dresden, 2012-07-24
  • 60. Further Reading • H. Weisbach et al. “Generic User-Level PCI Drivers” http://os.inf.tu-dresden.de/papers_ps/rtlws2011-dde.pdf Bringing the DDE approach to Linux • Lackorzynski et al. “Generic Virtualization with Virtual Processors” http://os.inf.tu-dresden.de/papers_ps/rtlws2010_genericvirt.pdf Introducing the L4Linux vCPU model • Steinberg et al.: “NOVA: A Microhypervisor-based Secure Virtualization Architecture” http://os.inf.tu-dresden.de/papers_ps/steinberg_eurosys2010.pdf A bare-metal microhypervisor • Singaravelu et al.: “Enforcing Configurable Trust in Client- side Software Stacks by Splitting Information Flow” http://os.inf.tu-dresden.de/papers_ps/git-cercs-07-11.pdf Splitting applications into trusted and untrusted parts TU Dresden, 2012-07-24 L4Re: Advanced Components Slide 60 / 54