mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
backends/igvm: Add IGVM loader and configuration
Adds an IGVM loader to QEMU which processes a given IGVM file and applies the directives within the file to the current guest configuration. The IGVM loader can be used to configure both confidential and non-confidential guests. For confidential guests, the ConfidentialGuestSupport object for the system is used to encrypt memory, apply the initial CPU state and perform other confidential guest operations. The loader is configured via a new IgvmCfg QOM object which allows the user to provide a path to the IGVM file to process. Signed-off-by: Roy Hopkins <roy.hopkins@randomman.co.uk> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Gerd Hoffman <kraxel@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Link: https://lore.kernel.org/r/ae3a07d8f514d93845a9c16bb155c847cb567b0d.1751554099.git.roy.hopkins@randomman.co.uk Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
committed by
Paolo Bonzini
parent
e7ed19507b
commit
c1d466d267
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* QEMU IGVM interface
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023-2024 SUSE
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Roy Hopkins <roy.hopkins@randomman.co.uk>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
|
||||||
|
#include "system/igvm-cfg.h"
|
||||||
|
#include "igvm.h"
|
||||||
|
#include "qom/object_interfaces.h"
|
||||||
|
|
||||||
|
static char *get_igvm(Object *obj, Error **errp)
|
||||||
|
{
|
||||||
|
IgvmCfg *igvm = IGVM_CFG(obj);
|
||||||
|
return g_strdup(igvm->filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_igvm(Object *obj, const char *value, Error **errp)
|
||||||
|
{
|
||||||
|
IgvmCfg *igvm = IGVM_CFG(obj);
|
||||||
|
g_free(igvm->filename);
|
||||||
|
igvm->filename = g_strdup(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
OBJECT_DEFINE_TYPE_WITH_INTERFACES(IgvmCfg, igvm_cfg, IGVM_CFG, OBJECT,
|
||||||
|
{ TYPE_USER_CREATABLE }, { NULL })
|
||||||
|
|
||||||
|
static void igvm_cfg_class_init(ObjectClass *oc, const void *data)
|
||||||
|
{
|
||||||
|
IgvmCfgClass *igvmc = IGVM_CFG_CLASS(oc);
|
||||||
|
|
||||||
|
object_class_property_add_str(oc, "file", get_igvm, set_igvm);
|
||||||
|
object_class_property_set_description(oc, "file",
|
||||||
|
"Set the IGVM filename to use");
|
||||||
|
|
||||||
|
igvmc->process = qigvm_process_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void igvm_cfg_init(Object *obj)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void igvm_cfg_finalize(Object *obj)
|
||||||
|
{
|
||||||
|
}
|
||||||
+807
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* QEMU IGVM configuration backend for Confidential Guests
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023-2024 SUSE
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Roy Hopkins <roy.hopkins@randomman.co.uk>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BACKENDS_IGVM_H
|
||||||
|
#define BACKENDS_IGVM_H
|
||||||
|
|
||||||
|
#include "system/confidential-guest-support.h"
|
||||||
|
#include "system/igvm-cfg.h"
|
||||||
|
#include "qapi/error.h"
|
||||||
|
|
||||||
|
int qigvm_process_file(IgvmCfg *igvm, ConfidentialGuestSupport *cgs,
|
||||||
|
Error **errp);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -36,6 +36,8 @@ system_ss.add(when: gio, if_true: files('dbus-vmstate.c'))
|
|||||||
system_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c'))
|
system_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c'))
|
||||||
if igvm.found()
|
if igvm.found()
|
||||||
system_ss.add(igvm)
|
system_ss.add(igvm)
|
||||||
|
system_ss.add(files('igvm-cfg.c'), igvm)
|
||||||
|
system_ss.add(files('igvm.c'), igvm)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
system_ss.add(when: 'CONFIG_SPDM_SOCKET', if_true: files('spdm-socket.c'))
|
system_ss.add(when: 'CONFIG_SPDM_SOCKET', if_true: files('spdm-socket.c'))
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* QEMU IGVM interface
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 SUSE
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Roy Hopkins <roy.hopkins@randomman.co.uk>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef QEMU_IGVM_CFG_H
|
||||||
|
#define QEMU_IGVM_CFG_H
|
||||||
|
|
||||||
|
#include "qom/object.h"
|
||||||
|
|
||||||
|
typedef struct IgvmCfg {
|
||||||
|
ObjectClass parent_class;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* filename: Filename that specifies a file that contains the configuration
|
||||||
|
* of the guest in Independent Guest Virtual Machine (IGVM)
|
||||||
|
* format.
|
||||||
|
*/
|
||||||
|
char *filename;
|
||||||
|
} IgvmCfg;
|
||||||
|
|
||||||
|
typedef struct IgvmCfgClass {
|
||||||
|
ObjectClass parent_class;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If an IGVM filename has been specified then process the IGVM file.
|
||||||
|
* Performs a no-op if no filename has been specified.
|
||||||
|
*
|
||||||
|
* Returns 0 for ok and -1 on error.
|
||||||
|
*/
|
||||||
|
int (*process)(IgvmCfg *cfg, ConfidentialGuestSupport *cgs,
|
||||||
|
Error **errp);
|
||||||
|
|
||||||
|
} IgvmCfgClass;
|
||||||
|
|
||||||
|
#define TYPE_IGVM_CFG "igvm-cfg"
|
||||||
|
|
||||||
|
OBJECT_DECLARE_TYPE(IgvmCfg, IgvmCfgClass, IGVM_CFG)
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -932,6 +932,19 @@
|
|||||||
'data': { '*filename': 'str' },
|
'data': { '*filename': 'str' },
|
||||||
'if': 'CONFIG_POSIX' }
|
'if': 'CONFIG_POSIX' }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @IgvmCfgProperties:
|
||||||
|
#
|
||||||
|
# Properties common to objects that handle IGVM files.
|
||||||
|
#
|
||||||
|
# @file: IGVM file to use to configure guest
|
||||||
|
#
|
||||||
|
# Since: 10.1
|
||||||
|
##
|
||||||
|
{ 'struct': 'IgvmCfgProperties',
|
||||||
|
'if': 'CONFIG_IGVM',
|
||||||
|
'data': { 'file': 'str' } }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @SevCommonProperties:
|
# @SevCommonProperties:
|
||||||
#
|
#
|
||||||
@@ -1142,6 +1155,8 @@
|
|||||||
'filter-redirector',
|
'filter-redirector',
|
||||||
'filter-replay',
|
'filter-replay',
|
||||||
'filter-rewriter',
|
'filter-rewriter',
|
||||||
|
{ 'name': 'igvm-cfg',
|
||||||
|
'if': 'CONFIG_IGVM' },
|
||||||
'input-barrier',
|
'input-barrier',
|
||||||
{ 'name': 'input-linux',
|
{ 'name': 'input-linux',
|
||||||
'if': 'CONFIG_LINUX' },
|
'if': 'CONFIG_LINUX' },
|
||||||
@@ -1218,6 +1233,8 @@
|
|||||||
'filter-redirector': 'FilterRedirectorProperties',
|
'filter-redirector': 'FilterRedirectorProperties',
|
||||||
'filter-replay': 'NetfilterProperties',
|
'filter-replay': 'NetfilterProperties',
|
||||||
'filter-rewriter': 'FilterRewriterProperties',
|
'filter-rewriter': 'FilterRewriterProperties',
|
||||||
|
'igvm-cfg': { 'type': 'IgvmCfgProperties',
|
||||||
|
'if': 'CONFIG_IGVM' },
|
||||||
'input-barrier': 'InputBarrierProperties',
|
'input-barrier': 'InputBarrierProperties',
|
||||||
'input-linux': { 'type': 'InputLinuxProperties',
|
'input-linux': { 'type': 'InputLinuxProperties',
|
||||||
'if': 'CONFIG_LINUX' },
|
'if': 'CONFIG_LINUX' },
|
||||||
|
|||||||
Reference in New Issue
Block a user