remarkable-linux/arch/mips/kernel
Maciej W. Rozycki 06947aaaf9 MIPS: Implement random_get_entropy with CP0 Random
Update to commit 9c9b415c50 [MIPS:
Reimplement get_cycles().]

On systems were for whatever reasons we can't use the cycle counter, fall
back to the c0_random register as an entropy source.  It has however a
very small range that makes it suitable for random_get_entropy only and
not get_cycles.

This optimised version compiles to 8 instructions in the fast path even in
the worst case of all the conditions to check being variable (including a
MFC0 move delay slot that is only required for very old processors):

     828:	8cf90000 	lw	t9,0(a3)
			828: R_MIPS_LO16	jiffies
     82c:	40057800 	mfc0	a1,c0_prid
     830:	3c0200ff 	lui	v0,0xff
     834:	00a21024 	and	v0,a1,v0
     838:	1040007d 	beqz	v0,a30 <add_interrupt_randomness+0x22c>
     83c:	3c030000 	lui	v1,0x0
			83c: R_MIPS_HI16	cpu_data
     840:	40024800 	mfc0	v0,c0_count
     844:	00000000 	nop
     848:	00409021 	move	s2,v0
     84c:	8ce20000 	lw	v0,0(a3)
			84c: R_MIPS_LO16	jiffies

On most targets the sequence will be shorter and on some it will reduce to
a single `MFC0 <reg>,c0_count', as all MIPS architecture (i.e. non-legacy
MIPS) processors require the CP0 Count register to be present.

The only known exception that reports MIPS architecture compliance, but
contrary to that lacks CP0 Count is the Ingenic JZ4740 thingy.  For broken
platforms like that this code requires cpu_has_counter to be hardcoded to
0 (i.e. no variable setting is permitted) so as not to penalise all the
other good platforms out there.

The asm barrier is required so that the compiler does not pull any
potentially costly (cold cache!) `cpu_data' variable access into the fast
path.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: John Crispin <blogic@openwrt.org>
Cc: Andrew McGregor <andrewmcgr@gmail.com>
Cc: Dave Taht <dave.taht@bufferbloat.net>
Cc: Felix Fietkau <nbd@nbd.name>
Cc: Simon Kelley <simon@thekelleys.org.uk>
Cc: Jim Gettys <jg@freedesktop.org>
Cc: David Daney <ddaney@caviumnetworks.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/6702/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2014-05-30 18:21:30 +02:00
..
.gitignore
8250-platform.c
asm-offsets.c Merge branch 'wip-mips-pm' of https://github.com/paulburton/linux into mips-for-linux-next 2014-05-29 15:08:23 +02:00
binfmt_elfn32.c
binfmt_elfo32.c MIPS: Support for 64-bit FP with O32 binaries 2014-01-13 23:40:56 +01:00
bmips_vec.S MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
branch.c MIPS: Sort out mm_isBranchInstr. 2014-05-23 15:12:37 +02:00
cevt-bcm1480.c
cevt-ds1287.c
cevt-gic.c MIPS: allow GIC clockevent device config from other CPUs 2014-05-02 16:39:11 +01:00
cevt-gt641xx.c
cevt-r4k.c Merge branch 'wip-mips-pm' of https://github.com/paulburton/linux into mips-for-linux-next 2014-05-29 15:08:23 +02:00
cevt-sb1250.c
cevt-txx9.c
cps-vec.S MIPS: smp-cps: duplicate core0 CCA on secondary cores 2014-05-28 16:20:33 +01:00
cpu-bugs64.c
cpu-probe.c MIPS: Implement random_get_entropy with CP0 Random 2014-05-30 18:21:30 +02:00
crash.c mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
crash_dump.c
csrc-bcm1480.c
csrc-gic.c
csrc-ioasic.c
csrc-r4k.c
csrc-sb1250.c
early_printk.c
early_printk_8250.c
entry.S MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
ftrace.c Most of the changes were largely clean ups, and some documentation. 2014-04-03 10:26:31 -07:00
genex.S MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
gpio_txx9.c
head.S MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
i8253.c
i8259.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
idle.c Merge branch 'wip-mips-pm' of https://github.com/paulburton/linux into mips-for-linux-next 2014-05-29 15:08:23 +02:00
irq-gic.c MIPS: allow GIC clockevent device config from other CPUs 2014-05-02 16:39:11 +01:00
irq-gt641xx.c
irq-msc01.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
irq-rm7000.c
irq.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
irq_cpu.c
irq_txx9.c
jump_label.c
kgdb.c MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes 2014-03-26 23:09:18 +01:00
kprobes.c
linux32.c
machine_kexec.c
Makefile Merge branch 'wip-mips-pm' of https://github.com/paulburton/linux into mips-for-linux-next 2014-05-29 15:08:23 +02:00
mcount.S
mips-cm.c MIPS: Add generic CM probe & access code 2014-03-06 21:25:22 +01:00
mips-cpc.c MIPS: smp-cps: rework core/VPE initialisation 2014-05-28 16:20:28 +01:00
mips-mt-fpaff.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
mips-mt.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
mips_ksyms.c MIPS: checksum: Split the 'copy_user' symbol 2014-03-26 23:09:17 +01:00
mips_machine.c
module-rela.c
module.c
octeon_switch.S
perf_event.c
perf_event_mipsxx.c MIPS: perf: Add interAptiv support 2014-03-31 18:17:12 +02:00
pm-cps.c MIPS: pm-cps: add PM state entry code for CPS systems 2014-05-28 16:20:31 +01:00
pm.c MIPS: PM: Implement PM helper macros 2014-05-02 16:39:10 +01:00
proc.c Revert "MIPS: MT: proc: Add support for printing VPE and TC ids" 2014-05-13 00:29:33 +02:00
process.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
prom.c
ptrace.c Merge git://git.infradead.org/users/eparis/audit 2014-04-12 12:38:53 -07:00
ptrace32.c MIPS: Simplify PTRACE_PEEKUSR for FPC_EIR 2014-03-31 18:17:12 +02:00
r4k_fpu.S Merge branch '3.14-fixes' into mips-for-linux-next 2014-03-31 18:17:33 +02:00
r4k_switch.S MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
r2300_fpu.S
r2300_switch.S
r6000_fpu.S
relocate_kernel.S
reset.c
rtlx-cmp.c MIPS: APRP: Unregister rtlx interrupt hook at module exit 2014-03-06 20:55:07 +01:00
rtlx-mt.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
rtlx.c MIPS: APRP: Code formatting clean-ups. 2014-01-22 20:19:02 +01:00
scall32-o32.S MIPS: Wire up renameat2 syscall. 2014-05-13 17:57:33 +02:00
scall64-64.S MIPS: Wire up renameat2 syscall. 2014-05-13 17:57:33 +02:00
scall64-n32.S MIPS: Wire up renameat2 syscall. 2014-05-13 17:57:33 +02:00
scall64-o32.S MIPS: Wire up renameat2 syscall. 2014-05-13 17:57:33 +02:00
segment.c MIPS: Add debugfs file to print the segmentation control registers 2014-01-22 20:19:00 +01:00
setup.c
signal-common.h
signal.c MIPS: kernel: signal: Prevent save/restore FPU context in user memory 2014-03-26 23:09:17 +01:00
signal32.c MIPS: Save/restore MSA context around signals 2014-03-26 23:09:11 +01:00
signal_n32.c
smp-bmips.c MIPS: SMP: Remove plat_smp_ops cpus_done method. 2014-05-27 11:06:42 +02:00
smp-cmp.c MIPS: SMP: Remove plat_smp_ops cpus_done method. 2014-05-27 11:06:42 +02:00
smp-cps.c Merge branch 'wip-mips-pm' of https://github.com/paulburton/linux into mips-for-linux-next 2014-05-29 15:08:23 +02:00
smp-gic.c cpuidle: cpuidle-cps: add MIPS CPS cpuidle driver 2014-05-28 16:20:36 +01:00
smp-mt.c MIPS: SMP: Remove plat_smp_ops cpus_done method. 2014-05-27 11:06:42 +02:00
smp-up.c MIPS: SMP: Remove plat_smp_ops cpus_done method. 2014-05-27 11:06:42 +02:00
smp.c Merge branch 'wip-mips-pm' of https://github.com/paulburton/linux into mips-for-linux-next 2014-05-29 15:08:23 +02:00
spinlock_test.c
spram.c MIPS: Use current_cpu_type() instead of c->cputype 2014-03-31 18:17:12 +02:00
stacktrace.c
sync-r4k.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
syscall.c MIPS: Fix gigaton of warning building with microMIPS. 2014-03-31 18:17:12 +02:00
time.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
topology.c
traps.c Merge branch 'wip-mips-pm' of https://github.com/paulburton/linux into mips-for-linux-next 2014-05-29 15:08:23 +02:00
unaligned.c MIPS: kernel: unaligned: Handle unaligned accesses for EVA 2014-03-26 23:09:16 +01:00
vdso.c
vmlinux.lds.S
vpe-cmp.c MIPS: APRP: Add VPE loader support for CMP platforms. 2014-01-22 20:19:02 +01:00
vpe-mt.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
vpe.c Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2014-01-30 17:20:32 -08:00
watch.c