15 Jul, 2019

1 commit


05 Oct, 2018

1 commit

  • quality field is currently documented as being 'per mill'. In fact the
    math involved is:

    add_hwgenerator_randomness((void *)rng_fillbuf, rc,
    rc * current_quality * 8 >> 10);

    thus the actual definition is "bits of entropy per 1024 bits of input".

    The current documentation seems to have confused multiple people
    in the past, let's fix the documentation to match code.

    An alternative is to change core to match driver expectations, replacing
    rc * current_quality * 8 >> 10
    with
    rc * current_quality / 1000
    but that has performance costs, so probably isn't a good option.

    Fixes: 0f734e6e768 ("hwrng: add per-device entropy derating")
    Reported-by: "Dr. David Alan Gilbert"
    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Herbert Xu

    Michael S. Tsirkin
     

21 Nov, 2016

1 commit


24 Aug, 2016

1 commit

  • Currently, very few RNG drivers support single byte reads using the
    ->read() interface. Of the 14 drivers in drivers/char/hw_random that
    support this interface only three of these actually support max == 1.
    The other behaviours vary between return 0, return 2, return 4 and return
    -EIO).

    This is not a problem in practice because the core hw_random code never
    performs a read shorter than 16 bytes. The documentation for this function
    already contrains the alignment of the buffer pointer, so let's also
    guarantee that the buffer is at least as large as its alignment.

    This constraint is intended to be the weakest guarantee neccessary to
    allow driver writers to safely simplify their code.

    Signed-off-by: Daniel Thompson
    Signed-off-by: Herbert Xu

    Daniel Thompson
     

16 Mar, 2015

1 commit


26 Dec, 2014

1 commit


22 Dec, 2014

2 commits

  • The previous patch added one potential problem: we can still be
    reading from a hwrng when it's unregistered. Add a wait for zero
    in the hwrng_unregister path.

    Signed-off-by: Rusty Russell
    Signed-off-by: Amos Kong
    Signed-off-by: Herbert Xu

    Rusty Russell
     
  • current_rng holds one reference, and we bump it every time we want
    to do a read from it.

    This means we only hold the rng_mutex to grab or drop a reference,
    so accessing /sys/devices/virtual/misc/hw_random/rng_current doesn't
    block on read of /dev/hwrng.

    Using a kref is overkill (we're always under the rng_mutex), but
    a standard pattern.

    This also solves the problem that the hwrng_fillfn thread was
    accessing current_rng without a lock, which could change (eg. to NULL)
    underneath it.

    Signed-off-by: Rusty Russell
    Signed-off-by: Amos Kong
    Signed-off-by: Herbert Xu

    Rusty Russell
     

15 Jul, 2014

2 commits


25 May, 2011

1 commit


01 Dec, 2009

1 commit

  • This patch implements a new method by which hw_random hardware drivers
    can pass data to the core more efficiently, using a shared buffer.

    The old methods have been retained as a compatability layer until all the
    drivers have been updated.

    Signed-off-by: Ian Molton
    Acked-by: Matt Mackall
    Acked-by: Rusty Russell
    Signed-off-by: Herbert Xu

    Ian Molton
     

30 Apr, 2008

1 commit


20 Apr, 2008

1 commit

  • After 2.6.24 there was a plan to make the PM core acquire all device
    semaphores during a suspend/hibernation to protect itself from
    concurrent operations involving device objects. That proved to be
    too heavy-handed and we found a better way to achieve the goal, but
    before it happened, we had introduced the functions
    device_pm_schedule_removal() and destroy_suspended_device() to allow
    drivers to "safely" destroy a suspended device and we had adapted some
    drivers to use them. Now that these functions are no longer necessary,
    it seems reasonable to remove them and modify their users to use the
    normal device unregistration instead.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

06 Feb, 2008

1 commit

  • Make it possible to unregister a Hardware Random Number Generator
    device object in a safe way during a suspend/resume cycle.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Michael Buesch
    Cc: Michael Buesch
    Cc: Pavel Machek
    Cc: "John W. Linville"
    Cc: Alan Stern
    Cc: Len Brown
    Cc: Greg KH
    Cc: Kay Sievers
    Cc: Richard Purdie
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

11 Jan, 2008

1 commit


27 Jun, 2006

1 commit