drivers/platform/x86/amd/pmf/tee-if.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/amd/pmf/tee-if.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/amd/pmf/tee-if.c- Extension
.c- Size
- 16439 bytes
- Lines
- 626
- Domain
- Driver Families
- Bucket
- drivers/platform
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/debugfs.hlinux/tee_drv.hlinux/uuid.hpmf.h
Detected Declarations
function amd_pmf_prepare_argsfunction amd_pmf_update_ueventsfunction amd_pmf_get_bios_output_idxfunction amd_pmf_update_bios_outputfunction amd_pmf_apply_policiesfunction amd_pmf_invoke_cmd_enactfunction amd_pmf_invoke_cmd_initfunction amd_pmf_invoke_cmdfunction amd_pmf_start_policy_enginefunction amd_pmf_pb_validfunction amd_pmf_hex_dump_pbfunction amd_pmf_get_pb_datafunction amd_pmf_open_pbfunction amd_pmf_remove_pbfunction amd_pmf_open_pbfunction amd_pmf_ta_open_sessionfunction amd_pmf_register_input_devicefunction amd_pmf_tee_initfunction amd_pmf_tee_deinitfunction amd_pmf_init_smart_pcfunction amd_pmf_deinit_smart_pc
Annotated Snippet
static const struct file_operations pb_fops = {
.write = amd_pmf_get_pb_data,
.open = simple_open,
};
static void amd_pmf_open_pb(struct amd_pmf_dev *dev, struct dentry *debugfs_root)
{
dev->esbin = debugfs_create_dir("pb", debugfs_root);
debugfs_create_file("update_policy", 0644, dev->esbin, dev, &pb_fops);
}
static void amd_pmf_remove_pb(struct amd_pmf_dev *dev)
{
debugfs_remove_recursive(dev->esbin);
}
#else
static void amd_pmf_open_pb(struct amd_pmf_dev *dev, struct dentry *debugfs_root) {}
static void amd_pmf_remove_pb(struct amd_pmf_dev *dev) {}
static void amd_pmf_hex_dump_pb(struct amd_pmf_dev *dev) {}
#endif
static int amd_pmf_amdtee_ta_match(struct tee_ioctl_version_data *ver, const void *data)
{
return ver->impl_id == TEE_IMPL_ID_AMDTEE;
}
static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id, const uuid_t *uuid)
{
struct tee_ioctl_open_session_arg sess_arg = {};
int rc;
export_uuid(sess_arg.uuid, uuid);
sess_arg.clnt_login = TEE_IOCTL_LOGIN_PUBLIC;
sess_arg.num_params = 0;
rc = tee_client_open_session(ctx, &sess_arg, NULL);
if (rc < 0 || sess_arg.ret != 0) {
pr_err("Failed to open TEE session err:%#x, rc:%d\n", sess_arg.ret, rc);
return rc ?: -EINVAL;
}
*id = sess_arg.session;
return 0;
}
static int amd_pmf_register_input_device(struct amd_pmf_dev *dev)
{
int err;
dev->pmf_idev = devm_input_allocate_device(dev->dev);
if (!dev->pmf_idev)
return -ENOMEM;
dev->pmf_idev->name = "PMF-TA output events";
dev->pmf_idev->phys = "amd-pmf/input0";
input_set_capability(dev->pmf_idev, EV_KEY, KEY_SLEEP);
input_set_capability(dev->pmf_idev, EV_KEY, KEY_SCREENLOCK);
input_set_capability(dev->pmf_idev, EV_KEY, KEY_SUSPEND);
err = input_register_device(dev->pmf_idev);
if (err) {
dev_err(dev->dev, "Failed to register input device: %d\n", err);
return err;
}
return 0;
}
int amd_pmf_tee_init(struct amd_pmf_dev *dev, const uuid_t *uuid)
{
u32 size;
int ret;
dev->tee_ctx = tee_client_open_context(NULL, amd_pmf_amdtee_ta_match, NULL, NULL);
if (IS_ERR(dev->tee_ctx)) {
dev_err(dev->dev, "Failed to open TEE context\n");
ret = PTR_ERR(dev->tee_ctx);
dev->tee_ctx = NULL;
return ret;
}
ret = amd_pmf_ta_open_session(dev->tee_ctx, &dev->session_id, uuid);
if (ret) {
dev_err(dev->dev, "Failed to open TA session (%d)\n", ret);
ret = -EINVAL;
goto out_ctx;
}
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/tee_drv.h`, `linux/uuid.h`, `pmf.h`.
- Detected declarations: `function amd_pmf_prepare_args`, `function amd_pmf_update_uevents`, `function amd_pmf_get_bios_output_idx`, `function amd_pmf_update_bios_output`, `function amd_pmf_apply_policies`, `function amd_pmf_invoke_cmd_enact`, `function amd_pmf_invoke_cmd_init`, `function amd_pmf_invoke_cmd`, `function amd_pmf_start_policy_engine`, `function amd_pmf_pb_valid`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.