linux/arch/h8300
H. Peter Anvin bdc807871d avoid overflows in kernel/time.c
When the conversion factor between jiffies and milli- or microseconds is
not a single multiply or divide, as for the case of HZ == 300, we currently
do a multiply followed by a divide.  The intervening result, however, is
subject to overflows, especially since the fraction is not simplified (for
HZ == 300, we multiply by 300 and divide by 1000).

This is exposed to the user when passing a large timeout to poll(), for
example.

This patch replaces the multiply-divide with a reciprocal multiplication on
32-bit platforms.  When the input is an unsigned long, there is no portable
way to do this on 64-bit platforms there is no portable way to do this
since it requires a 128-bit intermediate result (which gcc does support on
64-bit platforms but may generate libgcc calls, e.g.  on 64-bit s390), but
since the output is a 32-bit integer in the cases affected, just simplify
the multiply-divide (*3/10 instead of *300/1000).

The reciprocal multiply used can have off-by-one errors in the upper half
of the valid output range.  This could be avoided at the expense of having
to deal with a potential 65-bit intermediate result.  Since the intent is
to avoid overflow problems and most of the other time conversions are only
semiexact, the off-by-one errors were considered an acceptable tradeoff.

At Ralf Baechle's suggestion, this version uses a Perl script to compute
the necessary constants.  We already have dependencies on Perl for kernel
compiles.  This does, however, require the Perl module Math::BigInt, which
is included in the standard Perl distribution starting with version 5.8.0.
In order to support older versions of Perl, include a table of canned
constants in the script itself, and structure the script so that
Math::BigInt isn't required if pulling values from said table.

Running the script requires that the HZ value is available from the
Makefile.  Thus, this patch also adds the Kconfig variable CONFIG_HZ to the
architectures which didn't already have it (alpha, cris, frv, h8300, m32r,
m68k, m68knommu, sparc, v850, and xtensa.) It does *not* touch the sh or
sh64 architectures, since Paul Mundt has dealt with those separately in the
sh tree.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
Cc: Sam Ravnborg <sam@ravnborg.org>,
Cc: Paul Mundt <lethal@linux-sh.org>,
Cc: Richard Henderson <rth@twiddle.net>,
Cc: Michael Starvik <starvik@axis.com>,
Cc: David Howells <dhowells@redhat.com>,
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>,
Cc: Hirokazu Takata <takata@linux-m32r.org>,
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
Cc: Roman Zippel <zippel@linux-m68k.org>,
Cc: William L. Irwin <sparclinux@vger.kernel.org>,
Cc: Chris Zankel <chris@zankel.net>,
Cc: H. Peter Anvin <hpa@zytor.com>,
Cc: Jan Engelhardt <jengelh@computergmbh.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-08 09:22:39 -08:00
..
boot h8300 zImage support update 2007-07-16 09:05:37 -07:00
kernel procfs: constify function pointer tables 2008-02-08 09:22:38 -08:00
lib kbuild: fix AFLAGS use in h8300 and m68knommu 2007-10-15 21:03:59 +02:00
mm h8300 generic irq 2007-05-07 12:12:58 -07:00
platform arch/h8300/: Spelling fixes 2008-02-03 16:52:33 +02:00
Kconfig avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
Kconfig.cpu [PATCH] fix a typo in the CPU_H8300H dependencies 2006-02-14 16:09:35 -08:00
Kconfig.debug H8300: Typo: "buildin" -> "builtin" 2007-10-20 00:26:06 +02:00
Kconfig.ide Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
Makefile kbuild: enable 'make AFLAGS=...' to add additional options to AS 2007-10-15 21:59:31 +02:00
README Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
defconfig [PATCH] H8/300: CONFIG_CONFIG_ doesn't fly. 2006-02-20 20:04:19 -08:00

README

linux-2.6 for H8/300 README
Yoshinori Sato <ysato@users.sourceforge.jp>

* Supported CPU
H8/300H and H8S

* Supported Target
1.simulator of GDB
  require patches.

2.AE 3068/AE 3069
  more information 
  MICROTRONIQUE <http://www.microtronique.com/>
  Akizuki Denshi Tsusho Ltd. <http://www.akizuki.ne.jp> (Japanese Only)

3.H8MAX 
  see http://ip-sol.jp/h8max/ (Japanese Only)

4.EDOSK2674
  see http://www.eu.renesas.com/products/mpumcu/tool/edk/support/edosk2674.html
      http://www.azpower.com/H8-uClinux/

* Toolchain Version
gcc-3.1 or higher and patch
see arch/h8300/tools_patch/README
binutils-2.12 or higher
gdb-5.2 or higher
The environment that can compile a h8300-elf binary is necessary.

* Userland Develop environment
used h8300-elf toolchains.
see http://www.uclinux.org/pub/uClinux/ports/h8/

* A few words of thanks
Porting to H8/300 serieses is support of Information-technology Promotion Agency, Japan.
I thank support.
and All developer/user.