qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] a8dc82: qom: Allow optional sugar props


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] a8dc82: qom: Allow optional sugar props
Date: Mon, 08 Feb 2021 05:01:01 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: a8dc82ce828579b92cf602cdc307a6c5b144069c
      
https://github.com/qemu/qemu/commit/a8dc82ce828579b92cf602cdc307a6c5b144069c
  Author: Greg Kurz <groug@kaod.org>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M include/qom/object.h
    M qom/object.c
    M softmmu/rtc.c
    M softmmu/vl.c

  Log Message:
  -----------
  qom: Allow optional sugar props

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: Greg Kurz <groug@kaod.org>
Message-Id: <159738953558.377274.16617742952571083440.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


  Commit: f91f9f254ba10e94468663b23d0b780c240df268
      
https://github.com/qemu/qemu/commit/f91f9f254ba10e94468663b23d0b780c240df268
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    A backends/confidential-guest-support.c
    M backends/meson.build
    A include/exec/confidential-guest-support.h
    M include/qemu/typedefs.h
    M target/i386/sev.c

  Log Message:
  -----------
  confidential guest support: Introduce new confidential guest support class

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: David Gibson <david@gibson.dropbear.id.au>


  Commit: aacdb8441376de05d9e21e93799d5a37b81f0f38
      
https://github.com/qemu/qemu/commit/aacdb8441376de05d9e21e93799d5a37b81f0f38
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M accel/kvm/kvm-all.c
    M accel/kvm/sev-stub.c
    M accel/stubs/kvm-stub.c
    M hw/i386/pc_sysfw.c
    M include/sysemu/kvm.h
    M include/sysemu/sev.h
    M target/i386/sev-stub.c
    M target/i386/sev.c

  Log Message:
  -----------
  sev: Remove false abstraction of flash encryption

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: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>


  Commit: 6e6a6ca7d9097d1aa68089379cdaa7553dad7a25
      
https://github.com/qemu/qemu/commit/6e6a6ca7d9097d1aa68089379cdaa7553dad7a25
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M hw/core/machine.c

  Log Message:
  -----------
  confidential guest support: Move side effect out of 
machine_set_memory_encryption()

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: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>


  Commit: e0292d7c62673546c01d5c6b245735fdfef81840
      
https://github.com/qemu/qemu/commit/e0292d7c62673546c01d5c6b245735fdfef81840
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M accel/kvm/kvm-all.c
    M accel/kvm/sev-stub.c
    M hw/core/machine.c
    M include/hw/boards.h
    M include/sysemu/sev.h
    M target/i386/sev.c

  Log Message:
  -----------
  confidential guest support: Rework the "memory-encryption" property

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: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>


  Commit: c9f5aaa6bce819c1863c2a56b187cb9eb521fc92
      
https://github.com/qemu/qemu/commit/c9f5aaa6bce819c1863c2a56b187cb9eb521fc92
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M accel/kvm/kvm-all.c
    M accel/kvm/sev-stub.c
    M include/sysemu/sev.h
    M target/i386/sev.c

  Log Message:
  -----------
  sev: Add Error ** to sev_kvm_init()

This allows failures to be reported richly and idiomatically.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>


  Commit: abc27d4241f99bfaebb0b843b9a967d557ac10e8
      
https://github.com/qemu/qemu/commit/abc27d4241f99bfaebb0b843b9a967d557ac10e8
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M include/exec/confidential-guest-support.h
    M softmmu/vl.c
    M target/i386/sev.c

  Log Message:
  -----------
  confidential guest support: Introduce cgs "ready" flag

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: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>


  Commit: ec78e2cda3e006e0e01e2177caf3718db5600635
      
https://github.com/qemu/qemu/commit/ec78e2cda3e006e0e01e2177caf3718db5600635
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M accel/kvm/kvm-all.c
    M accel/kvm/sev-stub.c
    M target/i386/kvm/kvm.c
    M target/i386/sev.c

  Log Message:
  -----------
  confidential guest support: Move SEV initialization into arch specific code

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: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>


  Commit: 64d19f333464a877f3ebe538510a10a514db0eb9
      
https://github.com/qemu/qemu/commit/64d19f333464a877f3ebe538510a10a514db0eb9
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M docs/amd-memory-encryption.txt
    A docs/confidential-guest-support.txt

  Log Message:
  -----------
  confidential guest support: Update documentation

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: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>


  Commit: 6c8ebe30ea8055fce8b24730e970532b3c849fdb
      
https://github.com/qemu/qemu/commit/6c8ebe30ea8055fce8b24730e970532b3c849fdb
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M docs/confidential-guest-support.txt
    A docs/papr-pef.txt
    M hw/ppc/meson.build
    A hw/ppc/pef.c
    M hw/ppc/spapr.c
    A include/hw/ppc/pef.h
    M target/ppc/kvm.c
    M target/ppc/kvm_ppc.h

  Log Message:
  -----------
  spapr: Add PEF based confidential guest support

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: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>


  Commit: 6742eefc9314678bba39e461fe8cdd0a841c3e92
      
https://github.com/qemu/qemu/commit/6742eefc9314678bba39e461fe8cdd0a841c3e92
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M hw/ppc/pef.c

  Log Message:
  -----------
  spapr: PEF: prevent migration

We haven't yet implemented the fairly involved handshaking that will be
needed to migrate PEF protected guests.  For now, just use a migration
blocker so we get a meaningful error if someone attempts this (this is the
same approach used by AMD SEV).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>


  Commit: 9f88a7a3df11a5aaa6212ea535d40d5f92561683
      
https://github.com/qemu/qemu/commit/9f88a7a3df11a5aaa6212ea535d40d5f92561683
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M hw/core/machine.c

  Log Message:
  -----------
  confidential guest support: Alter virtio default properties for protected 
guests

The default behaviour for virtio devices is not to use the platforms normal
DMA paths, but instead to use the fact that it's running in a hypervisor
to directly access guest memory.  That doesn't work if the guest's memory
is protected from hypervisor access, such as with AMD's SEV or POWER's PEF.

So, if a confidential guest mechanism is enabled, then apply the
iommu_platform=on option so it will go through normal DMA mechanisms.
Those will presumably have some way of marking memory as shared with
the hypervisor or hardware so that DMA will work.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>


  Commit: 651615d92d244a6dfd7c81ab97bd3369fbe41d06
      
https://github.com/qemu/qemu/commit/651615d92d244a6dfd7c81ab97bd3369fbe41d06
  Author: David Gibson <david@gibson.dropbear.id.au>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M docs/confidential-guest-support.txt
    M docs/system/s390x/protvirt.rst
    M hw/s390x/pv.c
    M hw/s390x/s390-virtio-ccw.c
    M include/hw/s390x/pv.h

  Log Message:
  -----------
  s390: Recognize confidential-guest-support option

At least some s390 cpu models support "Protected Virtualization" (PV),
a mechanism to protect guests from eavesdropping by a compromised
hypervisor.

This is similar in function to other mechanisms like AMD's SEV and
POWER's PEF, which are controlled by the "confidential-guest-support"
machine option.  s390 is a slightly special case, because we already
supported PV, simply by using a CPU model with the required feature
(S390_FEAT_UNPACK).

To integrate this with the option used by other platforms, we
implement the following compromise:

 - When the confidential-guest-support option is set, s390 will
   recognize it, verify that the CPU can support PV (failing if not)
   and set virtio default options necessary for encrypted or protected
   guests, as on other platforms.  i.e. if confidential-guest-support
   is set, we will either create a guest capable of entering PV mode,
   or fail outright.

 - If confidential-guest-support is not set, guests might still be
   able to enter PV mode, if the CPU has the right model.  This may be
   a little surprising, but shouldn't actually be harmful.

To start a guest supporting Protected Virtualization using the new
option use the command line arguments:
    -object s390-pv-guest,id=pv0 -machine confidential-guest-support=pv0

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>


  Commit: 6f0e9c26dbae9ac18b89d359791008fe3432ca91
      
https://github.com/qemu/qemu/commit/6f0e9c26dbae9ac18b89d359791008fe3432ca91
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2021-02-08 (Mon, 08 Feb 2021)

  Changed paths:
    M accel/kvm/kvm-all.c
    M accel/kvm/sev-stub.c
    M accel/stubs/kvm-stub.c
    A backends/confidential-guest-support.c
    M backends/meson.build
    M docs/amd-memory-encryption.txt
    A docs/confidential-guest-support.txt
    A docs/papr-pef.txt
    M docs/system/s390x/protvirt.rst
    M hw/core/machine.c
    M hw/i386/pc_sysfw.c
    M hw/ppc/meson.build
    A hw/ppc/pef.c
    M hw/ppc/spapr.c
    M hw/s390x/pv.c
    M hw/s390x/s390-virtio-ccw.c
    A include/exec/confidential-guest-support.h
    M include/hw/boards.h
    A include/hw/ppc/pef.h
    M include/hw/s390x/pv.h
    M include/qemu/typedefs.h
    M include/qom/object.h
    M include/sysemu/kvm.h
    M include/sysemu/sev.h
    M qom/object.c
    M softmmu/rtc.c
    M softmmu/vl.c
    M target/i386/kvm/kvm.c
    M target/i386/sev-stub.c
    M target/i386/sev.c
    M target/ppc/kvm.c
    M target/ppc/kvm_ppc.h

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/dg-gitlab/tags/cgs-pull-request' into 
staging

Generalize memory encryption models

A number of hardware platforms are implementing mechanisms whereby the
hypervisor does not have unfettered access to guest memory, in order
to mitigate the security impact of a compromised hypervisor.

AMD's SEV implements this with in-cpu memory encryption, and Intel has
its own memory encryption mechanism.  POWER has an upcoming mechanism
to accomplish this in a different way, using a new memory protection
level plus a small trusted ultravisor.  s390 also has a protected
execution environment.

The current code (committed or draft) for these features has each
platform's version configured entirely differently.  That doesn't seem
ideal for users, or particularly for management layers.

AMD SEV introduces a notionally generic machine option
"machine-encryption", but it doesn't actually cover any cases other
than SEV.

This series is a proposal to at least partially unify configuration
for these mechanisms, by renaming and generalizing AMD's
"memory-encryption" property.  It is replaced by a
"confidential-guest-support" property pointing to a platform specific
object which configures and manages the specific details.

Note to Ram Pai: the documentation I've included for PEF is very
minimal.  If you could send a patch expanding on that, it would be
very helpful.

Changes since v8:
 * Rebase
 * Fixed some cosmetic typos
Changes since v7:
 * Tweaked and clarified meaning of the 'ready' flag
 * Polished the interface to the PEF internals
 * Shifted initialization for s390 PV later (I hope I've finally got
   this after apply_cpu_model() where it needs to be)
Changes since v6:
 * Moved to using OBJECT_DECLARE_TYPE and OBJECT_DEFINE_TYPE macros
 * Assorted minor fixes
Changes since v5:
 * Renamed from "securable guest memory" to "confidential guest
   support"
 * Simpler reworking of x86 boot time flash encryption
 * Added a bunch of documentation
 * Fixed some compile errors on POWER
Changes since v4:
 * Renamed from "host trust limitation" to "securable guest memory",
   which I think is marginally more descriptive
 * Re-organized initialization, because the previous model called at
   kvm_init didn't work for s390
 * Assorted fixes to the s390 implementation; rudimentary testing
   (gitlab CI) only
Changes since v3:
 * Rebased
 * Added first cut at handling of s390 protected virtualization
Changes since RFCv2:
 * Rebased
 * Removed preliminary SEV cleanups (they've been merged)
 * Changed name to "host trust limitation"
 * Added migration blocker to the PEF code (based on SEV's version)
Changes since RFCv1:
 * Rebased
 * Fixed some errors pointed out by Dave Gilbert

# gpg: Signature made Mon 08 Feb 2021 06:07:27 GMT
# gpg:                using RSA key 75F46586AE61A66CC44E87DC6C38CACA20D9B392
# gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>" [full]
# gpg:                 aka "David Gibson (Red Hat) <dgibson@redhat.com>" [full]
# gpg:                 aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>" 
[full]
# gpg:                 aka "David Gibson (kernel.org) <dwg@kernel.org>" 
[unknown]
# Primary key fingerprint: 75F4 6586 AE61 A66C C44E  87DC 6C38 CACA 20D9 B392

* remotes/dg-gitlab/tags/cgs-pull-request:
  s390: Recognize confidential-guest-support option
  confidential guest support: Alter virtio default properties for protected 
guests
  spapr: PEF: prevent migration
  spapr: Add PEF based confidential guest support
  confidential guest support: Update documentation
  confidential guest support: Move SEV initialization into arch specific code
  confidential guest support: Introduce cgs "ready" flag
  sev: Add Error ** to sev_kvm_init()
  confidential guest support: Rework the "memory-encryption" property
  confidential guest support: Move side effect out of 
machine_set_memory_encryption()
  sev: Remove false abstraction of flash encryption
  confidential guest support: Introduce new confidential guest support class
  qom: Allow optional sugar props

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/276604334574...6f0e9c26dbae



reply via email to

[Prev in Thread] Current Thread [Next in Thread]