From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
To: grub-devel@gnu.org
Cc: daniel.kiper@oracle.com, sridharm@linux.ibm.com,
ssrish@linux.ibm.com, mlewando@redhat.com, phcoder@gmail.com,
Sudhakar Kuppusamy <sudhakar@linux.ibm.com>,
stefanb@linux.ibm.com,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Subject: [PATCH v2] appendedsig: Exclude PKS support for grub-emu
Date: Tue, 3 Mar 2026 20:45:15 +0530 [thread overview]
Message-ID: <20260303151515.98524-1-sudhakar@linux.ibm.com> (raw)
Configuring the build with --with-platform=emu fails on 32-bit PowerPC with:
/usr/bin/ld: appendedsig.module: in function `grub_mod_init':
/home/glaubitz/grub/grub-core/commands/appendedsig/appendedsig.c:1615:(.text+0x2ab4): undefined reference to `grub_pks_get_keystore'
/usr/bin/ld: appendedsig.module: in function `create_dbs_from_pks':
/home/glaubitz/grub/grub-core/commands/appendedsig/appendedsig.c:1400:(.text+0x2c3c): undefined reference to `grub_pks_free_data'
collect2: error: ld returned 1 exit status
Fixing this by excluding the Platform Keystore (PKS) for grub-emu.
Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
---
v1: https://lists.gnu.org/archive/html/grub-devel/2026-02/msg00094.html
Thank you, John Paul Adrian Glaubitz and Vladimir 'phcoder' Serbinenko,
for your feedback on v1.
v2: Avoided the inclusion of the powerpc/ieee1275/platform_keystore.h and
PKS support in emu.
---
grub-core/commands/appendedsig/appendedsig.c | 12 ++++++++++++
include/grub/powerpc/ieee1275/platform_keystore.h | 13 -------------
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/grub-core/commands/appendedsig/appendedsig.c b/grub-core/commands/appendedsig/appendedsig.c
index 5c53f634c..65ec134c0 100644
--- a/grub-core/commands/appendedsig/appendedsig.c
+++ b/grub-core/commands/appendedsig/appendedsig.c
@@ -33,7 +33,9 @@
#include <libtasn1.h>
#include <grub/env.h>
#include <grub/lockdown.h>
+#if !defined(GRUB_MACHINE_EMU)
#include <grub/powerpc/ieee1275/platform_keystore.h>
+#endif
#include <grub/efi/pks.h>
#include "appendedsig.h"
@@ -123,8 +125,10 @@ static bool check_sigs = false;
*/
static bool append_key_mgmt = false;
+#if !defined(GRUB_MACHINE_EMU)
/* Platform KeyStore db and dbx. */
static grub_pks_t *pks_keystore;
+#endif
/* Appended signature size. */
static grub_size_t append_sig_len = 0;
@@ -344,6 +348,7 @@ add_hash (grub_uint8_t *const data, const grub_size_t data_size, sb_database_t *
return GRUB_ERR_NONE;
}
+#if !defined(GRUB_MACHINE_EMU)
static bool
is_hash (const grub_packed_guid_t *guid)
{
@@ -370,6 +375,7 @@ is_x509 (const grub_packed_guid_t *guid)
return false;
}
+#endif
static bool
is_cert_match (const grub_x509_cert_t *cert1, const grub_x509_cert_t *cert2)
@@ -1269,6 +1275,7 @@ grub_cmd_add_dbx_hash (grub_extcmd_context_t ctxt, int argc __attribute__ ((unus
return rc;
}
+#if !defined(GRUB_MACHINE_EMU)
/* Add the X.509 certificates/binary hash to the db list from PKS. */
static grub_err_t
load_pks2db (void)
@@ -1330,6 +1337,7 @@ load_pks2dbx (void)
return GRUB_ERR_NONE;
}
+#endif
/*
* Extract the X.509 certificates from the ELF Note header, parse it, and add
@@ -1378,6 +1386,7 @@ load_elf2db (void)
static void
create_dbs_from_pks (void)
{
+#if !defined(GRUB_MACHINE_EMU)
grub_err_t err;
err = load_pks2dbx ();
@@ -1402,6 +1411,7 @@ create_dbs_from_pks (void)
"the dbx list now has %u keys\n",
db.hash_entries + db.cert_entries,
dbx.hash_entries + dbx.cert_entries);
+#endif
}
/* Free db list memory */
@@ -1611,10 +1621,12 @@ GRUB_MOD_INIT (appendedsig)
if (grub_is_lockdown () == GRUB_LOCKDOWN_ENABLED)
check_sigs = true;
+#if !defined(GRUB_MACHINE_EMU)
/* If PKS keystore is available, use dynamic key management. */
pks_keystore = grub_pks_get_keystore ();
if (pks_keystore != NULL)
append_key_mgmt = true;
+#endif
/*
* This is appended signature verification environment variable. It is
diff --git a/include/grub/powerpc/ieee1275/platform_keystore.h b/include/grub/powerpc/ieee1275/platform_keystore.h
index 931ada224..edb342aae 100644
--- a/include/grub/powerpc/ieee1275/platform_keystore.h
+++ b/include/grub/powerpc/ieee1275/platform_keystore.h
@@ -96,7 +96,6 @@ struct grub_pks
};
typedef struct grub_pks grub_pks_t;
-#if defined(__powerpc__)
/* Initialization of the Platform Keystore. */
extern void
grub_pks_keystore_init (void);
@@ -108,16 +107,4 @@ EXPORT_FUNC (grub_pks_get_keystore) (void);
/* Free allocated memory. */
extern void
EXPORT_FUNC (grub_pks_free_data) (void);
-#else
-static inline grub_pks_t *
-grub_pks_get_keystore (void)
-{
- return NULL;
-}
-
-static inline void
-grub_pks_free_data (void)
-{
-}
-#endif /* __powerpc__ */
#endif
--
2.50.1 (Apple Git-155)
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next reply other threads:[~2026-03-03 15:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 15:15 Sudhakar Kuppusamy [this message]
2026-03-04 8:44 ` [PATCH v2] appendedsig: Exclude PKS support for grub-emu John Paul Adrian Glaubitz
2026-03-12 19:15 ` John Paul Adrian Glaubitz
2026-03-17 21:04 ` Leo Sandoval via Grub-devel
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=20260303151515.98524-1-sudhakar@linux.ibm.com \
--to=sudhakar@linux.ibm.com \
--cc=daniel.kiper@oracle.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=grub-devel@gnu.org \
--cc=mlewando@redhat.com \
--cc=phcoder@gmail.com \
--cc=sridharm@linux.ibm.com \
--cc=ssrish@linux.ibm.com \
--cc=stefanb@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