From: Mahesh Jagannath Salgaonkar <mahesh@linux.vnet.ibm.com>
To: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
horms@verge.net.au, kexec@lists.infradead.org
Subject: Re: [PATCH] kexec/ppc64 Enable early kernel's OPAL calls
Date: Fri, 31 Jan 2014 08:24:21 +0530 [thread overview]
Message-ID: <52EB105D.2060907@linux.vnet.ibm.com> (raw)
In-Reply-To: <20140124141614.6404.37733.stgit@nimbus>
On 01/24/2014 07:46 PM, Laurent Dufour wrote:
> When the kernel is built with CONFIG_PPC_EARLY_DEBUG_OPAL set, it is
> expecting to get r8 and r9 filled respectively with OPAL base address and
> OPAL entry address (arc/power/head_64.S).
>
> On the new powernv platform, having these 2 registers set allows the kernel
> to perform OPAL calls before it parse the device tree.
>
> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Tested-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
> ---
> kexec/arch/ppc64/kexec-elf-ppc64.c | 43 ++++++++++++++++++++++++++++++++
> purgatory/arch/ppc64/purgatory-ppc64.c | 2 +
> purgatory/arch/ppc64/v2wrap.S | 4 +++
> 3 files changed, 49 insertions(+)
>
> diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c
> index 7d49d8a..ce10367 100644
> --- a/kexec/arch/ppc64/kexec-elf-ppc64.c
> +++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
> @@ -71,6 +71,26 @@ void arch_reuse_initrd(void)
> reuse_initrd = 1;
> }
>
> +static int read_prop(char *name, void *value, size_t len)
> +{
> + int fd;
> + size_t rlen;
> +
> + fd = open(name, O_RDONLY);
> + if (fd == -1)
> + return -1;
> +
> + rlen = read(fd, value, len);
> + if (rlen < 0)
> + fprintf(stderr, "Warning : Can't read %s : %s",
> + name, strerror(errno));
> + else if (rlen != len)
> + fprintf(stderr, "Warning : short read from %s", name);
> +
> + close(fd);
> + return 0;
> +}
> +
> int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
> struct kexec_info *info)
> {
> @@ -90,6 +110,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
> int i;
> int result, opt;
> uint64_t my_kernel, my_dt_offset;
> + uint64_t my_opal_base = 0, my_opal_entry = 0;
> unsigned int my_panic_kernel;
> uint64_t my_stack, my_backup_start;
> uint64_t toc_addr;
> @@ -246,6 +267,20 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
> *rsvmap_ptr = cpu_to_be64((uint64_t)be32_to_cpu(bb_ptr->totalsize));
> #endif
>
> + if (read_prop("/proc/device-tree/ibm,opal/opal-base-address",
> + &my_opal_base, sizeof(my_opal_base)) == 0) {
> + my_opal_base = be64_to_cpu(my_opal_base);
> + elf_rel_set_symbol(&info->rhdr, "opal_base",
> + &my_opal_base, sizeof(my_opal_base));
> + }
> +
> + if (read_prop("/proc/device-tree/ibm,opal/opal-entry-address",
> + &my_opal_entry, sizeof(my_opal_entry)) == 0) {
> + my_opal_entry = be64_to_cpu(my_opal_entry);
> + elf_rel_set_symbol(&info->rhdr, "opal_entry",
> + &my_opal_entry, sizeof(my_opal_entry));
> + }
> +
> /* Set kernel */
> elf_rel_set_symbol(&info->rhdr, "kernel", &my_kernel, sizeof(my_kernel));
>
> @@ -306,7 +341,13 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
> toc_addr = 0;
> my_run_at_load = 0;
> my_debug = 0;
> + my_opal_base = 0;
> + my_opal_entry = 0;
>
> + elf_rel_get_symbol(&info->rhdr, "opal_base", &my_opal_base,
> + sizeof(my_opal_base));
> + elf_rel_get_symbol(&info->rhdr, "opal_entry", &my_opal_entry,
> + sizeof(my_opal_entry));
> elf_rel_get_symbol(&info->rhdr, "kernel", &my_kernel, sizeof(my_kernel));
> elf_rel_get_symbol(&info->rhdr, "dt_offset", &my_dt_offset,
> sizeof(my_dt_offset));
> @@ -333,6 +374,8 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
> dbgprintf("toc_addr is %llx\n", (unsigned long long)toc_addr);
> dbgprintf("purgatory size is %zu\n", purgatory_size);
> dbgprintf("debug is %d\n", my_debug);
> + dbgprintf("opal_base is %llx\n", (unsigned long long) my_opal_base);
> + dbgprintf("opal_entry is %llx\n", (unsigned long long) my_opal_entry);
>
> for (i = 0; i < info->nr_segments; i++)
> fprintf(stderr, "segment[%d].mem:%p memsz:%zu\n", i,
> diff --git a/purgatory/arch/ppc64/purgatory-ppc64.c b/purgatory/arch/ppc64/purgatory-ppc64.c
> index 0b6d326..7248ac8 100644
> --- a/purgatory/arch/ppc64/purgatory-ppc64.c
> +++ b/purgatory/arch/ppc64/purgatory-ppc64.c
> @@ -29,6 +29,8 @@ unsigned long dt_offset = 0;
> unsigned long my_toc = 0;
> unsigned long kernel = 0;
> unsigned int debug = 0;
> +unsigned long opal_base = 0;
> +unsigned long opal_entry = 0;
>
> void setup_arch(void)
> {
> diff --git a/purgatory/arch/ppc64/v2wrap.S b/purgatory/arch/ppc64/v2wrap.S
> index 2761c14..6fc62e3 100644
> --- a/purgatory/arch/ppc64/v2wrap.S
> +++ b/purgatory/arch/ppc64/v2wrap.S
> @@ -95,6 +95,10 @@ master:
> blt 80f
> stw 17,28(3) # save my cpu number as boot_cpu_phys
> 80:
> + LOADADDR(6,opal_base) # For OPAL early debug
> + ld 8,0(6) # load the OPAL base address in r8
> + LOADADDR(6,opal_entry) # For OPAL early debug
> + ld 9,0(6) # load the OPAL entry address in r9
> LOADADDR(6,kernel)
> ld 4,0(6) # load the kernel address
> LOADADDR(6,run_at_load) # the load flag
>
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2014-01-31 2:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-24 14:16 [PATCH] kexec/ppc64 Enable early kernel's OPAL calls Laurent Dufour
2014-01-31 2:54 ` Mahesh Jagannath Salgaonkar [this message]
2014-02-04 9:01 ` Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52EB105D.2060907@linux.vnet.ibm.com \
--to=mahesh@linux.vnet.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=horms@verge.net.au \
--cc=kexec@lists.infradead.org \
--cc=ldufour@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox