From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH 14/14] machine: add helpers for declaring secure/insecure machine types
Date: Wed, 9 Sep 2026 18:56:56 +0100 [thread overview]
Message-ID: <20260909175656.1572689-15-berrange@redhat.com> (raw)
In-Reply-To: <20260909175656.1572689-1-berrange@redhat.com>
The current DEFINE_MACHINE macro will declare machine type without any
explicit statement about the security status. As such the machine type
will be treated as implicitly insecure at runtime.
Introduce a new DEFINE_SECURE_MACHINE macro (with variants) that
allow code to make an explicit statement that the machine is treated
as secure. This should primarily be used for versioned machine types
that are intended to be used with KVM, though some others may warrant
a security declaration.
Use of the existing macros marks a machine as insecure, which is the
desired default for most machines servicing emulation use cases.
The same is done for the specialized i386 PC related macros.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
hw/arm/bananapi_m2u.c | 2 +-
hw/arm/cubieboard.c | 2 +-
hw/arm/imx8mm-evk.c | 2 +-
hw/arm/integratorcp.c | 2 +-
hw/arm/mcimx7d-sabre.c | 2 +-
hw/arm/orangepi.c | 2 +-
hw/ppc/pegasos.c | 3 ++-
include/hw/core/boards.h | 25 ++++++++++++++++++++-----
include/hw/i386/pc.h | 11 ++++++++++-
9 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/hw/arm/bananapi_m2u.c b/hw/arm/bananapi_m2u.c
index 8f59111fd4..ccf60ba295 100644
--- a/hw/arm/bananapi_m2u.c
+++ b/hw/arm/bananapi_m2u.c
@@ -153,4 +153,4 @@ static void bpim2u_machine_init(MachineClass *mc)
}
DEFINE_MACHINE_EXTENDED("bpim2u", MACHINE, Bpim2uMachineState,
- bpim2u_machine_init, false, NULL)
+ bpim2u_machine_init, false, false, NULL)
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
index ae27056938..e4fef9cd76 100644
--- a/hw/arm/cubieboard.c
+++ b/hw/arm/cubieboard.c
@@ -133,5 +133,5 @@ static void cubieboard_machine_init(MachineClass *mc)
}
DEFINE_MACHINE_EXTENDED("cubieboard", MACHINE, CubieboardMachineState,
- cubieboard_machine_init, false,
+ cubieboard_machine_init, false, false,
NULL)
diff --git a/hw/arm/imx8mm-evk.c b/hw/arm/imx8mm-evk.c
index 8a5737502f..c3215b11cb 100644
--- a/hw/arm/imx8mm-evk.c
+++ b/hw/arm/imx8mm-evk.c
@@ -134,5 +134,5 @@ static void imx8mm_evk_machine_init(MachineClass *mc)
}
DEFINE_MACHINE_EXTENDED("imx8mm-evk", MACHINE, Imx8mmEvkMachineState,
- imx8mm_evk_machine_init, false,
+ imx8mm_evk_machine_init, false, false,
NULL)
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 382ea7850d..b766edeeee 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -704,7 +704,7 @@ static void integratorcp_machine_init(MachineClass *mc)
}
DEFINE_MACHINE_EXTENDED("integratorcp", MACHINE, IntegratorcpMachineState,
- integratorcp_machine_init, false,
+ integratorcp_machine_init, false, false,
NULL)
static const Property core_properties[] = {
diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c
index db8a62e5f6..65fdb19c06 100644
--- a/hw/arm/mcimx7d-sabre.c
+++ b/hw/arm/mcimx7d-sabre.c
@@ -86,5 +86,5 @@ static void mcimx7d_sabre_machine_init(MachineClass *mc)
}
DEFINE_MACHINE_EXTENDED("mcimx7d-sabre", MACHINE, Mcimx7dSabreMachineState,
- mcimx7d_sabre_machine_init, false,
+ mcimx7d_sabre_machine_init, false, false,
NULL)
diff --git a/hw/arm/orangepi.c b/hw/arm/orangepi.c
index 7a19732f5d..18ed174032 100644
--- a/hw/arm/orangepi.c
+++ b/hw/arm/orangepi.c
@@ -133,5 +133,5 @@ static void orangepi_machine_init(MachineClass *mc)
}
DEFINE_MACHINE_EXTENDED("orangepi-pc", MACHINE, OrangePiMachineState,
- orangepi_machine_init, false,
+ orangepi_machine_init, false, false,
NULL)
diff --git a/hw/ppc/pegasos.c b/hw/ppc/pegasos.c
index 9d7e279123..fba2a55890 100644
--- a/hw/ppc/pegasos.c
+++ b/hw/ppc/pegasos.c
@@ -788,7 +788,8 @@ static void pegasos2_machine_class_init(ObjectClass *oc, const void *data)
}
DEFINE_MACHINE_EXTENDED("pegasos", MACHINE, PegasosMachineState,
- pegasos_machine_init, true, (const InterfaceInfo[]) {
+ pegasos_machine_init, true, false,
+ (const InterfaceInfo[]) {
{ TYPE_PPC_VIRTUAL_HYPERVISOR },
{ TYPE_VOF_MACHINE_IF }, { } })
diff --git a/include/hw/core/boards.h b/include/hw/core/boards.h
index a436d48c8e..c2e0327a39 100644
--- a/include/hw/core/boards.h
+++ b/include/hw/core/boards.h
@@ -514,7 +514,7 @@ struct MachineState {
*/
#define DEFINE_MACHINE_EXTENDED(namestr, PARENT_NAME, InstanceName, \
- machine_initfn, ABSTRACT, ifaces...) \
+ machine_initfn, ABSTRACT, SECURE, ifaces...) \
static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \
{ \
MachineClass *mc = MACHINE_CLASS(oc); \
@@ -526,6 +526,7 @@ struct MachineState {
.class_init = machine_initfn##_class_init, \
.instance_size = sizeof(InstanceName), \
.abstract = ABSTRACT, \
+ .secure = SECURE, \
.interfaces = ifaces, \
}; \
static void machine_initfn##_register_types(void) \
@@ -534,18 +535,32 @@ struct MachineState {
} \
type_init(machine_initfn##_register_types)
+/* Implicitly insecure */
#define DEFINE_MACHINE(namestr, machine_initfn) \
DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
- false, NULL)
+ false, false, NULL)
-#define DEFINE_MACHINE_WITH_INTERFACE_ARRAY(namestr, machine_initfn, ifaces...)\
+#define DEFINE_MACHINE_WITH_INTERFACE_ARRAY(namestr, machine_initfn, ifaces...) \
DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
- false, ifaces)
+ false, false, ifaces)
-#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
+#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
DEFINE_MACHINE_WITH_INTERFACE_ARRAY(namestr, machine_initfn, \
(const InterfaceInfo[]) { __VA_ARGS__ })
+
+#define DEFINE_SECURE_MACHINE(namestr, machine_initfn) \
+ DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
+ false, true, NULL)
+
+#define DEFINE_SECURE_MACHINE_WITH_INTERFACE_ARRAY(namestr, machine_initfn, ifaces...) \
+ DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
+ false, true, ifaces)
+
+#define DEFINE_SECURE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
+ DEFINE_SECURE_MACHINE_WITH_INTERFACE_ARRAY(namestr, machine_initfn, \
+ (const InterfaceInfo[]) { __VA_ARGS__ })
+
/*
* Helper for dispatching different macros based on how
* many __VA_ARGS__ are passed. Supports 1 to 5 variadic
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index ac03da97b6..d5dc79df17 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -275,7 +275,7 @@ extern const size_t pc_compat_4_2_len;
extern GlobalProperty pc_compat_4_1[];
extern const size_t pc_compat_4_1_len;
-#define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
+#define DEFINE_PC_MACHINE_EXTENDED(suffix, namestr, initfn, optsfn, issecure) \
static void pc_machine_##suffix##_class_init(ObjectClass *oc, \
const void *data) \
{ \
@@ -287,6 +287,7 @@ extern const size_t pc_compat_4_1_len;
.name = namestr TYPE_MACHINE_SUFFIX, \
.parent = TYPE_PC_MACHINE, \
.class_init = pc_machine_##suffix##_class_init, \
+ .secure = issecure, \
}; \
static void pc_machine_init_##suffix(void) \
{ \
@@ -294,6 +295,14 @@ extern const size_t pc_compat_4_1_len;
} \
type_init(pc_machine_init_##suffix)
+/* Implicitly insecure */
+#define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
+ DEFINE_PC_MACHINE_EXTENDED(suffix, namestr, initfn, optsfn, false)
+
+#define DEFINE_SECURE_PC_MACHINE(suffix, namestr, initfn, optsfn) \
+ DEFINE_PC_MACHINE_EXTENDED(suffix, namestr, initfn, optsfn, true)
+
+
#define DEFINE_PC_VER_MACHINE(namesym, namestr, initfn, isdefault, malias, ...) \
static void MACHINE_VER_SYM(init, namesym, __VA_ARGS__)( \
MachineState *machine) \
--
2.55.0
next prev parent reply other threads:[~2026-09-09 17:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 17:56 [PATCH 00/14] Encode object type security status in code Daniel P. Berrangé
2026-09-09 17:56 ` [PATCH 01/14] qom: add tracking of security state of object types Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 02/14] qapi: add 'insecure-types' option for -compat argument Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 03/14] qom: add helper APIs for checking object security policy compliance Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 04/14] system: check security for accelerator types Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 05/14] system: report acclerator security status in help output Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 06/14] system: check security for machine types Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 07/14] system: report machine security status in help output Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 08/14] system: check security of device types Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 09/14] system: report device security status in help output Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 10/14] hw/core: report security status in query-machines Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 11/14] qom: refactor data passing for QOM list filtering Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 12/14] qom: report & filter on security status in qom-list-types Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` [PATCH 13/14] docs: expand security docs with info about security status Daniel P. Berrangé
2026-09-09 20:19 ` marcandre.lureau
2026-09-09 17:56 ` Daniel P. Berrangé [this message]
2026-09-09 20:19 ` [PATCH 14/14] machine: add helpers for declaring secure/insecure machine types marcandre.lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260909175656.1572689-15-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.