drivers/crypto/ccree/cc_fips.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccree/cc_fips.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccree/cc_fips.c- Extension
.c- Size
- 3845 bytes
- Lines
- 155
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/fips.hlinux/notifier.hcc_driver.hcc_fips.h
Detected Declarations
struct cc_fips_handlefunction cc_get_tee_fips_statusfunction cc_set_ree_fips_statusfunction cc_ree_fips_failurefunction cc_fips_finifunction fips_handlerfunction tee_fips_errorfunction cc_tee_handle_fips_errorfunction fips_dsrfunction cc_fips_init
Annotated Snippet
struct cc_fips_handle {
struct tasklet_struct tasklet;
struct notifier_block nb;
struct cc_drvdata *drvdata;
};
/* The function called once at driver entry point to check
* whether TEE FIPS error occurred.
*/
static bool 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 */
return true;
}
/*
* 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 */
static int cc_ree_fips_failure(struct notifier_block *nb, unsigned long 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");
return NOTIFY_OK;
}
void cc_fips_fini(struct cc_drvdata *drvdata)
{
struct cc_fips_handle *fips_h = drvdata->fips_handle;
if (drvdata->hw_rev < CC_HW_REV_712 || !fips_h)
return;
atomic_notifier_chain_unregister(&fips_fail_notif_chain, &fips_h->nb);
/* Kill tasklet */
tasklet_kill(&fips_h->tasklet);
drvdata->fips_handle = NULL;
}
void fips_handler(struct cc_drvdata *drvdata)
{
struct cc_fips_handle *fips_handle_ptr = drvdata->fips_handle;
if (drvdata->hw_rev < CC_HW_REV_712)
return;
tasklet_schedule(&fips_handle_ptr->tasklet);
}
static inline void 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
*/
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/fips.h`, `linux/notifier.h`, `cc_driver.h`, `cc_fips.h`.
- Detected declarations: `struct cc_fips_handle`, `function cc_get_tee_fips_status`, `function cc_set_ree_fips_status`, `function cc_ree_fips_failure`, `function cc_fips_fini`, `function fips_handler`, `function tee_fips_error`, `function cc_tee_handle_fips_error`, `function fips_dsr`, `function cc_fips_init`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.