[Skiboot] [PATCH 03/19] hdata/tpmrel.c: add firmware event log info to the tpm node
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Tue Nov 28 17:26:57 AEDT 2017
On 11/11/2017 10:58 PM, Claudio Carvalho wrote:
> This parses the firmware event log information from the
> secureboot_tpm_info HDAT structure and add it to the tpm device tree
> node.
>
> There can be multiple secureboot_tpm_info entries with each entry
> corresponding to a master processor that has a tpm device, however,
> multiple tpm is not supported.
>
> Signed-off-by: Claudio Carvalho <cclaudio at linux.vnet.ibm.com>
> ---
> hdata/Makefile.inc | 2 +-
> hdata/hdata.h | 1 +
> hdata/spira.c | 3 ++
> hdata/spira.h | 33 ++++++++++++++++++
> hdata/test/hdata_to_dt.c | 1 +
> hdata/tpmrel.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++
> 6 files changed, 129 insertions(+), 1 deletion(-)
> create mode 100644 hdata/tpmrel.c
>
.../...
> +
> +static void tpmrel_add_firmware_event_log(const struct HDIF_common_hdr *hdif_hdr)
> +{
> + const struct secureboot_tpm_info *stinfo;
> + struct dt_node *xscom, *node;
> + uint64_t addr;
> + bool tpmfound = false;
> + int count, i;
> +
> + count = HDIF_get_iarray_size(hdif_hdr, TPMREL_IDATA_SECUREBOOT_TPM_INFO);
> + if (count > 1) {
> + prlog(PR_ERR, "multinode not supported, count=%d\n", count);
> + return;
> + }
> +
> + for (i = 0; i < count; i++) {
> +
> + stinfo = HDIF_get_iarray_item(hdif_hdr,
> + TPMREL_IDATA_SECUREBOOT_TPM_INFO,
> + i, NULL);
Again don't trust HDAT too much. Please check whether stinfo got valid data or not.
> +
> + xscom = find_xscom_for_chip(be32_to_cpu(stinfo->chip_id));
> + if (xscom) {
> + dt_for_each_node(xscom, node) {
> + if (dt_has_node_property(node, "label", "tpm")) {
> + tpmfound=true;
> + addr = (uint64_t) stinfo +
> + be32_to_cpu(stinfo->srtm_log_offset);
> + dt_add_property_u64s(node, "linux,sml-base", addr);
> + dt_add_property_cells(node, "linux,sml-size",
> + be32_to_cpu(stinfo->srtm_log_size));
> + break;
> + }
> + }
> + if (!tpmfound &&
> + stinfo->tpm_status == TPM_PRESENT_AND_FUNCTIONAL) {
> + prlog(PR_ERR, "TPM functional but not found "
> + "for chip_id=%d.\n", stinfo->chip_id);
> + continue;
> + }
> + } else {
> + prlog(PR_ERR, "could not add TPM device, chip_id=%d "
> + "invalid\n", stinfo->chip_id);
> + continue;
> + }
> + }
> +}
> +
> +void node_stb_parse(void)
> +{
> + struct HDIF_common_hdr *hdif_hdr;
> +
> + /* TPMREL exists only on POWER9 and above */
> + if (proc_gen < proc_gen_p9)
> + return;
> +
> + hdif_hdr = get_hdif(&spira.ntuples.node_stb_data, "TPMREL");
> + if (!hdif_hdr) {
> + prlog(PR_DEBUG, "could not find TPMREL data\n");
> + return;
Coding style issue.
-Vasant
More information about the Skiboot
mailing list