Skip to contentSkip to conversation

arm64: head: set TEXT_OFFSET to the historical value

PATCH In review Dmitry Baryshkov 4 participants 6 messages Oct 5, 2025 – Oct 9, 2025

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

PATCH 1/1 arm64: head: set TEXT_OFFSET to the historical value

From: Dmitry Baryshkov <[email protected]>

Historically arm64 kernel contained (almost fixed) value of 0x8000 at the TEXT_OFFSET. The commit cfa7ede20f13 ("arm64: set TEXT_OFFSET to 0x0 in preparation for removing it entirely") and then commit 120dc60d0bdb ("arm64: get rid of TEXT_OFFSET") replaced this field with 0.

This caused no problems so far, because nobody seemed to be playing with the extremely picky Qualcomm bootloader as used on some of Google Pixel phones. Current attempting to boot the Linux kernel on those devices will fail to load on those phones with the following message:

KernelDecompress failed: Invalid Parameter Kernel TextOffset does not match Error calling BootPrepareAsync Invalid Parameter

Since the kernel ignores the field, set it to the expected value of 0x8000, unbreaking boot of upstream kernels on Qualcomm devices.

Note: I purposedly didn't add Fixes tags, since those commits didn't break any of devices that were supported at that time.

---
 arch/arm64/kernel/head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/head.S +1 -1
index ca04b338cb0d173f6d9f5bcee52f6d3d06552599..05e874977de376835625f52bfdda78305dca28b5 100644
@@ -60,7 +60,7 @@
 	 */
 	efi_signature_nop			// special NOP to identity as PE/COFF executable
 	b	primary_entry			// branch to kernel start, magic
-	.quad	0				// Image load offset from start of RAM, little-endian
+	.quad	0x80000				// Image load offset from start of RAM, little-endian
 	le64sym	_kernel_size_le			// Effective size of kernel image, little-endian
 	le64sym	_kernel_flags_le		// Informative flags, little-endian
 	.quad	0				// reserved

---
base-commit: bd773c01d149aec064ea0fc890a54be277acfa3b
change-id: 20251006-arm64-text-offset-a45fee505c4d

Best regards,

Signature · 2 lines
With best wishes
Dmitry
Reviewed-by on v1 1/1
#1 lore raw

Hi.

So far, only Pixel 3 and 3 XL with "recent" bootloaders are affected.

As I see it, the cost of making it compatible is accepting the commit at zero maintenance or runtime cost.

Would make sense to also update the comment in the code to reflect the change?

Thank you!

Quoted 46 lines · Dmitry Baryshkov

From: Dmitry Baryshkov <[email protected]>

Historically arm64 kernel contained (almost fixed) value of 0x8000 at the TEXT_OFFSET. The commit cfa7ede20f13 ("arm64: set TEXT_OFFSET to 0x0 in preparation for removing it entirely") and then commit 120dc60d0bdb ("arm64: get rid of TEXT_OFFSET") replaced this field with 0.

This caused no problems so far, because nobody seemed to be playing with the extremely picky Qualcomm bootloader as used on some of Google Pixel phones. Current attempting to boot the Linux kernel on those devices will fail to load on those phones with the following message:

KernelDecompress failed: Invalid Parameter Kernel TextOffset does not match Error calling BootPrepareAsync Invalid Parameter

Since the kernel ignores the field, set it to the expected value of 0x8000, unbreaking boot of upstream kernels on Qualcomm devices.

Note: I purposedly didn't add Fixes tags, since those commits didn't break any of devices that were supported at that time.

---
  arch/arm64/kernel/head.S | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/head.S +1 -2
index ca04b338cb0d173f6d9f5bcee52f6d3d06552599..05e874977de376835625f52bfdda78305dca28b5 100644
@@ -60,7 +60,7 @@
  	 */
  	efi_signature_nop			// special NOP to identity as PE/COFF executable
  	b	primary_entry			// branch to kernel start, magic
-	.quad	0				// Image load offset from start of RAM, little-endian
+	.quad	0x80000				// Image load offset from start of RAM, little-endian
  	le64sym	_kernel_size_le			// Effective size of kernel image, little-endian
  	le64sym	_kernel_flags_le		// Informative flags, little-endian
  	.quad	0				// reserved
 
---

base-commit: bd773c01d149aec064ea0fc890a54be277acfa3b
change-id: 20251006-arm64-text-offset-a45fee505c4d

Best regards,

Signature · 1 line
David Heidelberg
maintainer
#2 lore raw
In reply to Dmitry Baryshkov

[+Ard and Mark]

Quoted 3 lines · Dmitry Baryshkov

From: Dmitry Baryshkov <[email protected]>

Historically arm64 kernel contained (almost fixed) value of 0x8000 at

0x8000 or 0x80000?

Quoted 3 lines

the TEXT_OFFSET. The commit cfa7ede20f13 ("arm64: set TEXT_OFFSET to 0x0 in preparation for removing it entirely") and then commit 120dc60d0bdb ("arm64: get rid of TEXT_OFFSET") replaced this field with 0.

Given that we made the initial change over five years ago, I'm struggling to see why we should start caring about old broken bootloaders _now_.

In fact, I'm far more concerned about changing this to a non-zero value and having more recent bootloaders misbehave.

Quoted 10 lines

This caused no problems so far, because nobody seemed to be playing with the extremely picky Qualcomm bootloader as used on some of Google Pixel phones. Current attempting to boot the Linux kernel on those devices will fail to load on those phones with the following message:

KernelDecompress failed: Invalid Parameter Kernel TextOffset does not match Error calling BootPrepareAsync Invalid Parameter

Since the kernel ignores the field, set it to the expected value of 0x8000, unbreaking boot of upstream kernels on Qualcomm devices.

(same typo)

Quoted 14 lines

Note: I purposedly didn't add Fixes tags, since those commits didn't break any of devices that were supported at that time.

---
 arch/arm64/kernel/head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/head.S +0 -0
index ca04b338cb0d173f6d9f5bcee52f6d3d06552599..05e874977de376835625f52bfdda78305dca28b5 100644

arch/arm64/kernel/head.S line 66

Quoted 8 lines
arch/arm64/kernel/head.S +1 -1
@@ -60,7 +60,7 @@
 	 */
 	efi_signature_nop			// special NOP to identity as PE/COFF executable
 	b	primary_entry			// branch to kernel start, magic
-	.quad	0				// Image load offset from start of RAM, little-endian
+	.quad	0x80000				// Image load offset from start of RAM, little-endian
 	le64sym	_kernel_size_le			// Effective size of kernel image, little-endian
 	le64sym	_kernel_flags_le		// Informative flags, little-endian
 	.quad	0				// reserved

Could you wrap the kernel Image in your own header to workaround the issue?

Will

#3 lore raw
Quoted 25 lines · Will Deacon

[+Ard and Mark]

Quoted 3 lines · Dmitry Baryshkov

From: Dmitry Baryshkov <[email protected]>

Historically arm64 kernel contained (almost fixed) value of 0x8000 at

0x8000 or 0x80000?

Quoted 3 lines

the TEXT_OFFSET. The commit cfa7ede20f13 ("arm64: set TEXT_OFFSET to 0x0 in preparation for removing it entirely") and then commit 120dc60d0bdb ("arm64: get rid of TEXT_OFFSET") replaced this field with 0.

Given that we made the initial change over five years ago, I'm struggling to see why we should start caring about old broken bootloaders _now_.

In fact, I'm far more concerned about changing this to a non-zero value and having more recent bootloaders misbehave.

Quoted 5 lines

This caused no problems so far, because nobody seemed to be playing with the extremely picky Qualcomm bootloader as used on some of Google Pixel phones. Current attempting to boot the Linux kernel on those devices will fail to load on those phones with the following message:

Quoted 8 lines
Quoted 5 lines

KernelDecompress failed: Invalid Parameter Kernel TextOffset does not match Error calling BootPrepareAsync Invalid Parameter

Since the kernel ignores the field, set it to the expected value of 0x8000, unbreaking boot of upstream kernels on Qualcomm devices.

(same typo)

Just setting the header field and not updating the base address also means that the boot breaks without CONFIG_RELOCATABLE, and you will get a warning in the kernel log about the load address not being aligned to 2 MiB.

So I don't think this is the right solution.

If this is really something that needs to be fixed upstream, we should just bring back TEXT_OFFSET in its entirety, but I'm not convinced that this is really justified here. As a workaround, you could just add 2 MiB - 0x80000 bytes of padding at the start of the image, and add your own header (as Will alludes to as well)

#4 lore raw
Quoted 9 lines · Ard Biesheuvel
Quoted 8 lines · Will Deacon

[+Ard and Mark]

Quoted 3 lines · Dmitry Baryshkov

From: Dmitry Baryshkov <[email protected]>

Historically arm64 kernel contained (almost fixed) value of 0x8000 at

Quoted 8 lines
Quoted 8 lines

0x8000 or 0x80000?

Quoted 3 lines

the TEXT_OFFSET. The commit cfa7ede20f13 ("arm64: set TEXT_OFFSET to 0x0 in preparation for removing it entirely") and then commit 120dc60d0bdb ("arm64: get rid of TEXT_OFFSET") replaced this field with 0.

Given that we made the initial change over five years ago, I'm struggling to see why we should start caring about old broken bootloaders _now_.

Well... because support for these devices wasn't upstreamed and so a similar patch was being kept in the down-upstream kernel.

Quoted 3 lines
Quoted 3 lines

In fact, I'm far more concerned about changing this to a non-zero value and having more recent bootloaders misbehave.

I see.

Quoted 15 lines
Quoted 6 lines
Quoted 6 lines

This caused no problems so far, because nobody seemed to be playing with the extremely picky Qualcomm bootloader as used on some of Google Pixel phones. Current attempting to boot the Linux kernel on those devices will fail to load on those phones with the following message:

Quoted 8 lines
Quoted 5 lines

KernelDecompress failed: Invalid Parameter Kernel TextOffset does not match Error calling BootPrepareAsync Invalid Parameter

Since the kernel ignores the field, set it to the expected value of 0x8000, unbreaking boot of upstream kernels on Qualcomm devices.

(same typo)

Quoted 6 lines

Just setting the header field and not updating the base address also means that the boot breaks without CONFIG_RELOCATABLE, and you will get a warning in the kernel log about the load address not being aligned to 2 MiB.

So I don't think this is the right solution.

Since most of the people build the kernel with CONFIG_RELOCATABLE, would it be better to set it to 0x80000 for relocatable kernels and to 0 otherwise?

Quoted 6 lines

If this is really something that needs to be fixed upstream, we should just bring back TEXT_OFFSET in its entirety, but I'm not convinced that this is really justified here. As a workaround, you could just add 2 MiB - 0x80000 bytes of padding at the start of the image, and add your own header (as Will alludes to as well)

Does it mean building a device specific kernel? Or just packing everything while building the Android boot image?

Signature · 2 lines
With best wishes
Dmitry
#5 lore raw
Quoted 2 lines · Dmitry Baryshkov

On Tue, Oct 07, 2025 at 01:46:08AM +0200, Ard Biesheuvel wrote:

...

Quoted 6 lines
Quoted 6 lines

Just setting the header field and not updating the base address also means that the boot breaks without CONFIG_RELOCATABLE, and you will get a warning in the kernel log about the load address not being aligned to 2 MiB.

Quoted 6 lines
Quoted 1 line

So I don't think this is the right solution.

Since most of the people build the kernel with CONFIG_RELOCATABLE, would it be better to set it to 0x80000 for relocatable kernels and to 0 otherwise?

When CONFIG_RELOCATABLE is set, any multiple of 64k is acceptable in practice, but given that this violates the documented boot protocol for arm64, we only permit this when booting via the EFI stub.

When we set this field to 0x80000, we are basically instructing bootloaders to violate the boot protocol, which is not ideal, and we should definitely not issue the pr_warn() we have today in arch/arm64/kernel/setup.c.

Quoted 10 lines
Quoted 6 lines

If this is really something that needs to be fixed upstream, we should just bring back TEXT_OFFSET in its entirety, but I'm not convinced that this is really justified here. As a workaround, you could just add 2 MiB - 0x80000 bytes of padding at the start of the image, and add your own header (as Will alludes to as well)

Does it mean building a device specific kernel? Or just packing everything while building the Android boot image?

No idea. What does the Android boot image contain? Is the first thing that gets loaded the kernel image? In that case, you would wrap the kernel image before sticking it into the Android boot image, yes.