arch/s390/crypto/prng.c
Source file repositories/reference/linux-study-clean/arch/s390/crypto/prng.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/crypto/prng.c- Extension
.c- Size
- 24532 bytes
- Lines
- 911
- Domain
- Architecture Layer
- Bucket
- arch/s390
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern 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 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.
- 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/fs.hlinux/fips.hlinux/init.hlinux/kernel.hlinux/device.hlinux/miscdevice.hlinux/module.hlinux/moduleparam.hlinux/mutex.hlinux/cpufeature.hlinux/random.hlinux/slab.hlinux/sched/signal.hasm/debug.hlinux/uaccess.hasm/timex.hasm/cpacf.h
Detected Declarations
struct prng_ws_sstruct prno_ws_sstruct prng_data_sfunction stckffunction prng_tdes_add_entropyfunction prng_tdes_seedfunction prng_tdes_instantiatefunction prng_tdes_deinstantiatefunction prng_sha512_selftestfunction prng_sha512_instantiatefunction prng_sha512_deinstantiatefunction prng_sha512_reseedfunction prng_sha512_generatefunction prng_openfunction prng_tdes_readfunction prng_sha512_readfunction prng_chunksize_showfunction prng_counter_showfunction prng_errorflag_showfunction prng_mode_showfunction prng_reseed_storefunction prng_reseed_limit_showfunction prng_reseed_limit_storefunction prng_strength_showfunction prng_initfunction prng_exit
Annotated Snippet
static const struct file_operations prng_sha512_fops = {
.owner = THIS_MODULE,
.open = &prng_open,
.release = NULL,
.read = &prng_sha512_read,
.llseek = noop_llseek,
};
static const struct file_operations prng_tdes_fops = {
.owner = THIS_MODULE,
.open = &prng_open,
.release = NULL,
.read = &prng_tdes_read,
.llseek = noop_llseek,
};
/* chunksize attribute (ro) */
static ssize_t prng_chunksize_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
return sysfs_emit(buf, "%u\n", prng_chunk_size);
}
static DEVICE_ATTR(chunksize, 0444, prng_chunksize_show, NULL);
/* counter attribute (ro) */
static ssize_t prng_counter_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
u64 counter;
if (mutex_lock_interruptible(&prng_data->mutex))
return -ERESTARTSYS;
if (prng_mode == PRNG_MODE_SHA512)
counter = prng_data->prnows.stream_bytes;
else
counter = prng_data->prngws.byte_counter;
mutex_unlock(&prng_data->mutex);
return sysfs_emit(buf, "%llu\n", counter);
}
static DEVICE_ATTR(byte_counter, 0444, prng_counter_show, NULL);
/* errorflag attribute (ro) */
static ssize_t prng_errorflag_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
return sysfs_emit(buf, "%d\n", prng_errorflag);
}
static DEVICE_ATTR(errorflag, 0444, prng_errorflag_show, NULL);
/* mode attribute (ro) */
static ssize_t prng_mode_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
if (prng_mode == PRNG_MODE_TDES)
return sysfs_emit(buf, "TDES\n");
else
return sysfs_emit(buf, "SHA512\n");
}
static DEVICE_ATTR(mode, 0444, prng_mode_show, NULL);
/* reseed attribute (w) */
static ssize_t prng_reseed_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
if (mutex_lock_interruptible(&prng_data->mutex))
return -ERESTARTSYS;
prng_sha512_reseed();
mutex_unlock(&prng_data->mutex);
return count;
}
static DEVICE_ATTR(reseed, 0200, NULL, prng_reseed_store);
/* reseed limit attribute (rw) */
static ssize_t prng_reseed_limit_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
return sysfs_emit(buf, "%u\n", prng_reseed_limit);
}
static ssize_t prng_reseed_limit_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
unsigned limit;
Annotation
- Immediate include surface: `linux/fs.h`, `linux/fips.h`, `linux/init.h`, `linux/kernel.h`, `linux/device.h`, `linux/miscdevice.h`, `linux/module.h`, `linux/moduleparam.h`.
- Detected declarations: `struct prng_ws_s`, `struct prno_ws_s`, `struct prng_data_s`, `function stckf`, `function prng_tdes_add_entropy`, `function prng_tdes_seed`, `function prng_tdes_instantiate`, `function prng_tdes_deinstantiate`, `function prng_sha512_selftest`, `function prng_sha512_instantiate`.
- Atlas domain: Architecture Layer / arch/s390.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.