linux_dsm_epyc7002/arch/v850
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
..
configs [PATCH] v850: Update defconfigs 2005-09-02 00:57:31 -07:00
kernel procfs: constify function pointer tables 2008-02-08 09:22:38 -08:00
lib [NET]: V850 checksum annotations and cleanups. 2006-12-02 21:23:13 -08:00
Kconfig avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
Kconfig.debug Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
Makefile kbuild: enable 'make CFLAGS=...' to add additional options to CC 2007-10-14 22:21:35 +02:00
README [PATCH] v850: Add defconfigs 2005-07-27 16:26:02 -07:00

This port to the NEC V850E processor supports the following platforms:

   "sim"
	The gdb v850e simulator (CONFIG_V850E_SIM).

   "rte-ma1-cb"
	The Midas labs RTE-V850E/MA1-CB and RTE-V850E/NB85E-CB evaluation
	boards (CONFIG_RTE_CB_MA1 and CONFIG_RTE_CB_NB85E).  This support
	has only been tested when running with the Multi-debugger monitor
	ROM (for the Green Hills Multi debugger).  The optional NEC
	Solution Gear RTE-MOTHER-A motherboard is also supported, which
	allows PCI boards to be used (CONFIG_RTE_MB_A_PCI).

   "rte-me2-cb"
	The Midas labs RTE-V850E/ME2-CB evaluation board (CONFIG_RTE_CB_ME2).
     	This has only been tested using a kernel downloaded via an ICE
     	connection using the Multi debugger.  Support for the RTE-MOTHER-A is
     	present, but hasn't been tested (unlike the other Midas labs cpu
     	boards, the RTE-V850E/ME2-CB includes an ethernet adaptor).

   "as85ep1"
	The NEC AS85EP1 V850E evaluation chip/board (CONFIG_V850E_AS85EP1).

   "anna"
	The NEC `Anna' (board/chip) implementation of the V850E2 processor
	(CONFIG_V850E2_ANNA).

   "sim85e2c", "sim85e2s"
   	The sim85e2c and sim85e2s simulators, which are verilog simulations
	of the V850E2 NA85E2C/NA85E2S cpu cores (CONFIG_V850E2_SIM85E2C and
	CONFIG_V850E2_SIM85E2S).

   "fpga85e2c"
	A FPGA implementation of the V850E2 NA85E2C cpu core
	(CONFIG_V850E2_FPGA85E2C).

To get a default kernel configuration for a particular platform, you can
use a <platform>_defconfig make target (e.g., "make rte-me2-cb_defconfig");
to see which default configurations are possible, look in the directory
"arch/v850/configs".

Porting to anything with a V850E/MA1 or MA2 processor should be simple.
See the file <asm-v850/machdep.h> and the files it includes for an example of
how to add platform/chip-specific support.