[PATCH 3/4] arm64: kexec: Introduce d_size to carry cacheline size information

Pingfan Liu piliu at redhat.com
Thu Mar 28 04:56:53 PDT 2024


Introducing kimage_arch.d_size to carry the data cacheline size
information, so that the relocate_kernel C routine can be implemented
simpler. The cache size info will be used in the next patch

Signed-off-by: Pingfan Liu <piliu at redhat.com>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Will Deacon <will at kernel.org>
Cc: Ard Biesheuvel <ardb at kernel.org>
Cc: Kees Cook <keescook at chromium.org>
Cc: Mark Rutland <mark.rutland at arm.com>
Cc: Pasha Tatashin <pasha.tatashin at soleen.com>
To: linux-arm-kernel at lists.infradead.org
---
 arch/arm64/include/asm/kexec.h    | 1 +
 arch/arm64/kernel/machine_kexec.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h
index 9ac9572a3bbe..882d00786f92 100644
--- a/arch/arm64/include/asm/kexec.h
+++ b/arch/arm64/include/asm/kexec.h
@@ -116,6 +116,7 @@ struct kimage_arch {
 	phys_addr_t zero_page;
 	unsigned long phys_offset;
 	unsigned long t0sz;
+	unsigned long d_size;
 };
 
 #ifdef CONFIG_KEXEC_FILE
diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
index de4e9e0ad682..b4ae24dcac8c 100644
--- a/arch/arm64/kernel/machine_kexec.c
+++ b/arch/arm64/kernel/machine_kexec.c
@@ -146,6 +146,9 @@ int machine_kexec_post_load(struct kimage *kimage)
 	if (rc)
 		return rc;
 	kimage->arch.phys_offset = virt_to_phys(kimage) - (long)kimage;
+	kimage->arch.d_size = 4 << cpuid_feature_extract_unsigned_field(
+							arm64_ftr_reg_ctrel0.sys_val,
+							CTR_EL0_DminLine_SHIFT);
 
 	/* Flush the reloc_code in preparation for its execution. */
 	dcache_clean_inval_poc((unsigned long)reloc_code,
-- 
2.41.0




More information about the linux-arm-kernel mailing list