History log of /linux-master/arch/mips/kernel/vpe.c
Revision Date Author Comments
# 2f9060b1 03-Jan-2024 Bjorn Helgaas <bhelgaas@google.com>

MIPS: Fix typos

Fix typos, most reported by "codespell arch/mips". Only touches comments,
no code changes.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-mips@vger.kernel.org
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>


# 7fb6f7b0 05-Apr-2023 Thomas Bogendoerfer <tsbogend@alpha.franken.de>

MIPS: Remove deprecated CONFIG_MIPS_CMP

Commit 5cac93b35c14 ("MIPS: Deprecate CONFIG_MIPS_CMP") deprecated
CONFIG_MIPS_CMP and after 9 years it's time to remove it.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>


# efaa2496 13-Feb-2023 Randy Dunlap <rdunlap@infradead.org>

module: fix MIPS module_layout -> module_memory

Correct the struct's field/member name from mod_mem to mem.

Fixes this build error:
../arch/mips/kernel/vpe.c: In function 'vpe_elfload':
../arch/mips/kernel/vpe.c:643:41: error: 'struct module' has no member named 'mod_mem'
643 | v->load_addr = alloc_progmem(mod.mod_mem[MOD_TEXT].size);

Fixes: 2ece476a2346 ("module: replace module_layout with module_memory")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Song Liu <song@kernel.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-mips@vger.kernel.org
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>


# ac3b4328 06-Feb-2023 Song Liu <song@kernel.org>

module: replace module_layout with module_memory

module_layout manages different types of memory (text, data, rodata, etc.)
in one allocation, which is problematic for some reasons:

1. It is hard to enable CONFIG_STRICT_MODULE_RWX.
2. It is hard to use huge pages in modules (and not break strict rwx).
3. Many archs uses module_layout for arch-specific data, but it is not
obvious how these data are used (are they RO, RX, or RW?)

Improve the scenario by replacing 2 (or 3) module_layout per module with
up to 7 module_memory per module:

MOD_TEXT,
MOD_DATA,
MOD_RODATA,
MOD_RO_AFTER_INIT,
MOD_INIT_TEXT,
MOD_INIT_DATA,
MOD_INIT_RODATA,

and allocating them separately. This adds slightly more entries to
mod_tree (from up to 3 entries per module, to up to 7 entries per
module). However, this at most adds a small constant overhead to
__module_address(), which is expected to be fast.

Various archs use module_layout for different data. These data are put
into different module_memory based on their location in module_layout.
IOW, data that used to go with text is allocated with MOD_MEM_TYPE_TEXT;
data that used to go with data is allocated with MOD_MEM_TYPE_DATA, etc.

module_memory simplifies quite some of the module code. For example,
ARCH_WANTS_MODULES_DATA_IN_VMALLOC is a lot cleaner, as it just uses a
different allocator for the data. kernel/module/strict_rwx.c is also
much cleaner with module_memory.

Signed-off-by: Song Liu <song@kernel.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>


# 7cf52001 21-Jan-2021 Thomas Bogendoerfer <tsbogend@alpha.franken.de>

MIPS: vpe: Remove vpe_getcwd

I couldn't find any user of the dubious vpe_getcwd so far. So remove it and
get rid of another set_fs(KERNEL_DS).

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>


# bef8e2df 02-Feb-2020 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

MIPS: VPE: Fix a double free and a memory leak in 'release_vpe()'

Pointer on the memory allocated by 'alloc_progmem()' is stored in
'v->load_addr'. So this is this memory that should be freed by
'release_progmem()'.

'release_progmem()' is only a call to 'kfree()'.

With the current code, there is both a double free and a memory leak.
Fix it by passing the correct pointer to 'release_progmem()'.

Fixes: e01402b115ccc ("More AP / SP bits for the 34K, the Malta bits and things. Still wants")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Paul Burton <paulburton@kernel.org>
Cc: ralf@linux-mips.org
Cc: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org


# 57c8a661 30-Oct-2018 Mike Rapoport <rppt@linux.vnet.ibm.com>

mm: remove include/linux/bootmem.h

Move remaining definitions and declarations from include/linux/bootmem.h
into include/linux/memblock.h and remove the redundant header.

The includes were replaced with the semantic patch below and then
semi-automated removal of duplicated '#include <linux/memblock.h>

@@
@@
- #include <linux/bootmem.h>
+ #include <linux/memblock.h>

[sfr@canb.auug.org.au: dma-direct: fix up for the removal of linux/bootmem.h]
Link: http://lkml.kernel.org/r/20181002185342.133d1680@canb.auug.org.au
[sfr@canb.auug.org.au: powerpc: fix up for removal of linux/bootmem.h]
Link: http://lkml.kernel.org/r/20181005161406.73ef8727@canb.auug.org.au
[sfr@canb.auug.org.au: x86/kaslr, ACPI/NUMA: fix for linux/bootmem.h removal]
Link: http://lkml.kernel.org/r/20181008190341.5e396491@canb.auug.org.au
Link: http://lkml.kernel.org/r/1536927045-23536-30-git-send-email-rppt@linux.vnet.ibm.com
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greentime Hu <green.hu@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Ley Foon Tan <lftan@altera.com>
Cc: Mark Salter <msalter@redhat.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Paul Burton <paul.burton@mips.com>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Serge Semin <fancer.lancer@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# aae22f16 10-May-2018 Colin Ian King <colin.king@canonical.com>

MIPS: VPE: Fix spelling mistake: "uneeded" -> "unneeded"

Trivial fix to spelling mistake in pr_warn message text.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kernel-janitors@vger.kernel.org
Signed-off-by: James Hogan <jhogan@kernel.org>


# 7523e4dc 25-Nov-2015 Rusty Russell <rusty@rustcorp.com.au>

module: use a structure to encapsulate layout.

Makes it easier to handle init vs core cleanly, though the change is
fairly invasive across random architectures.

It simplifies the rbtree code immediately, however, while keeping the
core data together in the same cachline (now iff the rbtree code is
enabled).

Acked-by: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# c60f9944 12-Jul-2015 Bjorn Helgaas <bhelgaas@google.com>

MIPS: MT: Remove "weak" from vpe_run() declaration

Weak header file declarations are error-prone because they make every
definition weak, and the linker chooses one based on link order (see
10629d711ed7 ("PCI: Remove __weak annotation from pcibios_get_phb_of_node
decl")).

That's not a problem for vpe_run() because Kconfig ensures there's never
more than one definition:

- vpe_run() is defined in arch/mips/kernel/vpe-mt.c if
CONFIG_MIPS_VPE_LOADER_MT=y

- vpe_run() is defined in arch/mips/mti-malta/malta-amon.c if
CONFIG_MIPS_CMP=y

- CONFIG_MIPS_VPE_LOADER_MT cannot be set if CONFIG_MIPS_CMP=y

But it's simpler to verify correctness if we remove "weak" from the picture
and test the config symbols directly.

Remove "weak" from the vpe_run() declaration and use #if to test whether a
definition should be present.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Andrew Bresticker <abrestic@chromium.org>
Cc: linux-mips@linux-mips.org
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/10684/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 1c205b9c 12-Jul-2015 Bjorn Helgaas <bhelgaas@google.com>

MIPS: VPE: Exit vpe_release() early if vpe_run() isn't defined

vpe_run() is a weak symbol. If there's no definition of it, its value is
zero.

If vpe_run is zero, return failure early. We're going to fail anyway, so
there's no point in getting a VPE and attempting to load it.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Andrew Bresticker <abrestic@chromium.org>
Cc: linux-mips@linux-mips.org
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/10683/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# f58437f1 21-Jan-2014 Eric W. Biederman <ebiederm@xmission.com>

MIPS: VPE: Remove vpe_getuid and vpe_getgid

The linux build-bot recently reported a build error in arch/mips/kernel/vpe.c

tree: git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git for-linus
head: 261000a56b6382f597bcb12000f55c9ff26a1efb
commit: 261000a56b6382f597bcb12000f55c9ff26a1efb [4/4] userns: userns: Remove UIDGID_STRICT_TYPE_CHECKS
config: make ARCH=mips maltaaprp_defconfig

All error/warnings:

arch/mips/kernel/vpe.c: In function 'vpe_open':
>> arch/mips/kernel/vpe.c:1086:9: error: incompatible types when assigning to type 'unsigned int' from type 'kuid_t'
>> arch/mips/kernel/vpe.c:1087:9: error: incompatible types when assigning to type 'unsigned int' from type 'kgid_t'

vim +1086 arch/mips/kernel/vpe.c

863abad4 Jesper Juhl 2010-10-30 1080 return -ENOMEM;
863abad4 Jesper Juhl 2010-10-30 1081 }
e01402b1 Ralf Baechle 2005-07-14 1082 v->plen = P_SIZE;
e01402b1 Ralf Baechle 2005-07-14 1083 v->load_addr = NULL;
e01402b1 Ralf Baechle 2005-07-14 1084 v->len = 0;
e01402b1 Ralf Baechle 2005-07-14 1085
d76b0d9b David Howells 2008-11-14 @1086 v->uid = filp->f_cred->fsuid;
d76b0d9b David Howells 2008-11-14 @1087 v->gid = filp->f_cred->fsgid;
2600990e Ralf Baechle 2006-04-05 1088
2600990e Ralf Baechle 2006-04-05 1089 v->cwd[0] = 0;
2600990e Ralf Baechle 2006-04-05 1090 ret = getcwd(v->cwd, VPE_PATH_MAX);

When examining the code to see what v->uid and v->gid were used for I
discovered that the only users in the kernel are vpe_getuid and
vpe_getgid, and that vpe_getuid and vpe_getgid are never called.

So instead of proposing a conversion to use kuid_t and kgid_t instead
of unsigned int/int as I normally would let's just kill this dead code
so no one has to worry about it further.

Deng-Cheng Zhu said:

This is a good catch. vpe_get[u|g]id was originally used by KSPD which
has been removed.

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Reviewed-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>


# 5792bf64 01-Jan-2014 Steven J. Hill <Steven.Hill@imgtec.com>

MIPS: APRP: Code formatting clean-ups.

Clean-up code according to the 'checkpatch.pl' script.

Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
Patchwork: http://patchwork.linux-mips.org/patch/6097/
Reviewed-by: John Crispin <blogic@openwrt.org>


# 1a2a6d7e 30-Oct-2013 Dengcheng Zhu <dzhu@wavecomp.com>

MIPS: APRP: Split VPE loader into separate files.

Split the VPE functionality in preparation for adding support
for CMP platforms. Common functions remain in the original file
and a new file contains code specific to platforms that do not
have a CMP present.

Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com>
Signed-off-by: John Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/6094/


# 1b467633 11-Sep-2013 Markos Chandras <markos.chandras@imgtec.com>

MIPS: kernel: vpe: Make vpe_attrs an array of pointers.

Commit 567b21e973ccf5b0d13776e408d7c67099749eb8
"mips: convert vpe_class to use dev_groups"

broke the build on MIPS since vpe_attrs should be an array
of 'struct device_attribute' pointers.

Fixes the following build problem:
arch/mips/kernel/vpe.c:1372:2: error: missing braces around initializer
[-Werror=missing-braces]
arch/mips/kernel/vpe.c:1372:2: error: (near initialization for 'vpe_attrs[0]')
[-Werror=missing-braces]

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Crispin <blogic@openwrt.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5819/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 567b21e9 24-Jul-2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mips: convert vpe_class to use dev_groups

The dev_attrs field of struct class is going away soon, dev_groups
should be used instead. This converts the MIPS vpe_class code to use
the correct field.

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: John Crispin <blogic@openwrt.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 496ad9aa 23-Jan-2013 Al Viro <viro@zeniv.linux.org.uk>

new helper: file_inode(file)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 535237ce 16-Feb-2013 John Crispin <blogic@openwrt.org>

MIPS: remove broken conditional inside vpe loader code

The commit [1] breaks builds and results in the following error

arch/mips/kernel/vpe.c: In function 'vpe_run':
arch/mips/kernel/vpe.c:708:16: error: invalid type argument of '->' (have 'struct list_head')

Taking a closer look at the conditional we notice that list_first_entry wont
ever return NULL. The easiest fix is to just drop the dead code.

[1]
commit 3d2d03247632920aa21b42a0b032a4ffd44ce15e
MIPS: vpe.c: Fix null pointer dereference in print arguments.

Signed-off-by: John Crispin <blogic@openwrt.org>


# 70342287 21-Jan-2013 Ralf Baechle <ralf@linux-mips.org>

MIPS: Whitespace cleanup.

Having received another series of whitespace patches I decided to do this
once and for all rather than dealing with this kind of patches trickling
in forever.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 3d2d0324 14-Jan-2013 Cong Ding <dinggnu@gmail.com>

MIPS: vpe.c: Fix null pointer dereference in print arguments.

In the printk, the variable t euqals to NULL, so there is no t->index.
Use v->tc->index instead.

[ralf@linux-mips.org: Use opportunity of changing this line anyway to make
this line whitespacely correct.]

Signed-off-by: Cong Ding <dinggnu@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/4792/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 2551aebc 11-Oct-2012 Ralf Baechle <ralf@linux-mips.org>

MIPS: MT: Remove kspd.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# b81947c6 28-Mar-2012 David Howells <dhowells@redhat.com>

Disintegrate asm/system.h for MIPS

Disintegrate asm/system.h for MIPS.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
cc: linux-mips@linux-mips.org


# 848484e2 23-Jul-2011 Paul Gortmaker <paul.gortmaker@windriver.com>

mips: remove needless include of module.h from core kernel files.

None of these files are using modular infrastructure, and build
tests reveal that none of these files are really relying on any
implicit inclusions via. module.h either. So delete them.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>


# 9fbcbd7e 04-Aug-2011 Hillf Danton <dhillf@gmail.com>

MIPS: VPE: Select correct tc

If we could find tc on the tc list for @index, the found tc should be returned.

Signed-off-by: Hillf Danton <dhillf@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2692/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 60063497 26-Jul-2011 Arun Sharma <asharma@fb.com>

atomic: use <linux/atomic.h>

This allows us to move duplicated code in <asm/atomic.h>
(atomic_inc_not_zero() for now) to <linux/atomic.h>

Signed-off-by: Arun Sharma <asharma@fb.com>
Reviewed-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: David Miller <davem@davemloft.net>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 25985edc 30-Mar-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi>

Fix common misspellings

Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>


# 52bd080d 23-Jan-2011 Thomas Gleixner <tglx@linutronix.de>

MIPS: Replace deprecated spinlock initialization

SPIN_LOCK_UNLOCK is deprecated. Use the lockdep capable variant instead.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2025/
Signed-off-by: Ralf Baechle <ralf@duck.linux-mips.net>


# 7424cdf7 23-Jan-2011 Thomas Gleixner <tglx@linutronix.de>

mips: Replace deprecated spinlock initialization

SPIN_LOCK_UNLOCK is deprecated. Use the lockdep capable variant
instead.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ralf Baechle <ralf@linux-mips.org>


# 863abad4 30-Oct-2010 Jesper Juhl <jj@chaosbits.net>

MIPS: VPE loader: Check vmalloc return value in vpe_open

The return value of the vmalloc() call in arch/mips/kernel/vpe.c::vpe_open()
is not checked, so we potentially store a null pointer in v->pbuffer. Add
a check for a null return and then return -ENOMEM in that case.

[Ralf: The check added by Jesper's original patch is where it logically
should be. Adding it eleminated the need for the checks in a few other
places, so I removed them. There still is a zillion of other things that
need to be fixed in this file / API.]

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/1747/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 6038f373 15-Aug-2010 Arnd Bergmann <arnd@arndb.de>

llseek: automatically add .llseek fop

All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.

The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.

New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.

The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.

Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.

Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.

===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}

@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}

@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}

@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}

@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}

@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}

@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};

@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};

@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};

@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};

@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};

// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};

@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};

// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};

// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};

// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};

@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};

// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////

@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};

@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};

@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};

@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>


# 8facefd0 26-Feb-2010 Ralf Baechle <ralf@linux-mips.org>

MIPS: Don't include <linux/smp_lock.h> unnecessarily.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# a22d621c 08-Oct-2009 Ralf Baechle <ralf@linux-mips.org>

MIPS: VPE: Remove stray unlock_kernel.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Reported-by: Josip Rodin <joy@entuzijast.net>


# 1bbfc20d 28-Sep-2009 Ralf Baechle <ralf@linux-mips.org>

MIPS: VPE: Get rid of BKL.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 982f6ffe 16-Sep-2009 Ralf Baechle <ralf@linux-mips.org>

MIPS: Remove useless zero initializations.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# ce21f4e8 02-Aug-2009 Ralf Baechle <ralf@linux-mips.org>

MIPS: VPE: Delete unused function get_tc_unused().

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 349c4229 02-Aug-2009 Ralf Baechle <ralf@linux-mips.org>

MIPS: VPE: Fix bogus indentation.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# f18b51cc 02-Aug-2009 Ralf Baechle <ralf@linux-mips.org>

MIPS: VPE: Make various functions static.

None of these is used outside the VPE loader.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 477c4b07 02-Aug-2009 Ralf Baechle <ralf@linux-mips.org>

MIPS: VPE: Free relocation chain on error.

This may happen if a bad sequence of relocations is being encountered.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# e2a9cf96 10-Jul-2009 Raghu Gandham <raghu@mips.com>

MIPS: VPE: Fix compiler warning.

Signed-off-by: Raghu Gandham <raghu@mips.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 52a7a27c 28-Jun-2009 Joe Perches <joe@perches.com>

MIPS: MT: Remove unnecessary semicolons

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 1bb5beb4 06-Jan-2009 Kay Sievers <kay.sievers@vrfy.org>

mips: struct device - replace bus_id with dev_name(), dev_set_name()

Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 8ebcfc8b 04-Dec-2008 Nick Andrew <nick@nick-andrew.net>

MIPS: Fix incorrect use of loose in vpe.c

It should be 'lose', not 'loose'.

Signed-off-by: Nick Andrew <nick@nick-andrew.net>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# d76b0d9b 13-Nov-2008 David Howells <dhowells@redhat.com>

CRED: Use creds in file structs

Attach creds to file structs and discard f_uid/f_gid.

file_operations::open() methods (such as hppfs_open()) should use file->f_cred
rather than current_cred(). At the moment file->f_cred will be current_cred()
at this point.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: James Morris <jmorris@namei.org>
Signed-off-by: James Morris <jmorris@namei.org>


# 7558da94 15-May-2008 Jonathan Corbet <corbet@lwn.net>

mips: cdev lock_kernel() pushdown

Push the cdev lock_kernel() call into MIPS-specific drivers.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# d303f4a1 04-May-2008 Cyrill Gorcunov <gorcunov@gmail.com>

[MIPS] ELF handling - use SELFMAG instead of numeric constant

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 9f2546ad 17-Apr-2008 Ralf Baechle <ralf@linux-mips.org>

[MIPS] Don't use max_pfn which is no longer initialized these days.

Still won't play nicely with esotheric configurations such as discontig
memory ...

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# b618336a 16-Apr-2008 Kevin D. Kissell <kevink@mips.com>

[MIPS] Fixes necessary for non-SMP kernels and non-relocatable binaries

Signed-off-by: Kevin D. Kissell <kevink@mips.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 5408c490 13-Mar-2008 Ralf Baechle <ralf@linux-mips.org>

[MIPS] VPE loader: Check result of memory allocation.

And while at it, make it a little cleaner. Issue originally reported by
Tiejun Chen (tiejun.chen@windriver.com).

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# adfb8998 05-Nov-2007 Lucas Woods <woodzy@gmail.com>

[MIPS] Remove duplicate includes.

Signed-off-by: Lucas Woods <woodzy@gmail.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# b1e3afa0 19-Nov-2007 Joe Perches <joe@perches.com>

[MIPS] vpe: Add missing "space"

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 7c3a622d 08-Nov-2007 Nigel Stephens <nigel@mips.com>

[MIPS] vpe: handle halting TCs in an errata safe way.

Adds a JR.HB after halting a TC, to ensure that the TC has really halted.
only modifies the TCSTATUS register when the TC is safely halted.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 82923663 24-Oct-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] vpe: Use p_paddr instead of p_vaddr loader.

This subtle difference makes ELF overlays work.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 736fad17 15-Oct-2007 Kay Sievers <kay.sievers@vrfy.org>

[MIPS] VPE loader: convert from struct class_ device to struct device

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# bdf5d42c 10-Oct-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] VPE: reimplement ELF loader.

Loading ELF binaries based on the section table is totally wrong. This
still leaves the other fat bug of referencing symbols in an executable
unfixed, so people better don't run strip on their binaries ...

As added bonus the new loader is also 23 lines shorter.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 21a151d8 11-Oct-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] checkfiles: Fix "need space after that ','" errors.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 0f5d0df3 27-Jul-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] RP: Sysfs interface for stopping RP program

The old method of attempting to load a invalid program was just too icky.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 41790e04 27-Jul-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] RP: Pass number of TCs available to RP program in $2.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 07cc0c9e 27-Jul-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] MT: Enable coexistence of AP/SP with VSMP and SMTC.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# f5dbeaf5 22-Jul-2007 David Rientjes <rientjes@google.com>

[MIPS] Replace __attribute_used__ with __used

Replaces the deprecated __attribute_used__ with __used. Also makes some
style adjustments to abide by the kernel coding conventions.

Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 6fb88ce0 07-Jun-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] AP/SP: Avoid triggering the 34K E125 performance issue

C0_status doesn't need to be initialized at this point anyway; the register
will be initialized later.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# c4c4018b 23-Feb-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] RTLX, VPE: Make open actually atomic.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 5dfe4c96 12-Feb-2007 Arjan van de Ven <arjan@linux.intel.com>

[PATCH] mark struct file_operations const 2

Many struct file_operations in the kernel can be "const". Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data. In addition it'll catch accidental writes at compile time to
these shared resources.

[akpm@osdl.org: sparc64 fix]
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 27a3bbaf 07-Feb-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] VPE: Sprinkle device model code into code to make udev happier.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# e0daad44 04-Feb-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] Whitespace cleanups.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# be6e1437 06-Feb-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] vpe_elfload and vpe_run are only used locally, make them static.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 9cfdf6f1 24-Jan-2007 Ralf Baechle <ralf@linux-mips.org>

[MIPS] VPE loader: Initialize lists before they're actually being used ...

kspd which due to makefile order happens to be initialized before the
vpe loader causes references to vpecontrol lists before they're actually
been initialized.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 1b04fe9a 08-Dec-2006 Josef Sipek <jsipek@fsl.cs.sunysb.edu>

[PATCH] struct path: convert mips

Signed-off-by: Josef Sipek <jsipek@fsl.cs.sunysb.edu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# a94d7020 16-Aug-2006 Elizabeth Oldham <beth@mips.com>

[MIPS] MT: Fix setting of XTC.

XTC can only be set if VPA is clear, which it may not be. There is
also the possibility of a back to back c0 register access hazard to
take care of.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# e1e80b4d 01-Jul-2006 Ralf Baechle <ralf@linux-mips.org>

[MIPS] Don't include obsolete <linux/config.h>.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 79e55bcf 24-Apr-2006 Ralf Baechle <ralf@linux-mips.org>

[MIPS] Cleanup inode->r_dev usage.

imajor()/iminor() should be used instead of accessing r_dev directly.

Based on patch from Eric Sesterhenn (snakebyte@gmx.de).

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 2600990e 05-Apr-2006 Ralf Baechle <ralf@linux-mips.org>

[MIPS] kpsd and other AP/SP improvements.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 571e0bed 07-Dec-2005 Ralf Baechle <ralf@linux-mips.org>

MIPS: MT: Fix 32-bit dependencies.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 682e852e 09-Jan-2006 Alexey Dobriyan <adobriyan@gmail.com>

[PATCH] Fix more "if ((err = foo() < 0))" typos

Another reason to use:

ret = foo();
if (ret < 0)
goto out;

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 307bd284 31-Oct-2005 Ralf Baechle <ralf@linux-mips.org>

VPE loader janitoring

o Switch to dynamic major
o Remove duplicate SHN_MIPS_SCOMMON definition
o Coding style: remove typedefs.
o Coding style: reorder to avoid the need for forward declarations
o Use kzalloc.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# 340ee4b9 17-Aug-2005 Ralf Baechle <ralf@linux-mips.org>

Virtual SMP support for the 34K.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>


# e01402b1 14-Jul-2005 Ralf Baechle <ralf@linux-mips.org>

More AP / SP bits for the 34K, the Malta bits and things. Still wants
a little polishing.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>