* [PATCH v2 0/2] SEV-SNP: Add KVM support for SNP certificate fetching via KVM_EXIT_COCO
@ 2024-11-19 13:35 Michael Roth
2024-11-19 13:35 ` [PATCH v2 1/2] KVM: Introduce KVM_EXIT_COCO exit type Michael Roth
2024-11-19 13:35 ` [PATCH v2 2/2] KVM: SEV: Add certificate support for SNP_EXTENDED_GUEST_REQUEST events Michael Roth
0 siblings, 2 replies; 5+ messages in thread
From: Michael Roth @ 2024-11-19 13:35 UTC (permalink / raw)
To: kvm
Cc: linux-coco, linux-kernel, x86, pbonzini, seanjc, jroedel,
thomas.lendacky, pgonda, ashish.kalra, bp, pankaj.gupta,
liam.merwick, dionnaglaze
This patchset is also available at:
https://github.com/amdese/linux/commits/snp-certs-v2
and is based on top of kvm/next (d96c77bd4eeb)
v1 of these patches were originally included as part of a larger series
that went upstream without the certificate support included:
https://lore.kernel.org/lkml/20240621134041.3170480-1-michael.roth@amd.com/
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 exit type is
used to fetch the data similarly to KVM_EXIT_MMIO/etc. Since there is
potential for more CoCo-related exits, this series implements this as a more
general KVM_EXIT_COCO exit type, where individual sub-types can be enabled
similarly to how KVM_EXIT_HYPERCALL/KVM_CAP_EXIT_HYPERCALL are handled, and
then introduces the KVM_EXIT_COCO_REQ_CERTS sub-type to implement certficate
handling.
[1] https://lore.kernel.org/kvm/ZS614OSoritrE1d2@google.com/
Testing
-------
For testing this via QEMU, use the following tree:
https://github.com/amdese/qemu/commits/snp-certs-wip1
A basic command-line invocation for SNP 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
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
Changes since v1:
* Drop subtype-specific error codes. Instead use standard error codes like
ENOSPC/etc. and let KVM determine whether a particular error requires
special handling for a particular KVM_EXIT_COCO subtype. (Sean)
* Introduce special handling for EAGAIN for KVM_EXIT_COCO_REQ_CERTS such
that the guest can be instructed to retry if userspace is temporarily unable
to immediately lock/provide the certificate data. (Sean)
* Move the 'ret' field of struct kvm_exit_coco to the top-level so all
sub-types can propagate error codes the same way.
* Add more clarifying details in KVM documentation about the suggested
file-locking scheme to avoid races between certificate requests and updates
to SNP firmware that might modify the endorsement key corresponding to the
certificate data.
Changes since splitting this off from v15 SNP KVM patchset:
* Address clang-reported warnings regarding uninitialized variables
* Address a memory leak of the request/response buffer pages, and refactor
the code based on Sean's suggestions:
https://lore.kernel.org/kvm/ZktbBRLXeOp9X6aH@google.com/
* Fix SNP Extended Guest Request handling to only attempt to fetch
certificates if handling MSG_REQ_REPORT (attestation) message types
* Drop KVM_EXIT_VMGEXIT and introduce KVM_EXIT_COCO events instead
* Refactor patch layout for easier handling/review
----------------------------------------------------------------
Michael Roth (2):
KVM: Introduce KVM_EXIT_COCO exit type
KVM: SEV: Add certificate support for SNP_EXTENDED_GUEST_REQUEST events
Documentation/virt/kvm/api.rst | 119 ++++++++++++++++++++++++++++++++++++++++
arch/x86/include/asm/kvm_host.h | 1 +
arch/x86/kvm/svm/sev.c | 44 +++++++++++++--
arch/x86/kvm/x86.c | 13 +++++
include/uapi/linux/kvm.h | 19 +++++++
include/uapi/linux/sev-guest.h | 8 +++
6 files changed, 198 insertions(+), 6 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] KVM: Introduce KVM_EXIT_COCO exit type
2024-11-19 13:35 [PATCH v2 0/2] SEV-SNP: Add KVM support for SNP certificate fetching via KVM_EXIT_COCO Michael Roth
@ 2024-11-19 13:35 ` Michael Roth
2024-11-20 4:54 ` Dionna Amalie Glaze
2024-11-19 13:35 ` [PATCH v2 2/2] KVM: SEV: Add certificate support for SNP_EXTENDED_GUEST_REQUEST events Michael Roth
1 sibling, 1 reply; 5+ messages in thread
From: Michael Roth @ 2024-11-19 13:35 UTC (permalink / raw)
To: kvm
Cc: linux-coco, linux-kernel, x86, pbonzini, seanjc, jroedel,
thomas.lendacky, pgonda, ashish.kalra, bp, pankaj.gupta,
liam.merwick, dionnaglaze
Confidential VMs have a number of additional requirements on the host
side which might involve interactions with userspace. One such case is
with SEV-SNP guests, where the host can optionally provide a certificate
table to the guest when it issues an attestation request to firmware
(see GHCB 2.0 specification regarding "SNP Extended Guest Requests").
This certificate table can then be used to verify the endorsement key
used by firmware to sign the attestation report.
While it is possible for guests to obtain the certificates through other
means, handling it via the host provides more flexibility in being able
to keep the certificate data in sync with the endorsement key throughout
host-side operations that might resulting in the endorsement key
changing.
In the case of KVM, userspace will be responsible for fetching the
certificate table and keeping it in sync with any modifications to the
endorsement key. Define a new KVM_EXIT_* event where userspace is
provided with the GPA of the buffer the guest has provided as part of
the attestation request so that userspace can write the certificate data
into it.
Since there is potential for additional CoCo-related events in the
future, introduce this in the form of a more general KVM_EXIT_COCO exit
type that handles multiple sub-types, similarly to KVM_EXIT_HYPERCALL,
and then define a KVM_EXIT_COCO_REQ_CERTS sub-type to handle the actual
certificate-fetching mentioned above.
Also introduce a KVM_CAP_EXIT_COCO capability to enable/disable
individual sub-types, similarly to KVM_CAP_EXIT_HYPERCALL.
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
Documentation/virt/kvm/api.rst | 119 ++++++++++++++++++++++++++++++++
arch/x86/include/asm/kvm_host.h | 1 +
arch/x86/kvm/x86.c | 13 ++++
include/uapi/linux/kvm.h | 19 +++++
4 files changed, 152 insertions(+)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index 454c2aaa155e..664fba2739a9 100644
--- a/Documentation/virt/kvm/api.rst
+++ b/Documentation/virt/kvm/api.rst
@@ -7173,6 +7173,107 @@ Please note that the kernel is allowed to use the kvm_run structure as the
primary storage for certain register types. Therefore, the kernel may use the
values in kvm_run even if the corresponding bit in kvm_dirty_regs is not set.
+::
+
+ /* KVM_EXIT_COCO */
+ struct kvm_exit_coco {
+ #define KVM_EXIT_COCO_REQ_CERTS 0
+ #define KVM_EXIT_COCO_MAX 1
+ __u8 nr;
+ __u8 pad0[7];
+ __u32 ret;
+ __u32 pad1;
+ union {
+ struct {
+ __u64 gfn;
+ __u32 npages;
+ } req_certs;
+ };
+ };
+
+KVM_EXIT_COCO events are intended to handle cases where a confidential
+VM requires some action on the part of userspace, or cases where userspace
+needs to be informed of some activity relating to a confidential VM.
+
+A `kvm_exit_coco` structure is defined to encapsulate the data to be sent to
+or returned by userspace. The `nr` field defines the specific type of event
+that needs to be serviced, and that type is used as a discriminator to
+determine which union type should be used for input/output. If the exit is
+successfully processed by userspace, `ret` should be set to 0 to indicate
+success. A non-zero `ret` value will be treated as an error unless there is
+specific handling associated with a particular error code in the per-union
+type documentation.
+
+The parameters for each of these event/union types are documented below:
+
+ - ``KVM_EXIT_COCO_REQ_CERTS``
+
+ This event provides a way to request certificate data from userspace and
+ have it written into guest memory. This is intended primarily to handle
+ attestation requests made by SEV-SNP guests (using the Extended Guest
+ Requests GHCB command as defined by the GHCB 2.0 specification for SEV-SNP
+ guests), where additional certificate data corresponding to the
+ endorsement key used by firmware to sign an attestation report can be
+ optionally provided by userspace to pass along to the guest together with
+ the firmware-provided attestation report.
+
+ In the case of ``KVM_EXIT_COCO_REQ_CERTS`` events, the `req_certs` union
+ type is used. KVM will supply in `gfn` the non-private guest page that
+ userspace should use to write the contents of certificate data. In the
+ case of SEV-SNP, the format of this certificate data is defined in the
+ GHCB 2.0 specification (see section "SNP Extended Guest Request"). KVM
+ will also supply in `npages` the number of contiguous pages available
+ for writing the certificate data into.
+
+ - If the supplied number of pages is sufficient, userspace must write
+ the certificate table blob (in the format defined by the GHCB spec)
+ into the address corresponding to `gfn` and set `ret` to 0 to indicate
+ success. If no certificate data is available, then userspace can
+ either write an empty certificate table into the address corresponding
+ to `gfn`, or it can disable ``KVM_EXIT_COCO_REQ_CERTS`` (via
+ ``KVM_CAP_EXIT_COCO``), in which case KVM will handle returning an
+ empty certificate table to the guest.
+
+ - If the number of pages supplied is not sufficient, userspace must set
+ the required number of pages in `npages` and then set `ret` to
+ ``ENOSPC``.
+
+ - If the certificate cannot be immediately provided, userspace should set
+ `ret` to ``EAGAIN``, which will inform the guest to retry the request
+ later. One scenario where this would be useful is if the certificate
+ is in the process of being updated and cannot be fetched until the
+ update completes (see the NOTE below regarding how file-locking can
+ be used to orchestrate such updates between management/guests).
+
+ - If some other error occurred, userspace must set `ret` to ``EIO``.
+
+ NOTE: In the case of SEV-SNP, the endorsement key used by firmware may
+ change as a result of management activities like updating SEV-SNP firmware
+ or loading new endorsement keys, so some care should be taken to keep the
+ returned certificate data in sync with the actual endorsement key in use by
+ firmware at the time the attestation request is sent to SNP firmware. The
+ recommended scheme to do this is to use file locking (e.g. via fcntl()'s
+ F_OFD_SETLK) in the following manner:
+
+ - The VMM should obtain a shared/read or exclusive/write lock on the path
+ the certificate blob file resides at before reading it and returning it
+ to KVM, and continue to hold the lock until the attestation request is
+ actually sent to firmware. To facilitate this, the VMM can set the
+ ``immediate_exit`` flag of kvm_run just after supplying the certificate
+ data, and just before and resuming the vCPU. This will ensure the vCPU
+ will exit again to userspace with ``-EINTR`` after it finishes fetching
+ the attestation request from firmware, at which point the VMM can
+ safely drop the file lock.
+
+ - Tools/libraries that perform updates to SNP firmware TCB values or
+ endorsement keys (e.g. via /dev/sev interfaces such as ``SNP_COMMIT``,
+ ``SNP_SET_CONFIG``, or ``SNP_VLEK_LOAD``, see
+ Documentation/virt/coco/sev-guest.rst for more details) in such a way
+ that the certificate blob needs to be updated, should similarly take an
+ exclusive lock on the certificate blob for the duration of any updates
+ to endorsement keys or the certificate blob contents to ensure that
+ VMMs using the above scheme will not return certificate blob data that
+ is out of sync with the endorsement key used by firmware.
.. _cap_enable:
@@ -9017,6 +9118,24 @@ Do not use KVM_X86_SW_PROTECTED_VM for "real" VMs, and especially not in
production. The behavior and effective ABI for software-protected VMs is
unstable.
+8.42 KVM_CAP_EXIT_COCO
+----------------------
+
+:Capability: KVM_CAP_EXIT_COCO
+:Architectures: x86
+:Type: vm
+
+This capability, if enabled, will cause KVM to exit to userspace with
+KVM_EXIT_COCO exit reason to process certain events related to confidential
+guests.
+
+Calling KVM_CHECK_EXTENSION for this capability will return a bitmask of
+KVM_EXIT_COCO event types that can be configured to exit to userspace.
+
+The argument to KVM_ENABLE_CAP is also a bitmask, and must be a subset
+of the result of KVM_CHECK_EXTENSION. KVM will forward to userspace
+the event types whose corresponding bit is in the argument.
+
9. Known KVM API problems
=========================
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index e159e44a6a1b..1b4fb019023e 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1438,6 +1438,7 @@ struct kvm_arch {
struct kvm_x86_msr_filter __rcu *msr_filter;
u32 hypercall_exit_enabled;
+ u64 coco_exit_enabled;
/* Guest can access the SGX PROVISIONKEY. */
bool sgx_provisioning_allowed;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 2e713480933a..c9bcc39725e0 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -128,6 +128,8 @@ static u64 __read_mostly cr4_reserved_bits = CR4_RESERVED_BITS;
#define KVM_X2APIC_API_VALID_FLAGS (KVM_X2APIC_API_USE_32BIT_IDS | \
KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK)
+#define KVM_EXIT_COCO_VALID_MASK BIT_ULL(KVM_EXIT_COCO_REQ_CERTS)
+
static void update_cr8_intercept(struct kvm_vcpu *vcpu);
static void process_nmi(struct kvm_vcpu *vcpu);
static void __kvm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags);
@@ -4782,6 +4784,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
case KVM_CAP_READONLY_MEM:
r = kvm ? kvm_arch_has_readonly_mem(kvm) : 1;
break;
+ case KVM_CAP_EXIT_COCO:
+ r = KVM_EXIT_COCO_VALID_MASK;
+ break;
default:
break;
}
@@ -6743,6 +6748,14 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
mutex_unlock(&kvm->lock);
break;
}
+ case KVM_CAP_EXIT_COCO:
+ if (cap->args[0] & ~KVM_EXIT_COCO_VALID_MASK) {
+ r = -EINVAL;
+ break;
+ }
+ kvm->arch.coco_exit_enabled = cap->args[0];
+ r = 0;
+ break;
default:
r = -EINVAL;
break;
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 502ea63b5d2e..f64abda153cf 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -135,6 +135,21 @@ struct kvm_xen_exit {
} u;
};
+struct kvm_exit_coco {
+#define KVM_EXIT_COCO_REQ_CERTS 0
+#define KVM_EXIT_COCO_MAX 1
+ __u8 nr;
+ __u8 pad0[7];
+ __u32 ret;
+ __u32 pad1;
+ union {
+ struct {
+ __u64 gfn;
+ __u32 npages;
+ } req_certs;
+ };
+};
+
#define KVM_S390_GET_SKEYS_NONE 1
#define KVM_S390_SKEYS_MAX 1048576
@@ -178,6 +193,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_COCO 40
/* For KVM_EXIT_INTERNAL_ERROR */
/* Emulate instruction failed. */
@@ -446,6 +462,8 @@ struct kvm_run {
__u64 gpa;
__u64 size;
} memory_fault;
+ /* KVM_EXIT_COCO */
+ struct kvm_exit_coco coco;
/* Fix the size of the union. */
char padding[256];
};
@@ -933,6 +951,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_COCO 239
struct kvm_irq_routing_irqchip {
__u32 irqchip;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] KVM: SEV: Add certificate support for SNP_EXTENDED_GUEST_REQUEST events
2024-11-19 13:35 [PATCH v2 0/2] SEV-SNP: Add KVM support for SNP certificate fetching via KVM_EXIT_COCO Michael Roth
2024-11-19 13:35 ` [PATCH v2 1/2] KVM: Introduce KVM_EXIT_COCO exit type Michael Roth
@ 2024-11-19 13:35 ` Michael Roth
1 sibling, 0 replies; 5+ messages in thread
From: Michael Roth @ 2024-11-19 13:35 UTC (permalink / raw)
To: kvm
Cc: linux-coco, linux-kernel, x86, pbonzini, seanjc, jroedel,
thomas.lendacky, pgonda, ashish.kalra, bp, pankaj.gupta,
liam.merwick, dionnaglaze
Currently KVM implements a stub version of SNP Extended Guest Requests
that always supplies NULL certificate data alongside the attestation
report. Make use of the newly-defined KVM_EXIT_COCO_REQ_CERTS event to
provide a way for userspace to optionally supply this certificate data.
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
arch/x86/kvm/svm/sev.c | 44 +++++++++++++++++++++++++++++-----
include/uapi/linux/sev-guest.h | 8 +++++++
2 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 72674b8825c4..4827a8ed4d16 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -4077,6 +4077,30 @@ static int snp_handle_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t resp_
return ret;
}
+static int snp_complete_req_certs(struct kvm_vcpu *vcpu)
+{
+ struct vcpu_svm *svm = to_svm(vcpu);
+ struct vmcb_control_area *control = &svm->vmcb->control;
+
+ if (vcpu->run->coco.ret) {
+ if (vcpu->run->coco.ret == ENOSPC) {
+ vcpu->arch.regs[VCPU_REGS_RBX] = vcpu->run->coco.req_certs.npages;
+ ghcb_set_sw_exit_info_2(svm->sev_es.ghcb,
+ SNP_GUEST_ERR(SNP_GUEST_VMM_ERR_INVALID_LEN, 0));
+ } else if (vcpu->run->coco.ret == EAGAIN) {
+ ghcb_set_sw_exit_info_2(svm->sev_es.ghcb,
+ SNP_GUEST_ERR(SNP_GUEST_VMM_ERR_BUSY, 0));
+ } else {
+ ghcb_set_sw_exit_info_2(svm->sev_es.ghcb,
+ SNP_GUEST_ERR(SNP_GUEST_VMM_ERR_GENERIC, 0));
+ }
+
+ return 1; /* resume guest */
+ }
+
+ return snp_handle_guest_req(svm, control->exit_info_1, control->exit_info_2);
+}
+
static int snp_handle_ext_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t resp_gpa)
{
struct kvm *kvm = svm->vcpu.kvm;
@@ -4092,12 +4116,10 @@ static int snp_handle_ext_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t r
/*
* As per GHCB spec, requests of type MSG_REPORT_REQ also allow for
* additional certificate data to be provided alongside the attestation
- * report via the guest-provided data pages indicated by RAX/RBX. The
- * certificate data is optional and requires additional KVM enablement
- * to provide an interface for userspace to provide it, but KVM still
- * needs to be able to handle extended guest requests either way. So
- * provide a stub implementation that will always return an empty
- * certificate table in the guest-provided data pages.
+ * report via the guest-provided data pages indicated by RAX/RBX. If
+ * userspace enables KVM_EXIT_COCO_REQ_CERTS, then exit to userspace
+ * to fetch the certificate data. Otherwise, return an empty certificate
+ * table in the guest-provided data pages.
*/
if (msg_type == SNP_MSG_REPORT_REQ) {
struct kvm_vcpu *vcpu = &svm->vcpu;
@@ -4113,6 +4135,16 @@ static int snp_handle_ext_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t r
if (!PAGE_ALIGNED(data_gpa))
goto request_invalid;
+ if ((vcpu->kvm->arch.coco_exit_enabled & BIT_ULL(KVM_EXIT_COCO_REQ_CERTS))) {
+ vcpu->run->exit_reason = KVM_EXIT_COCO;
+ vcpu->run->coco.nr = KVM_EXIT_COCO_REQ_CERTS;
+ vcpu->run->coco.req_certs.gfn = gpa_to_gfn(data_gpa);
+ vcpu->run->coco.req_certs.npages = data_npages;
+ vcpu->arch.complete_userspace_io = snp_complete_req_certs;
+ vcpu->run->coco.ret = 0;
+ return 0; /* fetch certs from userspace */
+ }
+
/*
* As per GHCB spec (see "SNP Extended Guest Request"), the
* certificate table is terminated by 24-bytes of zeroes.
diff --git a/include/uapi/linux/sev-guest.h b/include/uapi/linux/sev-guest.h
index fcdfea767fca..4c4ed8bc71d7 100644
--- a/include/uapi/linux/sev-guest.h
+++ b/include/uapi/linux/sev-guest.h
@@ -95,5 +95,13 @@ struct snp_ext_report_req {
#define SNP_GUEST_VMM_ERR_INVALID_LEN 1
#define SNP_GUEST_VMM_ERR_BUSY 2
+/*
+ * The GHCB spec essentially states that all non-zero error codes other than
+ * those explicitly defined above should be treated as an error by the guest.
+ * Define a generic error to cover that case, and choose a value that is not
+ * likely to overlap with new explicit error codes should more be added to
+ * the GHCB spec later.
+ */
+#define SNP_GUEST_VMM_ERR_GENERIC ((u32)~0U)
#endif /* __UAPI_LINUX_SEV_GUEST_H_ */
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] KVM: Introduce KVM_EXIT_COCO exit type
2024-11-19 13:35 ` [PATCH v2 1/2] KVM: Introduce KVM_EXIT_COCO exit type Michael Roth
@ 2024-11-20 4:54 ` Dionna Amalie Glaze
2024-11-20 4:55 ` Dionna Amalie Glaze
0 siblings, 1 reply; 5+ messages in thread
From: Dionna Amalie Glaze @ 2024-11-20 4:54 UTC (permalink / raw)
To: Michael Roth
Cc: kvm, linux-coco, linux-kernel, x86, pbonzini, seanjc, jroedel,
thomas.lendacky, pgonda, ashish.kalra, bp, pankaj.gupta,
liam.merwick
On Tue, Nov 19, 2024 at 5:51 AM Michael Roth <michael.roth@amd.com> wrote:
>
> +struct kvm_exit_coco {
> +#define KVM_EXIT_COCO_REQ_CERTS 0
> +#define KVM_EXIT_COCO_MAX 1
> + __u8 nr;
> + __u8 pad0[7];
> + __u32 ret;
> + __u32 pad1;
> + union {
> + struct {
> + __u64 gfn;
> + __u32 npages;
Should this not also include a vmm_err code to report to the guest? We
need some way for user space to indicate that KVM should write the
vmm_err to the upper 32 bits of exit_info_2.
I don't think we have a snapshot of the GHCB accessible to userspace.
I'm still not quite able to get a good test of this patch series
ready. Making the certificate file accessible to the VMM process has
been unfortunately challenging due to how we manage chroots and VMM
upgrades.
Still, I'm stuck in the VMM implementation of grabbing the file lock
for the certificates and asking myself "how do I tell KVM to write
exit_info_2 = (2 << 32) | (exit_info_2 & ((1 << 32)-1) before entering
the guest?"
A __u32 vmm_err field of this struct would nicely make its size 64-bit aligned..
--
-Dionna Glaze, PhD, CISSP, CCSP (she/her)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] KVM: Introduce KVM_EXIT_COCO exit type
2024-11-20 4:54 ` Dionna Amalie Glaze
@ 2024-11-20 4:55 ` Dionna Amalie Glaze
0 siblings, 0 replies; 5+ messages in thread
From: Dionna Amalie Glaze @ 2024-11-20 4:55 UTC (permalink / raw)
To: Michael Roth
Cc: kvm, linux-coco, linux-kernel, x86, pbonzini, seanjc, jroedel,
thomas.lendacky, pgonda, ashish.kalra, bp, pankaj.gupta,
liam.merwick
On Tue, Nov 19, 2024 at 8:54 PM Dionna Amalie Glaze
<dionnaglaze@google.com> wrote:
>
> On Tue, Nov 19, 2024 at 5:51 AM Michael Roth <michael.roth@amd.com> wrote:
> >
> > +struct kvm_exit_coco {
> > +#define KVM_EXIT_COCO_REQ_CERTS 0
> > +#define KVM_EXIT_COCO_MAX 1
> > + __u8 nr;
> > + __u8 pad0[7];
> > + __u32 ret;
> > + __u32 pad1;
> > + union {
> > + struct {
> > + __u64 gfn;
> > + __u32 npages;
>
> Should this not also include a vmm_err code to report to the guest? We
> need some way for user space to indicate that KVM should write the
> vmm_err to the upper 32 bits of exit_info_2.
> I don't think we have a snapshot of the GHCB accessible to userspace.
>
> I'm still not quite able to get a good test of this patch series
> ready. Making the certificate file accessible to the VMM process has
> been unfortunately challenging due to how we manage chroots and VMM
> upgrades.
> Still, I'm stuck in the VMM implementation of grabbing the file lock
> for the certificates and asking myself "how do I tell KVM to write
> exit_info_2 = (2 << 32) | (exit_info_2 & ((1 << 32)-1) before entering
> the guest?"
> A __u32 vmm_err field of this struct would nicely make its size 64-bit aligned..
retracted. I needed to look 2 lines lower. I need to stop working this late.
>
> --
> -Dionna Glaze, PhD, CISSP, CCSP (she/her)
--
-Dionna Glaze, PhD, CISSP, CCSP (she/her)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-11-20 4:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-19 13:35 [PATCH v2 0/2] SEV-SNP: Add KVM support for SNP certificate fetching via KVM_EXIT_COCO Michael Roth
2024-11-19 13:35 ` [PATCH v2 1/2] KVM: Introduce KVM_EXIT_COCO exit type Michael Roth
2024-11-20 4:54 ` Dionna Amalie Glaze
2024-11-20 4:55 ` Dionna Amalie Glaze
2024-11-19 13:35 ` [PATCH v2 2/2] KVM: SEV: Add certificate support for SNP_EXTENDED_GUEST_REQUEST events Michael Roth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox