Skip to content

Commit 2e6bd22

Browse files
hbathinimpe
authored andcommitted
powerpc/kexec_file: Enable early kernel OPAL calls
Kernels built with CONFIG_PPC_EARLY_DEBUG_OPAL enabled expects r8 & r9 to be filled with OPAL base & entry addresses respectively. Setting these registers allows the kernel to perform OPAL calls before the device tree is parsed. Signed-off-by: Hari Bathini <[email protected]> Reviewed-by: Thiago Jung Bauermann <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/159602303975.575379.5032301944162937479.stgit@hbathini
1 parent b5667d1 commit 2e6bd22

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

arch/powerpc/kexec/file_load_64.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code,
876876
const void *fdt, unsigned long kernel_load_addr,
877877
unsigned long fdt_load_addr)
878878
{
879+
struct device_node *dn = NULL;
879880
int ret;
880881

881882
ret = setup_purgatory(image, slave_code, fdt, kernel_load_addr,
@@ -903,9 +904,28 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code,
903904
&image->arch.backup_start,
904905
sizeof(image->arch.backup_start),
905906
false);
907+
if (ret)
908+
goto out;
909+
910+
/* Setup OPAL base & entry values */
911+
dn = of_find_node_by_path("/ibm,opal");
912+
if (dn) {
913+
u64 val;
914+
915+
of_property_read_u64(dn, "opal-base-address", &val);
916+
ret = kexec_purgatory_get_set_symbol(image, "opal_base", &val,
917+
sizeof(val), false);
918+
if (ret)
919+
goto out;
920+
921+
of_property_read_u64(dn, "opal-entry-address", &val);
922+
ret = kexec_purgatory_get_set_symbol(image, "opal_entry", &val,
923+
sizeof(val), false);
924+
}
906925
out:
907926
if (ret)
908927
pr_err("Failed to setup purgatory symbols");
928+
of_node_put(dn);
909929
return ret;
910930
}
911931

arch/powerpc/purgatory/trampoline_64.S

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ master:
8787
li %r4,28
8888
STWX_BE %r17,%r3,%r4 /* Store my cpu as __be32 at byte 28 */
8989
1:
90+
/* Load opal base and entry values in r8 & r9 respectively */
91+
ld %r8,(opal_base - 0b)(%r18)
92+
ld %r9,(opal_entry - 0b)(%r18)
93+
9094
/* load the kernel address */
9195
ld %r4,(kernel - 0b)(%r18)
9296

@@ -133,6 +137,18 @@ backup_start:
133137
.8byte 0x0
134138
.size backup_start, . - backup_start
135139

140+
.balign 8
141+
.globl opal_base
142+
opal_base:
143+
.8byte 0x0
144+
.size opal_base, . - opal_base
145+
146+
.balign 8
147+
.globl opal_entry
148+
opal_entry:
149+
.8byte 0x0
150+
.size opal_entry, . - opal_entry
151+
136152
.data
137153
.balign 8
138154
.globl purgatory_sha256_digest

0 commit comments

Comments
 (0)