arch/powerpc/platforms/pseries/plpks_sed_ops.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/pseries/plpks_sed_ops.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/pseries/plpks_sed_ops.c- Extension
.c- Size
- 3113 bytes
- Lines
- 132
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/slab.hlinux/string.hlinux/ioctl.hlinux/sed-opal-key.hasm/plpks.h
Detected Declarations
struct plpks_sed_object_datafunction plpks_init_varfunction sed_read_keyfunction sed_write_key
Annotated Snippet
struct plpks_sed_object_data {
u_char version;
u_char pad1[7];
u_long authority;
u_long range;
u_int key_len;
u_char key[32];
};
#define PLPKS_SED_OBJECT_DATA_V0 0
#define PLPKS_SED_MANGLED_LABEL "/default/pri"
#define PLPKS_SED_COMPONENT "sed-opal"
#define PLPKS_SED_KEY "opal-boot-pin"
/*
* authority is admin1 and range is global
*/
#define PLPKS_SED_AUTHORITY 0x0000000900010001
#define PLPKS_SED_RANGE 0x0000080200000001
static void plpks_init_var(struct plpks_var *var, char *keyname)
{
if (!plpks_sed_initialized) {
plpks_sed_initialized = true;
plpks_sed_available = plpks_is_available();
if (!plpks_sed_available)
pr_err("SED: plpks not available\n");
}
var->name = keyname;
var->namelen = strlen(keyname);
if (strcmp(PLPKS_SED_KEY, keyname) == 0) {
var->name = PLPKS_SED_MANGLED_LABEL;
var->namelen = strlen(keyname);
}
var->policy = PLPKS_WORLDREADABLE;
var->os = PLPKS_VAR_COMMON;
var->data = NULL;
var->datalen = 0;
var->component = PLPKS_SED_COMPONENT;
}
/*
* Read the SED Opal key from PLPKS given the label
*/
int sed_read_key(char *keyname, char *key, u_int *keylen)
{
struct plpks_var var;
struct plpks_sed_object_data data;
int ret;
u_int len;
plpks_init_var(&var, keyname);
if (!plpks_sed_available)
return -EOPNOTSUPP;
var.data = (u8 *)&data;
var.datalen = sizeof(data);
ret = plpks_read_os_var(&var);
if (ret != 0)
return ret;
len = min_t(u16, be32_to_cpu(data.key_len), var.datalen);
memcpy(key, data.key, len);
key[len] = '\0';
*keylen = len;
return 0;
}
/*
* Write the SED Opal key to PLPKS given the label
*/
int sed_write_key(char *keyname, char *key, u_int keylen)
{
struct plpks_var var;
struct plpks_sed_object_data data;
struct plpks_var_name vname;
plpks_init_var(&var, keyname);
if (!plpks_sed_available)
return -EOPNOTSUPP;
var.datalen = sizeof(struct plpks_sed_object_data);
var.data = (u8 *)&data;
/* initialize SED object */
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/string.h`, `linux/ioctl.h`, `linux/sed-opal-key.h`, `asm/plpks.h`.
- Detected declarations: `struct plpks_sed_object_data`, `function plpks_init_var`, `function sed_read_key`, `function sed_write_key`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
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.