linux/arch/mips
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
..
alchemy MIPS: Alchemy: Default to noncoherent IO on Au1200 AB 2014-05-28 11:04:48 +02:00
ar7 MIPS: Restore init.h usage to arch/mips/ar7/time.c 2014-03-26 23:09:23 +01:00
ath79 usb: host: remove selects of USB_ARCH_HAS_?HCI 2014-02-18 12:36:38 -08:00
bcm47xx MIPS: BCM47XX: Slightly clean memory detection 2014-05-30 11:00:21 +02:00
bcm63xx MIPS: Use current_cpu_type() instead of c->cputype 2014-03-31 18:17:12 +02:00
boot mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
cavium-octeon MIPS: octeon: Add interface mode detection for Octeon II 2014-05-29 23:02:42 +02:00
cobalt
configs Merge branch 'wip-mips-pm' of https://github.com/paulburton/linux into mips-for-linux-next 2014-05-29 15:08:23 +02:00
dec MIPS: DEC/SNI: O32 wrapper stack switching fixes 2014-05-13 00:29:35 +02:00
emma MIPS: Remove panic_timeout settings 2013-11-26 12:12:27 +01:00
fw MIPS: DEC/SNI: O32 wrapper stack switching fixes 2014-05-13 00:29:35 +02:00
include MIPS: Implement random_get_entropy with CP0 Random 2014-05-30 18:21:30 +02:00
jazz
jz4740 mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
kernel MIPS: Implement random_get_entropy with CP0 Random 2014-05-30 18:21:30 +02:00
kvm MIPS: KVM: Remove dead code in CP0 emulation 2014-03-19 17:01:50 +01:00
lantiq MIPS: DTS: Fix missing device_type="memory" property in memory nodes 2014-05-26 16:15:38 +02:00
lasat MIPS: Lasat: Replace del_timer by del_timer_sync 2014-03-31 18:17:12 +02:00
lib MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
loongson MIPS: Lemote 2F: cs5536: mfgpt: depend on !highres 2014-05-28 10:49:24 +02:00
loongson1 MIPS: Disable MIPS16/microMIPS crap for platforms not supporting these ASEs. 2014-05-23 15:12:37 +02:00
math-emu MIPS: math-emu: Add IEEE754 exception statistics to debugfs 2014-05-30 11:55:23 +02:00
mm MIPS: uasm: Add lb uasm instruction 2014-05-30 16:10:19 +02:00
mti-malta MIPS: malta: Remove 'maybe_unused' attribute from ememsize{, _str} 2014-05-25 14:29:05 +02:00
mti-sead3 MIPS: SEAD3: Introduce the use of the managed version of kzalloc 2014-05-26 16:06:35 +02:00
net MIPS: net: Add BPF JIT 2014-05-30 16:10:20 +02:00
netlogic MIPS: Netlogic: XLP9XX on-chip SATA support 2014-05-30 16:51:47 +02:00
oprofile MIPS: Add support for the M5150 processor 2014-03-26 23:09:22 +01:00
pci MIPS: Add MSI support for XLP9XX 2014-05-30 16:51:02 +02:00
pmcs-msp71xx MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
pnx833x MIPS: PNX833x: Remove checks for CONFIG_I2C_PNX0105 2014-05-23 15:12:39 +02:00
power MIPS: Hibernate: Flush TLB entries in swsusp_arch_resume() 2014-03-31 10:16:53 +02:00
ralink MIPS: DTS: Fix missing device_type="memory" property in memory nodes 2014-05-26 16:15:38 +02:00
rb532
sgi-ip22 mips: Use the core irq stats function 2014-03-04 17:37:53 +01:00
sgi-ip27 MIPS: SMP: Remove plat_smp_ops cpus_done method. 2014-05-27 11:06:42 +02:00
sgi-ip32
sibyte MIPS: SMP: Remove plat_smp_ops cpus_done method. 2014-05-27 11:06:42 +02:00
sni
txx9
vr41xx
Kbuild MIPS: net: Add BPF JIT 2014-05-30 16:10:20 +02:00
Kbuild.platforms
Kconfig MIPS: Support upto 256 CPUs 2014-05-30 16:44:36 +02:00
Kconfig.debug MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
Makefile MIPS: math-emu: Move various objects into an ar library. 2014-05-23 15:11:14 +02:00