From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH 03/15] machine: add 'require-secure' and 'prohibit-insecure' properties
Date: Tue, 9 Sep 2025 17:57:14 +0100 [thread overview]
Message-ID: <20250909165726.3814465-4-berrange@redhat.com> (raw)
In-Reply-To: <20250909165726.3814465-1-berrange@redhat.com>
Both default to 'false' to maintain the historical behaviour.
If 'require-secure' is set to 'yes', then types which
explicitly declare themselves as secure are required.
If 'prohibit-insecure' is set to 'yes', then types which
explicitly declare themselves as insecure are forbidden.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
hw/core/machine.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
include/hw/boards.h | 5 ++++
2 files changed, 65 insertions(+)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 38c949c4f2..b43c315bab 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -440,6 +440,34 @@ static void machine_set_dump_guest_core(Object *obj, bool value, Error **errp)
ms->dump_guest_core = value;
}
+static bool machine_get_require_secure(Object *obj, Error **errp)
+{
+ MachineState *ms = MACHINE(obj);
+
+ return ms->require_secure;
+}
+
+static void machine_set_require_secure(Object *obj, bool value, Error **errp)
+{
+ MachineState *ms = MACHINE(obj);
+
+ ms->require_secure = value;
+}
+
+static bool machine_get_prohibit_insecure(Object *obj, Error **errp)
+{
+ MachineState *ms = MACHINE(obj);
+
+ return ms->prohibit_insecure;
+}
+
+static void machine_set_prohibit_insecure(Object *obj, bool value, Error **errp)
+{
+ MachineState *ms = MACHINE(obj);
+
+ ms->prohibit_insecure = value;
+}
+
static bool machine_get_mem_merge(Object *obj, Error **errp)
{
MachineState *ms = MACHINE(obj);
@@ -1245,6 +1273,17 @@ static void machine_class_init(ObjectClass *oc, const void *data)
NULL, NULL);
object_class_property_set_description(oc, "memory",
"Memory size configuration");
+
+ object_class_property_add_bool(oc, "require-secure",
+ machine_get_require_secure, machine_set_require_secure);
+ object_class_property_set_description(oc, "require-secure",
+ "Define whether explicitly secure impls are required");
+
+ object_class_property_add_bool(oc, "prohibit-insecure",
+ machine_get_prohibit_insecure, machine_set_prohibit_insecure);
+ object_class_property_set_description(oc, "prohibit-insecure",
+ "Define whether explicitly insecure impls are prohibited");
+
}
static void machine_class_base_init(ObjectClass *oc, const void *data)
@@ -1269,6 +1308,8 @@ static void machine_initfn(Object *obj)
MachineClass *mc = MACHINE_GET_CLASS(obj);
ms->dump_guest_core = true;
+ ms->require_secure = false;
+ ms->prohibit_insecure = false;
ms->mem_merge = (QEMU_MADV_MERGEABLE != QEMU_MADV_INVALID);
ms->enable_graphics = true;
ms->kernel_cmdline = g_strdup("");
@@ -1362,6 +1403,25 @@ bool machine_dump_guest_core(MachineState *machine)
return machine->dump_guest_core;
}
+bool machine_check_security(MachineState *machine,
+ ObjectClass *cls,
+ Error **errp)
+{
+ if (machine->require_secure &&
+ !object_class_is_secure(cls)) {
+ error_setg(errp, "Type '%s' is not declared as secure",
+ object_class_get_name(cls));
+ return false;
+ }
+ if (machine->prohibit_insecure &&
+ object_class_is_insecure(cls)) {
+ error_setg(errp, "Type '%s' is declared as insecure",
+ object_class_get_name(cls));
+ return false;
+ }
+ return true;
+}
+
bool machine_mem_merge(MachineState *machine)
{
return machine->mem_merge;
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 665b620121..61f6942016 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -36,6 +36,9 @@ void machine_run_board_init(MachineState *machine, const char *mem_path, Error *
bool machine_usb(MachineState *machine);
int machine_phandle_start(MachineState *machine);
bool machine_dump_guest_core(MachineState *machine);
+bool machine_check_security(MachineState *machine,
+ ObjectClass *cls,
+ Error **errp);
bool machine_mem_merge(MachineState *machine);
bool machine_require_guest_memfd(MachineState *machine);
HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine);
@@ -403,6 +406,8 @@ struct MachineState {
int phandle_start;
char *dt_compatible;
bool dump_guest_core;
+ bool require_secure;
+ bool prohibit_insecure;
bool mem_merge;
bool usb;
bool usb_disabled;
--
2.50.1
next prev parent reply other threads:[~2025-09-09 16:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 16:57 [PATCH <RFC> 00/15] Encode object type security status in code Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 01/15] qom: replace 'abstract' with 'flags' Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 02/15] qom: add tracking of security state of object types Daniel P. Berrangé
2025-09-22 21:33 ` Eric Blake
2025-09-09 16:57 ` Daniel P. Berrangé [this message]
2025-09-09 16:57 ` [PATCH 04/15] machine: check security for machine and accelerator types Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 05/15] system: report machine security status in help output Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 06/15] system: check security of device types Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 07/15] system: report device security status in help output Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 08/15] hw/core: report secure/insecure status in query-machines Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 09/15] accel: mark 'kvm' as secure and 'tcg' as insecure Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 10/15] hw/virtio: mark all virtio PCI devices as secure Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 11/15] hw: mark x86, s390, ppc, arm versioned machine types " Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 12/15] hw: declare Xen & microvm machines as secure, isapc as insecure Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 13/15] hw/core: declare 'none' machine to be insecure Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 14/15] hw/net: mark all NICs as insecure except e1000, e1000e & xen Daniel P. Berrangé
2025-09-09 16:57 ` [PATCH 15/15] docs: expand security docs with info about secure/insecure markers Daniel P. Berrangé
2025-09-16 16:43 ` [PATCH <RFC> 00/15] Encode object type security status in code Daniel P. Berrangé
2025-09-16 16:51 ` Peter Maydell
2025-09-18 11:35 ` Markus Armbruster
2025-09-18 12:29 ` Daniel P. Berrangé
2025-09-18 14:44 ` Markus Armbruster
2025-09-18 14:51 ` Daniel P. Berrangé
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=20250909165726.3814465-4-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@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.