<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/arch/sh/kernel, branch mybooklive-amatus</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/arch/sh/kernel?h=mybooklive-amatus</id>
<link rel='self' href='https://git.amat.us/linux/atom/arch/sh/kernel?h=mybooklive-amatus'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2014-06-04T23:53:52Z</updated>
<entry>
<title>sh: Replace __get_cpu_var uses</title>
<updated>2014-06-04T23:53:52Z</updated>
<author>
<name>Christoph Lameter</name>
<email>cl@linux.com</email>
</author>
<published>2014-06-04T23:05:51Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=c473b2c6f6c6d012da98416b5de28cc48c4306c9'/>
<id>urn:sha1:c473b2c6f6c6d012da98416b5de28cc48c4306c9</id>
<content type='text'>
__get_cpu_var() is used for multiple purposes in the kernel source.  One
of them is address calculation via the form &amp;__get_cpu_var(x).  This
calculates the address for the instance of the percpu variable of the
current processor based on an offset.

Other use cases are for storing and retrieving data from the current
processors percpu area.  __get_cpu_var() can be used as an lvalue when
writing data or on the right side of an assignment.

__get_cpu_var() is defined as :

#define __get_cpu_var(var) (*this_cpu_ptr(&amp;(var)))

__get_cpu_var() always only does an address determination.  However, store
and retrieve operations could use a segment prefix (or global register on
other platforms) to avoid the address calculation.

this_cpu_write() and this_cpu_read() can directly take an offset into a
percpu area and use optimized assembly code to read and write per cpu
variables.

This patch converts __get_cpu_var into either an explicit address
calculation using this_cpu_ptr() or into a use of this_cpu operations that
use the offset.  Thereby address calculations are avoided and less
registers are used when code is generated.

At the end of the patch set all uses of __get_cpu_var have been removed so
the macro is removed too.

The patch set includes passes over all arches as well.  Once these
operations are used throughout then specialized macros can be defined in
non -x86 arches as well in order to optimize per cpu access by f.e.  using
a global register that may be set to the per cpu base.

Transformations done to __get_cpu_var()

1. Determine the address of the percpu instance of the current processor.

	DEFINE_PER_CPU(int, y);
	int *x = &amp;__get_cpu_var(y);

    Converts to

	int *x = this_cpu_ptr(&amp;y);

2. Same as #1 but this time an array structure is involved.

	DEFINE_PER_CPU(int, y[20]);
	int *x = __get_cpu_var(y);

    Converts to

	int *x = this_cpu_ptr(y);

3. Retrieve the content of the current processors instance of a per cpu
variable.

	DEFINE_PER_CPU(int, y);
	int x = __get_cpu_var(y)

   Converts to

	int x = __this_cpu_read(y);

4. Retrieve the content of a percpu struct

	DEFINE_PER_CPU(struct mystruct, y);
	struct mystruct x = __get_cpu_var(y);

   Converts to

	memcpy(&amp;x, this_cpu_ptr(&amp;y), sizeof(x));

5. Assignment to a per cpu variable

	DEFINE_PER_CPU(int, y)
	__get_cpu_var(y) = x;

   Converts to

	__this_cpu_write(y, x);

6. Increment/Decrement etc of a per cpu variable

	DEFINE_PER_CPU(int, y);
	__get_cpu_var(y)++

   Converts to

	__this_cpu_inc(y)

Signed-off-by: Christoph Lameter &lt;cl@linux.com&gt;
Tested-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt; [compilation only]
Cc: Paul Mundt &lt;lethal@linux-sh.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>sh: Switch to new style MTU2 device</title>
<updated>2014-05-11T10:35:28Z</updated>
<author>
<name>Laurent Pinchart</name>
<email>laurent.pinchart+renesas@ideasonboard.com</email>
</author>
<published>2014-04-23T11:15:21Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=5204601c0877b3ffc90e417bf30fccc9bdf47962'/>
<id>urn:sha1:5204601c0877b3ffc90e417bf30fccc9bdf47962</id>
<content type='text'>
The MTU2 (Multi-Function Timer Pulse Unit 2) driver implements a new
style of platform data that handles the timer as a single device with
multiple channel. Switch from the old-style platform data to the
new-style platform data.

Signed-off-by: Laurent Pinchart &lt;laurent.pinchart+renesas@ideasonboard.com&gt;
Tested-by: Wolfram Sang &lt;wsa@sang-engineering.com&gt;
Signed-off-by: Simon Horman &lt;horms+renesas@verge.net.au&gt;
</content>
</entry>
<entry>
<title>sh: Switch to new style TMU device</title>
<updated>2014-05-11T10:35:27Z</updated>
<author>
<name>Laurent Pinchart</name>
<email>laurent.pinchart+renesas@ideasonboard.com</email>
</author>
<published>2014-04-23T11:15:15Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=1399c195ef5009bf44a41649da4718f6e67c0bff'/>
<id>urn:sha1:1399c195ef5009bf44a41649da4718f6e67c0bff</id>
<content type='text'>
The TMU (Timer Unit) driver implements a new style of platform data that
handles the timer as a single device with multiple channel. Switch from
the old-style platform data to the new-style platform data.

Signed-off-by: Laurent Pinchart &lt;laurent.pinchart+renesas@ideasonboard.com&gt;
Signed-off-by: Simon Horman &lt;horms+renesas@verge.net.au&gt;
</content>
</entry>
<entry>
<title>sh: Switch to new style CMT device</title>
<updated>2014-05-11T10:35:26Z</updated>
<author>
<name>Laurent Pinchart</name>
<email>laurent.pinchart+renesas@ideasonboard.com</email>
</author>
<published>2014-04-23T11:15:08Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=9b17e48cd4df4e129976c37660cf9ec644c66059'/>
<id>urn:sha1:9b17e48cd4df4e129976c37660cf9ec644c66059</id>
<content type='text'>
The CMT (Compare Match Timer) driver implements a new style of platform
data that handles the timer as a single device with multiple channel.
Switch from the old-style platform data to the new-style platform data.

Signed-off-by: Laurent Pinchart &lt;laurent.pinchart+renesas@ideasonboard.com&gt;
Signed-off-by: Simon Horman &lt;horms+renesas@verge.net.au&gt;
</content>
</entry>
<entry>
<title>Kconfig: rename HAS_IOPORT to HAS_IOPORT_MAP</title>
<updated>2014-04-07T23:36:11Z</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@pengutronix.de</email>
</author>
<published>2014-04-07T22:39:19Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=ce816fa88cca083c47ab9000b2138a83043a78be'/>
<id>urn:sha1:ce816fa88cca083c47ab9000b2138a83043a78be</id>
<content type='text'>
If the renamed symbol is defined lib/iomap.c implements ioport_map and
ioport_unmap and currently (nearly) all platforms define the port
accessor functions outb/inb and friend unconditionally.  So
HAS_IOPORT_MAP is the better name for this.

Consequently NO_IOPORT is renamed to NO_IOPORT_MAP.

The motivation for this change is to reintroduce a symbol HAS_IOPORT
that signals if outb/int et al are available.  I will address that at
least one merge window later though to keep surprises to a minimum and
catch new introductions of (HAS|NO)_IOPORT.

The changes in this commit were done using:

	$ git grep -l -E '(NO|HAS)_IOPORT' | xargs perl -p -i -e 's/\b((?:CONFIG_)?(?:NO|HAS)_IOPORT)\b/$1_MAP/'

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Acked-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'akpm' (incoming from Andrew)</title>
<updated>2014-04-03T23:22:16Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2014-04-03T23:22:16Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=76ca7d1cca761bb9712dfcad9a27d70b520874ae'/>
<id>urn:sha1:76ca7d1cca761bb9712dfcad9a27d70b520874ae</id>
<content type='text'>
Merge first patch-bomb from Andrew Morton:
 - Various misc bits
 - kmemleak fixes
 - small befs, codafs, cifs, efs, freexxfs, hfsplus, minixfs, reiserfs things
 - fanotify
 - I appear to have become SuperH maintainer
 - ocfs2 updates
 - direct-io tweaks
 - a bit of the MM queue
 - printk updates
 - MAINTAINERS maintenance
 - some backlight things
 - lib/ updates
 - checkpatch updates
 - the rtc queue
 - nilfs2 updates
 - Small Documentation/ updates

* emailed patches from Andrew Morton &lt;akpm@linux-foundation.org&gt;: (237 commits)
  Documentation/SubmittingPatches: remove references to patch-scripts
  Documentation/SubmittingPatches: update some dead URLs
  Documentation/filesystems/ntfs.txt: remove changelog reference
  Documentation/kmemleak.txt: updates
  fs/reiserfs/super.c: add __init to init_inodecache
  fs/reiserfs: move prototype declaration to header file
  fs/hfsplus/attributes.c: add __init to hfsplus_create_attr_tree_cache()
  fs/hfsplus/extents.c: fix concurrent acess of alloc_blocks
  fs/hfsplus/extents.c: remove unused variable in hfsplus_get_block
  nilfs2: update project's web site in nilfs2.txt
  nilfs2: update MAINTAINERS file entries fix
  nilfs2: verify metadata sizes read from disk
  nilfs2: add FITRIM ioctl support for nilfs2
  nilfs2: add nilfs_sufile_trim_fs to trim clean segs
  nilfs2: implementation of NILFS_IOCTL_SET_SUINFO ioctl
  nilfs2: add nilfs_sufile_set_suinfo to update segment usage
  nilfs2: add struct nilfs_suinfo_update and flags
  nilfs2: update MAINTAINERS file entries
  fs/coda/inode.c: add __init to init_inodecache()
  BEFS: logging cleanup
  ...
</content>
</entry>
<entry>
<title>sh: sh7757: switch RSPI clock to dev ID match</title>
<updated>2014-04-03T23:20:53Z</updated>
<author>
<name>Geert Uytterhoeven</name>
<email>geert+renesas@linux-m68k.org</email>
</author>
<published>2014-04-03T21:46:43Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=ba6e8b8f02e0431550e9e3c12cbc7dd2d1e14534'/>
<id>urn:sha1:ba6e8b8f02e0431550e9e3c12cbc7dd2d1e14534</id>
<content type='text'>
Switch the RSPI MSTP clock on SH7757 from a con ID match to a dev ID
match, so we can start looking it up using clk_get() with a NULL ID.

Signed-off-by: Geert Uytterhoeven &lt;geert+renesas@linux-m68k.org&gt;
Tested-by: Yoshihiro Shimoda &lt;yoshihiro.shimoda.uh@renesas.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>sh: don't pass saved userspace state to exception handlers</title>
<updated>2014-04-03T23:20:52Z</updated>
<author>
<name>Bobby Bingham</name>
<email>koorogi@koorogi.info</email>
</author>
<published>2014-04-03T21:46:41Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a3c195144e162097c42e4284323ed6d386de105d'/>
<id>urn:sha1:a3c195144e162097c42e4284323ed6d386de105d</id>
<content type='text'>
The compiler is permitted to generate code which overwrites the
parameters to a function.  If those parameters include the only saved
copy we have of userspace's registers, we're in trouble.

Signed-off-by: Bobby Bingham &lt;koorogi@koorogi.info&gt;
Cc: Paul Mundt &lt;paul.mundt@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>sh: push extra copy of r0-r2 for syscall parameters</title>
<updated>2014-04-03T23:20:52Z</updated>
<author>
<name>Bobby Bingham</name>
<email>koorogi@koorogi.info</email>
</author>
<published>2014-04-03T21:46:39Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=abafe5d9b04648a2f699202e9ae2d15ffe44c3a3'/>
<id>urn:sha1:abafe5d9b04648a2f699202e9ae2d15ffe44c3a3</id>
<content type='text'>
When invoking syscall handlers on sh32, the saved userspace registers
are at the top of the stack.  This seems to have been intentional, as it
is an easy way to pass r0, r1, ...  to the handler as parameters 5, 6,
...

It causes problems, however, because the compiler is allowed to generate
code for a function which clobbers that function's own parameters.  For
example, gcc generates the following code for clone:

    &lt;SyS_clone&gt;:
        mov.l   8c020714 &lt;SyS_clone+0xc&gt;,r1  ! 8c020540 &lt;do_fork&gt;
        mov.l   r7,@r15
        mov     r6,r7
        jmp     @r1
        mov     #0,r6
        nop
        .word 0x0540
        .word 0x8c02

The `mov.l r7,@r15` clobbers the saved value of r0 passed from
userspace.  For most system calls, this might not be a problem, because
we'll be overwriting r0 with the return value anyway.  But in the case
of clone, copy_thread will need the original value of r0 if the
CLONE_SETTLS flag was specified.

The first patch in this series fixes this issue for system calls by
pushing to the stack and extra copy of r0-r2 before invoking the
handler.  We discard this copy before restoring the userspace registers,
so it is not a problem if they are clobbered.

Exception handlers also receive the userspace register values in a
similar manner, and may hit the same problem.  The second patch removes
the do_fpu_error handler, which looks susceptible to this problem and
which, as far as I can tell, has not been used in some time.  The third
patch addresses other exception handlers.

This patch (of 3):

The userspace registers are stored at the top of the stack when the
syscall handler is invoked, which allows r0-r2 to act as parameters 5-7.
Parameters passed on the stack may be clobbered by the syscall handler.
The solution is to push an extra copy of the registers which might be
used as syscall parameters to the stack, so that the authoritative set
of saved register values does not get clobbered.

A few system call handlers are also updated to get the userspace
registers using current_pt_regs() instead of from the stack.

Signed-off-by: Bobby Bingham &lt;koorogi@koorogi.info&gt;
Cc: Paul Mundt &lt;paul.mundt@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>sh: fix format string bug in stack tracer</title>
<updated>2014-04-03T23:20:49Z</updated>
<author>
<name>Matt Fleming</name>
<email>matt.fleming@intel.com</email>
</author>
<published>2014-04-03T21:46:20Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a0c32761e73c9999cbf592b702f284221fea8040'/>
<id>urn:sha1:a0c32761e73c9999cbf592b702f284221fea8040</id>
<content type='text'>
Kees reported the following error:

   arch/sh/kernel/dumpstack.c: In function 'print_trace_address':
   arch/sh/kernel/dumpstack.c:118:2: error: format not a string literal and no format arguments [-Werror=format-security]

Use the "%s" format so that it's impossible to interpret 'data' as a
format string.

Signed-off-by: Matt Fleming &lt;matt.fleming@intel.com&gt;
Reported-by: Kees Cook &lt;keescook@chromium.org&gt;
Acked-by: Kees Cook &lt;keescook@chromium.org&gt;
Cc: Paul Mundt &lt;lethal@linux-sh.org&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
