Skip to content
Snippets Groups Projects
  1. Jun 14, 2022
  2. Jun 13, 2022
  3. Jun 09, 2022
  4. Jun 08, 2022
  5. Jun 07, 2022
  6. Jun 06, 2022
    • Simon McVittie's avatar
      pv-runtime: Be more compatible with interpreters like FEX-Emu · b6e5d13e
      Simon McVittie authored
      
      A common approach to transparent CPU-architecture emulation is to have
      an overlay with binaries for the emulated architecture, and transparently
      use those (as though they were an overlayfs over the real filesystem)
      when an emulated process accesses their paths.
      
      For example, FEX-Emu emulates x86 on aarch64 systems. When an aarch64
      process opens an architecture-dependent file like /usr/lib64/libc.so.6
      or /etc/ld.so.cache, it gets the real file; when an emulated x86 process
      opens an architecture-dependent file, if that file exists in the
      FEX-Emu "rootfs", FEX-Emu will transparently redirect the file access
      to the copy in the "rootfs".
      
      When we enter the Steam Runtime container, we need two environments
      inside the container: an aarch64 environment that can run the FEX-Emu
      interpreter itself, and an x86 environment that can run
      pressure-vessel-adverb, Steam Runtime executables, and the actual game.
      
      To arrange for this to happen, we can use a subset of the real aarch64
      operating system as the root of the container, and set up a new FEX-Emu
      rootfs in /run/pressure-vessel/interpreter-root. This means that
      aarch64 executables in the Steam Runtime container see the real host OS,
      but x86 executables see the Steam Runtime.
      
      Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
      b6e5d13e
    • Simon McVittie's avatar
      pv-wrap: Adjust paths set up by Flatpak code for FEX-Emu rootfs · 42d397f6
      Simon McVittie authored
      
      The code we've borrowed from Flatpak to deal with things like X11 and
      D-Bus can find files and directories in either the real root filesystem,
      or the FEX-Emu rootfs. If we naively pass the paths it has discovered to
      bwrap, we'll find that they don't necessarily exist: for example, the
      minimal aarch64 system I'm using for initial testing of this code
      doesn't have /var/cache/fontconfig, but the rootfs does. This makes
      bwrap fail when it tries to bind-mount /oldroot/var/cache/fontconfig
      onto /newroot/var/cache/fontconfig.
      
      To avoid this failure mode, look up the paths in the rootfs, and if
      necessary rewrite them. For example, we can bind-mount
      /oldroot/$FEX_ROOTFS/var/cache/fontconfig onto
      /newroot/var/cache/fontconfig, and that will work fine.
      
      Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
      42d397f6
    • Simon McVittie's avatar
      pv-wrap: Use the FEX-Emu rootfs as the default graphics stack provider · 3de3e03c
      Simon McVittie authored
      
      We don't yet do anything with FEX-Emu thunks (substitute shared
      libraries that override certain real libraries), so we need to provide
      a complete x86 graphics stack, and the FEX-Emu rootfs is a good place
      to find one of those.
      
      Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
      3de3e03c
    • Simon McVittie's avatar
      pv-wrap: Bypass FEX-Emu overlay for most top-level directories · 5c3fb090
      Simon McVittie authored
      
      The FEX-Emu "rootfs" is conceptually just a /usr (plus parts of /etc and
      /var), just like the Steam Runtime. However, the rootfs versions that
      are currently distributed contain some files in /etc, /run and so on.
      
      When we open files with opendir() or access() or similar, FEX-Emu will
      transparently substitute files from the "rootfs" if they exist. However,
      when we're building up a list of bind-mounts for a root filesystem,
      this is counterproductive: bwrap will do the equivalent of
      `mount --bind /oldroot/run/foo /newroot/run/foo`, which is not going
      to work if /foo is really /home/me/.fex-emu/RootFS/Ubuntu_21_10/run/foo.
      
      For several categories of file, and in particular /run and other API
      filesystems, what we really want to do is to ignore the "rootfs" and
      take the files and directories from the real root. Because FEX-Emu's
      rewriting is path-based rather than identity-based, we can do this by
      looking up the paths relative to /proc/self/root.
      
      Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
      5c3fb090
    • Simon McVittie's avatar
      pv-wrap: Detect FEX-Emu "rootfs" filesystem overlay · 21866684
      Simon McVittie authored
      
      A common approach to transparent CPU-architecture emulation is to have
      an overlay with binaries for the emulated architecture, and transparently
      use those (as though they were an overlayfs over the real filesystem)
      when an emulated process accesses their paths.
      
      For example, FEX-Emu emulates x86 on aarch64 systems. When an aarch64
      process opens an architecture-dependent file like /usr/lib64/libc.so.6
      or /etc/ld.so.cache, it gets the real file; when an emulated x86 process
      opens an architecture-dependent file, if that file exists in the
      FEX-Emu "rootfs", FEX-Emu will transparently redirect the file access
      to the copy in the "rootfs".
      
      When we enter the Steam Runtime container, we need two environments
      inside the container: an aarch64 environment that can run the FEX-Emu
      interpreter itself, and an x86 environment that can run
      pressure-vessel-adverb, Steam Runtime executables, and the actual game.
      To set this up, we have to be able to distinguish between the two
      environments.
      
      Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
      21866684
    • Simon McVittie's avatar
      pv-wrap: Return new bwrap object from pv_wrap_share_sockets() · 5e2e8831
      Simon McVittie authored
      
      It'll be easier to pass this through transformations like adjust_exports()
      if we can know that everything in the new bwrap object was produced by
      pv_wrap_share_sockets().
      
      Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
      5e2e8831
    • Simon McVittie's avatar
      pv-wrap: Handle a larger subset of bwrap command-line syntax · 69987dbb
      Simon McVittie authored
      
      When we add support for transparent emulation such as FEX-Emu, we'll
      need to carry out rewriting for bwrap arguments generated from the
      code we borrow from Flatpak. This will be easier to do if we support
      more of bwrap's command-line options.
      
      As before, we classify them by how many arguments they have, and which
      arguments are paths in the host system.
      
      Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
      69987dbb
    • Simon McVittie's avatar
  7. Jun 01, 2022
  8. May 31, 2022
Loading