2018-03-08 15:48:41 +03:00
|
|
|
/*
|
|
|
|
* QEMU Secure Encrypted Virutualization (SEV) support
|
|
|
|
*
|
|
|
|
* Copyright: Advanced Micro Devices, 2016-2018
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Brijesh Singh <brijesh.singh@amd.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-05-06 16:49:08 +03:00
|
|
|
#ifndef I386_SEV_H
|
|
|
|
#define I386_SEV_H
|
2018-03-08 15:48:41 +03:00
|
|
|
|
2021-10-07 19:17:09 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
#include CONFIG_DEVICES /* CONFIG_SEV */
|
|
|
|
#endif
|
|
|
|
|
2021-10-07 19:17:08 +03:00
|
|
|
#include "exec/confidential-guest-support.h"
|
2018-03-08 15:48:41 +03:00
|
|
|
|
i386/sev: Introduce "sev-common" type to encapsulate common SEV state
Currently all SEV/SEV-ES functionality is managed through a single
'sev-guest' QOM type. With upcoming support for SEV-SNP, taking this
same approach won't work well since some of the properties/state
managed by 'sev-guest' is not applicable to SEV-SNP, which will instead
rely on a new QOM type with its own set of properties/state.
To prepare for this, this patch moves common state into an abstract
'sev-common' parent type to encapsulate properties/state that are
common to both SEV/SEV-ES and SEV-SNP, leaving only SEV/SEV-ES-specific
properties/state in the current 'sev-guest' type. This should not
affect current behavior or command-line options.
As part of this patch, some related changes are also made:
- a static 'sev_guest' variable is currently used to keep track of
the 'sev-guest' instance. SEV-SNP would similarly introduce an
'sev_snp_guest' static variable. But these instances are now
available via qdev_get_machine()->cgs, so switch to using that
instead and drop the static variable.
- 'sev_guest' is currently used as the name for the static variable
holding a pointer to the 'sev-guest' instance. Re-purpose the name
as a local variable referring the 'sev-guest' instance, and use
that consistently throughout the code so it can be easily
distinguished from sev-common/sev-snp-guest instances.
- 'sev' is generally used as the name for local variables holding a
pointer to the 'sev-guest' instance. In cases where that now points
to common state, use the name 'sev_common'; in cases where that now
points to state specific to 'sev-guest' instance, use the name
'sev_guest'
In order to enable kernel-hashes for SNP, pull it from
SevGuestProperties to its parent SevCommonProperties so
it will be available for both SEV and SNP.
Signed-off-by: Michael Roth <michael.roth@amd.com>
Co-developed-by: Dov Murik <dovmurik@linux.ibm.com>
Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
Acked-by: Markus Armbruster <armbru@redhat.com> (QAPI schema)
Co-developed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-5-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-05-30 14:16:16 +03:00
|
|
|
#define TYPE_SEV_COMMON "sev-common"
|
|
|
|
#define TYPE_SEV_GUEST "sev-guest"
|
|
|
|
|
2018-03-08 15:48:41 +03:00
|
|
|
#define SEV_POLICY_NODBG 0x1
|
|
|
|
#define SEV_POLICY_NOKS 0x2
|
|
|
|
#define SEV_POLICY_ES 0x4
|
|
|
|
#define SEV_POLICY_NOSEND 0x8
|
|
|
|
#define SEV_POLICY_DOMAIN 0x10
|
|
|
|
#define SEV_POLICY_SEV 0x20
|
|
|
|
|
2021-09-30 08:49:14 +03:00
|
|
|
typedef struct SevKernelLoaderContext {
|
|
|
|
char *setup_data;
|
|
|
|
size_t setup_size;
|
|
|
|
char *kernel_data;
|
|
|
|
size_t kernel_size;
|
|
|
|
char *initrd_data;
|
|
|
|
size_t initrd_size;
|
|
|
|
char *cmdline_data;
|
|
|
|
size_t cmdline_size;
|
|
|
|
} SevKernelLoaderContext;
|
|
|
|
|
2021-10-07 19:17:09 +03:00
|
|
|
#ifdef CONFIG_SEV
|
2021-10-07 19:17:08 +03:00
|
|
|
bool sev_enabled(void);
|
2021-10-07 19:17:09 +03:00
|
|
|
bool sev_es_enabled(void);
|
|
|
|
#else
|
|
|
|
#define sev_enabled() 0
|
|
|
|
#define sev_es_enabled() 0
|
|
|
|
#endif
|
|
|
|
|
2023-03-20 16:21:29 +03:00
|
|
|
uint32_t sev_get_cbit_position(void);
|
|
|
|
uint32_t sev_get_reduced_phys_bits(void);
|
|
|
|
bool sev_add_kernel_loader_hashes(SevKernelLoaderContext *ctx, Error **errp);
|
2018-03-08 15:48:44 +03:00
|
|
|
|
2021-10-07 19:17:08 +03:00
|
|
|
int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp);
|
|
|
|
int sev_inject_launch_secret(const char *hdr, const char *secret,
|
|
|
|
uint64_t gpa, Error **errp);
|
|
|
|
|
|
|
|
int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size);
|
|
|
|
void sev_es_set_reset_vector(CPUState *cpu);
|
|
|
|
|
2018-03-08 15:48:41 +03:00
|
|
|
#endif
|