aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/vpe.c
Commit message (Collapse)AuthorAge
* MIPS: VPE loader: Check vmalloc return value in vpe_openJesper Juhl2010-12-16
| | | | | | | | | | | | | | | | | 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>
* llseek: automatically add .llseek fopArnd Bergmann2010-10-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* MIPS: Don't include <linux/smp_lock.h> unnecessarily.Ralf Baechle2010-02-27
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* MIPS: VPE: Remove stray unlock_kernel.Ralf Baechle2009-11-02
| | | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Reported-by: Josip Rodin <joy@entuzijast.net>
* MIPS: VPE: Get rid of BKL.Ralf Baechle2009-09-30
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* MIPS: Remove useless zero initializations.Ralf Baechle2009-09-17
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* MIPS: VPE: Delete unused function get_tc_unused().Ralf Baechle2009-08-03
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* MIPS: VPE: Fix bogus indentation.Ralf Baechle2009-08-03
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* MIPS: VPE: Make various functions static.Ralf Baechle2009-08-03
| | | | | | None of these is used outside the VPE loader. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* MIPS: VPE: Free relocation chain on error.Ralf Baechle2009-08-03
| | | | | | This may happen if a bad sequence of relocations is being encountered. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* MIPS: VPE: Fix compiler warning.Raghu Gandham2009-08-03
| | | | | Signed-off-by: Raghu Gandham <raghu@mips.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* MIPS: MT: Remove unnecessary semicolonsJoe Perches2009-07-03
| | | | | Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* mips: struct device - replace bus_id with dev_name(), dev_set_name()Kay Sievers2009-01-06
| | | | | | 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>
* Merge branch 'next' into for-linusJames Morris2008-12-24
|\
| * CRED: Use creds in file structsDavid Howells2008-11-13
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | MIPS: Fix incorrect use of loose in vpe.cNick Andrew2008-12-05
|/ | | | | | | It should be 'lose', not 'loose'. Signed-off-by: Nick Andrew <nick@nick-andrew.net> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* mips: cdev lock_kernel() pushdownJonathan Corbet2008-05-18
| | | | | | Push the cdev lock_kernel() call into MIPS-specific drivers. Signed-off-by: Jonathan Corbet <corbet@lwn.net>
* [MIPS] ELF handling - use SELFMAG instead of numeric constantCyrill Gorcunov2008-05-12
| | | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] Don't use max_pfn which is no longer initialized these days.Ralf Baechle2008-05-12
| | | | | | | Still won't play nicely with esotheric configurations such as discontig memory ... Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] Fixes necessary for non-SMP kernels and non-relocatable binariesKevin D. Kissell2008-05-12
| | | | | Signed-off-by: Kevin D. Kissell <kevink@mips.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] VPE loader: Check result of memory allocation.Ralf Baechle2008-04-01
| | | | | | | 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>
* [MIPS] Remove duplicate includes.Lucas Woods2008-01-29
| | | | | Signed-off-by: Lucas Woods <woodzy@gmail.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] vpe: Add missing "space"Joe Perches2007-11-26
| | | | | Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] vpe: handle halting TCs in an errata safe way.Nigel Stephens2007-11-15
| | | | | | | 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>
* [MIPS] vpe: Use p_paddr instead of p_vaddr loader.Ralf Baechle2007-10-29
| | | | | | This subtle difference makes ELF overlays work. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] VPE loader: convert from struct class_ device to struct deviceKay Sievers2007-10-16
| | | | | Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] VPE: reimplement ELF loader.Ralf Baechle2007-10-11
| | | | | | | | | | 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>
* [MIPS] checkfiles: Fix "need space after that ','" errors.Ralf Baechle2007-10-11
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] RP: Sysfs interface for stopping RP programRalf Baechle2007-07-31
| | | | | | The old method of attempting to load a invalid program was just too icky. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] RP: Pass number of TCs available to RP program in $2.Ralf Baechle2007-07-31
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] MT: Enable coexistence of AP/SP with VSMP and SMTC.Ralf Baechle2007-07-31
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] Replace __attribute_used__ with __usedDavid Rientjes2007-07-24
| | | | | | | | | 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>
* [MIPS] AP/SP: Avoid triggering the 34K E125 performance issueRalf Baechle2007-07-06
| | | | | | | 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>
* [MIPS] RTLX, VPE: Make open actually atomic.Ralf Baechle2007-02-26
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [PATCH] mark struct file_operations const 2Arjan van de Ven2007-02-12
| | | | | | | | | | | | 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>
* [MIPS] VPE: Sprinkle device model code into code to make udev happier.Ralf Baechle2007-02-10
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] Whitespace cleanups.Ralf Baechle2007-02-06
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] vpe_elfload and vpe_run are only used locally, make them static.Ralf Baechle2007-02-06
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] VPE loader: Initialize lists before they're actually being used ...Ralf Baechle2007-01-24
| | | | | | | | 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>
* [PATCH] struct path: convert mipsJosef Sipek2006-12-08
| | | | | | 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>
* [MIPS] MT: Fix setting of XTC.Elizabeth Oldham2006-09-27
| | | | | | | | 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>
* [MIPS] Don't include obsolete <linux/config.h>.Ralf Baechle2006-07-13
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [MIPS] Cleanup inode->r_dev usage.Ralf Baechle2006-04-27
| | | | | | | | 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>
* [MIPS] kpsd and other AP/SP improvements.Ralf Baechle2006-04-18
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* MIPS: MT: Fix 32-bit dependencies.Ralf Baechle2006-01-10
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* [PATCH] Fix more "if ((err = foo() < 0))" typosAlexey Dobriyan2006-01-09
| | | | | | | | | | | 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>
* VPE loader janitoringRalf Baechle2005-11-07
| | | | | | | | | | 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>
* Virtual SMP support for the 34K.Ralf Baechle2005-10-29
| | | | Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
* More AP / SP bits for the 34K, the Malta bits and things. Still wantsRalf Baechle2005-10-29
a little polishing. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>