kernel_optimize_test/arch/mips/kvm
Paul Burton e6331a321a
MIPS: KVM: Use prandom_u32_max() to generate tlbwr index
Emulation of the tlbwr instruction, which writes a TLB entry to a random
index in the TLB, currently uses get_random_bytes() to generate a 4 byte
random number which we then mask to form the index. This is overkill in
a couple of ways:

  - We don't need 4 bytes here since we mask the value to form a 6 bit
    number anyway, so we waste /dev/random entropy generating 3 random
    bytes that are unused.

  - We don't need crypto-grade randomness here - the architecture spec
    allows implementations to use any algorithm & merely encourages that
    some pseudo-randomness be used rather than a simple counter. The
    fast prandom_u32() function fits that criteria well.

So rather than using get_random_bytes() & consuming /dev/random entropy,
switch to using the faster prandom_u32_max() which provides what we need
here whilst also performing the masking/modulo for us.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Reported-by: George Spelvin <lkml@sdf.org>
Cc: James Hogan <jhogan@kernel.org>
Cc: linux-mips@vger.kernel.org
2019-03-25 14:02:12 -07:00
..
00README.txt
callback.c
commpage.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
commpage.h
dyntrans.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
emulate.c MIPS: KVM: Use prandom_u32_max() to generate tlbwr index 2019-03-25 14:02:12 -07:00
entry.c KVM: MIPS/Entry: Update entry code to support VZ 2017-03-28 14:53:51 +01:00
fpu.S
hypcall.c KVM: MIPS: Implement HYPCALL emulation 2017-03-28 14:53:33 +01:00
interrupt.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
interrupt.h KVM: MIPS: Implement VZ support 2017-03-28 14:53:54 +01:00
Kconfig Kconfig updates for v4.21 2018-12-29 13:03:29 -08:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mips.c MIPS: MemoryMapID (MMID) Support 2019-02-04 10:56:41 -08:00
mmu.c KVM: Make kvm_set_spte_hva() return int 2018-12-21 11:28:41 +01:00
msa.S
stats.c
tlb.c KVM: MIPS: Fix maybe-uninitialized build failure 2017-06-20 17:02:48 +02:00
trace.h KVM: MIPS/VZ: Trace guest mode changes 2017-03-28 14:54:00 +01:00
trap_emul.c MIPS: mm: Add set_cpu_context() for ASID assignments 2019-02-04 10:56:33 -08:00
vz.c MIPS: mm: Unify ASID version checks 2019-02-04 10:56:30 -08:00