Skip to contentSkip to conversation

system certificates: specify byte alignment

PATCH In review Giuliano Procida 4 participants 9 messages Sep 12, 2025 – Oct 13

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 system certificates: specify byte alignment

The .align macro is architecture dependent. On arm64 it behaves as .p2align. The various alignments in this file are all bytes.

So use the .balign macro to avoid unnecessary padding due to over-alignment.

---
 certs/system_certificates.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
certs/system_certificates.S +4 -4
index 003e25d4a17e..ea6984b427c9 100644
@@ -4,7 +4,7 @@
 
 	__INITRODATA
 
-	.align 8
+	.balign 8
 	.globl system_certificate_list
 system_certificate_list:
 __cert_list_start:
@@ -20,14 +20,14 @@ __cert_list_end:
 system_extra_cert:
 	.fill CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE, 1, 0
 
-	.align 4
+	.balign 4
 	.globl system_extra_cert_used
 system_extra_cert_used:
 	.int 0
 
 #endif /* CONFIG_SYSTEM_EXTRA_CERTIFICATE */
 
-	.align 8
+	.balign 8
 	.globl system_certificate_list_size
 system_certificate_list_size:
 #ifdef CONFIG_64BIT
@@ -36,7 +36,7 @@ system_certificate_list_size:
 	.long __cert_list_end - __cert_list_start
 #endif
 
-	.align 8
+	.balign 8
 	.globl module_cert_size
 module_cert_size:
 #ifdef CONFIG_64BIT
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
#1 lore raw
Quoted 10 lines · Giuliano Procida

The .align macro is architecture dependent. On arm64 it behaves as .p2align. The various alignments in this file are all bytes.

So use the .balign macro to avoid unnecessary padding due to over-alignment.

---
 certs/system_certificates.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Does certs/revocation_certificates.S need fixing as well?

Will

#2 lore raw
Quoted 8 lines · Will Deacon
Quoted 6 lines · Giuliano Procida

The .align macro is architecture dependent. On arm64 it behaves as .p2align. The various alignments in this file are all bytes.

So use the .balign macro to avoid unnecessary padding due to over-alignment.

Quoted 6 lines
Quoted 4 lines
---
 certs/system_certificates.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Does certs/revocation_certificates.S need fixing as well?

Yes. I will post a v2.

Quoted 1 line

Will

#3 lore raw

PATCH v2 1/1 certs: specify byte alignment

In reply to Giuliano Procida

The alignments specified in system_certificates.S and revocation_certificates.S are intended to be byte quantities.

However, the .align macro is architecture dependent and on arm64 it behaves as .p2align. So use the .balign macro to avoid unnecessary padding due to over-alignment.

---
 certs/revocation_certificates.S | 4 ++--
 certs/system_certificates.S     | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
certs/revocation_certificates.S +2 -2
index f21aae8a8f0e..a53b49d49931 100644
@@ -4,14 +4,14 @@
 
 	__INITRODATA
 
-	.align 8
+	.balign 8
 	.globl revocation_certificate_list
 revocation_certificate_list:
 __revocation_list_start:
 	.incbin "certs/x509_revocation_list"
 __revocation_list_end:
 
-	.align 8
+	.balign 8
 	.globl revocation_certificate_list_size
 revocation_certificate_list_size:
 #ifdef CONFIG_64BIT
certs/system_certificates.S +4 -4
index 003e25d4a17e..ea6984b427c9 100644
@@ -4,7 +4,7 @@
 
 	__INITRODATA
 
-	.align 8
+	.balign 8
 	.globl system_certificate_list
 system_certificate_list:
 __cert_list_start:
@@ -20,14 +20,14 @@ __cert_list_end:
 system_extra_cert:
 	.fill CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE, 1, 0
 
-	.align 4
+	.balign 4
 	.globl system_extra_cert_used
 system_extra_cert_used:
 	.int 0
 
 #endif /* CONFIG_SYSTEM_EXTRA_CERTIFICATE */
 
-	.align 8
+	.balign 8
 	.globl system_certificate_list_size
 system_certificate_list_size:
 #ifdef CONFIG_64BIT
@@ -36,7 +36,7 @@ system_certificate_list_size:
 	.long __cert_list_end - __cert_list_start
 #endif
 
-	.align 8
+	.balign 8
 	.globl module_cert_size
 module_cert_size:
 #ifdef CONFIG_64BIT
Signature · 1 line
2.51.0.534.gc79095c0ca-goog
Acked-by on v2 1/1
#4 lore raw

Re: [PATCH v2] certs: specify byte alignment

Quoted 7 lines · Giuliano Procida

The alignments specified in system_certificates.S and revocation_certificates.S are intended to be byte quantities.

However, the .align macro is architecture dependent and on arm64 it behaves as .p2align. So use the .balign macro to avoid unnecessary padding due to over-alignment.

Quoted 5 lines
---
 certs/revocation_certificates.S | 4 ++--
 certs/system_certificates.S     | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

Will

#5 lore raw

Re: [PATCH v2] certs: specify byte alignment

Quoted 14 lines · Will Deacon
Quoted 7 lines · Giuliano Procida

The alignments specified in system_certificates.S and revocation_certificates.S are intended to be byte quantities.

However, the .align macro is architecture dependent and on arm64 it behaves as .p2align. So use the .balign macro to avoid unnecessary padding due to over-alignment.

Quoted 5 lines

---
 certs/revocation_certificates.S | 4 ++--
 certs/system_certificates.S     | 8 ++++----

 2 files changed, 6 insertions(+), 6 deletions(-)
Quoted 3 lines

Will

Hi,

It seems this patch somehow got lost?

Kexy found MIPS is specifically affected by the .align directive: on MIPS it not only behaves as p2align and introduces a lot of extra padding, but also moved before the __revocation_list_end label in the case of

__revocation_list_end:

.align 8

in revocation_certificates.S. It seems the GNU assembler moves the .align earlier to mimic the IRIX assembler behavior described at page 110 of https://irix7.com/techpubs/007-2418-006.pdf:

Labels immediately preceding an automatic or explicit alignment are also realigned. For example, foo:
.align 3; .word 0 is the same as .align 3;
foo: .word 0.

Kexy's AI proposed the same fix as this patch. So maybe we should apply it now?

Signature · 1 line
Xi Ruoyao <[email protected]>
#6 lore raw

Re: [PATCH v2] certs: specify byte alignment

Hi.

Quoted 38 lines · Xi Ruoyao
Quoted 14 lines · Will Deacon
Quoted 7 lines · Giuliano Procida

The alignments specified in system_certificates.S and revocation_certificates.S are intended to be byte quantities.

However, the .align macro is architecture dependent and on arm64 it behaves as .p2align. So use the .balign macro to avoid unnecessary padding due to over-alignment.

Quoted 5 lines
---
 certs/revocation_certificates.S | 4 ++--
 certs/system_certificates.S     | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
Quoted 3 lines

Will

Hi,

It seems this patch somehow got lost?

Kexy found MIPS is specifically affected by the .align directive: on MIPS it not only behaves as p2align and introduces a lot of extra padding, but also moved before the __revocation_list_end label in the case of

__revocation_list_end:

.align 8

in revocation_certificates.S. It seems the GNU assembler moves the .align earlier to mimic the IRIX assembler behavior described at page 110 of https://irix7.com/techpubs/007-2418-006.pdf:

Quoted 7 lines

Labels immediately preceding an automatic or explicit alignment are also realigned. For example, foo:
.align 3; .word 0 is the same as .align 3;
foo: .word 0.

Kexy's AI proposed the same fix as this patch. So maybe we should apply it now?

That seems like a good idea. A colleague raised it again this week. We were considering just applying it to ACK and forgetting about upstream. I'm glad there's other interest though.

Could you raise this with the relevant maintainer?

Quoted 2 lines

--
Xi Ruoyao <[email protected]>

Thanks,
Giuliano.

#7 lore raw

Re: [PATCH v2] certs: specify byte alignment

Quoted 46 lines · Giuliano Procida

Hi.

Quoted 43 lines · Xi Ruoyao
Quoted 14 lines · Will Deacon
Quoted 7 lines · Giuliano Procida

The alignments specified in system_certificates.S and revocation_certificates.S are intended to be byte quantities.

However, the .align macro is architecture dependent and on arm64 it behaves as .p2align. So use the .balign macro to avoid unnecessary padding due to over-alignment.

Quoted 5 lines

---
 certs/revocation_certificates.S | 4 ++--
 certs/system_certificates.S     | 8 ++++----

 2 files changed, 6 insertions(+), 6 deletions(-)
Quoted 3 lines

Will

Hi,

It seems this patch somehow got lost?

Kexy found MIPS is specifically affected by the .align directive: on MIPS it not only behaves as p2align and introduces a lot of extra padding, but also moved before the __revocation_list_end label in the case of

__revocation_list_end:

    .align 8

in revocation_certificates.S.  It seems the GNU assembler moves the .align earlier to mimic the IRIX assembler behavior described at page 110 of https://irix7.com/techpubs/007-2418-006.pdf:

    Labels immediately preceding an automatic or explicit alignment are also realigned. For example, foo:
    .align 3; .word 0 is the same as .align 3;
    foo: .word 0.

Quoted 8 lines
Quoted 2 lines

Kexy's AI proposed the same fix as this patch.  So maybe we should apply it now?

That seems like a good idea. A colleague raised it again this week. We were considering just applying it to ACK and forgetting about upstream. I'm glad there's other interest though.

Could you raise this with the relevant maintainer?

Hmm, get_maintainers.pl shows David Howells and David Woodhouse are the relevant maintainers and they are already CC'ed. Or is the get_maintainers.pl output inaccurate?

Signature · 1 line
Xi Ruoyao <[email protected]>
#8 lore raw

PATCH v3 1/1 certs: specify byte alignment

From: Giuliano Procida <[email protected]>

The alignments specified in system_certificates.S and revocation_certificates.S are intended to be byte quantities.

However, the .align macro is architecture dependent and on arm64 it behaves as .p2align. So use the .balign macro to avoid unnecessary padding due to over-alignment.

---
v3: tested, collected tags, rebased on top of mainline.

 certs/revocation_certificates.S | 4 ++--
 certs/system_certificates.S     | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
certs/revocation_certificates.S +2 -2
index f21aae8a8f0e..a53b49d49931 100644
@@ -4,14 +4,14 @@
 
 	__INITRODATA
 
-	.align 8
+	.balign 8
 	.globl revocation_certificate_list
 revocation_certificate_list:
 __revocation_list_start:
 	.incbin "certs/x509_revocation_list"
 __revocation_list_end:
 
-	.align 8
+	.balign 8
 	.globl revocation_certificate_list_size
 revocation_certificate_list_size:
 #ifdef CONFIG_64BIT
certs/system_certificates.S +4 -4
index 003e25d4a17e..ea6984b427c9 100644
@@ -4,7 +4,7 @@
 
 	__INITRODATA
 
-	.align 8
+	.balign 8
 	.globl system_certificate_list
 system_certificate_list:
 __cert_list_start:
@@ -20,14 +20,14 @@ __cert_list_end:
 system_extra_cert:
 	.fill CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE, 1, 0
 
-	.align 4
+	.balign 4
 	.globl system_extra_cert_used
 system_extra_cert_used:
 	.int 0
 
 #endif /* CONFIG_SYSTEM_EXTRA_CERTIFICATE */
 
-	.align 8
+	.balign 8
 	.globl system_certificate_list_size
 system_certificate_list_size:
 #ifdef CONFIG_64BIT
@@ -36,7 +36,7 @@ system_certificate_list_size:
 	.long __cert_list_end - __cert_list_start
 #endif
 
-	.align 8
+	.balign 8
 	.globl module_cert_size
 module_cert_size:
 #ifdef CONFIG_64BIT
Signature · 1 line
2.56.0.385.gd3acb90ef8-goog