Skip to content

Commit

Permalink
libphal: Add method to find if control transitioned to host
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 host. During the period when host is initializing and not
yet fully operational, the host state is erroneously presumed to be in
hostboot. In situations where host encounters initial boot difficulties,
and the watchdog time is hit as the boot up process has not completed
within a specific time, 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 host. We have
devised a method that leverages this register to determine whether the
transition to host has already occurred.

By implementing this functionality we can determine which booting
subsystem is failed or stopped responding, and the dump can be extracted
from the right subsystem.

Signed-off-by: Deepa Karthikeyan <[email protected]>
  • Loading branch information
deepakala-k committed Oct 4, 2023
1 parent 668c4b0 commit eb51677
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libphal/libphal.H
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ 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
* Host
*
* @return true when we have moved to host
* @return false if there is any error in reading the scom address,
* consider control still in hostboot
*/
bool hasControlTransitionedToHost();

} // namespace pdbg

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

bool hasControlTransitionedToHost()
{
// Read the scratch register to find if the control has moved to host
auto 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 host (hypervisor)
uint64_t l_coreScratchRegAddr = 0x4602F489;

// Is there any error in reading the scom address, consider control is
// in hostboot
if (pib_read(pibTarget, l_coreScratchRegAddr, &l_coreScratchRegData)) {
// If unable to read the register, by default consider the
// control is in hostboot
log(level::ERROR, "scom read error: 0x%X",
l_coreScratchRegAddr);
return false;
}

// If the register reads zero, return control moved to host.
return (l_coreScratchRegData == 0);
}

} // namespace openpower::phal::pdbg

0 comments on commit eb51677

Please sign in to comment.