Skip to contentSkip to conversation

SEV-SNP: Add support for SNP certificate fetching

RFC PATCH In review Michael Roth 5 participants 14 messages Dec 18, 2024 – Feb 5, 2025

lore
Share & tools
lore
#0 lore raw

cover SEV-SNP: Add support for SNP certificate fetching

This patchset is also available at:

https://github.com/amdese/qemu/commits/snp-certs-rfc1

and is based on top of qemu master (8032c78e556c)

Overview
--------

The GHCB 2.0 specification defines 2 GHCB request types to allow SNP guests to send encrypted messages/requests to firmware: SNP Guest Requests and SNP Extended Guest Requests. These encrypted messages are used for things like servicing attestation requests issued by the guest. Implementing support for these is required to be fully GHCB-compliant.

For the most part, KVM only needs to handle forwarding these requests to firmware (to be issued via the SNP_GUEST_REQUEST firmware command defined in the SEV-SNP Firmware ABI), and then forwarding the encrypted response to the guest.

However, in the case of SNP Extended Guest Requests, the host is also able to provide the certificate data corresponding to the endorsement key used by firmware to sign attestation report requests. This certificate data is provided by userspace because:

1) It allows for different keys/key types to be used for each particular guest with requiring any sort of KVM API to configure the certificate table in advance on a per-guest basis.

2) It provides additional flexibility with how attestation requests might be handled during live migration where the certificate data for source/dest might be different.

3) It allows all synchronization between certificates and firmware/signing key updates to be handled purely by userspace rather than requiring some in-kernel mechanism to facilitate it. [1]

To support fetching certificate data from userspace, a new KVM KVM_EXIT_SNP_REQ_CERTS exit type is used to fetch the data similarly to KVM_EXIT_MMIO/etc, with an associate KVM capability to detect/enable the exits depending on whether userspace has been configured to provide certificate data.

Add support for this exit in QEMU. Additionally, because some of the locking behavior relies on kvm_immediate_exit, add an some infrastructure to allow for callbacks to be registered and executed upon a kvm_immediate_exit-induced exit from KVM.

See the Documentation in the related KVM patches for more details on the expected usage and kvm_immediate_exit handling:

https://lore.kernel.org/kvm/[email protected]/#t

[1] https://lore.kernel.org/kvm/[email protected]/

Testing
-------

For testing this, use the following host kernel:

https://github.com/amdese/linux/commits/snp-certs-v3

For the guest, any 5.19 or newer kernel will do.

A basic command-line invocation for an SNP guest with certificate data supplied would be:

qemu-system-x86_64 -smp 32,maxcpus=255 -cpu EPYC-Milan-v2
-machine q35,confidential-guest-support=sev0,memory-backend=ram1
-object memory-backend-memfd,id=ram1,size=4G,share=true,reserve=false
-object sev-snp-guest,id=sev0,cbitpos=51,reduced-phys-bits=1,id-auth=,certs-path=/home/mroth/cert.blob -bios OVMF.fd

Something like the following simple example can be used to simulate an exclusive lock being held on the certificate by management tools performing an update:

  #include <stdlib.h>
  #include <stdio.h>
  #define __USE_GNU
  #include <fcntl.h>
  #include <unistd.h>
  #include <errno.h>
  #include <stdbool.h>
  #include <sys/types.h>
  #include <sys/stat.h>
  
  int main(int argc, void **argv)
  {
      int ret, fd, i = 0;
      char *path = argv[1];
      struct flock fl = {
          .l_whence = SEEK_SET,
          .l_start = 0,
          .l_len = 0,
          .l_type = F_WRLCK
      };
  
      fd = open(path, O_RDWR);
      ret = fcntl(fd, F_OFD_SETLK, &fl);
      if (ret) {
          printf("error locking file, ret %d errno %d\n", ret, errno);
          return ret;
      }
  
      while (true) {
          i++;
          printf("now holding lock (%d seconds elapsed)...\n", i);
          usleep(1000 * 1000);
      }
  
      return 0;

}

For requesting attestation with certificate data attached, you can use something like the following tool/workflow:

https://github.com/virtee/snpguest?tab=readme-ov-file#extended-attestation-workflow

The format of the certificate blob is defined in the GHCB 2.0 specification, but if it's not being parsed on the guest-side then random data will suffice for testing the KVM bits.

Any feedback/review is appreciated.

Thanks!

-Mike

----------------------------------------------------------------
Michael Roth (1):
i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

 qapi/qom.json                 |  23 +++-
 target/i386/kvm/kvm.c         |  10 ++
 target/i386/sev-sysemu-stub.c |   5 +
 target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++++++++++
 target/i386/sev.h             |   2 +
 5 files changed, 288 insertions(+), 1 deletion(-)
#1 lore raw

PATCH 1/3 linux-headers: Update for 6.12 and SNP certificate support

---
 linux-headers/linux/kvm.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
linux-headers/linux/kvm.h +10 -0
index 3bcd4eabe3..10f6c908d9 100644
@@ -135,6 +135,12 @@ struct kvm_xen_exit {
 	} u;
 };
 
+struct kvm_exit_snp_req_certs {
+	__u64 gfn;
+	__u32 npages;
+	__u32 ret;
+};
+
 #define KVM_S390_GET_SKEYS_NONE   1
 #define KVM_S390_SKEYS_MAX        1048576
 
@@ -178,6 +184,7 @@ struct kvm_xen_exit {
 #define KVM_EXIT_NOTIFY           37
 #define KVM_EXIT_LOONGARCH_IOCSR  38
 #define KVM_EXIT_MEMORY_FAULT     39
+#define KVM_EXIT_SNP_REQ_CERTS    40
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 /* Emulate instruction failed. */
@@ -438,6 +445,8 @@ struct kvm_run {
 			__u64 gpa;
 			__u64 size;
 		} memory_fault;
+		/* KVM_EXIT_SNP_REQ_CERTS */
+		struct kvm_exit_snp_req_certs snp_req_certs;
 		/* Fix the size of the union. */
 		char padding[256];
 	};
@@ -925,6 +934,7 @@ struct kvm_enable_cap {
 #define KVM_CAP_PRE_FAULT_MEMORY 236
 #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237
 #define KVM_CAP_X86_GUEST_MODE 238
+#define KVM_CAP_EXIT_SNP_REQ_CERTS 239
 
 struct kvm_irq_routing_irqchip {
 	__u32 irqchip;
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/3 accel/kvm: Add kvm_immediate_exit callback infrastructure

In reply to Michael Roth

Provide a generic mechanism so that users of struct kvm_run's 'immediate_exit' flag can register a callback that can be issued after returning from KVM.

---
 accel/kvm/kvm-all.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
 include/sysemu/kvm.h |  3 +++
 2 files changed, 46 insertions(+)
accel/kvm/kvm-all.c +43 -0
index 801cff16a5..14e98a96e6 100644
@@ -3080,6 +3080,46 @@ out_unref:
     return ret;
 }
 
+typedef struct ImmediateExitEntry ImmediateExitEntry;
+
+struct ImmediateExitEntry {
+    ImmediateExitCb *cb;
+    void *opaque;
+    QTAILQ_ENTRY(ImmediateExitEntry) next;
+};
+
+static QTAILQ_HEAD(, ImmediateExitEntry) immediate_exit_list = \
+    QTAILQ_HEAD_INITIALIZER(immediate_exit_list);
+
+void add_immediate_exit_callback(CPUState *cpu, ImmediateExitCb *cb, void *opaque)
+{
+    ImmediateExitEntry *entry = g_new(ImmediateExitEntry, 1);
+    entry->cb = cb;
+    entry->opaque = opaque;
+
+    bql_lock();
+    QTAILQ_INSERT_TAIL(&immediate_exit_list, entry, next);
+    bql_unlock();
+
+    kvm_cpu_kick(cpu);
+}
+
+static void process_immediate_exit_callbacks(void)
+{
+    ImmediateExitEntry *entry, *tmp;
+
+    bql_lock();
+
+    /* Handle any pending immediate-exit callbacks */
+    QTAILQ_FOREACH_SAFE(entry, &immediate_exit_list, next, tmp) {
+        entry->cb(entry->opaque);
+        QTAILQ_REMOVE(&immediate_exit_list, entry, next);
+        g_free(entry);
+    }
+
+    bql_unlock();
+}
+
 int kvm_cpu_exec(CPUState *cpu)
 {
     struct kvm_run *run = cpu->kvm_run;
@@ -3149,6 +3189,9 @@ int kvm_cpu_exec(CPUState *cpu)
             if (run_ret == -EINTR || run_ret == -EAGAIN) {
                 trace_kvm_io_window_exit();
                 kvm_eat_signals(cpu);
+                if (kvm_immediate_exit) {
+                    process_immediate_exit_callbacks();
+                }
                 ret = EXCP_INTERRUPT;
                 break;
             }
include/sysemu/kvm.h +3 -0
index c3a60b2890..5974645c62 100644
@@ -578,4 +578,7 @@ int kvm_set_memory_attributes_shared(hwaddr start, uint64_t size);
 
 int kvm_convert_memory(hwaddr start, hwaddr size, bool to_private);
 
+typedef void ImmediateExitCb(void *opaque);
+void add_immediate_exit_callback(CPUState *cpu, ImmediateExitCb *cb, void *opaque);
+
 #endif
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/3 i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

In reply to Michael Roth

The GHCB specification[1] defines a VMGEXIT-based Guest Request hypercall to allow an SNP guest to issue encrypted requests directly to SNP firmware to do things like query the attestation report for the guest. These are generally handled purely in the kernel.

In some some cases, it's useful for the host to be able to additionally supply the certificate chain for the signing key that SNP firmware uses to sign these attestation reports. To allow for this, the GHCB specification defines an Extended Guest Request where this certificate data can be provided in a special format described in the GHCB spec. This certificate data may be global or guest-specific depending on how the guest was configured. Rather than providing interfaces to manage these within the kernel, KVM provides a new KVM_EXIT_SNP_REQ_CERTS exit to request the certificate contents from userspace. Implement support for that here.

To synchronize delivery of the certificates to the guest in a way where they will not be rendered invalid by updates to SNP firmware or attestation singing/endorsement keys by management tools outside the purview of QEMU, it is expected by users of KVM_EXIT_SNP_REQ_CERTS to obtain a shared/read lock on the certificate file prior to delivering them back to KVM. Only after this will the attestation report be retrieved from firmware and bundled with the certificate data, so QEMU must continue to hold the file lock until KVM confirms that the attestation report has been retrieved/bundled. This confirmation is done by way of the kvm_immediate_exit callback infrastructure that was introduced in a previous patch.

[1] "Guest Hypervisor Communication Block (GHCB) Standardization",
https://www.amd.com/en/developer/sev.html

---
 qapi/qom.json                 |  23 +++-
 target/i386/kvm/kvm.c         |  10 ++
 target/i386/sev-sysemu-stub.c |   5 +
 target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++
 target/i386/sev.h             |   2 +
 5 files changed, 288 insertions(+), 1 deletion(-)
qapi/qom.json +22 -1
index 28ce24cd8d..6eaf0e7721 100644
@@ -1034,6 +1034,25 @@
 #     firmware.  Set this to true to disable the use of VCEK.
 #     (default: false) (since: 9.1)
 #
+# @certs-path: Path to certificate data that can be passed to guests via
+#              SNP Extended Guest Requests. File should be in the format
+#              described in the GHCB specification. (default: none)
+#              (since: 10.0)
+#
+# @certs-timeout: Max time in milliseconds to wait to obtain a read lock
+#                 on the certificate file specified by @certs-path. This
+#                 is not a cumulative value and only affects how long
+#                 QEMU waits before returning execution to the vCPU and
+#                 informing the guest of the timeout, so the guest can
+#                 still continuing retrying for as long as it likes
+#                 (which will be about 60 seconds for linux guests at
+#                 the time of this writing). If the guest-side timeout
+#                 is insufficient, set this higher to allow more time to
+#                 fetch the certificate. If the guest-side timeout is
+#                 sufficient, set this lower to reduce the likelihood of
+#                 soft lockups in the guest.
+#                 (default: 100) (since: 10.0)
+#
 # Since: 9.1
 ##
 { 'struct': 'SevSnpGuestProperties',
@@ -1045,7 +1064,9 @@
             '*id-auth': 'str',
             '*author-key-enabled': 'bool',
             '*host-data': 'str',
-            '*vcek-disabled': 'bool' } }
+            '*vcek-disabled': 'bool',
+            '*certs-path': 'str',
+            '*certs-timeout': 'uint32' } }
 
 ##
 # @ThreadContextProperties:
target/i386/kvm/kvm.c +10 -0
index 8e17942c3b..cffc7ff33e 100644
@@ -6107,6 +6107,16 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
 #endif
     case KVM_EXIT_HYPERCALL:
         ret = kvm_handle_hypercall(run);
+        break;
+    case KVM_EXIT_SNP_REQ_CERTS:
+        if (!sev_snp_enabled()) {
+            error_report("KVM: Encountered a certificate request exit for a "
+                         "non-SEV-SNP guest.");
+            ret = -1;
+        } else {
+            ret = kvm_handle_snp_req_certs(cs, run);
+        }
+
         break;
     default:
         fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason);
target/i386/sev-sysemu-stub.c +5 -0
index d5bf886e79..685c56f62c 100644
@@ -71,3 +71,8 @@ void hmp_info_sev(Monitor *mon, const QDict *qdict)
 void pc_system_parse_sev_metadata(uint8_t *flash_ptr, size_t flash_size)
 {
 }
+
+int kvm_handle_snp_req_certs(CPUState *cpu, struct kvm_run *run)
+{
+    g_assert_not_reached();
+}
target/i386/sev.c +249 -0

291 lines not on this page · raw message

target/i386/sev.h +2 -0
index 858005a119..91b9c38ac1 100644
@@ -68,4 +68,6 @@ void sev_es_set_reset_vector(CPUState *cpu);
 
 void pc_system_parse_sev_metadata(uint8_t *flash_ptr, size_t flash_size);
 
+int kvm_handle_snp_req_certs(CPUState *cpu, struct kvm_run *run);
+
 #endif
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH v1 3/3] i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

Quoted 16 lines · Michael Roth

The GHCB specification[1] defines a VMGEXIT-based Guest Request hypercall to allow an SNP guest to issue encrypted requests directly to SNP firmware to do things like query the attestation report for the guest. These are generally handled purely in the kernel.

In some some cases, it's useful for the host to be able to additionally supply the certificate chain for the signing key that SNP firmware uses to sign these attestation reports. To allow for this, the GHCB specification defines an Extended Guest Request where this certificate data can be provided in a special format described in the GHCB spec. This certificate data may be global or guest-specific depending on how the guest was configured. Rather than providing interfaces to manage these within the kernel, KVM provides a new KVM_EXIT_SNP_REQ_CERTS exit to request the certificate contents from userspace. Implement support for that here.

Quoted 11 lines

To synchronize delivery of the certificates to the guest in a way where they will not be rendered invalid by updates to SNP firmware or attestation singing/endorsement keys by management tools outside the purview of QEMU, it is expected by users of KVM_EXIT_SNP_REQ_CERTS to obtain a shared/read lock on the certificate file prior to delivering them back to KVM. Only after this will the attestation report be retrieved from firmware and bundled with the certificate data, so QEMU must continue to hold the file lock until KVM confirms that the attestation report has been retrieved/bundled. This confirmation is done by way of the kvm_immediate_exit callback infrastructure that was introduced in a previous patch.

The "management tools outside the purview of QEMU" will all obtain the same kind of file lock?

Quoted 17 lines

[1] "Guest Hypervisor Communication Block (GHCB) Standardization",
https://www.amd.com/en/developer/sev.html

---
 qapi/qom.json                 |  23 +++-
 target/i386/kvm/kvm.c         |  10 ++
 target/i386/sev-sysemu-stub.c |   5 +
 target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++
 target/i386/sev.h             |   2 +
 5 files changed, 288 insertions(+), 1 deletion(-)
qapi/qom.json +0 -0
index 28ce24cd8d..6eaf0e7721 100644

qapi/qom.json line 1040

Quoted 7 lines
qapi/qom.json +4 -0
@@ -1034,6 +1034,25 @@
 #     firmware.  Set this to true to disable the use of VCEK.
 #     (default: false) (since: 9.1)
 #
+# @certs-path: Path to certificate data that can be passed to guests via
+#              SNP Extended Guest Requests. File should be in the format
+#              described in the GHCB specification. (default: none)
+#              (since: 10.0)

I prefer "filename" to "path". We have many kinds of paths: pathnames (denoting files), QOM paths (denoting objects), qdev paths, search paths, ... With "filename", your readers immediately know what you're talking about.

SevGuestProperties has a member 'dh-cert-file'. Whether that's related to your file I can't tell from its documentation.

qapi/qom.json line 1042

Quoted 2 lines
qapi/qom.json +2 -0
+#
+# @certs-timeout: Max time in milliseconds to wait to obtain a read lock

Please don't abbreviate "Maximum" here.

Confident millisecond granularity will suffice forever?

Quoted 5 lines
qapi/qom.json +5 -0
+#                 on the certificate file specified by @certs-path. This
+#                 is not a cumulative value and only affects how long
+#                 QEMU waits before returning execution to the vCPU and
+#                 informing the guest of the timeout, so the guest can
+#                 still continuing retrying for as long as it likes

qapi/qom.json line 1057

Quoted 10 lines
qapi/qom.json +8 -0
+#                 (which will be about 60 seconds for linux guests at
+#                 the time of this writing). If the guest-side timeout
+#                 is insufficient, set this higher to allow more time to
+#                 fetch the certificate. If the guest-side timeout is
+#                 sufficient, set this lower to reduce the likelihood of
+#                 soft lockups in the guest.
+#                 (default: 100) (since: 10.0)
+#
 # Since: 9.1
 ##

Please format like

# @certs-path: Path to certificate data that can be passed to guests

   #     via SNP Extended Guest Requests.  File should be in the format
   #     described in the GHCB specification.
   #     (default: none) (since: 10.0)
   #
   # @certs-timeout: Max time in milliseconds to wait to obtain a read
   #     lock on the certificate file specified by @certs-path.  This is
   #     not a cumulative value and only affects how long QEMU waits
   #     before returning execution to the vCPU and informing the guest
   #     of the timeout, so the guest can still continuing retrying for
   #     as long as it likes (which will be about 60 seconds for linux
   #     guests at the time of this writing).  If the guest-side timeout
   #     is insufficient, set this higher to allow more time to fetch the
   #     certificate.  If the guest-side timeout is sufficient, set this
   #     lower to reduce the likelihood of soft lockups in the guest.
   #     (default: 100) (since: 10.0)

to blend in with commit a937b6aa739 (qapi: Reformat doc comments to conform to current conventions).

Quoted 12 lines
qapi/qom.json +3 -1
 { 'struct': 'SevSnpGuestProperties',
@@ -1045,7 +1064,9 @@
             '*id-auth': 'str',
             '*author-key-enabled': 'bool',
             '*host-data': 'str',
-            '*vcek-disabled': 'bool' } }
+            '*vcek-disabled': 'bool',
+            '*certs-path': 'str',
+            '*certs-timeout': 'uint32' } }
 
 ##
 # @ThreadContextProperties:

[...]

#5 lore raw

Re: [PATCH v1 3/3] i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

Quoted 30 lines · Markus Armbruster
Quoted 16 lines · Michael Roth

The GHCB specification[1] defines a VMGEXIT-based Guest Request hypercall to allow an SNP guest to issue encrypted requests directly to SNP firmware to do things like query the attestation report for the guest. These are generally handled purely in the kernel.

In some some cases, it's useful for the host to be able to additionally supply the certificate chain for the signing key that SNP firmware uses to sign these attestation reports. To allow for this, the GHCB specification defines an Extended Guest Request where this certificate data can be provided in a special format described in the GHCB spec. This certificate data may be global or guest-specific depending on how the guest was configured. Rather than providing interfaces to manage these within the kernel, KVM provides a new KVM_EXIT_SNP_REQ_CERTS exit to request the certificate contents from userspace. Implement support for that here.

Quoted 11 lines

To synchronize delivery of the certificates to the guest in a way where they will not be rendered invalid by updates to SNP firmware or attestation singing/endorsement keys by management tools outside the purview of QEMU, it is expected by users of KVM_EXIT_SNP_REQ_CERTS to obtain a shared/read lock on the certificate file prior to delivering them back to KVM. Only after this will the attestation report be retrieved from firmware and bundled with the certificate data, so QEMU must continue to hold the file lock until KVM confirms that the attestation report has been retrieved/bundled. This confirmation is done by way of the kvm_immediate_exit callback infrastructure that was introduced in a previous patch.

Quoted 2 lines

The "management tools outside the purview of QEMU" will all obtain the same kind of file lock?

Yes, this is meant for a cooperative environment where the cloud provider has opted to provide guest certificates in this manner and needs a way to synchronize guest attestation requests with other parts of their stack handling management duties like updating firmware/endorsement keys/etc. which might occur between the time a certificate is fetched and the time the attestation report is generated by firmware.

The idea is to provide a path of least resistance using a common framework like filesystem locks, then heavily suggest that approach on the kernel documentation side, so that tools purposely or naturally opt to use this mechanism rather than every service provider coming up with some separate thing that they'll need to work into some custom QEMU/VMM to solve the same problem.

Of course, userspace is free to implement their own completely separate mechanism for handling all this and completely ignore file-locking. But QEMU is only trying to play nice with this above-mentioned reference implementation and cooperative management tools, and not trying to profess to provide any sort of synchronization for cases where those sorts of management-level updates are performed without utilizing this reference implementation for synchronization.

I should have touched on this in the schema documentation. I'll make sure to add that in the next spin.

Quoted 34 lines
Quoted 18 lines

[1] "Guest Hypervisor Communication Block (GHCB) Standardization",
https://www.amd.com/en/developer/sev.html

---
 qapi/qom.json                 |  23 +++-
 target/i386/kvm/kvm.c         |  10 ++
 target/i386/sev-sysemu-stub.c |   5 +
 target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++
 target/i386/sev.h             |   2 +
 5 files changed, 288 insertions(+), 1 deletion(-)
qapi/qom.json +0 -0
index 28ce24cd8d..6eaf0e7721 100644

qapi/qom.json line 1040

Quoted 7 lines
qapi/qom.json +4 -0
@@ -1034,6 +1034,25 @@
 #     firmware.  Set this to true to disable the use of VCEK.
 #     (default: false) (since: 9.1)
 #
+# @certs-path: Path to certificate data that can be passed to guests via
+#              SNP Extended Guest Requests. File should be in the format
+#              described in the GHCB specification. (default: none)
+#              (since: 10.0)

I prefer "filename" to "path". We have many kinds of paths: pathnames (denoting files), QOM paths (denoting objects), qdev paths, search paths, ... With "filename", your readers immediately know what you're talking about.

SevGuestProperties has a member 'dh-cert-file'. Whether that's related to your file I can't tell from its documentation.

Quoted 6 lines

qapi/qom.json line 1042

Quoted 2 lines
qapi/qom.json +2 -0
+#
+# @certs-timeout: Max time in milliseconds to wait to obtain a read lock

Please don't abbreviate "Maximum" here.

Confident millisecond granularity will suffice forever?

I believe so.

There will likely be some form of rate-limiting added to KVM along the lines of this patch, with proposals on the order of 2 requests per second for guest requests to avoid DoS'ing each other:

https://lore.kernel.org/all/[email protected]/

I believe guest kernels already voluntarily limit themselves to something similar before retrying requests.

So the only case I can think of where a sub-1ms interval would be desired would be cases where the guest has very aggressive soft-lockup detection settings, in which case we might as well just set the timeout to 0 and not busy-wait at all, which should be allowed for here. (There's more documentation in the related handling in target/i386/sev.c, but in such cases the guest will get an EAGAIN and generally retry the request later).

Quoted 36 lines
Quoted 6 lines
qapi/qom.json +5 -0
+#                 on the certificate file specified by @certs-path. This
+#                 is not a cumulative value and only affects how long
+#                 QEMU waits before returning execution to the vCPU and
+#                 informing the guest of the timeout, so the guest can
+#                 still continuing retrying for as long as it likes

qapi/qom.json line 1057

Quoted 10 lines
qapi/qom.json +8 -0
+#                 (which will be about 60 seconds for linux guests at
+#                 the time of this writing). If the guest-side timeout
+#                 is insufficient, set this higher to allow more time to
+#                 fetch the certificate. If the guest-side timeout is
+#                 sufficient, set this lower to reduce the likelihood of
+#                 soft lockups in the guest.
+#                 (default: 100) (since: 10.0)
+#
 # Since: 9.1
 ##

Please format like

# @certs-path: Path to certificate data that can be passed to guests

   #     via SNP Extended Guest Requests.  File should be in the format
   #     described in the GHCB specification.
   #     (default: none) (since: 10.0)
   #
   # @certs-timeout: Max time in milliseconds to wait to obtain a read
   #     lock on the certificate file specified by @certs-path.  This is
   #     not a cumulative value and only affects how long QEMU waits
   #     before returning execution to the vCPU and informing the guest
   #     of the timeout, so the guest can still continuing retrying for
   #     as long as it likes (which will be about 60 seconds for linux
   #     guests at the time of this writing).  If the guest-side timeout
   #     is insufficient, set this higher to allow more time to fetch the
   #     certificate.  If the guest-side timeout is sufficient, set this
   #     lower to reduce the likelihood of soft lockups in the guest.
   #     (default: 100) (since: 10.0)
Quoted 2 lines

to blend in with commit a937b6aa739 (qapi: Reformat doc comments to conform to current conventions).

Will do!

-Mike

Quoted 16 lines
Quoted 13 lines
qapi/qom.json +3 -1
 { 'struct': 'SevSnpGuestProperties',
@@ -1045,7 +1064,9 @@
             '*id-auth': 'str',
             '*author-key-enabled': 'bool',
             '*host-data': 'str',
-            '*vcek-disabled': 'bool' } }
+            '*vcek-disabled': 'bool',
+            '*certs-path': 'str',
+            '*certs-timeout': 'uint32' } }
 
 ##
 # @ThreadContextProperties:

[...]

#6 lore raw

Re: [PATCH v1 3/3] i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

In reply to Michael Roth
Quoted 45 lines · Michael Roth

The GHCB specification[1] defines a VMGEXIT-based Guest Request hypercall to allow an SNP guest to issue encrypted requests directly to SNP firmware to do things like query the attestation report for the guest. These are generally handled purely in the kernel.

In some some cases, it's useful for the host to be able to additionally supply the certificate chain for the signing key that SNP firmware uses to sign these attestation reports. To allow for this, the GHCB specification defines an Extended Guest Request where this certificate data can be provided in a special format described in the GHCB spec. This certificate data may be global or guest-specific depending on how the guest was configured. Rather than providing interfaces to manage these within the kernel, KVM provides a new KVM_EXIT_SNP_REQ_CERTS exit to request the certificate contents from userspace. Implement support for that here.

To synchronize delivery of the certificates to the guest in a way where they will not be rendered invalid by updates to SNP firmware or attestation singing/endorsement keys by management tools outside the purview of QEMU, it is expected by users of KVM_EXIT_SNP_REQ_CERTS to obtain a shared/read lock on the certificate file prior to delivering them back to KVM. Only after this will the attestation report be retrieved from firmware and bundled with the certificate data, so QEMU must continue to hold the file lock until KVM confirms that the attestation report has been retrieved/bundled. This confirmation is done by way of the kvm_immediate_exit callback infrastructure that was introduced in a previous patch.

[1] "Guest Hypervisor Communication Block (GHCB) Standardization",
https://www.amd.com/en/developer/sev.html

---
 qapi/qom.json                 |  23 +++-
 target/i386/kvm/kvm.c         |  10 ++
 target/i386/sev-sysemu-stub.c |   5 +
 target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++
 target/i386/sev.h             |   2 +
 5 files changed, 288 insertions(+), 1 deletion(-)
qapi/qom.json +0 -0
index 28ce24cd8d..6eaf0e7721 100644

qapi/qom.json line 1040

Quoted 7 lines
qapi/qom.json +4 -0
@@ -1034,6 +1034,25 @@
 #     firmware.  Set this to true to disable the use of VCEK.
 #     (default: false) (since: 9.1)
 #
+# @certs-path: Path to certificate data that can be passed to guests via
+#              SNP Extended Guest Requests. File should be in the format
+#              described in the GHCB specification. (default: none)
+#              (since: 10.0)

Can we document the required format here explicitly, rather than expecting users to go searching for specs which are often practically impossible to find, and even harder to read & interpret ?

Quoted 30 lines
target/i386/sev.c +15 -0
index 1a4eb1ada6..2c41bdbccf 100644
@@ -157,6 +157,9 @@ struct SevSnpGuestState {
     char *id_auth_base64;
     uint8_t *id_auth;
     char *host_data;
+    char *certs_path;
+    int certs_fd;
+    uint32_t certs_timeout;
 
     struct kvm_sev_snp_launch_start kvm_start_conf;
     struct kvm_sev_snp_launch_finish kvm_finish_conf;
@@ -1355,6 +1358,215 @@ sev_snp_launch_finish(SevCommonState *sev_common)
     }
 }
 
+static int open_certs_locked(SevSnpGuestState *sev_snp_guest)
+{
+    int fd, ret;
+
+    if (sev_snp_guest->certs_fd != -1) {
+        return 0;
+    }
+
+    fd = qemu_open(sev_snp_guest->certs_path, O_RDONLY, NULL);
+    if (fd == -1) {
+        error_report("Unable to open certificate blob at path %s, ret %d",
+                     sev_snp_guest->certs_path, fd);

target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1382

Quoted 10 lines
target/i386/sev.c +10 -0
+        return fd;
+    }
+
+    ret = qemu_lock_fd(fd, 0, 0, false);
+    if (ret == -EAGAIN || ret == -EACCES) {
+        ret = -EAGAIN;
+        goto out_close;
+    } else if (ret) {
+        goto out_close;
+    }

This locking scheme is likely unsafe. Consider this sequence

* QEMU runs qemu_open(path)
* External mgmt app runs unlink(path)
* External mgmt app runs open(path)
* External mgmt app runs lock(fd)
* QEMU runs qemu_lock_fd(fd)

QEMU has successfully acquired a lock on an FD that corresponds to a deleted file, not the current existing file.

Avoiding this problem requires either that the external mgmt app agrees to *NEVER* unlink() the files under any circumstance, or for QEMU to run its open + lock logic in a loop, checking 'stat' and 'fstat' before opening and after locking, in order to detect a replaced file from its changed inode.

I'm not inclined to rely on mgmt apps never unlink()ing as that's to easy to mess up IMHO.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#7 lore raw

Re: [PATCH v1 3/3] i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

Quoted 41 lines · Daniel P. Berrangé
Quoted 40 lines · Michael Roth

The GHCB specification[1] defines a VMGEXIT-based Guest Request hypercall to allow an SNP guest to issue encrypted requests directly to SNP firmware to do things like query the attestation report for the guest. These are generally handled purely in the kernel.

In some some cases, it's useful for the host to be able to additionally supply the certificate chain for the signing key that SNP firmware uses to sign these attestation reports. To allow for this, the GHCB specification defines an Extended Guest Request where this certificate data can be provided in a special format described in the GHCB spec. This certificate data may be global or guest-specific depending on how the guest was configured. Rather than providing interfaces to manage these within the kernel, KVM provides a new KVM_EXIT_SNP_REQ_CERTS exit to request the certificate contents from userspace. Implement support for that here.

To synchronize delivery of the certificates to the guest in a way where they will not be rendered invalid by updates to SNP firmware or attestation singing/endorsement keys by management tools outside the purview of QEMU, it is expected by users of KVM_EXIT_SNP_REQ_CERTS to obtain a shared/read lock on the certificate file prior to delivering them back to KVM. Only after this will the attestation report be retrieved from firmware and bundled with the certificate data, so QEMU must continue to hold the file lock until KVM confirms that the attestation report has been retrieved/bundled. This confirmation is done by way of the kvm_immediate_exit callback infrastructure that was introduced in a previous patch.

[1] "Guest Hypervisor Communication Block (GHCB) Standardization",
https://www.amd.com/en/developer/sev.html

---
 qapi/qom.json                 |  23 +++-
 target/i386/kvm/kvm.c         |  10 ++
 target/i386/sev-sysemu-stub.c |   5 +
 target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++
 target/i386/sev.h             |   2 +
 5 files changed, 288 insertions(+), 1 deletion(-)
Quoted 16 lines

qapi/qom.json line 1040

Quoted 12 lines
qapi/qom.json +4 -0
index 28ce24cd8d..6eaf0e7721 100644
@@ -1034,6 +1034,25 @@
 #     firmware.  Set this to true to disable the use of VCEK.
 #     (default: false) (since: 9.1)
 #
+# @certs-path: Path to certificate data that can be passed to guests via
+#              SNP Extended Guest Requests. File should be in the format
+#              described in the GHCB specification. (default: none)
+#              (since: 10.0)

Can we document the required format here explicitly, rather than expecting users to go searching for specs which are often practically impossible to find, and even harder to read & interpret ?

It'll be difficult to summarize in a way that will be self-reliant, since knowing the certificate format is not sufficient to make sure it coincides with the endorsement key being used by firmware. So I can't promise to completely reduce reliance on external specs, but at least give a better of the format and where those external specs will come into play in filling out the data.

If it needs to be at least somewhat self-sufficient then that might warrant a separate document in docs/system/i386/amd-memory-encryption.rst or somewhere thereabouts that summarizes the whole attestation flow and how certificates tie into that.

Any preferences?

Quoted 53 lines
Quoted 31 lines
target/i386/sev.c +15 -0
index 1a4eb1ada6..2c41bdbccf 100644
@@ -157,6 +157,9 @@ struct SevSnpGuestState {
     char *id_auth_base64;
     uint8_t *id_auth;
     char *host_data;
+    char *certs_path;
+    int certs_fd;
+    uint32_t certs_timeout;
 
     struct kvm_sev_snp_launch_start kvm_start_conf;
     struct kvm_sev_snp_launch_finish kvm_finish_conf;
@@ -1355,6 +1358,215 @@ sev_snp_launch_finish(SevCommonState *sev_common)
     }
 }
 
+static int open_certs_locked(SevSnpGuestState *sev_snp_guest)
+{
+    int fd, ret;
+
+    if (sev_snp_guest->certs_fd != -1) {
+        return 0;
+    }
+
+    fd = qemu_open(sev_snp_guest->certs_path, O_RDONLY, NULL);
+    if (fd == -1) {
+        error_report("Unable to open certificate blob at path %s, ret %d",
+                     sev_snp_guest->certs_path, fd);

target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1382

Quoted 10 lines
target/i386/sev.c +10 -0
+        return fd;
+    }
+
+    ret = qemu_lock_fd(fd, 0, 0, false);
+    if (ret == -EAGAIN || ret == -EACCES) {
+        ret = -EAGAIN;
+        goto out_close;
+    } else if (ret) {
+        goto out_close;
+    }

This locking scheme is likely unsafe. Consider this sequence

* QEMU runs qemu_open(path)
* External mgmt app runs unlink(path)
* External mgmt app runs open(path)
* External mgmt app runs lock(fd)
* QEMU runs qemu_lock_fd(fd)

QEMU has successfully acquired a lock on an FD that corresponds to a deleted file, not the current existing file.

Quoted 8 lines

Avoiding this problem requires either that the external mgmt app agrees to *NEVER* unlink() the files under any circumstance, or for QEMU to run its open + lock logic in a loop, checking 'stat' and 'fstat' before opening and after locking, in order to detect a replaced file from its changed inode.

I'm not inclined to rely on mgmt apps never unlink()ing as that's to easy to mess up IMHO.

Yah I went into more detail in my response to Markus, but long story short is that we are assuming mgmt is cooperative in this case, and so as you mentioned, it would never unlink files while SNP guests are running, but instead take an exclusive lock on them and update them in place with the understanding that doing anything otherwise would open a race window where guests might get stale certificates.

-Mike

Quoted 8 lines

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#8 lore raw

Re: [PATCH v1 3/3] i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

Quoted 135 lines · Michael Roth
Quoted 41 lines · Daniel P. Berrangé
Quoted 40 lines · Michael Roth

The GHCB specification[1] defines a VMGEXIT-based Guest Request hypercall to allow an SNP guest to issue encrypted requests directly to SNP firmware to do things like query the attestation report for the guest. These are generally handled purely in the kernel.

In some some cases, it's useful for the host to be able to additionally supply the certificate chain for the signing key that SNP firmware uses to sign these attestation reports. To allow for this, the GHCB specification defines an Extended Guest Request where this certificate data can be provided in a special format described in the GHCB spec. This certificate data may be global or guest-specific depending on how the guest was configured. Rather than providing interfaces to manage these within the kernel, KVM provides a new KVM_EXIT_SNP_REQ_CERTS exit to request the certificate contents from userspace. Implement support for that here.

To synchronize delivery of the certificates to the guest in a way where they will not be rendered invalid by updates to SNP firmware or attestation singing/endorsement keys by management tools outside the purview of QEMU, it is expected by users of KVM_EXIT_SNP_REQ_CERTS to obtain a shared/read lock on the certificate file prior to delivering them back to KVM. Only after this will the attestation report be retrieved from firmware and bundled with the certificate data, so QEMU must continue to hold the file lock until KVM confirms that the attestation report has been retrieved/bundled. This confirmation is done by way of the kvm_immediate_exit callback infrastructure that was introduced in a previous patch.

[1] "Guest Hypervisor Communication Block (GHCB) Standardization",
https://www.amd.com/en/developer/sev.html

---
 qapi/qom.json                 |  23 +++-
 target/i386/kvm/kvm.c         |  10 ++
 target/i386/sev-sysemu-stub.c |   5 +
 target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++
 target/i386/sev.h             |   2 +
 5 files changed, 288 insertions(+), 1 deletion(-)
Quoted 16 lines

qapi/qom.json line 1040

Quoted 12 lines
qapi/qom.json +4 -0
index 28ce24cd8d..6eaf0e7721 100644
@@ -1034,6 +1034,25 @@
 #     firmware.  Set this to true to disable the use of VCEK.
 #     (default: false) (since: 9.1)
 #
+# @certs-path: Path to certificate data that can be passed to guests via
+#              SNP Extended Guest Requests. File should be in the format
+#              described in the GHCB specification. (default: none)
+#              (since: 10.0)

Can we document the required format here explicitly, rather than expecting users to go searching for specs which are often practically impossible to find, and even harder to read & interpret ?

It'll be difficult to summarize in a way that will be self-reliant, since knowing the certificate format is not sufficient to make sure it coincides with the endorsement key being used by firmware. So I can't promise to completely reduce reliance on external specs, but at least give a better of the format and where those external specs will come into play in filling out the data.

If it needs to be at least somewhat self-sufficient then that might warrant a separate document in docs/system/i386/amd-memory-encryption.rst or somewhere thereabouts that summarizes the whole attestation flow and how certificates tie into that.

Any preferences?

Quoted 53 lines
Quoted 31 lines
target/i386/sev.c +15 -0
index 1a4eb1ada6..2c41bdbccf 100644
@@ -157,6 +157,9 @@ struct SevSnpGuestState {
     char *id_auth_base64;
     uint8_t *id_auth;
     char *host_data;
+    char *certs_path;
+    int certs_fd;
+    uint32_t certs_timeout;
 
     struct kvm_sev_snp_launch_start kvm_start_conf;
     struct kvm_sev_snp_launch_finish kvm_finish_conf;
@@ -1355,6 +1358,215 @@ sev_snp_launch_finish(SevCommonState *sev_common)
     }
 }
 
+static int open_certs_locked(SevSnpGuestState *sev_snp_guest)
+{
+    int fd, ret;
+
+    if (sev_snp_guest->certs_fd != -1) {
+        return 0;
+    }
+
+    fd = qemu_open(sev_snp_guest->certs_path, O_RDONLY, NULL);
+    if (fd == -1) {
+        error_report("Unable to open certificate blob at path %s, ret %d",
+                     sev_snp_guest->certs_path, fd);

target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1382

Quoted 10 lines
target/i386/sev.c +10 -0
+        return fd;
+    }
+
+    ret = qemu_lock_fd(fd, 0, 0, false);
+    if (ret == -EAGAIN || ret == -EACCES) {
+        ret = -EAGAIN;
+        goto out_close;
+    } else if (ret) {
+        goto out_close;
+    }

This locking scheme is likely unsafe. Consider this sequence

* QEMU runs qemu_open(path)
* External mgmt app runs unlink(path)
* External mgmt app runs open(path)
* External mgmt app runs lock(fd)
* QEMU runs qemu_lock_fd(fd)

QEMU has successfully acquired a lock on an FD that corresponds to a deleted file, not the current existing file.

Quoted 8 lines

Avoiding this problem requires either that the external mgmt app agrees to *NEVER* unlink() the files under any circumstance, or for QEMU to run its open + lock logic in a loop, checking 'stat' and 'fstat' before opening and after locking, in order to detect a replaced file from its changed inode.

I'm not inclined to rely on mgmt apps never unlink()ing as that's to easy to mess up IMHO.

Quoted 6 lines

Yah I went into more detail in my response to Markus, but long story short is that we are assuming mgmt is cooperative in this case, and so as you mentioned, it would never unlink files while SNP guests are running, but instead take an exclusive lock on them and update them in place with the understanding that doing anything otherwise would open a race window where guests might get stale certificates.

If there's an expectation & requirement that no SNP guests are running, then IMHO this whole thing is just over-engineered. Just remove all this locking code entirely, and document that none of this must be changed while QEMU is running - which is a common requirement for a great many things on the host.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#9 lore raw

Re: [PATCH v1 3/3] i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

Quoted 143 lines · Daniel P. Berrangé
Quoted 135 lines · Michael Roth
Quoted 41 lines · Daniel P. Berrangé
Quoted 40 lines · Michael Roth

The GHCB specification[1] defines a VMGEXIT-based Guest Request hypercall to allow an SNP guest to issue encrypted requests directly to SNP firmware to do things like query the attestation report for the guest. These are generally handled purely in the kernel.

In some some cases, it's useful for the host to be able to additionally supply the certificate chain for the signing key that SNP firmware uses to sign these attestation reports. To allow for this, the GHCB specification defines an Extended Guest Request where this certificate data can be provided in a special format described in the GHCB spec. This certificate data may be global or guest-specific depending on how the guest was configured. Rather than providing interfaces to manage these within the kernel, KVM provides a new KVM_EXIT_SNP_REQ_CERTS exit to request the certificate contents from userspace. Implement support for that here.

To synchronize delivery of the certificates to the guest in a way where they will not be rendered invalid by updates to SNP firmware or attestation singing/endorsement keys by management tools outside the purview of QEMU, it is expected by users of KVM_EXIT_SNP_REQ_CERTS to obtain a shared/read lock on the certificate file prior to delivering them back to KVM. Only after this will the attestation report be retrieved from firmware and bundled with the certificate data, so QEMU must continue to hold the file lock until KVM confirms that the attestation report has been retrieved/bundled. This confirmation is done by way of the kvm_immediate_exit callback infrastructure that was introduced in a previous patch.

[1] "Guest Hypervisor Communication Block (GHCB) Standardization",
https://www.amd.com/en/developer/sev.html

---
 qapi/qom.json                 |  23 +++-
 target/i386/kvm/kvm.c         |  10 ++
 target/i386/sev-sysemu-stub.c |   5 +
 target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++
 target/i386/sev.h             |   2 +
 5 files changed, 288 insertions(+), 1 deletion(-)
Quoted 16 lines

qapi/qom.json line 1040

Quoted 12 lines
qapi/qom.json +4 -0
index 28ce24cd8d..6eaf0e7721 100644
@@ -1034,6 +1034,25 @@
 #     firmware.  Set this to true to disable the use of VCEK.
 #     (default: false) (since: 9.1)
 #
+# @certs-path: Path to certificate data that can be passed to guests via
+#              SNP Extended Guest Requests. File should be in the format
+#              described in the GHCB specification. (default: none)
+#              (since: 10.0)

Can we document the required format here explicitly, rather than expecting users to go searching for specs which are often practically impossible to find, and even harder to read & interpret ?

It'll be difficult to summarize in a way that will be self-reliant, since knowing the certificate format is not sufficient to make sure it coincides with the endorsement key being used by firmware. So I can't promise to completely reduce reliance on external specs, but at least give a better of the format and where those external specs will come into play in filling out the data.

If it needs to be at least somewhat self-sufficient then that might warrant a separate document in docs/system/i386/amd-memory-encryption.rst or somewhere thereabouts that summarizes the whole attestation flow and how certificates tie into that.

Any preferences?

Quoted 53 lines
Quoted 31 lines
target/i386/sev.c +15 -0
index 1a4eb1ada6..2c41bdbccf 100644
@@ -157,6 +157,9 @@ struct SevSnpGuestState {
     char *id_auth_base64;
     uint8_t *id_auth;
     char *host_data;
+    char *certs_path;
+    int certs_fd;
+    uint32_t certs_timeout;
 
     struct kvm_sev_snp_launch_start kvm_start_conf;
     struct kvm_sev_snp_launch_finish kvm_finish_conf;
@@ -1355,6 +1358,215 @@ sev_snp_launch_finish(SevCommonState *sev_common)
     }
 }
 
+static int open_certs_locked(SevSnpGuestState *sev_snp_guest)
+{
+    int fd, ret;
+
+    if (sev_snp_guest->certs_fd != -1) {
+        return 0;
+    }
+
+    fd = qemu_open(sev_snp_guest->certs_path, O_RDONLY, NULL);
+    if (fd == -1) {
+        error_report("Unable to open certificate blob at path %s, ret %d",
+                     sev_snp_guest->certs_path, fd);

target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1382

Quoted 10 lines
target/i386/sev.c +10 -0
+        return fd;
+    }
+
+    ret = qemu_lock_fd(fd, 0, 0, false);
+    if (ret == -EAGAIN || ret == -EACCES) {
+        ret = -EAGAIN;
+        goto out_close;
+    } else if (ret) {
+        goto out_close;
+    }

This locking scheme is likely unsafe. Consider this sequence

* QEMU runs qemu_open(path)
* External mgmt app runs unlink(path)
* External mgmt app runs open(path)
* External mgmt app runs lock(fd)
* QEMU runs qemu_lock_fd(fd)

QEMU has successfully acquired a lock on an FD that corresponds to a deleted file, not the current existing file.

Quoted 8 lines

Avoiding this problem requires either that the external mgmt app agrees to *NEVER* unlink() the files under any circumstance, or for QEMU to run its open + lock logic in a loop, checking 'stat' and 'fstat' before opening and after locking, in order to detect a replaced file from its changed inode.

I'm not inclined to rely on mgmt apps never unlink()ing as that's to easy to mess up IMHO.

Quoted 6 lines

Yah I went into more detail in my response to Markus, but long story short is that we are assuming mgmt is cooperative in this case, and so as you mentioned, it would never unlink files while SNP guests are running, but instead take an exclusive lock on them and update them in place with the understanding that doing anything otherwise would open a race window where guests might get stale certificates.

Quoted 5 lines

If there's an expectation & requirement that no SNP guests are running, then IMHO this whole thing is just over-engineered. Just remove all this locking code entirely, and document that none of this must be changed while QEMU is running - which is a common requirement for a great many things on the host.

VCEK endorsement keys can change as a result of SNP firmware updates, which can be done while SNP guests are running and are often done in such a way to patch bugs/security holes. VLEK endorsement keys can similarly be updated on a live host. Both these sorts of interactions cannot be made compatible with bundling certificates with attestation reports without some orchestration in place to keep them atomic relative to the endorsement key being used by firmware to sign attestation reports. Every CSP implementing this will need to solve it in some way, and I'm sure some will handle all this completely differently. But it will make interoperative management/tooling a mess, and having a reference implementation based around something common will make it easier to steer CSPs to that common solution and give management tools authors *some* reference approach to target rather than expecting to retrofit some custom solution on top.

With these patches, you can update firmware and endorsement keys while SNP guests are running, but it requires write locks on any active certificates as defined here and in the kernel, and doing certificate file updates in place while that write lock is still held. I don't really think that's over-engineered. I think it's surprisingly simple given the potential complexity of the above-mentioned requirements.

But yes if management tries to unlink certificates while SNP guests are running, all bets are off. But at that point they are not cooperating with kernel/QEMU, and we don't need to care about that. And if they really do need to blow away certificates for a complete re-install or data-wipe or whatever, at that point they'd just need to ensure they stop all their SNP guests first.

-Mike

Quoted 8 lines

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#10 lore raw

Re: [PATCH v1 3/3] i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

Quoted 172 lines · Michael Roth
Quoted 143 lines · Daniel P. Berrangé
Quoted 135 lines · Michael Roth
Quoted 41 lines · Daniel P. Berrangé
Quoted 40 lines · Michael Roth

The GHCB specification[1] defines a VMGEXIT-based Guest Request hypercall to allow an SNP guest to issue encrypted requests directly to SNP firmware to do things like query the attestation report for the guest. These are generally handled purely in the kernel.

In some some cases, it's useful for the host to be able to additionally supply the certificate chain for the signing key that SNP firmware uses to sign these attestation reports. To allow for this, the GHCB specification defines an Extended Guest Request where this certificate data can be provided in a special format described in the GHCB spec. This certificate data may be global or guest-specific depending on how the guest was configured. Rather than providing interfaces to manage these within the kernel, KVM provides a new KVM_EXIT_SNP_REQ_CERTS exit to request the certificate contents from userspace. Implement support for that here.

To synchronize delivery of the certificates to the guest in a way where they will not be rendered invalid by updates to SNP firmware or attestation singing/endorsement keys by management tools outside the purview of QEMU, it is expected by users of KVM_EXIT_SNP_REQ_CERTS to obtain a shared/read lock on the certificate file prior to delivering them back to KVM. Only after this will the attestation report be retrieved from firmware and bundled with the certificate data, so QEMU must continue to hold the file lock until KVM confirms that the attestation report has been retrieved/bundled. This confirmation is done by way of the kvm_immediate_exit callback infrastructure that was introduced in a previous patch.

[1] "Guest Hypervisor Communication Block (GHCB) Standardization",
https://www.amd.com/en/developer/sev.html

---
 qapi/qom.json                 |  23 +++-
 target/i386/kvm/kvm.c         |  10 ++
 target/i386/sev-sysemu-stub.c |   5 +
 target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++
 target/i386/sev.h             |   2 +
 5 files changed, 288 insertions(+), 1 deletion(-)
Quoted 16 lines

qapi/qom.json line 1040

Quoted 12 lines
qapi/qom.json +4 -0
index 28ce24cd8d..6eaf0e7721 100644
@@ -1034,6 +1034,25 @@
 #     firmware.  Set this to true to disable the use of VCEK.
 #     (default: false) (since: 9.1)
 #
+# @certs-path: Path to certificate data that can be passed to guests via
+#              SNP Extended Guest Requests. File should be in the format
+#              described in the GHCB specification. (default: none)
+#              (since: 10.0)

Can we document the required format here explicitly, rather than expecting users to go searching for specs which are often practically impossible to find, and even harder to read & interpret ?

It'll be difficult to summarize in a way that will be self-reliant, since knowing the certificate format is not sufficient to make sure it coincides with the endorsement key being used by firmware. So I can't promise to completely reduce reliance on external specs, but at least give a better of the format and where those external specs will come into play in filling out the data.

If it needs to be at least somewhat self-sufficient then that might warrant a separate document in docs/system/i386/amd-memory-encryption.rst or somewhere thereabouts that summarizes the whole attestation flow and how certificates tie into that.

Any preferences?

Quoted 53 lines
Quoted 31 lines
target/i386/sev.c +15 -0
index 1a4eb1ada6..2c41bdbccf 100644
@@ -157,6 +157,9 @@ struct SevSnpGuestState {
     char *id_auth_base64;
     uint8_t *id_auth;
     char *host_data;
+    char *certs_path;
+    int certs_fd;
+    uint32_t certs_timeout;
 
     struct kvm_sev_snp_launch_start kvm_start_conf;
     struct kvm_sev_snp_launch_finish kvm_finish_conf;
@@ -1355,6 +1358,215 @@ sev_snp_launch_finish(SevCommonState *sev_common)
     }
 }
 
+static int open_certs_locked(SevSnpGuestState *sev_snp_guest)
+{
+    int fd, ret;
+
+    if (sev_snp_guest->certs_fd != -1) {
+        return 0;
+    }
+
+    fd = qemu_open(sev_snp_guest->certs_path, O_RDONLY, NULL);
+    if (fd == -1) {
+        error_report("Unable to open certificate blob at path %s, ret %d",
+                     sev_snp_guest->certs_path, fd);

target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1382

Quoted 10 lines
target/i386/sev.c +10 -0
+        return fd;
+    }
+
+    ret = qemu_lock_fd(fd, 0, 0, false);
+    if (ret == -EAGAIN || ret == -EACCES) {
+        ret = -EAGAIN;
+        goto out_close;
+    } else if (ret) {
+        goto out_close;
+    }

This locking scheme is likely unsafe. Consider this sequence

* QEMU runs qemu_open(path)
* External mgmt app runs unlink(path)
* External mgmt app runs open(path)
* External mgmt app runs lock(fd)
* QEMU runs qemu_lock_fd(fd)

QEMU has successfully acquired a lock on an FD that corresponds to a deleted file, not the current existing file.

Quoted 8 lines

Avoiding this problem requires either that the external mgmt app agrees to *NEVER* unlink() the files under any circumstance, or for QEMU to run its open + lock logic in a loop, checking 'stat' and 'fstat' before opening and after locking, in order to detect a replaced file from its changed inode.

I'm not inclined to rely on mgmt apps never unlink()ing as that's to easy to mess up IMHO.

Quoted 6 lines

Yah I went into more detail in my response to Markus, but long story short is that we are assuming mgmt is cooperative in this case, and so as you mentioned, it would never unlink files while SNP guests are running, but instead take an exclusive lock on them and update them in place with the understanding that doing anything otherwise would open a race window where guests might get stale certificates.

Quoted 5 lines

If there's an expectation & requirement that no SNP guests are running, then IMHO this whole thing is just over-engineered. Just remove all this locking code entirely, and document that none of this must be changed while QEMU is running - which is a common requirement for a great many things on the host.

VCEK endorsement keys can change as a result of SNP firmware updates, which can be done while SNP guests are running and are often done in such a way to patch bugs/security holes. VLEK endorsement keys can similarly be updated on a live host. Both these sorts of interactions cannot be made compatible with bundling certificates with attestation reports without some orchestration in place to keep them atomic relative to the endorsement key being used by firmware to sign attestation reports. Every CSP implementing this will need to solve it in some way, and I'm sure some will handle all this completely differently. But it will make interoperative management/tooling a mess, and having a reference implementation based around something common will make it easier to steer CSPs to that common solution and give management tools authors *some* reference approach to target rather than expecting to retrofit some custom solution on top.

With these patches, you can update firmware and endorsement keys while SNP guests are running, but it requires write locks on any active certificates as defined here and in the kernel, and doing certificate file updates in place while that write lock is still held. I don't really think that's over-engineered. I think it's surprisingly simple given the potential complexity of the above-mentioned requirements.

Quoted 6 lines

But yes if management tries to unlink certificates while SNP guests are running, all bets are off. But at that point they are not cooperating with kernel/QEMU, and we don't need to care about that. And if they really do need to blow away certificates for a complete re-install or data-wipe or whatever, at that point they'd just need to ensure they stop all their SNP guests first.

IMHO we msut consider unlink() to be a valid thing, because the right way for apps to perform crash safe atomic updates of existing files, is to use rename() from a temporary file, and the rename() in has an implicit unlink as part of its operation. ie apps would be doing:

fd = open("foo.tmp")
write(fd, ...)
fsync(fd)
close(fd)
rename("foo.tmp", "foo")

That final rename operation will have the same effect on the locks as unlink(). To cope with this anything doing locking has to run in a loop comparing the inode either side of acquiring the lock

TLDR: if we're going to do locking in QEMU, it needs to be done robustly.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#11 lore raw

Re: [PATCH v1 3/3] i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

Quoted 185 lines · Daniel P. Berrangé
Quoted 172 lines · Michael Roth
Quoted 143 lines · Daniel P. Berrangé
Quoted 135 lines · Michael Roth
Quoted 41 lines · Daniel P. Berrangé
Quoted 40 lines · Michael Roth

The GHCB specification[1] defines a VMGEXIT-based Guest Request hypercall to allow an SNP guest to issue encrypted requests directly to SNP firmware to do things like query the attestation report for the guest. These are generally handled purely in the kernel.

In some some cases, it's useful for the host to be able to additionally supply the certificate chain for the signing key that SNP firmware uses to sign these attestation reports. To allow for this, the GHCB specification defines an Extended Guest Request where this certificate data can be provided in a special format described in the GHCB spec. This certificate data may be global or guest-specific depending on how the guest was configured. Rather than providing interfaces to manage these within the kernel, KVM provides a new KVM_EXIT_SNP_REQ_CERTS exit to request the certificate contents from userspace. Implement support for that here.

To synchronize delivery of the certificates to the guest in a way where they will not be rendered invalid by updates to SNP firmware or attestation singing/endorsement keys by management tools outside the purview of QEMU, it is expected by users of KVM_EXIT_SNP_REQ_CERTS to obtain a shared/read lock on the certificate file prior to delivering them back to KVM. Only after this will the attestation report be retrieved from firmware and bundled with the certificate data, so QEMU must continue to hold the file lock until KVM confirms that the attestation report has been retrieved/bundled. This confirmation is done by way of the kvm_immediate_exit callback infrastructure that was introduced in a previous patch.

[1] "Guest Hypervisor Communication Block (GHCB) Standardization",
https://www.amd.com/en/developer/sev.html

---
 qapi/qom.json                 |  23 +++-
 target/i386/kvm/kvm.c         |  10 ++
 target/i386/sev-sysemu-stub.c |   5 +
 target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++
 target/i386/sev.h             |   2 +
 5 files changed, 288 insertions(+), 1 deletion(-)
Quoted 16 lines

qapi/qom.json line 1040

Quoted 12 lines
qapi/qom.json +4 -0
index 28ce24cd8d..6eaf0e7721 100644
@@ -1034,6 +1034,25 @@
 #     firmware.  Set this to true to disable the use of VCEK.
 #     (default: false) (since: 9.1)
 #
+# @certs-path: Path to certificate data that can be passed to guests via
+#              SNP Extended Guest Requests. File should be in the format
+#              described in the GHCB specification. (default: none)
+#              (since: 10.0)

Can we document the required format here explicitly, rather than expecting users to go searching for specs which are often practically impossible to find, and even harder to read & interpret ?

It'll be difficult to summarize in a way that will be self-reliant, since knowing the certificate format is not sufficient to make sure it coincides with the endorsement key being used by firmware. So I can't promise to completely reduce reliance on external specs, but at least give a better of the format and where those external specs will come into play in filling out the data.

If it needs to be at least somewhat self-sufficient then that might warrant a separate document in docs/system/i386/amd-memory-encryption.rst or somewhere thereabouts that summarizes the whole attestation flow and how certificates tie into that.

Any preferences?

Quoted 53 lines
Quoted 31 lines
target/i386/sev.c +15 -0
index 1a4eb1ada6..2c41bdbccf 100644
@@ -157,6 +157,9 @@ struct SevSnpGuestState {
     char *id_auth_base64;
     uint8_t *id_auth;
     char *host_data;
+    char *certs_path;
+    int certs_fd;
+    uint32_t certs_timeout;
 
     struct kvm_sev_snp_launch_start kvm_start_conf;
     struct kvm_sev_snp_launch_finish kvm_finish_conf;
@@ -1355,6 +1358,215 @@ sev_snp_launch_finish(SevCommonState *sev_common)
     }
 }
 
+static int open_certs_locked(SevSnpGuestState *sev_snp_guest)
+{
+    int fd, ret;
+
+    if (sev_snp_guest->certs_fd != -1) {
+        return 0;
+    }
+
+    fd = qemu_open(sev_snp_guest->certs_path, O_RDONLY, NULL);
+    if (fd == -1) {
+        error_report("Unable to open certificate blob at path %s, ret %d",
+                     sev_snp_guest->certs_path, fd);

target/i386/sev.c sev_snp_launch_finish(SevCommonState *sev_common) · line 1382

Quoted 10 lines
target/i386/sev.c +10 -0
+        return fd;
+    }
+
+    ret = qemu_lock_fd(fd, 0, 0, false);
+    if (ret == -EAGAIN || ret == -EACCES) {
+        ret = -EAGAIN;
+        goto out_close;
+    } else if (ret) {
+        goto out_close;
+    }

This locking scheme is likely unsafe. Consider this sequence

* QEMU runs qemu_open(path)
* External mgmt app runs unlink(path)
* External mgmt app runs open(path)
* External mgmt app runs lock(fd)
* QEMU runs qemu_lock_fd(fd)

QEMU has successfully acquired a lock on an FD that corresponds to a deleted file, not the current existing file.

Quoted 8 lines

Avoiding this problem requires either that the external mgmt app agrees to *NEVER* unlink() the files under any circumstance, or for QEMU to run its open + lock logic in a loop, checking 'stat' and 'fstat' before opening and after locking, in order to detect a replaced file from its changed inode.

I'm not inclined to rely on mgmt apps never unlink()ing as that's to easy to mess up IMHO.

Quoted 6 lines

Yah I went into more detail in my response to Markus, but long story short is that we are assuming mgmt is cooperative in this case, and so as you mentioned, it would never unlink files while SNP guests are running, but instead take an exclusive lock on them and update them in place with the understanding that doing anything otherwise would open a race window where guests might get stale certificates.

Quoted 5 lines

If there's an expectation & requirement that no SNP guests are running, then IMHO this whole thing is just over-engineered. Just remove all this locking code entirely, and document that none of this must be changed while QEMU is running - which is a common requirement for a great many things on the host.

VCEK endorsement keys can change as a result of SNP firmware updates, which can be done while SNP guests are running and are often done in such a way to patch bugs/security holes. VLEK endorsement keys can similarly be updated on a live host. Both these sorts of interactions cannot be made compatible with bundling certificates with attestation reports without some orchestration in place to keep them atomic relative to the endorsement key being used by firmware to sign attestation reports. Every CSP implementing this will need to solve it in some way, and I'm sure some will handle all this completely differently. But it will make interoperative management/tooling a mess, and having a reference implementation based around something common will make it easier to steer CSPs to that common solution and give management tools authors *some* reference approach to target rather than expecting to retrofit some custom solution on top.

With these patches, you can update firmware and endorsement keys while SNP guests are running, but it requires write locks on any active certificates as defined here and in the kernel, and doing certificate file updates in place while that write lock is still held. I don't really think that's over-engineered. I think it's surprisingly simple given the potential complexity of the above-mentioned requirements.

Quoted 6 lines

But yes if management tries to unlink certificates while SNP guests are running, all bets are off. But at that point they are not cooperating with kernel/QEMU, and we don't need to care about that. And if they really do need to blow away certificates for a complete re-install or data-wipe or whatever, at that point they'd just need to ensure they stop all their SNP guests first.

IMHO we msut consider unlink() to be a valid thing, because the right way for apps to perform crash safe atomic updates of existing files, is to use rename() from a temporary file, and the rename() in has an implicit unlink as part of its operation. ie apps would be doing:

Quoted 5 lines
   fd = open("foo.tmp")
   write(fd, ...)
   fsync(fd)
   close(fd)
   rename("foo.tmp", "foo")

If we still want to allow for this rather than enforcing in-place update, one alternative would be to just allow a separate lock file to be specified rather than locking the certificate file itself. That would provide a bit more flexibility.

I can update the QEMU implementation to take -certs-lock-file in addition to -certs-file so they can be specified separately. And if -certs-lock-file is not specified then QEMU will just assume management handles things different or has agreed to not do endorsement key updates while SNP guests are running.

I think we'd considered something like that originally but the thinking was that locking the certs themselves was more organic in terms of an "obvious"/natural solution. But it does end up being a bit more inflexible WRT how libraries/etc. might manage file updates underneath the covers, so maybe a lock file is the better approach after all.

-Mike

Quoted 15 lines

That final rename operation will have the same effect on the locks as unlink(). To cope with this anything doing locking has to run in a loop comparing the inode either side of acquiring the lock

TLDR: if we're going to do locking in QEMU, it needs to be done robustly.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#12 lore raw

Re: [PATCH v1 3/3] i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

Quoted 23 lines · Michael Roth
Quoted 10 lines · Daniel P. Berrangé

IMHO we msut consider unlink() to be a valid thing, because the right way for apps to perform crash safe atomic updates of existing files, is to use rename() from a temporary file, and the rename() in has an implicit unlink as part of its operation. ie apps would be doing:

   fd = open("foo.tmp")
   write(fd, ...)
   fsync(fd)
   close(fd)
   rename("foo.tmp", "foo")

If we still want to allow for this rather than enforcing in-place update, one alternative would be to just allow a separate lock file to be specified rather than locking the certificate file itself. That would provide a bit more flexibility.

I can update the QEMU implementation to take -certs-lock-file in addition to -certs-file so they can be specified separately. And if -certs-lock-file is not specified then QEMU will just assume management handles things different or has agreed to not do endorsement key updates while SNP guests are running.

Quoted 5 lines

I think we'd considered something like that originally but the thinking was that locking the certs themselves was more organic in terms of an "obvious"/natural solution. But it does end up being a bit more inflexible WRT how libraries/etc. might manage file updates underneath the covers, so maybe a lock file is the better approach after all.

If we want locking, I think locking the certs file directly is a nicer idea, as it avoids everyone having to agree on the location of the lock file, relative to the certs file.

The current locking code just needs to go inside a while(1) loop and have fstat + stat added to detect the recreation race. For example:

https://gitlab.com/libvirt/libvirt/-/blob/master/src/util/virpidfile.c#L376

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#13 lore raw

Re: [PATCH v1 3/3] i386/sev: Add KVM_EXIT_SNP_REQ_CERTS support for certificate-fetching

In reply to Michael Roth

Hi Michael,

Quoted 40 lines · Michael Roth

The GHCB specification[1] defines a VMGEXIT-based Guest Request hypercall to allow an SNP guest to issue encrypted requests directly to SNP firmware to do things like query the attestation report for the guest. These are generally handled purely in the kernel.

In some some cases, it's useful for the host to be able to additionally supply the certificate chain for the signing key that SNP firmware uses to sign these attestation reports. To allow for this, the GHCB specification defines an Extended Guest Request where this certificate data can be provided in a special format described in the GHCB spec. This certificate data may be global or guest-specific depending on how the guest was configured. Rather than providing interfaces to manage these within the kernel, KVM provides a new KVM_EXIT_SNP_REQ_CERTS exit to request the certificate contents from userspace. Implement support for that here.

To synchronize delivery of the certificates to the guest in a way where they will not be rendered invalid by updates to SNP firmware or attestation singing/endorsement keys by management tools outside the purview of QEMU, it is expected by users of KVM_EXIT_SNP_REQ_CERTS to obtain a shared/read lock on the certificate file prior to delivering them back to KVM. Only after this will the attestation report be retrieved from firmware and bundled with the certificate data, so QEMU must continue to hold the file lock until KVM confirms that the attestation report has been retrieved/bundled. This confirmation is done by way of the kvm_immediate_exit callback infrastructure that was introduced in a previous patch.

[1] "Guest Hypervisor Communication Block (GHCB) Standardization",
https://www.amd.com/en/developer/sev.html

---
  qapi/qom.json                 |  23 +++-
  target/i386/kvm/kvm.c         |  10 ++
  target/i386/sev-sysemu-stub.c |   5 +
  target/i386/sev.c             | 249 ++++++++++++++++++++++++++++++++++
  target/i386/sev.h             |   2 +
  5 files changed, 288 insertions(+), 1 deletion(-)

...

Quoted 11 lines
target/i386/sev.c +7 -0
@@ -2393,6 +2613,26 @@ sev_snp_guest_set_host_data(Object *obj, const char *value, Error **errp)
      memcpy(finish->host_data, blob, len);
  }
 
+static char *
+sev_snp_guest_get_certs_path(Object *obj, Error **errp)
+{
+    SevSnpGuestState *sev_snp_guest = SEV_SNP_GUEST(obj);
+
+    return g_strdup(sev_snp_guest->certs_path);
+}

target/i386/sev.c sev_snp_guest_set_host_data(Object *obj, const char *value, Error **errp) · line 2632

Quoted 10 lines
target/i386/sev.c +10 -0
+
+static void
+sev_snp_guest_set_certs_path(Object *obj, const char *value, Error **errp)
+{
+    SevSnpGuestState *sev_snp_guest = SEV_SNP_GUEST(obj);
+
+    if (sev_snp_guest->certs_path) {
+        g_free(sev_snp_guest->certs_path);
+    }
+

I think there needs to be a check here (sev_snp_guest_set_certs_filename() in snp-certs-rfc2) or sev_snp_kvm_init() that the cert file path exists as otherwise once
the guest boots and there's a request from the guest to the host to get
the cert, the failure in open_certs_locked() will crash the guest.

Regards,
Liam

Quoted 15 lines
target/i386/sev.c +6 -0
+    sev_snp_guest->certs_path = value ? g_strdup(value) : NULL;
+}
+
  static void
  sev_snp_guest_class_init(ObjectClass *oc, void *data)
  {
@@ -2428,6 +2668,9 @@ sev_snp_guest_class_init(ObjectClass *oc, void *data)
      object_class_property_add_str(oc, "host-data",
                                    sev_snp_guest_get_host_data,
                                    sev_snp_guest_set_host_data);
+    object_class_property_add_str(oc, "certs-path",
+                                  sev_snp_guest_get_certs_path,
+                                  sev_snp_guest_set_certs_path);
  }