arch/riscv/include/asm/archrandom.h

Source file repositories/reference/linux-study-clean/arch/riscv/include/asm/archrandom.h

File Facts

System
Linux kernel
Corpus path
arch/riscv/include/asm/archrandom.h
Extension
.h
Size
1534 bytes
Lines
73
Domain
Architecture Layer
Bucket
arch/riscv
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.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (opst) {
		case SEED_OPST_ES16:
			entropy[valid_seeds++] = csr_seed & SEED_ENTROPY_MASK;
			if (valid_seeds == needed_seeds)
				return true;
			break;

		case SEED_OPST_DEAD:
			pr_err_once("archrandom: Unrecoverable error\n");
			return false;

		case SEED_OPST_BIST:
		case SEED_OPST_WAIT:
		default:
			cpu_relax();
			continue;
		}
	} while (--retry);

	return false;
}

static inline size_t __must_check arch_get_random_longs(unsigned long *v, size_t max_longs)
{
	return 0;
}

static inline size_t __must_check arch_get_random_seed_longs(unsigned long *v, size_t max_longs)
{
	if (!max_longs)
		return 0;

	/*
	 * If Zkr is supported and csr_seed_long succeeds, we return one long
	 * worth of entropy.
	 */
	if (riscv_has_extension_likely(RISCV_ISA_EXT_ZKR) && csr_seed_long(v))
		return 1;

	return 0;
}

#endif /* ASM_RISCV_ARCHRANDOM_H */

Annotation

Implementation Notes