/* The function called once at driver entry point to check * whether TEE FIPS error occurred.
*/ staticbool cc_get_tee_fips_status(struct cc_drvdata *drvdata)
{
u32 reg;
reg = cc_ioread(drvdata, CC_REG(GPR_HOST)); /* Did the TEE report status? */ if (reg & CC_FIPS_SYNC_TEE_STATUS) /* Yes. Is it OK? */ return (reg & CC_FIPS_SYNC_MODULE_OK);
/* No. It's either not in use or will be reported later */ returntrue;
}
/* * This function should push the FIPS REE library status towards the TEE library * by writing the error state to HOST_GPR0 register.
*/ void cc_set_ree_fips_status(struct cc_drvdata *drvdata, bool status)
{ int val = CC_FIPS_SYNC_REE_STATUS;
if (drvdata->hw_rev < CC_HW_REV_712) return;
val |= (status ? CC_FIPS_SYNC_MODULE_OK : CC_FIPS_SYNC_MODULE_ERROR);
cc_iowrite(drvdata, CC_REG(HOST_GPR0), val);
}
/* Push REE side FIPS test failure to TEE side */ staticint cc_ree_fips_failure(struct notifier_block *nb, unsignedlong unused1, void *unused2)
{ struct cc_fips_handle *fips_h =
container_of(nb, struct cc_fips_handle, nb); struct cc_drvdata *drvdata = fips_h->drvdata; struct device *dev = drvdata_to_dev(drvdata);
cc_set_ree_fips_status(drvdata, false);
dev_info(dev, "Notifying TEE of FIPS test failure...\n");
staticinlinevoid tee_fips_error(struct device *dev)
{ if (fips_enabled)
panic("ccree: TEE reported cryptographic error in fips mode!\n"); else
dev_err(dev, "TEE reported error!\n");
}
/* * This function check if cryptocell tee fips error occurred * and in such case triggers system error
*/ void cc_tee_handle_fips_error(struct cc_drvdata *p_drvdata)
{ struct device *dev = drvdata_to_dev(p_drvdata);
if (!cc_get_tee_fips_status(p_drvdata))
tee_fips_error(dev);
}
/* Deferred service handler, run as interrupt-fired tasklet */ staticvoid fips_dsr(unsignedlong devarg)
{ struct cc_drvdata *drvdata = (struct cc_drvdata *)devarg;
u32 irq, val;
irq = (drvdata->irq & (CC_GPR0_IRQ_MASK));
if (irq) {
cc_tee_handle_fips_error(drvdata);
}
/* after verifying that there is nothing to do, * unmask AXI completion interrupt.
*/
val = (CC_REG(HOST_IMR) & ~irq);
cc_iowrite(drvdata, CC_REG(HOST_IMR), val);
}
/* The function called once at driver entry point .*/ int cc_fips_init(struct cc_drvdata *p_drvdata)
{ struct cc_fips_handle *fips_h; struct device *dev = drvdata_to_dev(p_drvdata);
if (p_drvdata->hw_rev < CC_HW_REV_712) return 0;
fips_h = devm_kzalloc(dev, sizeof(*fips_h), GFP_KERNEL); if (!fips_h) return -ENOMEM;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.