On 12/02/2026 21.43, Zhuoying Cai wrote:
Create a certificate store for boot certificates used for secure IPL.

Load certificates from the `boot-certs` parameter of s390-ccw-virtio
machine type option into the cert store.

Currently, only X.509 certificates in PEM format are supported, as the
QEMU command line accepts certificates in PEM format only.

Signed-off-by: Zhuoying Cai <[email protected]>
---
...
--- /dev/null
+++ b/hw/s390x/cert-store.c
@@ -0,0 +1,221 @@
...
+void s390_ipl_create_cert_store(S390IPLCertificateStore *cert_store)
+{
+    GPtrArray *cert_path_builder;
+    Error *err = NULL;
+
+    /* If cert store is already populated, then no work to do */
+    if (cert_store->count) {
+        return;
+    }
+
+    cert_path_builder = get_cert_paths(&err);
+    if (cert_path_builder == NULL) {
+        error_report_err(err);
+        exit(1);
+    }
+
+    if (cert_path_builder->len == 0) {
+        g_ptr_array_free(cert_path_builder, TRUE);
+        return;
+    }
+
+    if (cert_path_builder->len > MAX_CERTIFICATES - 1) {
+        error_report("Cert store exceeds maximum of %d certificates", 
MAX_CERTIFICATES);
+        g_ptr_array_free(cert_path_builder, TRUE);
+        exit(1);
+    }
+
+    cert_store->largest_cert_size = 0;
+    cert_store->total_bytes = 0;
+
+    for (int i = 0; i < cert_path_builder->len; i++) {
+        g_autofree S390IPLCertificate *cert = init_cert(
+                                              (char *) 
cert_path_builder->pdata[i],
+                                              &err);

I'd maybe write it like this to decrease indentation:

        g_autofree S390IPLCertificate *cert =
                   init_cert((char *) cert_path_builder->pdata[i],
                             &err);

... but up to you, it's just cosmetics.

...
diff --git a/hw/s390x/cert-store.h b/hw/s390x/cert-store.h
new file mode 100644
index 0000000000..50e36e2389
--- /dev/null
+++ b/hw/s390x/cert-store.h
@@ -0,0 +1,41 @@
...
+struct S390IPLCertificateStore {
+    uint16_t count;
+    size_t   largest_cert_size;
+    size_t   total_bytes;
+    S390IPLCertificate certs[MAX_CERTIFICATES];
+};
+typedef struct S390IPLCertificateStore S390IPLCertificateStore;
+QEMU_BUILD_BUG_MSG(sizeof(S390IPLCertificateStore) != 5656,
+                   "size of S390IPLCertificateStore is wrong");

Why is there a QEMU_BUILD_BUG_MSG here? As far as I can see, this is not a structure that we share in the API with the guest, is it? So if this is just internal to QEMU, the size of the structure should not matter here, I think?

 Thomas


Reply via email to