On Tue, 2026-03-03 at 20:45 +0530, Sudhakar Kuppusamy wrote: > 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 <[email protected]> > Signed-off-by: Sudhakar Kuppusamy <[email protected]> > --- > 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
This fixes the issue for me. Tested-by: John Paul Adrian Glaubitz <[email protected]> Thanks, Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
