Skip to content

Commit

Permalink
SBE: Send OPAL relocated base address to SBE
Browse files Browse the repository at this point in the history
OPAL relocates itself during boot. During memory preserving IPL hostboot needs
to access relocated OPAL base address to get MDST, MDDT tables. Hence send
relocated base address to SBE via 'stash MPIPL config' chip-op. During next
IPL SBE will send stashed data to hostboot... so that hostboot can access
these data.

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
[oliver: rebased]
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
  • Loading branch information
Vasant Hegde authored and oohal committed Aug 15, 2019
1 parent 8d0c8ae commit 166eda4
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/opal-dump.c
Expand Up @@ -23,6 +23,7 @@
#include <opal.h>
#include <opal-dump.h>
#include <opal-internal.h>
#include <sbe-p9.h>
#include <skiboot.h>

#include <ccan/endian/endian.h>
Expand Down Expand Up @@ -361,6 +362,9 @@ void opal_mpipl_init(void)

opal_mpipl_register();

/* Send OPAL relocated base address to SBE */
p9_sbe_send_relocated_base(SKIBOOT_BASE);

/* OPAL API for MPIPL update */
opal_register(OPAL_MPIPL_UPDATE, opal_mpipl_update, 4);
opal_register(OPAL_MPIPL_REGISTER_TAG, opal_mpipl_register_tag, 2);
Expand Down
48 changes: 48 additions & 0 deletions hw/sbe-p9.c
Expand Up @@ -851,6 +851,54 @@ bool p9_sbe_timer_ok(void)
return sbe_has_timer;
}

static void p9_sbe_stash_chipop_resp(struct p9_sbe_msg *msg)
{
int rc = p9_sbe_get_primary_rc(msg->resp);
struct p9_sbe *sbe = (void *)msg->user_data;

if (rc == SBE_STATUS_PRI_SUCCESS) {
prlog(PR_DEBUG, "Sent stash MPIPL config [chip id =0x%x]\n",
sbe->chip_id);
} else {
prlog(PR_ERR, "Failed to send stash MPIPL config "
"[chip id = 0x%x, rc = %d]\n", sbe->chip_id, rc);
}

p9_sbe_freemsg(msg);
}

static void p9_sbe_send_relocated_base_single(struct p9_sbe *sbe, u64 reloc_base)
{
u8 key = SBE_STASH_KEY_SKIBOOT_BASE;
u16 cmd = SBE_CMD_STASH_MPIPL_CONFIG;
u16 flag = SBE_CMD_CTRL_RESP_REQ;
struct p9_sbe_msg *msg;

msg = p9_sbe_mkmsg(cmd, flag, key, reloc_base, 0);
if (!msg) {
prlog(PR_ERR, "Message allocation failed\n");
return;
}

msg->user_data = (void *)sbe;
if (p9_sbe_queue_msg(sbe->chip_id, msg, p9_sbe_stash_chipop_resp)) {
prlog(PR_ERR, "Failed to queue stash MPIPL config message\n");
}
}

/* Send relocated skiboot base address to all SBE */
void p9_sbe_send_relocated_base(uint64_t reloc_base)
{
struct proc_chip *chip;

for_each_chip(chip) {
if (chip->sbe == NULL)
continue;

p9_sbe_send_relocated_base_single(chip->sbe, reloc_base);
}
}

void p9_sbe_init(void)
{
struct dt_node *xn;
Expand Down
6 changes: 6 additions & 0 deletions include/sbe-p9.h
Expand Up @@ -146,6 +146,9 @@
#define CONTROL_TIMER_START 0x0001
#define CONTROL_TIMER_STOP 0x0002

/* Stash MPIPL config */
#define SBE_STASH_KEY_SKIBOOT_BASE 0x03

/* SBE message state */
enum p9_sbe_msg_state {
sbe_msg_unused = 0, /* Free */
Expand Down Expand Up @@ -224,4 +227,7 @@ extern bool p9_sbe_timer_ok(void);
/* Update SBE timer expiry */
extern void p9_sbe_update_timer_expiry(uint64_t new_target);

/* Send skiboot relocated base address to SBE */
extern void p9_sbe_send_relocated_base(uint64_t reloc_base);

#endif /* __SBE_P9_H */

0 comments on commit 166eda4

Please sign in to comment.