Re: [PATCH 2/5] clocksource: add support for entropy-generation function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 13 Jun 2011, Jarod Wilson wrote:
> Add a new function pointer to struct clocksource that can optionally be
> filled in by clocksources deemed to be high enough resolution to feed
> the random number generator entropy pool.

Uurrg.
 
> + * @entropy:		random entropy pool addition function (optional, and
> + *			requires a fairly high-resolution clocksource)

Why do you want to do that ? Looking at the implementations of TSC and
HPET it's the same code. We really do not want to add that all over
the place. We can make that a property flag and the entropy function
common to the core code.

> +/**
> + * Do we have at least one clocksource that can generate entropy?
> + */
> +bool clocksource_entropy_available(void)
> +{
> +	struct clocksource *src;
> +	bool entropy_possible = false;
> +
> +	mutex_lock(&clocksource_mutex);
> +	list_for_each_entry(src, &clocksource_list, list) {
> +		if (src->entropy) {
> +			entropy_possible = true;
> +			break;
> +		}
> +	}
> +	mutex_unlock(&clocksource_mutex);
> +
> +	return entropy_possible;
> +}
> +EXPORT_SYMBOL(clocksource_entropy_available);

That should be evaluated when clocksources are registered not at some
random point in time, which might return total nonsense as it's not
guaranteed that the clocksource which has the entropy property is
going to end up as the current clocksource.

> +/**
> + * Call the clocksource's entropy-generation function, if set
> + */
> +void clocksource_add_entropy(void)
> +{
> +	if (!curr_clocksource->entropy)
> +		return;

Why restricting it to the current clocksource? We can use the best
registered one for this which has the entropy property set.

> +	curr_clocksource->entropy(curr_clocksource);
> +}
> +EXPORT_SYMBOL(clocksource_add_entropy);
> +
>  #ifdef CONFIG_SYSFS
>  /**
>   * sysfs_show_current_clocksources - sysfs interface for current clocksource
> -- 
> 1.7.1
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux