From: Dov Murik <dovmurik@linux.ibm.com>
To: qemu-devel@nongnu.org
Cc: "Dov Murik" <dovmurik@linux.ibm.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Eric Blake" <eblake@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"James Bottomley" <jejb@linux.ibm.com>,
"Tom Lendacky" <thomas.lendacky@amd.com>,
"Michael Roth" <michael.roth@amd.com>,
"Ashish Kalra" <ashish.kalra@amd.com>,
"Mario Smarduch" <mario.smarduch@amd.com>,
"Tobin Feldman-Fitzthum" <tobin@linux.ibm.com>
Subject: [RFC PATCH v3 1/4] qapi, i386: Move kernel-hashes to SevCommonProperties
Date: Thu, 2 Mar 2023 09:23:44 +0000 [thread overview]
Message-ID: <20230302092347.1988853-2-dovmurik@linux.ibm.com> (raw)
In-Reply-To: <20230302092347.1988853-1-dovmurik@linux.ibm.com>
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: Dov Murik <dovmurik@linux.ibm.com>
---
qapi/qom.json | 12 ++++++------
target/i386/sev.c | 44 ++++++++++++++++++--------------------------
2 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/qapi/qom.json b/qapi/qom.json
index 33abba0e04..9b2897d54c 100644
--- a/qapi/qom.json
+++ b/qapi/qom.json
@@ -836,6 +836,10 @@
# @reduced-phys-bits: number of bits in physical addresses that become
# unavailable when SEV is enabled
#
+# @kernel-hashes: if true, add hashes of kernel/initrd/cmdline to a
+# designated guest firmware page for measured boot
+# with -kernel (default: false) (since 6.2)
+#
# @upm-mode: configure Unmapped Private Memory mode
#
# @discard: configure how discarding is handled for memory after
@@ -848,6 +852,7 @@
'data': { '*sev-device': 'str',
'*cbitpos': 'uint32',
'reduced-phys-bits': 'uint32',
+ '*kernel-hashes': 'bool',
'*upm-mode': 'bool',
'*discard': 'str' } }
@@ -864,10 +869,6 @@
#
# @handle: SEV firmware handle (default: 0)
#
-# @kernel-hashes: if true, add hashes of kernel/initrd/cmdline to a
-# designated guest firmware page for measured boot
-# with -kernel (default: false) (since 6.2)
-#
# Since: 2.12
##
{ 'struct': 'SevGuestProperties',
@@ -875,8 +876,7 @@
'data': { '*dh-cert-file': 'str',
'*session-file': 'str',
'*policy': 'uint32',
- '*handle': 'uint32',
- '*kernel-hashes': 'bool' } }
+ '*handle': 'uint32' } }
##
# @SevSnpGuestProperties:
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 758e8225c2..6b8e85888f 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -64,6 +64,7 @@ struct SevCommonState {
char *sev_device;
uint32_t cbitpos;
uint32_t reduced_phys_bits;
+ bool kernel_hashes;
bool upm_mode;
char *discard;
@@ -88,7 +89,6 @@ struct SevGuestState {
uint32_t policy;
char *dh_cert_file;
char *session_file;
- bool kernel_hashes;
};
struct SevSnpGuestState {
@@ -390,6 +390,16 @@ sev_common_set_sev_device(Object *obj, const char *value, Error **errp)
SEV_COMMON(obj)->sev_device = g_strdup(value);
}
+static bool sev_common_get_kernel_hashes(Object *obj, Error **errp)
+{
+ return SEV_COMMON(obj)->kernel_hashes;
+}
+
+static void sev_common_set_kernel_hashes(Object *obj, bool value, Error **errp)
+{
+ SEV_COMMON(obj)->kernel_hashes = value;
+}
+
static bool sev_common_get_upm_mode(Object *obj, Error **errp)
{
return SEV_COMMON(obj)->upm_mode;
@@ -420,6 +430,11 @@ sev_common_class_init(ObjectClass *oc, void *data)
sev_common_set_sev_device);
object_class_property_set_description(oc, "sev-device",
"SEV device to use");
+ object_class_property_add_bool(oc, "kernel-hashes",
+ sev_common_get_kernel_hashes,
+ sev_common_set_kernel_hashes);
+ object_class_property_set_description(oc, "kernel-hashes",
+ "add kernel hashes to guest firmware for measured Linux boot");
object_class_property_add_bool(oc, "upm-mode",
sev_common_get_upm_mode,
sev_common_set_upm_mode);
@@ -484,20 +499,6 @@ sev_guest_set_session_file(Object *obj, const char *value, Error **errp)
SEV_GUEST(obj)->session_file = g_strdup(value);
}
-static bool sev_guest_get_kernel_hashes(Object *obj, Error **errp)
-{
- SevGuestState *sev_guest = SEV_GUEST(obj);
-
- return sev_guest->kernel_hashes;
-}
-
-static void sev_guest_set_kernel_hashes(Object *obj, bool value, Error **errp)
-{
- SevGuestState *sev = SEV_GUEST(obj);
-
- sev->kernel_hashes = value;
-}
-
static void
sev_guest_class_init(ObjectClass *oc, void *data)
{
@@ -511,11 +512,6 @@ sev_guest_class_init(ObjectClass *oc, void *data)
sev_guest_set_session_file);
object_class_property_set_description(oc, "session-file",
"guest owners session parameters (encoded with base64)");
- object_class_property_add_bool(oc, "kernel-hashes",
- sev_guest_get_kernel_hashes,
- sev_guest_set_kernel_hashes);
- object_class_property_set_description(oc, "kernel-hashes",
- "add kernel hashes to guest firmware for measured Linux boot");
}
static void
@@ -2088,16 +2084,12 @@ bool sev_add_kernel_loader_hashes(SevKernelLoaderContext *ctx, Error **errp)
MemTxAttrs attrs = { 0 };
bool ret = true;
SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs);
- SevGuestState *sev_guest =
- (SevGuestState *)object_dynamic_cast(OBJECT(sev_common),
- TYPE_SEV_GUEST);
/*
* Only add the kernel hashes if the sev-guest configuration explicitly
- * stated kernel-hashes=on. Currently only enabled for SEV/SEV-ES guests,
- * so check for TYPE_SEV_GUEST as well.
+ * stated kernel-hashes=on.
*/
- if (sev_guest && !sev_guest->kernel_hashes) {
+ if (!sev_common->kernel_hashes) {
return false;
}
--
2.25.1
next prev parent reply other threads:[~2023-03-02 9:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-02 9:23 [RFC PATCH v3 0/4] i386/sev: Support measured direct kernel boot on SNP Dov Murik
2023-03-02 9:23 ` Dov Murik [this message]
2023-03-02 9:23 ` [RFC PATCH v3 2/4] i386/sev: Extract build_kernel_loader_hashes Dov Murik
2023-03-02 9:23 ` [RFC PATCH v3 3/4] i386/sev: Reorder struct declarations Dov Murik
2023-03-02 9:23 ` [RFC PATCH v3 4/4] i386/sev: Allow measured direct kernel boot on SNP Dov Murik
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=20230302092347.1988853-2-dovmurik@linux.ibm.com \
--to=dovmurik@linux.ibm.com \
--cc=armbru@redhat.com \
--cc=ashish.kalra@amd.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=jejb@linux.ibm.com \
--cc=kraxel@redhat.com \
--cc=mario.smarduch@amd.com \
--cc=michael.roth@amd.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thomas.lendacky@amd.com \
--cc=tobin@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).