Skip to content
Snippets Groups Projects
  1. Feb 08, 2021
    • David Gibson's avatar
      spapr: Add PEF based confidential guest support · 6c8ebe30
      David Gibson authored
      
      Some upcoming POWER machines have a system called PEF (Protected
      Execution Facility) which uses a small ultravisor to allow guests to
      run in a way that they can't be eavesdropped by the hypervisor.  The
      effect is roughly similar to AMD SEV, although the mechanisms are
      quite different.
      
      Most of the work of this is done between the guest, KVM and the
      ultravisor, with little need for involvement by qemu.  However qemu
      does need to tell KVM to allow secure VMs.
      
      Because the availability of secure mode is a guest visible difference
      which depends on having the right hardware and firmware, we don't
      enable this by default.  In order to run a secure guest you need to
      create a "pef-guest" object and set the confidential-guest-support
      property to point to it.
      
      Note that this just *allows* secure guests, the architecture of PEF is
      such that the guest still needs to talk to the ultravisor to enter
      secure mode.  Qemu has no direct way of knowing if the guest is in
      secure mode, and certainly can't know until well after machine
      creation time.
      
      To start a PEF-capable guest, use the command line options:
          -object pef-guest,id=pef0 -machine confidential-guest-support=pef0
      
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      6c8ebe30
    • David Gibson's avatar
      confidential guest support: Update documentation · 64d19f33
      David Gibson authored
      
      Now that we've implemented a generic machine option for configuring various
      confidential guest support mechanisms:
        1. Update docs/amd-memory-encryption.txt to reference this rather than
           the earlier SEV specific option
        2. Add a docs/confidential-guest-support.txt to cover the generalities of
           the confidential guest support scheme
      
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      64d19f33
    • David Gibson's avatar
      confidential guest support: Move SEV initialization into arch specific code · ec78e2cd
      David Gibson authored
      
      While we've abstracted some (potential) differences between mechanisms for
      securing guest memory, the initialization is still specific to SEV.  Given
      that, move it into x86's kvm_arch_init() code, rather than the generic
      kvm_init() code.
      
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      ec78e2cd
    • David Gibson's avatar
      confidential guest support: Introduce cgs "ready" flag · abc27d42
      David Gibson authored
      
      The platform specific details of mechanisms for implementing
      confidential guest support may require setup at various points during
      initialization.  Thus, it's not really feasible to have a single cgs
      initialization hook, but instead each mechanism needs its own
      initialization calls in arch or machine specific code.
      
      However, to make it harder to have a bug where a mechanism isn't
      properly initialized under some circumstances, we want to have a
      common place, late in boot, where we verify that cgs has been
      initialized if it was requested.
      
      This patch introduces a ready flag to the ConfidentialGuestSupport
      base type to accomplish this, which we verify in
      qemu_machine_creation_done().
      
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      abc27d42
    • David Gibson's avatar
      sev: Add Error ** to sev_kvm_init() · c9f5aaa6
      David Gibson authored
      
      This allows failures to be reported richly and idiomatically.
      
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      c9f5aaa6
    • David Gibson's avatar
      confidential guest support: Rework the "memory-encryption" property · e0292d7c
      David Gibson authored
      
      Currently the "memory-encryption" property is only looked at once we
      get to kvm_init().  Although protection of guest memory from the
      hypervisor isn't something that could really ever work with TCG, it's
      not conceptually tied to the KVM accelerator.
      
      In addition, the way the string property is resolved to an object is
      almost identical to how a QOM link property is handled.
      
      So, create a new "confidential-guest-support" link property which sets
      this QOM interface link directly in the machine.  For compatibility we
      keep the "memory-encryption" property, but now implemented in terms of
      the new property.
      
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      e0292d7c
    • David Gibson's avatar
      confidential guest support: Move side effect out of machine_set_memory_encryption() · 6e6a6ca7
      David Gibson authored
      
      When the "memory-encryption" property is set, we also disable KSM
      merging for the guest, since it won't accomplish anything.
      
      We want that, but doing it in the property set function itself is
      thereoretically incorrect, in the unlikely event of some configuration
      environment that set the property then cleared it again before
      constructing the guest.
      
      More importantly, it makes some other cleanups we want more difficult.
      So, instead move this logic to machine_run_board_init() conditional on
      the final value of the property.
      
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Reviewed-by: default avatarGreg Kurz <groug@kaod.org>
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      6e6a6ca7
    • David Gibson's avatar
      sev: Remove false abstraction of flash encryption · aacdb844
      David Gibson authored
      
      When AMD's SEV memory encryption is in use, flash memory banks (which are
      initialed by pc_system_flash_map()) need to be encrypted with the guest's
      key, so that the guest can read them.
      
      That's abstracted via the kvm_memcrypt_encrypt_data() callback in the KVM
      state.. except, that it doesn't really abstract much at all.
      
      For starters, the only call site is in code specific to the 'pc'
      family of machine types, so it's obviously specific to those and to
      x86 to begin with.  But it makes a bunch of further assumptions that
      need not be true about an arbitrary confidential guest system based on
      memory encryption, let alone one based on other mechanisms:
      
       * it assumes that the flash memory is defined to be encrypted with the
         guest key, rather than being shared with hypervisor
       * it assumes that that hypervisor has some mechanism to encrypt data into
         the guest, even though it can't decrypt it out, since that's the whole
         point
       * the interface assumes that this encrypt can be done in place, which
         implies that the hypervisor can write into a confidential guests's
         memory, even if what it writes isn't meaningful
      
      So really, this "abstraction" is actually pretty specific to the way SEV
      works.  So, this patch removes it and instead has the PC flash
      initialization code call into a SEV specific callback.
      
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      aacdb844
    • David Gibson's avatar
      confidential guest support: Introduce new confidential guest support class · f91f9f25
      David Gibson authored
      
      Several architectures have mechanisms which are designed to protect
      guest memory from interference or eavesdropping by a compromised
      hypervisor.  AMD SEV does this with in-chip memory encryption and
      Intel's TDX can do similar things.  POWER's Protected Execution
      Framework (PEF) accomplishes a similar goal using an ultravisor and
      new memory protection features, instead of encryption.
      
      To (partially) unify handling for these, this introduces a new
      ConfidentialGuestSupport QOM base class.  "Confidential" is kind of vague,
      but "confidential computing" seems to be the buzzword about these schemes,
      and "secure" or "protected" are often used in connection to unrelated
      things (such as hypervisor-from-guest or guest-from-guest security).
      
      The "support" in the name is significant because in at least some of the
      cases it requires the guest to take specific actions in order to protect
      itself from hypervisor eavesdropping.
      
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      f91f9f25
    • Greg Kurz's avatar
      qom: Allow optional sugar props · a8dc82ce
      Greg Kurz authored
      
      Global properties have an @optional field, which allows to apply a given
      property to a given type even if one of its subclasses doesn't support
      it. This is especially used in the compat code when dealing with the
      "disable-modern" and "disable-legacy" properties and the "virtio-pci"
      type.
      
      Allow object_register_sugar_prop() to set this field as well.
      
      Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
      Message-Id: <159738953558.377274.16617742952571083440.stgit@bahia.lan>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      a8dc82ce
  2. Feb 05, 2021
Loading