lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130603093938.GG18614@n2100.arm.linux.org.uk>
Date:	Mon, 3 Jun 2013 10:39:38 +0100
From:	Russell King - ARM Linux <linux@....linux.org.uk>
To:	Stephen Boyd <sboyd@...eaurora.org>
Cc:	John Stultz <john.stultz@...aro.org>, linux-kernel@...r.kernel.org,
	linux-arm-msm@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, arm@...nel.org,
	Catalin Marinas <catalin.marinas@....com>,
	Will Deacon <will.deacon@....com>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCHv2 4/6] sched_clock: Add support for >32 bit sched_clock

On Sat, Jun 01, 2013 at 11:39:41PM -0700, Stephen Boyd wrote:
> The ARM architected system counter has at least 56 useable bits.
> Add support for counters with more than 32 bits to the generic
> sched_clock implementation so we can avoid the complexity of
> dealing with wrap-around on these devices while benefiting from
> the irqtime accounting and suspend/resume handling that the
> generic sched_clock code already has.

This looks like a horrid hack to me.

> +static unsigned long long notrace sched_clock_64(void)
> +{
> +	u64 cyc = read_sched_clock_64() - cd.epoch_ns;
> +	return cyc * cd.mult;

So, the use of cd.mult implies that the return value from
read_sched_clock_64() is not nanoseconds but something else.  But then
we subtract it from the nanoseconds epoch - which has to be nanoseconds
because you simply return that when suspended.

> +}
> +
> +void __init
> +setup_sched_clock_64(u64 (*read)(void), int bits, unsigned long rate)
> +{
> +	if (cd.rate > rate)
> +		return;
> +
> +	BUG_ON(bits <= 32);
> +	WARN_ON(!irqs_disabled());
> +	read_sched_clock_64 = read;
> +	sched_clock_func = sched_clock_64;
> +	cd.rate = rate;
> +	cd.mult = NSEC_PER_SEC / rate;

Here, you don't check that the (2^bits) * mult results in a wrap of the
resulting 64-bit number, which is a _basic_ requirement for sched_clock
(hence all the code for <=32bit clocks, otherwise we wouldn't need this
complexity in the first place.)

So, I think this whole approach is broken.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ