Skip to contentSkip to conversation

appendedsig: Exclude PKS support for grub-emu

PATCH In review Sudhakar Kuppusamy 3 participants 4 messages Mar 3 – Mar 17

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 appendedsig: Exclude PKS support for grub-emu

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.

---
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(-)
grub-core/commands/appendedsig/appendedsig.c +12 -0
index 5c53f634c..65ec134c0 100644
@@ -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
include/grub/powerpc/ieee1275/platform_keystore.h +0 -13
index 931ada224..edb342aae 100644
@@ -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
Signature · 7 lines
2.50.1 (Apple Git-155)


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Tested-by on v2 1/1
#1 lore raw
Quoted 129 lines · Sudhakar Kuppusamy

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.

---
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(-)
grub-core/commands/appendedsig/appendedsig.c +12 -0
index 5c53f634c..65ec134c0 100644
@@ -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
include/grub/powerpc/ieee1275/platform_keystore.h +0 -4
index 931ada224..edb342aae 100644
@@ -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)

include/grub/powerpc/ieee1275/platform_keystore.h EXPORT_FUNC (grub_pks_get_keystore) (void); · line 110

Quoted 10 lines
include/grub/powerpc/ieee1275/platform_keystore.h +0 -9
-{
-  return NULL;
-}
-
-static inline void
-grub_pks_free_data (void)
-{
-}
-#endif /* __powerpc__ */
 #endif

This fixes the issue for me.

Thanks,
Adrian

Signature · 9 lines
 .''`.  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
#2 lore raw

Hi,

Quoted 143 lines · John Paul Adrian Glaubitz
Quoted 129 lines · Sudhakar Kuppusamy

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.

---
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(-)
grub-core/commands/appendedsig/appendedsig.c +12 -0
index 5c53f634c..65ec134c0 100644
@@ -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
include/grub/powerpc/ieee1275/platform_keystore.h +0 -4
index 931ada224..edb342aae 100644
@@ -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)

include/grub/powerpc/ieee1275/platform_keystore.h EXPORT_FUNC (grub_pks_get_keystore) (void); · line 110

Quoted 10 lines
include/grub/powerpc/ieee1275/platform_keystore.h +0 -9
-{
-  return NULL;
-}
-
-static inline void
-grub_pks_free_data (void)
-{
-}
-#endif /* __powerpc__ */
 #endif

This fixes the issue for me.

Quoted 1 line

Any chance we can move forward with this fix or an alternative one?

Thanks,
Adrian

Signature · 9 lines
 .''`.  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
#3 lore raw
In reply to John Paul Adrian Glaubitz

Sudhakar,

LGTM but please send the PR at freedesktop: all development has moved to freedesktop as described
https://lists.gnu.org/archive/html/grub-devel/2026-03/msg00002.html

Quoted 165 lines · John Paul Adrian Glaubitz
Quoted 1 line · Sudhakar Kuppusamy

Configuring the build with --with-platform=emu fails on 32-bit PowerPC

with:

Quoted 3 lines

/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'

Quoted 2 lines

/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'

Quoted 11 lines

collect2: error: ld returned 1 exit status

Fixing this by excluding the Platform Keystore (PKS) for grub-emu.

---
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.

Review

Quoted 8 lines

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(-)
(quoted diff) +0 -0

b/grub-core/commands/appendedsig/appendedsig.c

grub-core/commands/appendedsig/appendedsig.c add_hash (grub_uint8_t *const data, const

Quoted 25 lines

index 5c53f634c..65ec134c0 100644

grub-core/commands/appendedsig/appendedsig.c +4 -0
@@ -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 *

Quoted 8 lines
grub-core/commands/appendedsig/appendedsig.c +1 -0
   return GRUB_ERR_NONE;
 }
 
+#if !defined(GRUB_MACHINE_EMU)
 static bool
 is_hash (const grub_packed_guid_t *guid)
 {

grub-core/commands/appendedsig/appendedsig.c is_x509 (const grub_packed_guid_t *guid) · line 381

Quoted 7 lines
grub-core/commands/appendedsig/appendedsig.c +1 -0
@@ -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)

grub-core/commands/appendedsig/appendedsig.c grub_cmd_add_dbx_hash (grub_extcmd_context_t ctxt,

Quoted 1 line
grub-core/commands/appendedsig/appendedsig.c +0 -0
@@ -1269,6 +1275,7 @@ grub_cmd_add_dbx_hash (grub_extcmd_context_t ctxt,

int argc __attribute__ ((unus

Quoted 8 lines
grub-core/commands/appendedsig/appendedsig.c +1 -0
   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)

grub-core/commands/appendedsig/appendedsig.c load_pks2dbx (void) · line 1343

Quoted 7 lines
grub-core/commands/appendedsig/appendedsig.c +1 -0
@@ -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

Review

Quoted 30 lines
grub-core/commands/appendedsig/appendedsig.c +4 -0
@@ -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
(quoted diff) +0 -0

b/include/grub/powerpc/ieee1275/platform_keystore.h

Quoted 18 lines

index 931ada224..edb342aae 100644

include/grub/powerpc/ieee1275/platform_keystore.h +0 -4
@@ -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)

include/grub/powerpc/ieee1275/platform_keystore.h EXPORT_FUNC (grub_pks_get_keystore) (void); · line 110

Quoted 10 lines
include/grub/powerpc/ieee1275/platform_keystore.h +0 -9
-{
-  return NULL;
-}
-
-static inline void
-grub_pks_free_data (void)
-{
-}
-#endif /* __powerpc__ */
 #endif

This fixes the issue for me.

Thanks,
Adrian

--

 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel