Skip to content

Commit

Permalink
Add function to find if host is transitioning to PHYP
Browse files Browse the repository at this point in the history
Utilizing the xyz.openbmc_project.State.Host interface to ascertain the
host's operational status becomes less accurate when transitioning from
hostboot to PHYP. During the period when PHYP is initializing and not
yet fully operational, the host state is erroneously presumed to be in
hostboot. In situations where PHYP encounters initial boot difficulties
and activates a watchdog timer, this watchdog misinterprets the issue as
a problem with hostboot.

To address this, there exists a core scratch register that undergoes an
update by hostboot just before transferring control to PHYP. We have
devised a method that leverages this register to determine whether the
transition to PHYP has already occurred.

By implementing this functionality, we can accurately determine whether
control has transitioned to PHYP, allowing for more precise reporting of
the host's state.

Signed-off-by: Deepa Karthikeyan <[email protected]>
  • Loading branch information
deepakala-k committed Sep 27, 2023
1 parent 668c4b0 commit 614d607
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libphal/libphal.H
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ void putCFAM(struct pdbg_target *proc, const uint32_t addr, const uint32_t val);
*/
bool isSbeVitalAttnActive(struct pdbg_target *proc);

/**
* @brief Check if Hostboot has completed and the control transistioned to PHYP
*
* @return true when we have moved to PHYP
*/
bool hasControlTransitionedToPHYP();

} // namespace pdbg

namespace dump
Expand Down
27 changes: 27 additions & 0 deletions libphal/phal_pdbg.C
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,31 @@ bool isSbeVitalAttnActive(struct pdbg_target *proc)
return validAttn;
}

bool hasControlTransitionedToPHYP()
{
// If unable to read the register, by default consider the control is in hostboot
bool transitionedToPHYP = false;
//Read the scratch register to find if the host is transitioned to phyp
pdbg_target* pibTarget = pdbg_target_from_path(nullptr, "/proc0/pib");

uint64_t l_coreScratchRegData = 0xFFFFFFFFFFFFFFFFull;
// HB changes the below core scratch reg as one of the last instructions that is run,
// so if that is zero then we're in phyp
uint64_t l_coreScratchRegAddr = 0x4602F489;

// Is there any error in reading the scom address, assign default value to data
if (0 != pib_read(pibTarget, l_coreScratchRegAddr, &l_coreScratchRegData))
{
log(level::ERROR, "scom read error: 0x%X", l_coreScratchRegAddr );
l_coreScratchRegData = 0xFFFFFFFFFFFFFFFFull;
}

// If the register reads zero, return control moved to phyp.
if(l_coreScratchRegData == 0)
{
transitionedToPHYP = true;
}
return transitionedToPHYP;
}

} // namespace openpower::phal::pdbg

0 comments on commit 614d607

Please sign in to comment.