Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
Jeff Layton wrote: > Correct. We'd lose some fidelity in currently stored timestamps, but as > Linus and Ted pointed out, anything below ~100ns granularity is > effectively just noise, as that's the floor overhead for calling into > the kernel. It's hard to argue that any application needs that sort of > timestamp resolution, at least with contemporary hardware. Albeit with the danger of making Steve French very happy;-), would it make sense to switch internally to Microsoft-style 64-bit timestamps with their 100ns granularity? David
Re: Add fchmodat2() - or add a more general syscall?
Florian Weimer wrote: > > Rather than adding a fchmodat2() syscall, should we add a > > "set_file_attrs()" syscall that takes a mask and allows you to set a bunch > > of stuff all in one go? Basically, an interface to notify_change() in the > > kernel that would allow several stats to be set atomically. This might be > > of particular interest to network filesystems. > > Do you mean atomically as in compare-and-swap (update only if old values > match), or just a way to update multiple file attributes with a single > system call? I was thinking more in terms of the latter. AFAIK, there aren't any network filesystems support a CAS interface on file attributes like that. To be able to do a CAS operation, we'd need to pass in the old values as well as the new. Another thing we could look at is doing "create_and_set_attrs()", possibly allowing it to take a list of xattrs also. David
Add fchmodat2() - or add a more general syscall?
Rather than adding a fchmodat2() syscall, should we add a "set_file_attrs()" syscall that takes a mask and allows you to set a bunch of stuff all in one go? Basically, an interface to notify_change() in the kernel that would allow several stats to be set atomically. This might be of particular interest to network filesystems. David
Re: Memory transaction instructions
Linus Torvalds wrote: > And for the kernel, where we don't have bad locking, and where we > actually use fine-grained locks that are _near_ the data that we are > locking (the lockref of the dcache is obviously one example of that, > but the skbuff queue you mention is almost certainly exactly the same > situation): the lock is right by the data that the lock protects, and > the "shared lock cacheline" model simply does not work. You'll bounce > the data, and most likely you'll also touch the same lock cacheline > too. Yeah. The reason I was actually wondering about them was if it would be possible to avoid the requirement to disable interrupts/softirqs to, say, modify the skbuff queue. On some arches actually disabling irqs is quite a heavy operation (I think this is/was true on ppc64, for example; it certainly was on frv) and it was necessary to "emulate" the disablement. David
Memory transaction instructions
Hi Linus, I'm not sure how relevant it is to the topic, but I seem to remember you having a go at implementing spinlocks with x86_64 memory transaction instructions a while back. Do you have any thoughts on whether these instructions are ever likely to become something we can use? I was looking specifically at the skbuff queue stuff which does { spin_lock_irq, add to list, inc count, spin_unlock_irq } and thinking that might be a good place to use such a thing. David
Re: [PATCH 02/10] fs: don't allow splice read/write without explicit ops
Christoph Hellwig wrote: > > That said, for afs at least, the fix seems to be just this: > > And that is the correct fix, I was about to send it to you. Thanks. David
Re: [PATCH 02/10] fs: don't allow splice read/write without explicit ops
David Howells wrote: > > default_file_splice_write is the last piece of generic code that uses > > set_fs to make the uaccess routines operate on kernel pointers. It > > implements a "fallback loop" for splicing from files that do not actually > > provide a proper splice_read method. The usual file systems and other > > high bandwith instances all provide a ->splice_read, so this just removes > > support for various device drivers and procfs/debugfs files. If splice > > support for any of those turns out to be important it can be added back > > by switching them to the iter ops and using generic_file_splice_read. > > Hmmm... this causes the copy_file_range() syscall to fail with EINVAL in some > places where before it used to work. > > For my part, it causes the generic/112 xfstest to fail with afs, but there may > be other places. > > Is this a regression we need to fix in the VFS core? Or is it something we > need to fix in xfstests and assume userspace will fallback to doing it itself? That said, for afs at least, the fix seems to be just this: diff --git a/fs/afs/file.c b/fs/afs/file.c index 395075d7fe02..2bc6adfe351a 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -33,6 +33,7 @@ const struct file_operations afs_file_operations = { .write_iter = afs_file_write, .mmap = afs_file_mmap, .splice_read= generic_file_splice_read, + .splice_write = iter_file_splice_write, .fsync = afs_fsync, .lock = afs_lock, .flock = afs_flock, David
Re: [PATCH 02/10] fs: don't allow splice read/write without explicit ops
Christoph Hellwig wrote: > default_file_splice_write is the last piece of generic code that uses > set_fs to make the uaccess routines operate on kernel pointers. It > implements a "fallback loop" for splicing from files that do not actually > provide a proper splice_read method. The usual file systems and other > high bandwith instances all provide a ->splice_read, so this just removes > support for various device drivers and procfs/debugfs files. If splice > support for any of those turns out to be important it can be added back > by switching them to the iter ops and using generic_file_splice_read. Hmmm... this causes the copy_file_range() syscall to fail with EINVAL in some places where before it used to work. For my part, it causes the generic/112 xfstest to fail with afs, but there may be other places. Is this a regression we need to fix in the VFS core? Or is it something we need to fix in xfstests and assume userspace will fallback to doing it itself? David
Re: [PATCH v4 1/3] mm/slab: Use memzero_explicit() in kzfree()
Waiman Long wrote: > The kzfree() function is normally used to clear some sensitive > information, like encryption keys, in the buffer before freeing it back > to the pool. Memset() "memset()" is all lowercase. > is currently used for buffer clearing. However unlikely, there is still a > non-zero probability I'd say "a possibility". > that and I'd move "in [the] future" here. > the compiler may choose to optimize away the > memory clearing especially if LTO is being used in the future. To make sure > that this optimization will never happen "in these cases" > , memzero_explicit(), which is introduced in v3.18, is now used in "instead of"? > kzfree() to future-proof it. Davod
Re: [PATCH 1/2] mm, treewide: Rename kzfree() to kfree_sensitive()
Waiman Long wrote: > As said by Linus: > > A symmetric naming is only helpful if it implies symmetries in use. > Otherwise it's actively misleading. > > In "kzalloc()", the z is meaningful and an important part of what the > caller wants. > > In "kzfree()", the z is actively detrimental, because maybe in the > future we really _might_ want to use that "memfill(0xdeadbeef)" or > something. The "zero" part of the interface isn't even _relevant_. > > The main reason that kzfree() exists is to clear sensitive information > that should not be leaked to other future users of the same memory > objects. > > Rename kzfree() to kfree_sensitive() to follow the example of the > recently added kvfree_sensitive() and make the intention of the API > more explicit. In addition, memzero_explicit() is used to clear the > memory to make sure that it won't get optimized away by the compiler. > > The renaming is done by using the command sequence: > > git grep -w --name-only kzfree |\ > xargs sed -i 's/\bkzfree\b/kfree_sensitive/' > > followed by some editing of the kfree_sensitive() kerneldoc and the > use of memzero_explicit() instead of memset(). > > Suggested-by: Joe Perches > Signed-off-by: Waiman Long Since this changes a lot of crypto stuff, does it make sense for it to go via the crypto tree? Acked-by: David Howells
Re: [PATCH v1 1/2] PCI/AER: Use for_each_set_bit()
Andy Shevchenko wrote: > > but I confess to being a little ambivalent. It's > > arguably a little easier to read, > > I have another opinion here. Instead of parsing body of for-loop, the name of > the function tells you exactly what it's done. Besides the fact that reading > and parsing two lines, with zero conditionals, is faster. > > > but it's not nearly as efficient > > (not a great concern here) > > David, do you know why for_each_set_bit() has no optimization for the cases > when nbits <= BITS_PER_LONG? (Actually find_*bit() family of functions) I've not had anything to do with for_each_set_bit() itself. By 'nbits', I presume you mean the size parameter - max in the sample bit of code. It would need per-arch optimisation. Some arches have an instruction to find the next bit and some don't. Using for_each_set_bit() like this is definitely suboptimal, since find_first_bit() and find_next_bit() may well be out of line. It should probably be using something like __ffs() if size <= BITS_PER_LONG. David
Re: [PATCH v12 10/12] namei: aggressively check for nd->root escape on ".." resolution
Linus Torvalds wrote: > > Hinting to userspace to do a retry (with -EAGAIN as you mention in your > > other mail) wouldn't be a bad thing at all, though you'd almost > > certainly get quite a few spurious -EAGAINs -- &{mount,rename}_lock are > > global for the entire machine, after all. > > I'd hope that we have some future (possibly very long-term) > alternative that is not quite system-global, but yes, right now they > are. It ought to be reasonably easy to make them per-sb at least, I think. We don't allow cross-super rename, right? David
Re: Oops (request_key_auth_describe) while running cve-2016-7042 from LTP
Hi Hillf, Would you like to me to put you down as the author of this patch? If so, I'll need a Signed-off-by from you. David --- commit df882ad6d4e24a3763719c1798ea58e87d56c2d7 Author: Hillf Danton Date: Fri Aug 30 15:54:33 2019 +0100 keys: Fix missing null pointer check in request_key_auth_describe() If a request_key authentication token key gets revoked, there's a window in which request_key_auth_describe() can see it with a NULL payload - but it makes no check for this and something like the following oops may occur: BUG: Kernel NULL pointer dereference at 0x0038 Faulting instruction address: 0xc04ddf30 Oops: Kernel access of bad area, sig: 11 [#1] ... NIP [...] request_key_auth_describe+0x90/0xd0 LR [...] request_key_auth_describe+0x54/0xd0 Call Trace: [...] request_key_auth_describe+0x54/0xd0 (unreliable) [...] proc_keys_show+0x308/0x4c0 [...] seq_read+0x3d0/0x540 [...] proc_reg_read+0x90/0x110 [...] __vfs_read+0x3c/0x70 [...] vfs_read+0xb4/0x1b0 [...] ksys_read+0x7c/0x130 [...] system_call+0x5c/0x70 Fix this by checking for a NULL pointer when describing such a key. Also make the read routine check for a NULL pointer to be on the safe side. Fixes: 04c567d9313e ("[PATCH] Keys: Fix race between two instantiators of a key") Reported-by: Sachin Sant Signed-off-by: David Howells Tested-by: Sachin Sant diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c index e73ec040e250..ecba39c93fd9 100644 --- a/security/keys/request_key_auth.c +++ b/security/keys/request_key_auth.c @@ -66,6 +66,9 @@ static void request_key_auth_describe(const struct key *key, { struct request_key_auth *rka = dereference_key_rcu(key); + if (!rka) + return; + seq_puts(m, "key:"); seq_puts(m, key->description); if (key_is_positive(key)) @@ -83,6 +86,9 @@ static long request_key_auth_read(const struct key *key, size_t datalen; long ret; + if (!rka) + return -EKEYREVOKED; + datalen = rka->callout_len; ret = datalen;
Re: Oops (request_key_auth_describe) while running cve-2016-7042 from LTP
Can you try this patch instead of Hillf's? David --- commit df882ad6d4e24a3763719c1798ea58e87d56c2d7 Author: Hillf Danton Date: Fri Aug 30 15:54:33 2019 +0100 keys: Fix missing null pointer check in request_key_auth_describe() If a request_key authentication token key gets revoked, there's a window in which request_key_auth_describe() can see it with a NULL payload - but it makes no check for this and something like the following oops may occur: BUG: Kernel NULL pointer dereference at 0x0038 Faulting instruction address: 0xc04ddf30 Oops: Kernel access of bad area, sig: 11 [#1] ... NIP [...] request_key_auth_describe+0x90/0xd0 LR [...] request_key_auth_describe+0x54/0xd0 Call Trace: [...] request_key_auth_describe+0x54/0xd0 (unreliable) [...] proc_keys_show+0x308/0x4c0 [...] seq_read+0x3d0/0x540 [...] proc_reg_read+0x90/0x110 [...] __vfs_read+0x3c/0x70 [...] vfs_read+0xb4/0x1b0 [...] ksys_read+0x7c/0x130 [...] system_call+0x5c/0x70 Fix this by checking for a NULL pointer when describing such a key. Also make the read routine check for a NULL pointer to be on the safe side. Fixes: 04c567d9313e ("[PATCH] Keys: Fix race between two instantiators of a key") Reported-by: Sachin Sant Signed-off-by: David Howells diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c index e73ec040e250..ecba39c93fd9 100644 --- a/security/keys/request_key_auth.c +++ b/security/keys/request_key_auth.c @@ -66,6 +66,9 @@ static void request_key_auth_describe(const struct key *key, { struct request_key_auth *rka = dereference_key_rcu(key); + if (!rka) + return; + seq_puts(m, "key:"); seq_puts(m, key->description); if (key_is_positive(key)) @@ -83,6 +86,9 @@ static long request_key_auth_read(const struct key *key, size_t datalen; long ret; + if (!rka) + return -EKEYREVOKED; + datalen = rka->callout_len; ret = datalen;
Re: Oops (request_key_auth_describe) while running cve-2016-7042 from LTP
Hillf Danton wrote: > 1, callee has no pre defined duty to help caller in general; they should not > try to do anything, however, to help their callers in principle due to > limited info on their hands IMO. Ah, no. It's entirely reasonable for an API to specify that one of its methods will be called with one or more locks held - and that the method must be aware of this and may make use of this. > 3, no comment can be found in security/keys/request_key_auth.c about > the rcu already documented. There is API documentation in Documentation/security/keys/core.rst. If you look at about line 1538 onwards: * ``void (*describe)(const struct key *key, struct seq_file *p);`` This method is optional. It is called during /proc/keys reading to summarise a key's description and payload in text form. This method will be called with the RCU read lock held. rcu_dereference() should be used to read the payload pointer if the payload is to be accessed. key->datalen cannot be trusted to stay consistent with the contents of the payload. The description will not change, though the key's state may. It is not safe to sleep in this method; the RCU read lock is held by the caller. David
Re: Oops (request_key_auth_describe) while running cve-2016-7042 from LTP
Hillf Danton wrote: > - struct request_key_auth *rka = dereference_key_rcu(key); > + struct request_key_auth *rka; > + > + rcu_read_lock(); > + rka = dereference_key_rcu(key); This shouldn't help as the caller, proc_keys_show(), is holding the RCU read lock across the call. The end of the function reads: if (key->type->describe) key->type->describe(key, m); seq_putc(m, '\n'); rcu_read_unlock(); return 0; } and the documentation says "This method will be called with the RCU read lock held". I suspect the actual bugfix is this bit: > + if (!rka) > + goto out; David
Re: [PATCH 1/2] open: add close_range()
Al Viro wrote: > Umm... That's going to be very painful if you dup2() something to MAX_INT and > then run that; roughly 2G iterations of bouncing ->file_lock up and down, > without anything that would yield CPU in process. > > If anything, I would suggest something like > > fd = *start_fd; > grab the lock > fdt = files_fdtable(files); > more: > look for the next eviction candidate in ->open_fds, starting at fd > if there's none up to max_fd > drop the lock > return NULL > *start_fd = fd + 1; > if the fscker is really opened and not just reserved > rcu_assign_pointer(fdt->fd[fd], NULL); > __put_unused_fd(files, fd); > drop the lock > return the file we'd got > if (unlikely(need_resched())) > drop lock > cond_resched(); > grab lock > fdt = files_fdtable(files); > goto more; > > with the main loop being basically > while ((file = pick_next(files, _fd, max_fd)) != NULL) > filp_close(file, files); If we can live with close_from(int first) rather than close_range(), then this can perhaps be done a lot more efficiently by: new = alloc_fdtable(first); spin_lock(>file_lock); old = files_fdtable(files); copy_fds(new, old, 0, first - 1); rcu_assign_pointer(files->fdt, new); spin_unlock(>file_lock); clear_fds(old, 0, first - 1); close_fdt_from(old, first); kfree_rcu(old); David
[RFC PATCH 00/68] VFS: Convert a bunch of filesystems to the new mount API
Hi Al, Here's a set of patches that converts a bunch (but not yet all!) to the new mount API. To this end, it makes the following changes: (1) Provides a convenience member in struct fs_context that is OR'd into sb->s_iflags by sget_fc(). (2) Provides a convenience helper function, vfs_init_pseudo_fs_context(), for doing most of the work in mounting a pseudo filesystem. (3) Provides a convenience helper function, vfs_get_block_super(), for doing the work in setting up a block-based superblock. (4) Improves the handling of fd-type parameters. (5) Moves some of the subtype handling int fuse. (6) Provides a convenience helper function, vfs_get_mtd_super(), for doing the work in setting up an MTD device-based superblock. (7) Kills off mount_pseudo(), mount_pseudo_xattr(), mount_ns(), sget_userns(), mount_mtd(), mount_single(). (8) Converts a slew of filesystems to use the mount API. (9) Fixes a bug in hypfs. The patches can be found here also: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git on branch: mount-api-viro David --- Andrew Price (1): gfs2: Convert gfs2 to fs_context David Howells (66): vfs: Update mount API docs vfs: Fix refcounting of filenames in fs_parser vfs: Provide sb->s_iflags settings in fs_context struct vfs: Provide a mount_pseudo-replacement for the new mount API vfs: Convert aio to use the new mount API vfs: Convert anon_inodes to use the new mount API vfs: Convert bdev to use the new mount API vfs: Convert nsfs to use the new mount API vfs: Convert pipe to use the new mount API vfs: Convert zsmalloc to use the new mount API vfs: Convert sockfs to use the new mount API vfs: Convert dax to use the new mount API vfs: Convert drm to use the new mount API vfs: Convert ia64 perfmon to use the new mount API vfs: Convert cxl to use the new mount API vfs: Convert ocxlflash to use the new mount API vfs: Convert virtio_balloon to use the new mount API vfs: Convert btrfs_test to use the new mount API vfs: Kill off mount_pseudo() and mount_pseudo_xattr() vfs: Use sget_fc() for pseudo-filesystems vfs: Convert binderfs to use the new mount API vfs: Convert nfsctl to use the new mount API vfs: Convert rpc_pipefs to use the new mount API vfs: Kill mount_ns() vfs: Kill sget_userns() vfs: Convert binfmt_misc to use the new mount API vfs: Convert configfs to use the new mount API vfs: Convert efivarfs to use the new mount API vfs: Convert fusectl to use the new mount API vfs: Convert qib_fs/ipathfs to use the new mount API vfs: Convert ibmasmfs to use the new mount API vfs: Convert oprofilefs to use the new mount API vfs: Convert gadgetfs to use the new mount API vfs: Convert xenfs to use the new mount API vfs: Convert openpromfs to use the new mount API vfs: Convert apparmorfs to use the new mount API vfs: Convert securityfs to use the new mount API vfs: Convert selinuxfs to use the new mount API vfs: Convert smackfs to use the new mount API vfs: Convert ramfs, shmem, tmpfs, devtmpfs, rootfs to use the new mount API vfs: Create fs_context-aware mount_bdev() replacement vfs: Make fs_parse() handle fs_param_is_fd-type params better vfs: Convert fuse to use the new mount API vfs: Move the subtype parameter into fuse mtd: Provide fs_context-aware mount_mtd() replacement vfs: Convert romfs to use the new mount API vfs: Convert cramfs to use the new mount API vfs: Convert jffs2 to use the new mount API mtd: Kill mount_mtd() vfs: Convert squashfs to use the new mount API vfs: Convert ceph to use the new mount API vfs: Convert functionfs to use the new mount API vfs: Add a single-or-reconfig keying to vfs_get_super() vfs: Convert debugfs to use the new mount API vfs: Convert tracefs to use the new mount API vfs: Convert pstore to use the new mount API hypfs: Fix error number left in struct pointer member vfs: Convert hypfs to use the new mount API vfs: Convert spufs to use the new mount API vfs: Kill mount_single() vfs: Convert coda to use the new mount API vfs: Convert autofs to use the new mount API vfs: Convert devpts to use the new mount API vfs: Convert bpf to use the new mount API vfs: Convert ubifs to use the new mount API vfs: Convert orangefs to use the new mount API Masahiro Yamada (1): kbuild: skip sub-make for in-tree build with GNU Make 4.x Documentation/filesystems/mount_api.txt | 367 --- Documentation/filesystems/vfs.txt |4 Makefile | 31 + arch/ia64/kernel/perfmon.c| 14 - arch/powerpc/platforms/cell/spufs/inode.c
[RFC PATCH 60/68] vfs: Convert spufs to use the new mount API
Convert the spufs filesystem to the new internal mount API as the old one will be obsoleted and removed. This allows greater flexibility in communication of mount parameters between userspace, the VFS and the filesystem. See Documentation/filesystems/mount_api.txt for more information. Signed-off-by: David Howells cc: Jeremy Kerr cc: Arnd Bergmann cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/platforms/cell/spufs/inode.c | 207 - 1 file changed, 116 insertions(+), 91 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index db329d4bf1c3..f951a7fe4e3c 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include #include @@ -33,7 +35,6 @@ #include #include #include -#include #include #include @@ -43,7 +44,7 @@ #include "spufs.h" struct spufs_sb_info { - int debug; + bool debug; }; static struct kmem_cache *spufs_inode_cache; @@ -593,16 +594,27 @@ long spufs_create(struct path *path, struct dentry *dentry, } /* File system initialization */ +struct spufs_fs_context { + kuid_t uid; + kgid_t gid; + umode_t mode; +}; + enum { - Opt_uid, Opt_gid, Opt_mode, Opt_debug, Opt_err, + Opt_uid, Opt_gid, Opt_mode, Opt_debug, +}; + +static const struct fs_parameter_spec spufs_param_specs[] = { + fsparam_u32 ("gid", Opt_gid), + fsparam_u32oct ("mode",Opt_mode), + fsparam_u32 ("uid", Opt_uid), + fsparam_flag("debug", Opt_debug), + {} }; -static const match_table_t spufs_tokens = { - { Opt_uid, "uid=%d" }, - { Opt_gid, "gid=%d" }, - { Opt_mode, "mode=%o" }, - { Opt_debug, "debug" }, - { Opt_err,NULL }, +static const struct fs_parameter_description spufs_fs_parameters = { + .name = "spufs", + .specs = spufs_param_specs, }; static int spufs_show_options(struct seq_file *m, struct dentry *root) @@ -623,47 +635,41 @@ static int spufs_show_options(struct seq_file *m, struct dentry *root) return 0; } -static int -spufs_parse_options(struct super_block *sb, char *options, struct inode *root) -{ - char *p; - substring_t args[MAX_OPT_ARGS]; - - while ((p = strsep(, ",")) != NULL) { - int token, option; - - if (!*p) - continue; - - token = match_token(p, spufs_tokens, args); - switch (token) { - case Opt_uid: - if (match_int([0], )) - return 0; - root->i_uid = make_kuid(current_user_ns(), option); - if (!uid_valid(root->i_uid)) - return 0; - break; - case Opt_gid: - if (match_int([0], )) - return 0; - root->i_gid = make_kgid(current_user_ns(), option); - if (!gid_valid(root->i_gid)) - return 0; - break; - case Opt_mode: - if (match_octal([0], )) - return 0; - root->i_mode = option | S_IFDIR; - break; - case Opt_debug: - spufs_get_sb_info(sb)->debug = 1; - break; - default: - return 0; - } +static int spufs_parse_param(struct fs_context *fc, struct fs_parameter *param) +{ + struct spufs_fs_context *ctx = fc->fs_private; + struct spufs_sb_info *sbi = fc->s_fs_info; + struct fs_parse_result result; + kuid_t uid; + kgid_t gid; + int opt; + + opt = fs_parse(fc, _fs_parameters, param, ); + if (opt < 0) + return opt; + + switch (opt) { + case Opt_uid: + uid = make_kuid(current_user_ns(), result.uint_32); + if (!uid_valid(uid)) + return invalf(fc, "Unknown uid"); + ctx->uid = uid; + break; + case Opt_gid: + gid = make_kgid(current_user_ns(), result.uint_32); + if (!gid_valid(gid)) + return invalf(fc, "Unknown gid"); + ctx->gid = gid; + break; + case Opt_mode: + ctx->mode = result.uint_32 & S_IALLUGO; + break; + case Opt_debug: +
[RFC PATCH 16/68] vfs: Convert cxl to use the new mount API
Convert the cxl filesystem to the new internal mount API as the old one will be obsoleted and removed. This allows greater flexibility in communication of mount parameters between userspace, the VFS and the filesystem. See Documentation/filesystems/mount_api.txt for more information. Signed-off-by: David Howells Acked-by: Andrew Donnellan Acked-by: Frederic Barrat cc: linuxppc-dev@lists.ozlabs.org --- drivers/misc/cxl/api.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index 750470ef2049..395e9a88e6ba 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -41,17 +42,16 @@ static const struct dentry_operations cxl_fs_dops = { .d_dname= simple_dname, }; -static struct dentry *cxl_fs_mount(struct file_system_type *fs_type, int flags, - const char *dev_name, void *data) +static int cxl_fs_init_fs_context(struct fs_context *fc) { - return mount_pseudo(fs_type, "cxl:", NULL, _fs_dops, - CXL_PSEUDO_FS_MAGIC); + return vfs_init_pseudo_fs_context(fc, "cxl:", NULL, NULL, + _fs_dops, CXL_PSEUDO_FS_MAGIC); } static struct file_system_type cxl_fs_type = { .name = "cxl", .owner = THIS_MODULE, - .mount = cxl_fs_mount, + .init_fs_context = cxl_fs_init_fs_context, .kill_sb= kill_anon_super, };
[RFC PATCH 7/8] vfs: Convert spufs to fs_context
Signed-off-by: David Howells cc: Jeremy Kerr cc: Arnd Bergmann cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/platforms/cell/spufs/inode.c | 207 - 1 file changed, 116 insertions(+), 91 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index db329d4bf1c3..f951a7fe4e3c 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include #include @@ -33,7 +35,6 @@ #include #include #include -#include #include #include @@ -43,7 +44,7 @@ #include "spufs.h" struct spufs_sb_info { - int debug; + bool debug; }; static struct kmem_cache *spufs_inode_cache; @@ -593,16 +594,27 @@ long spufs_create(struct path *path, struct dentry *dentry, } /* File system initialization */ +struct spufs_fs_context { + kuid_t uid; + kgid_t gid; + umode_t mode; +}; + enum { - Opt_uid, Opt_gid, Opt_mode, Opt_debug, Opt_err, + Opt_uid, Opt_gid, Opt_mode, Opt_debug, +}; + +static const struct fs_parameter_spec spufs_param_specs[] = { + fsparam_u32 ("gid", Opt_gid), + fsparam_u32oct ("mode",Opt_mode), + fsparam_u32 ("uid", Opt_uid), + fsparam_flag("debug", Opt_debug), + {} }; -static const match_table_t spufs_tokens = { - { Opt_uid, "uid=%d" }, - { Opt_gid, "gid=%d" }, - { Opt_mode, "mode=%o" }, - { Opt_debug, "debug" }, - { Opt_err,NULL }, +static const struct fs_parameter_description spufs_fs_parameters = { + .name = "spufs", + .specs = spufs_param_specs, }; static int spufs_show_options(struct seq_file *m, struct dentry *root) @@ -623,47 +635,41 @@ static int spufs_show_options(struct seq_file *m, struct dentry *root) return 0; } -static int -spufs_parse_options(struct super_block *sb, char *options, struct inode *root) -{ - char *p; - substring_t args[MAX_OPT_ARGS]; - - while ((p = strsep(, ",")) != NULL) { - int token, option; - - if (!*p) - continue; - - token = match_token(p, spufs_tokens, args); - switch (token) { - case Opt_uid: - if (match_int([0], )) - return 0; - root->i_uid = make_kuid(current_user_ns(), option); - if (!uid_valid(root->i_uid)) - return 0; - break; - case Opt_gid: - if (match_int([0], )) - return 0; - root->i_gid = make_kgid(current_user_ns(), option); - if (!gid_valid(root->i_gid)) - return 0; - break; - case Opt_mode: - if (match_octal([0], )) - return 0; - root->i_mode = option | S_IFDIR; - break; - case Opt_debug: - spufs_get_sb_info(sb)->debug = 1; - break; - default: - return 0; - } +static int spufs_parse_param(struct fs_context *fc, struct fs_parameter *param) +{ + struct spufs_fs_context *ctx = fc->fs_private; + struct spufs_sb_info *sbi = fc->s_fs_info; + struct fs_parse_result result; + kuid_t uid; + kgid_t gid; + int opt; + + opt = fs_parse(fc, _fs_parameters, param, ); + if (opt < 0) + return opt; + + switch (opt) { + case Opt_uid: + uid = make_kuid(current_user_ns(), result.uint_32); + if (!uid_valid(uid)) + return invalf(fc, "Unknown uid"); + ctx->uid = uid; + break; + case Opt_gid: + gid = make_kgid(current_user_ns(), result.uint_32); + if (!gid_valid(gid)) + return invalf(fc, "Unknown gid"); + ctx->gid = gid; + break; + case Opt_mode: + ctx->mode = result.uint_32 & S_IALLUGO; + break; + case Opt_debug: + sbi->debug = true; + break; } - return 1; + + return 0; } static void spufs_exit_isolated_loader(void) @@ -697,79 +703,98 @@ spufs_init_isolated_loader(void) printk(KERN_INFO "spufs: SPU isolation mode enabled\n"); } -static int -spuf
[RFC PATCH 0/8] Convert mount_single-using filesystems to fs_context
Hi Al, Here's a set of patches that converts the mount_single()-using filesystems to use the new fs_context struct. There may be prerequisite commits in the branch detailed below. (1) Add a new keying to vfs_get_super() that indicates that ->reconfigure() should be called instead of (*fill_super)() if the superblock already exists. (2) Convert debugfs. (3) Convert tracefs. (4) Convert pstore. (5) Fix a bug in hypfs. (6) Convert hypfs. (7) Convert spufs. (8) Kill off mount_single(). These can be found in the following branch: http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=mount-api-viro Thanks, David --- David Howells (8): vfs: Add a single-or-reconfig keying to vfs_get_super() vfs: Convert debugfs to fs_context vfs: Convert tracefs to fs_context vfs: Convert pstore to fs_context hypfs: Fix error number left in struct pointer member vfs: Convert hypfs to fs_context vfs: Convert spufs to fs_context vfs: Kill off mount_single() Documentation/filesystems/vfs.txt |4 - arch/powerpc/platforms/cell/spufs/inode.c | 207 - arch/s390/hypfs/inode.c | 137 +++ fs/debugfs/inode.c| 186 -- fs/pstore/inode.c | 110 ++- fs/super.c| 73 ++ fs/tracefs/inode.c| 180 - include/linux/fs.h|3 include/linux/fs_context.h|1 9 files changed, 446 insertions(+), 455 deletions(-)
[PATCH 00/38] VFS: Convert trivial filesystems and more
Hi Al, Here's a set of patches that: (1) Provides a convenience member in struct fs_context that is OR'd into sb->s_iflags by sget_fc(). (2) Provides a convenience vfs_init_pseudo_fs_context() helper function for doing most of the work in mounting a pseudo filesystem. (3) Converts all the trivial filesystems that have no arguments to fs_context. (4) Converts binderfs (which was trivial before January). (5) Converts ramfs, tmpfs, rootfs and devtmpfs. (6) Kills off mount_pseudo(), mount_pseudo_xattr(), mount_ns(), sget_userns(). The patches can be found here also: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git on branch: mount-api-viro David --- David Howells (38): vfs: Provide sb->s_iflags settings in fs_context struct vfs: Provide a mount_pseudo-replacement for fs_context vfs: Convert aio to fs_context vfs: Convert anon_inodes to fs_context vfs: Convert bdev to fs_context vfs: Convert nsfs to fs_context vfs: Convert pipe to fs_context vfs: Convert zsmalloc to fs_context vfs: Convert sockfs to fs_context vfs: Convert dax to fs_context vfs: Convert drm to fs_context vfs: Convert ia64 perfmon to fs_context vfs: Convert cxl to fs_context vfs: Convert ocxlflash to fs_context vfs: Convert virtio_balloon to fs_context vfs: Convert btrfs_test to fs_context vfs: Kill off mount_pseudo() and mount_pseudo_xattr() vfs: Use sget_fc() for pseudo-filesystems vfs: Convert binderfs to fs_context vfs: Convert nfsctl to fs_context vfs: Convert rpc_pipefs to fs_context vfs: Kill off mount_ns() vfs: Kill sget_userns() vfs: Convert binfmt_misc to fs_context vfs: Convert configfs to fs_context vfs: Convert efivarfs to fs_context vfs: Convert fusectl to fs_context vfs: Convert qib_fs/ipathfs to fs_context vfs: Convert ibmasmfs to fs_context vfs: Convert oprofilefs to fs_context vfs: Convert gadgetfs to fs_context vfs: Convert xenfs to fs_context vfs: Convert openpromfs to fs_context vfs: Convert apparmorfs to fs_context vfs: Convert securityfs to fs_context vfs: Convert selinuxfs to fs_context vfs: Convert smackfs to fs_context tmpfs, devtmpfs, ramfs, rootfs: Convert to fs_context arch/ia64/kernel/perfmon.c | 14 + drivers/android/binderfs.c | 173 +--- drivers/base/devtmpfs.c| 16 + drivers/dax/super.c| 13 + drivers/gpu/drm/drm_drv.c | 14 + drivers/infiniband/hw/qib/qib_fs.c | 26 ++ drivers/misc/cxl/api.c | 10 - drivers/misc/ibmasm/ibmasmfs.c | 21 +- drivers/oprofile/oprofilefs.c | 20 +- drivers/scsi/cxlflash/ocxl_hw.c| 21 +- drivers/usb/gadget/legacy/inode.c | 21 +- drivers/virtio/virtio_balloon.c| 19 +- drivers/xen/xenfs/super.c | 21 +- fs/aio.c | 15 + fs/anon_inodes.c | 12 + fs/binfmt_misc.c | 20 +- fs/block_dev.c | 14 + fs/btrfs/tests/btrfs-tests.c | 13 + fs/configfs/mount.c| 20 +- fs/efivarfs/super.c| 20 +- fs/fuse/control.c | 20 +- fs/libfs.c | 91 ++-- fs/nfsd/nfsctl.c | 33 ++- fs/nsfs.c | 13 + fs/openpromfs/inode.c | 20 +- fs/pipe.c | 12 + fs/ramfs/inode.c | 104 ++--- fs/super.c | 106 ++ include/linux/fs.h | 21 -- include/linux/fs_context.h |8 + include/linux/ramfs.h |6 - include/linux/shmem_fs.h |4 init/do_mounts.c | 12 - mm/shmem.c | 396 mm/zsmalloc.c | 19 +- net/socket.c | 14 + net/sunrpc/rpc_pipe.c | 34 ++- security/apparmor/apparmorfs.c | 20 +- security/inode.c | 21 +- security/selinux/selinuxfs.c | 20 +- security/smack/smackfs.c | 34 ++- 41 files changed, 902 insertions(+), 609 deletions(-)
[PATCH 13/38] vfs: Convert cxl to fs_context
Signed-off-by: David Howells cc: Frederic Barrat cc: Andrew Donnellan cc: linuxppc-dev@lists.ozlabs.org --- drivers/misc/cxl/api.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index 750470ef2049..395e9a88e6ba 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -41,17 +42,16 @@ static const struct dentry_operations cxl_fs_dops = { .d_dname= simple_dname, }; -static struct dentry *cxl_fs_mount(struct file_system_type *fs_type, int flags, - const char *dev_name, void *data) +static int cxl_fs_init_fs_context(struct fs_context *fc) { - return mount_pseudo(fs_type, "cxl:", NULL, _fs_dops, - CXL_PSEUDO_FS_MAGIC); + return vfs_init_pseudo_fs_context(fc, "cxl:", NULL, NULL, + _fs_dops, CXL_PSEUDO_FS_MAGIC); } static struct file_system_type cxl_fs_type = { .name = "cxl", .owner = THIS_MODULE, - .mount = cxl_fs_mount, + .init_fs_context = cxl_fs_init_fs_context, .kill_sb= kill_anon_super, };
Re: [PATCH 0/2] Use ARRAY_SIZE to replace its implementation
> "Use ARRAY_SIZE to replace its implementation" Um, the subject line doesn't make sense. David
[PATCH 07/14] spufs: Implement show_options
Implement the show_options superblock op for spufs as part of a bid to get rid of s_options and generic_show_options() to make it easier to implement a context-based mount where the mount options can be passed individually over a file descriptor. Signed-off-by: David Howells <dhowe...@redhat.com> cc: Jeremy Kerr <j...@ozlabs.org> cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/platforms/cell/spufs/inode.c | 21 ++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index d8af9bc0489f..27a51a60bc33 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -605,6 +605,23 @@ static const match_table_t spufs_tokens = { { Opt_err,NULL }, }; +static int spufs_show_options(struct seq_file *m, struct dentry *root) +{ + struct spufs_sb_info *sbi = spufs_get_sb_info(root->d_sb); + + if (!uid_eq(root->i_uid, GLOBAL_ROOT_UID)) + seq_printf(m, ",uid=%u", + from_kuid_munged(_user_ns, root->i_uid)); + if (!gid_eq(root->i_gid, GLOBAL_ROOT_GID)) + seq_printf(m, ",gid=%u", + from_kgid_munged(_user_ns, root->i_gid)); + if (root->i_mode & S_IALLUGO != 0775) + seq_printf(m, ",mode=%o", root->i_mode); + if (sbi->debug) + seq_puts(m, ",debug"); + return 0; +} + static int spufs_parse_options(struct super_block *sb, char *options, struct inode *root) { @@ -724,11 +741,9 @@ spufs_fill_super(struct super_block *sb, void *data, int silent) .destroy_inode = spufs_destroy_inode, .statfs = simple_statfs, .evict_inode = spufs_evict_inode, - .show_options = generic_show_options, + .show_options = spufs_show_options, }; - save_mount_options(sb, data); - info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM;
[no subject]
> -header-y += msr-index.h I see it on my desktop as /usr/include/asm/msr-index.h and it's been there at least four years - and as such it's part of the UAPI. I don't think you can remove it unless you can guarantee there are no userspace users. David
[no subject]
Nicolas Dichtelwrote: > This header file is exported, thus move it to uapi. Exported how? > +#ifdef __INT32_TYPE__ > +#undef __INT32_TYPE__ > +#define __INT32_TYPE__ int > +#endif > + > +#ifdef __UINT32_TYPE__ > +#undef __UINT32_TYPE__ > +#define __UINT32_TYPE__ unsigned int > +#endif > + > +#ifdef __UINTPTR_TYPE__ > +#undef __UINTPTR_TYPE__ > +#define __UINTPTR_TYPE__ unsigned long > +#endif These weren't defined by the kernel before, so why do we need to define them now? Will defining __UINTPTR_TYPE__ cause problems in compiling libboost by changing the signature on C++ functions that use uintptr_t? David
Re: [PATCH] documentation: Add disclaimer
Paul E. McKenneywrote: > Good point! Would you be willing to add a Signed-off-by so I > can take the combined change, assuming Peter and Will are good > with it? Sure! David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] documentation: Add disclaimer
Peter Zijlstrawrote: > +== > +DISCLAIMER > +== > + > +This document is not a specification; it is intentionally (for the sake of > +brevity) and unintentionally (due to being human) incomplete. This document > is > +meant as a guide to using the various memory barriers provided by Linux, but > +in case of any doubt (and there are many) please ask. > + > +I repeat, this document is not a specification of what Linux expects from > +hardware. The purpose of this document is twofold: (1) to specify the minimum functionality that one can rely on for any particular barrier, and (2) to provide a guide as to how to use the barriers that are available. Note that an architecture can provide more than the minimum requirement for any particular barrier, but if the barrier provides less than that, it is incorrect. Note also that it is possible that a barrier may be a no-op for an architecture because the way that arch works renders an explicit barrier unnecessary in that case. > + Can you bung an extra blank line in here if you have to redo this at all? > + > +CONTENTS > + > > (*) Abstract memory access model. > David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: roundup_pow_of_two() may not handle 64-bit integers
Brian Norris computersforpe...@gmail.com wrote: I'm looking to use roundup_pow_of_two() (actually, order_base_2()) from linux/log2.h, but it seems that it only supports 64-bit integers if your toolchain uses a 64-bit 'unsigned long' type. This is strange, considering that ilog2() is explicitly designed for 32-bit or 64-bit compatibility. ilog2() was explicitly designed for use with 'unsigned long'. See the commit description (f0d1b0b30d250a07627ad8b9fbbb5c7cc08422e8). It may work with unsigned long long, however... David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 04/28] proc: Supply PDE attribute setting accessor functions [RFC]
Supply accessor functions to set attributes in proc_dir_entry structs. The following are supplied: proc_set_size() and proc_set_user(). Signed-off-by: David Howells dhowe...@redhat.com cc: linuxppc-dev@lists.ozlabs.org cc: linux-me...@vger.kernel.org cc: net...@vger.kernel.org cc: linux-wirel...@vger.kernel.org cc: linux-...@vger.kernel.org cc: netfilter-de...@vger.kernel.org cc: alsa-de...@alsa-project.org --- arch/powerpc/kernel/proc_powerpc.c|2 +- arch/powerpc/platforms/pseries/reconfig.c |2 +- drivers/media/pci/ttpci/av7110_ir.c |2 +- drivers/net/irda/vlsi_ir.c|2 +- drivers/net/wireless/airo.c | 34 + drivers/pci/proc.c|2 +- fs/proc/generic.c | 13 +++ include/linux/proc_fs.h |5 kernel/configs.c |2 +- kernel/profile.c |2 +- net/netfilter/xt_recent.c |3 +-- sound/core/info.c |2 +- 12 files changed, 38 insertions(+), 33 deletions(-) diff --git a/arch/powerpc/kernel/proc_powerpc.c b/arch/powerpc/kernel/proc_powerpc.c index 41d8ee9..feb8580 100644 --- a/arch/powerpc/kernel/proc_powerpc.c +++ b/arch/powerpc/kernel/proc_powerpc.c @@ -83,7 +83,7 @@ static int __init proc_ppc64_init(void) page_map_fops, vdso_data); if (!pde) return 1; - pde-size = PAGE_SIZE; + proc_set_size(pde, PAGE_SIZE); return 0; } diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c index d6491bd..f93cdf5 100644 --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c @@ -452,7 +452,7 @@ static int proc_ppc64_create_ofdt(void) ent = proc_create(powerpc/ofdt, S_IWUSR, NULL, ofdt_fops); if (ent) - ent-size = 0; + proc_set_size(ent, 0); return 0; } diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c index eb82286..0e763a7 100644 --- a/drivers/media/pci/ttpci/av7110_ir.c +++ b/drivers/media/pci/ttpci/av7110_ir.c @@ -375,7 +375,7 @@ int av7110_ir_init(struct av7110 *av7110) if (av_cnt == 1) { e = proc_create(av7110_ir, S_IWUSR, NULL, av7110_ir_proc_fops); if (e) - e-size = 4 + 256 * sizeof(u16); + proc_set_size(e, 4 + 256 * sizeof(u16)); } tasklet_init(av7110-ir.ir_tasklet, av7110_emit_key, (unsigned long) av7110-ir); diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c index e22cd4e..5f47584 100644 --- a/drivers/net/irda/vlsi_ir.c +++ b/drivers/net/irda/vlsi_ir.c @@ -1678,7 +1678,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id) IRDA_WARNING(%s: failed to create proc entry\n, __func__); } else { - ent-size = 0; + proc_set_size(ent, 0); } idev-proc_entry = ent; } diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 66e398d..21d0233 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -4507,73 +4507,63 @@ static int setup_proc_entry( struct net_device *dev, airo_entry); if (!apriv-proc_entry) goto fail; - apriv-proc_entry-uid = proc_kuid; - apriv-proc_entry-gid = proc_kgid; + proc_set_user(apriv-proc_entry, proc_kuid, proc_kgid); /* Setup the StatsDelta */ entry = proc_create_data(StatsDelta, S_IRUGO proc_perm, apriv-proc_entry, proc_statsdelta_ops, dev); if (!entry) goto fail_stats_delta; - entry-uid = proc_kuid; - entry-gid = proc_kgid; + proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the Stats */ entry = proc_create_data(Stats, S_IRUGO proc_perm, apriv-proc_entry, proc_stats_ops, dev); if (!entry) goto fail_stats; - entry-uid = proc_kuid; - entry-gid = proc_kgid; + proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the Status */ entry = proc_create_data(Status, S_IRUGO proc_perm, apriv-proc_entry, proc_status_ops, dev); if (!entry) goto fail_status; - entry-uid = proc_kuid; - entry-gid = proc_kgid; + proc_set_user(entry, proc_kuid, proc_kgid); /* Setup the Config */ entry = proc_create_data(Config, proc_perm, apriv-proc_entry, proc_config_ops, dev); if (!entry) goto fail_config; - entry-uid
[PATCH 22/28] ppc: Clean up rtas_flash driver somewhat [RFC]
Clean up some of the problems with the rtas_flash driver: (1) It shouldn't fiddle with the internals of the procfs filesystem (altering pde-count). (2) If pid namespaces are in effect, then you can get multiple inodes connected to a single pde, thereby rendering the pde-count 2 test useless. (3) The pde-count fudging doesn't work for forked, dup'd or cloned file descriptors, so add static mutexes and use them to wrap access to the driver through read, write and release methods. (4) The driver can only handle one device, so allocate most of the data previously attached to the pde-data as static variables instead (though allocate the validation data buffer with kmalloc). (5) We don't need to save the pde pointers as long as we have the filenames available for removal. (6) Don't try to multiplex what the update file read method does based on the filename. Instead provide separate file ops and split the function. Whilst we're at it, tabulate the procfile information and loop through it when creating or destroying them rather than manually coding each one. Signed-off-by: David Howells dhowe...@redhat.com cc: Benjamin Herrenschmidt b...@kernel.crashing.org cc: Paul Mackerras pau...@samba.org cc: Anton Blanchard an...@samba.org cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/rtas_flash.c | 446 +- 1 file changed, 200 insertions(+), 246 deletions(-) diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c index c642f01..8196bfb 100644 --- a/arch/powerpc/kernel/rtas_flash.c +++ b/arch/powerpc/kernel/rtas_flash.c @@ -102,9 +102,10 @@ static struct kmem_cache *flash_block_cache = NULL; #define FLASH_BLOCK_LIST_VERSION (1UL) -/* Local copy of the flash block list. - * We only allow one open of the flash proc file and create this - * list as we go. The rtas_firmware_flash_list varable will be +/* + * Local copy of the flash block list. + * + * The rtas_firmware_flash_list varable will be * set once the data is fully read. * * For convenience as we build the list we use virtual addrs, @@ -125,23 +126,23 @@ struct rtas_update_flash_t struct rtas_manage_flash_t { int status; /* Returned status */ - unsigned int op;/* Reject or commit image */ }; /* Status int must be first member of struct */ struct rtas_validate_flash_t { int status; /* Returned status */ - char buf[VALIDATE_BUF_SIZE];/* Candidate image buffer */ + char *buf; /* Candidate image buffer */ unsigned int buf_size; /* Size of image buf */ unsigned int update_results;/* Update results token */ }; -static DEFINE_SPINLOCK(flash_file_open_lock); -static struct proc_dir_entry *firmware_flash_pde; -static struct proc_dir_entry *firmware_update_pde; -static struct proc_dir_entry *validate_pde; -static struct proc_dir_entry *manage_pde; +static struct rtas_update_flash_t rtas_update_flash_data; +static struct rtas_manage_flash_t rtas_manage_flash_data; +static struct rtas_validate_flash_t rtas_validate_flash_data; +static DEFINE_MUTEX(rtas_update_flash_mutex); +static DEFINE_MUTEX(rtas_manage_flash_mutex); +static DEFINE_MUTEX(rtas_validate_flash_mutex); /* Do simple sanity checks on the flash image. */ static int flash_list_valid(struct flash_block_list *flist) @@ -191,10 +192,10 @@ static void free_flash_list(struct flash_block_list *f) static int rtas_flash_release(struct inode *inode, struct file *file) { - struct proc_dir_entry *dp = PDE(file_inode(file)); - struct rtas_update_flash_t *uf; - - uf = (struct rtas_update_flash_t *) dp-data; + struct rtas_update_flash_t *const uf = rtas_update_flash_data; + + mutex_lock(rtas_update_flash_mutex); + if (uf-flist) { /* File was opened in write mode for a new flash attempt */ /* Clear saved list */ @@ -214,13 +215,14 @@ static int rtas_flash_release(struct inode *inode, struct file *file) uf-flist = NULL; } - atomic_dec(dp-count); + mutex_unlock(rtas_update_flash_mutex); return 0; } -static void get_flash_status_msg(int status, char *buf) +static size_t get_flash_status_msg(int status, char *buf) { - char *msg; + const char *msg; + size_t len; switch (status) { case FLASH_AUTH: @@ -242,34 +244,51 @@ static void get_flash_status_msg(int status, char *buf) msg = ready: firmware image ready for flash on reboot\n; break; default: - sprintf(buf, error: unexpected status value %d\n, status); - return; + return sprintf(buf, error: unexpected status value %d\n, + status); } - strcpy(buf, msg); + len = strlen(msg
[PATCH 23/28] ppc: Clean up scanlog [RFC]
Clean up the pseries scanlog driver's use of procfs: (1) Don't need to save the proc_dir_entry pointer as we have the filename to remove with. (2) Save the scan log buffer pointer in a static variable (there is only one of it) and don't save it in the PDE (which doesn't have a destructor). Signed-off-by: David Howells dhowe...@redhat.com cc: Benjamin Herrenschmidt b...@kernel.crashing.org cc: Paul Mackerras pau...@samba.org cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/platforms/pseries/scanlog.c | 29 +++-- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c index cc220d2..b502ab6 100644 --- a/arch/powerpc/platforms/pseries/scanlog.c +++ b/arch/powerpc/platforms/pseries/scanlog.c @@ -41,12 +41,12 @@ static unsigned int ibm_scan_log_dump; /* RTAS token */ -static struct proc_dir_entry *proc_ppc64_scan_log_dump;/* The proc file */ +static unsigned int *scanlog_buffer; /* The data buffer */ static ssize_t scanlog_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - unsigned int *data = PDE_DATA(file_inode(file)); + unsigned int *data = scanlog_buffer; int status; unsigned long len, off; unsigned int wait_time; @@ -134,7 +134,7 @@ static ssize_t scanlog_write(struct file * file, const char __user * buf, static int scanlog_open(struct inode * inode, struct file * file) { - unsigned int *data = PDE_DATA(file_inode(file)); + unsigned int *data = scanlog_buffer; if (data[0] != 0) { /* This imperfect test stops a second copy of the @@ -150,10 +150,9 @@ static int scanlog_open(struct inode * inode, struct file * file) static int scanlog_release(struct inode * inode, struct file * file) { - unsigned int *data = PDE_DATA(file_inode(file)); + unsigned int *data = scanlog_buffer; data[0] = 0; - return 0; } @@ -169,7 +168,6 @@ const struct file_operations scanlog_fops = { static int __init scanlog_init(void) { struct proc_dir_entry *ent; - void *data; int err = -ENOMEM; ibm_scan_log_dump = rtas_token(ibm,scan-log-dump); @@ -177,29 +175,24 @@ static int __init scanlog_init(void) return -ENODEV; /* Ideally we could allocate a buffer 4G */ - data = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL); - if (!data) + scanlog_buffer = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL); + if (!scanlog_buffer) goto err; - ent = proc_create_data(powerpc/rtas/scan-log-dump, S_IRUSR, NULL, - scanlog_fops, data); + ent = proc_create(powerpc/rtas/scan-log-dump, S_IRUSR, NULL, + scanlog_fops); if (!ent) goto err; - - proc_ppc64_scan_log_dump = ent; - return 0; err: - kfree(data); + kfree(scanlog_buffer); return err; } static void __exit scanlog_cleanup(void) { - if (proc_ppc64_scan_log_dump) { - kfree(proc_ppc64_scan_log_dump-data); - remove_proc_entry(scan-log-dump, proc_ppc64_scan_log_dump-parent); - } + remove_proc_entry(powerpc/rtas/scan-log-dump, NULL); + kfree(scanlog_buffer); } module_init(scanlog_init); ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 10/26] fsl_udc: Don't use create_proc_read_entry() [RFC]
Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells dhowe...@redhat.com cc: Li Yang le...@freescale.com cc: Felipe Balbi ba...@ti.com cc: Greg Kroah-Hartman gre...@linuxfoundation.org cc: linux-...@vger.kernel.org cc: linuxppc-dev@lists.ozlabs.org --- drivers/usb/gadget/fsl_udc_core.c | 124 + 1 file changed, 43 insertions(+), 81 deletions(-) diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 04d5fef..ede70ff 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -2038,47 +2038,37 @@ static int fsl_udc_stop(struct usb_gadget *g, static const char proc_filename[] = driver/fsl_usb2_udc; -static int fsl_proc_read(char *page, char **start, off_t off, int count, - int *eof, void *_dev) +static int fsl_proc_read(struct seq_file *m, void *v) { - char *buf = page; - char *next = buf; - unsigned size = count; unsigned long flags; - int t, i; + int i; u32 tmp_reg; struct fsl_ep *ep = NULL; struct fsl_req *req; struct fsl_udc *udc = udc_controller; - if (off != 0) - return 0; spin_lock_irqsave(udc-lock, flags); /* --basic driver information */ - t = scnprintf(next, size, + seq_printf(m, DRIVER_DESC \n %s version: %s\n Gadget driver: %s\n\n, driver_name, DRIVER_VERSION, udc-driver ? udc-driver-driver.name : (none)); - size -= t; - next += t; /* -- DR Registers - */ tmp_reg = fsl_readl(dr_regs-usbcmd); - t = scnprintf(next, size, + seq_printf(m, USBCMD reg:\n SetupTW: %d\n Run/Stop: %s\n\n, (tmp_reg USB_CMD_SUTW) ? 1 : 0, (tmp_reg USB_CMD_RUN_STOP) ? Run : Stop); - size -= t; - next += t; tmp_reg = fsl_readl(dr_regs-usbsts); - t = scnprintf(next, size, + seq_printf(m, USB Status Reg:\n Dr Suspend: %d Reset Received: %d System Error: %s USB Error Interrupt: %s\n\n, @@ -2086,11 +2076,9 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, (tmp_reg USB_STS_RESET) ? 1 : 0, (tmp_reg USB_STS_SYS_ERR) ? Err : Normal, (tmp_reg USB_STS_ERR) ? Err detected : No err); - size -= t; - next += t; tmp_reg = fsl_readl(dr_regs-usbintr); - t = scnprintf(next, size, + seq_printf(m, USB Interrupt Enable Reg:\n Sleep Enable: %d SOF Received Enable: %d Reset Enable: %d\n @@ -2104,33 +2092,25 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, (tmp_reg USB_INTR_PTC_DETECT_EN) ? 1 : 0, (tmp_reg USB_INTR_ERR_INT_EN) ? 1 : 0, (tmp_reg USB_INTR_INT_EN) ? 1 : 0); - size -= t; - next += t; tmp_reg = fsl_readl(dr_regs-frindex); - t = scnprintf(next, size, + seq_printf(m, USB Frame Index Reg: Frame Number is 0x%x\n\n, (tmp_reg USB_FRINDEX_MASKS)); - size -= t; - next += t; tmp_reg = fsl_readl(dr_regs-deviceaddr); - t = scnprintf(next, size, + seq_printf(m, USB Device Address Reg: Device Addr is 0x%x\n\n, (tmp_reg USB_DEVICE_ADDRESS_MASK)); - size -= t; - next += t; tmp_reg = fsl_readl(dr_regs-endpointlistaddr); - t = scnprintf(next, size, + seq_printf(m, USB Endpoint List Address Reg: Device Addr is 0x%x\n\n, (tmp_reg USB_EP_LIST_ADDRESS_MASK)); - size -= t; - next += t; tmp_reg = fsl_readl(dr_regs-portsc1); - t = scnprintf(next, size, + seq_printf(m, USB Port StatusControl Reg:\n Port Transceiver Type : %s Port Speed: %s\n PHY Low Power Suspend: %s Port Reset: %s @@ -2139,7 +2119,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, Port Enable/Disable Change: %s\n Port Enabled/Disabled: %s Current Connect Status: %s\n\n, ( { - char *s; + const char *s; switch (tmp_reg PORTSCX_PTS_FSLS) { case PORTSCX_PTS_UTMI: s = UTMI; break; @@ -2165,13 +2145,11 @@ static
Re: [PATCH v5 01/45] percpu_rwlock: Introduce the global reader-writer lock backend
Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com wrote: We can use global rwlocks as shown below safely, without fear of deadlocks: Readers: CPU 0CPU 1 -- -- 1.spin_lock(random_lock); read_lock(my_rwlock); 2.read_lock(my_rwlock); spin_lock(random_lock); The lock order on CPU 0 is unsafe if CPU2 can do: write_lock(my_rwlock); spin_lock(random_lock); and on CPU 1 if CPU2 can do: spin_lock(random_lock); write_lock(my_rwlock); I presume you were specifically excluding these situations? David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 3/8] mm: use vm_unmapped_area() on frv architecture
Michel Lespinasse wal...@google.com wrote: Update the frv arch_get_unmapped_area function to make use of vm_unmapped_area() instead of implementing a brute force search. Signed-off-by: Michel Lespinasse wal...@google.com Acked-by: Rik van Riel r...@redhat.com Acked-by: David Howells dhowe...@redhat.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: linux-next: manual merge of the kvm-ppc tree with the powerpc-merge tree
Stephen Rothwell s...@canb.auug.org.au wrote: I just removed epapr_hcalls.h from the Kbuild file as I am not sure how it should be broken up. David, can you have a look at this, please? Files should be broken up along around __KERNEL__ conditionals. If there are no __KERNEL__ conditionals, it is assumed that the file is entirely UAPI and can just be moved. The problem appears to be this commit: https://github.com/agraf/linux-2.6/commit/4c09029a5639c955fcf6d65205796e4f1208aed3 From: Liu Yu yu@freescale.com Subject: KVM: PPC: Add support for ePAPR idle hcall in host kernel Just makes epapr_hcalls.h part of the userspace API in its entirety by this bit of the patch: +header-y += epapr_hcalls.h whilst not adding any __KERNEL__ guards - which is almost certainly incorrect. At the very least, I would say that the global variable declarations need limiting to kernel space, and thus so do the inline functions as they emit inline assembly to jump somewhere specified by one of the global variables (actually a code array). So for manual splitting purposes, I would go with just moving all the #defines prior to the __ASSEMBLY__ guard out to uapi. Everything within the __ASSEMBLY__ guard is KABI only by the looks of it. David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: linux-next: manual merge of the kvm-ppc tree with the powerpc-merge tree
Tabi Timur-B04825 b04...@freescale.com wrote: What is include/uapi? Take a look at http://lwn.net/Articles/507794/ David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: linux-next: manual merge of the kvm-ppc tree with the powerpc-merge tree
Alexander Graf ag...@suse.de wrote: Do I have to move them to their own header file or can I just #ifdef __KERNEL__ around the place where __ASSEMBLY__ starts to the end of the file? That depends on whether it happens before or after my disintegration script is run on the header. Ben has pulled my powerpc thing into the powerpc tree already. If he doesn't mind repulling, then if you give me a patch or a git branch to fix it, I can apply that and regenerate the powerpc branch. Otherwise, you need to disintegrate manually: (1) Move the public part to arch/powerpc/include/uapi/asm/epapr_hcalls.h (2) #include the public part from arch/powerpc/include/asm/epapr_hcalls.h (3) Move the headers-y += epapr_hcalls.h line from .../asm/Kbuild to .../uapi/asm/Kbuild. You should not then need __KERNEL__ guards in either header. David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[GIT PULL] Disintegrate UAPI for powerpc [ver #2]
Can you merge the following branch into the powerpc tree please. This is to complete part of the UAPI disintegration for which the preparatory patches were pulled recently. Now that the fixups and the asm-generic chunk have been merged, I've regenerated the patches to get rid of those dependencies and to take account of any changes made so far in the merge window. If you have already pulled the older version of the branch aimed at you, then please feel free to ignore this request. The following changes since commit 9e2d8656f5e8aa214e66b462680cf86b210b74a8: Merge branch 'akpm' (Andrew's patch-bomb) (2012-10-09 16:23:15 +0900) are available in the git repository at: git://git.infradead.org/users/dhowells/linux-headers.git tags/disintegrate-powerpc-20121009 for you to fetch changes up to c3617f72036c909e1f6086b5b9e364e0ef90a6da: UAPI: (Scripted) Disintegrate arch/powerpc/include/asm (2012-10-09 09:47:26 +0100) UAPI Disintegration 2012-10-09 David Howells (1): UAPI: (Scripted) Disintegrate arch/powerpc/include/asm arch/powerpc/include/asm/Kbuild | 35 -- arch/powerpc/include/asm/bootx.h | 123 +-- arch/powerpc/include/asm/cputable.h | 35 +- arch/powerpc/include/asm/elf.h| 311 +- arch/powerpc/include/asm/kvm_para.h | 70 +--- arch/powerpc/include/asm/mman.h | 27 +- arch/powerpc/include/asm/nvram.h | 55 +--- arch/powerpc/include/asm/ptrace.h | 242 +- arch/powerpc/include/asm/signal.h | 143 +--- arch/powerpc/include/asm/spu_info.h | 29 +- arch/powerpc/include/asm/swab.h | 15 +- arch/powerpc/include/asm/termios.h| 69 +--- arch/powerpc/include/asm/types.h | 30 +- arch/powerpc/include/asm/unistd.h | 374 + arch/powerpc/include/uapi/asm/Kbuild | 41 +++ arch/powerpc/include/{ = uapi}/asm/auxvec.h | 0 arch/powerpc/include/{ = uapi}/asm/bitsperlong.h | 0 arch/powerpc/include/uapi/asm/bootx.h | 132 arch/powerpc/include/{ = uapi}/asm/byteorder.h | 0 arch/powerpc/include/uapi/asm/cputable.h | 36 ++ arch/powerpc/include/uapi/asm/elf.h | 307 + arch/powerpc/include/{ = uapi}/asm/errno.h | 0 arch/powerpc/include/{ = uapi}/asm/fcntl.h | 0 arch/powerpc/include/{ = uapi}/asm/ioctl.h | 0 arch/powerpc/include/{ = uapi}/asm/ioctls.h | 0 arch/powerpc/include/{ = uapi}/asm/ipcbuf.h | 0 arch/powerpc/include/{ = uapi}/asm/kvm.h | 0 arch/powerpc/include/uapi/asm/kvm_para.h | 90 + arch/powerpc/include/{ = uapi}/asm/linkage.h | 0 arch/powerpc/include/uapi/asm/mman.h | 31 ++ arch/powerpc/include/{ = uapi}/asm/msgbuf.h | 0 arch/powerpc/include/uapi/asm/nvram.h | 62 arch/powerpc/include/{ = uapi}/asm/param.h | 0 arch/powerpc/include/{ = uapi}/asm/poll.h| 0 arch/powerpc/include/{ = uapi}/asm/posix_types.h | 0 arch/powerpc/include/{ = uapi}/asm/ps3fb.h | 0 arch/powerpc/include/uapi/asm/ptrace.h| 259 +++ arch/powerpc/include/{ = uapi}/asm/resource.h| 0 arch/powerpc/include/{ = uapi}/asm/seccomp.h | 0 arch/powerpc/include/{ = uapi}/asm/sembuf.h | 0 arch/powerpc/include/{ = uapi}/asm/setup.h | 0 arch/powerpc/include/{ = uapi}/asm/shmbuf.h | 0 arch/powerpc/include/{ = uapi}/asm/sigcontext.h | 0 arch/powerpc/include/{ = uapi}/asm/siginfo.h | 0 arch/powerpc/include/uapi/asm/signal.h| 145 + arch/powerpc/include/{ = uapi}/asm/socket.h | 0 arch/powerpc/include/{ = uapi}/asm/sockios.h | 0 arch/powerpc/include/uapi/asm/spu_info.h | 53 +++ arch/powerpc/include/{ = uapi}/asm/stat.h| 0 arch/powerpc/include/{ = uapi}/asm/statfs.h | 0 arch/powerpc/include/uapi/asm/swab.h | 23 ++ arch/powerpc/include/{ = uapi}/asm/termbits.h| 0 arch/powerpc/include/uapi/asm/termios.h | 76 + arch/powerpc/include/uapi/asm/types.h | 40 +++ arch/powerpc/include/{ = uapi}/asm/ucontext.h| 0 arch/powerpc/include/uapi/asm/unistd.h| 380 ++ 56 files changed, 1705 insertions(+), 1528 deletions(-) rename arch/powerpc/include/{ = uapi}/asm/auxvec.h (100%) rename arch/powerpc/include/{ = uapi}/asm/bitsperlong.h (100%) create mode 100644 arch/powerpc/include/uapi/asm/bootx.h rename arch/powerpc/include/{ = uapi}/asm/byteorder.h (100%) create mode 100644 arch/powerpc/include/uapi/asm/cputable.h create mode 100644 arch/powerpc/include/uapi/asm/elf.h rename arch
[GIT PULL] Disintegrate UAPI for powerpc
Can you merge the following branch into the powerpc tree please. This is to complete part of the UAPI disintegration for which the preparatory patches were pulled recently. Note that there are some fixup patches which are at the base of the branch aimed at you, plus all arches get the asm-generic branch merged in too. The following changes since commit 612a9aab56a93533e76e3ad91642db7033e03b69: Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux (2012-10-03 23:29:23 -0700) are available in the git repository at: git://git.infradead.org/users/dhowells/linux-headers.git disintegrate-powerpc for you to fetch changes up to d4b1059feb6486ae0800e936b9dd5fd4e05b9d0c: UAPI: (Scripted) Disintegrate arch/powerpc/include/asm (2012-10-04 18:21:17 +0100) David Howells (6): UAPI: Fix the guards on various asm/unistd.h files UAPI: Split compound conditionals containing __KERNEL__ in Arm64 Merge remote-tracking branch 'c6x/for-linux-next' into uapi-prep UAPI: Fix conditional header installation handling (notably kvm_para.h on m68k) UAPI: (Scripted) Disintegrate include/asm-generic UAPI: (Scripted) Disintegrate arch/powerpc/include/asm Mark Salter (2): c6x: make dsk6455 the default config c6x: remove c6x signal.h arch/arm64/include/asm/hwcap.h| 4 +- arch/arm64/include/asm/stat.h | 4 +- arch/arm64/include/asm/unistd.h | 8 +- arch/arm64/include/asm/unistd32.h | 4 - arch/c6x/Makefile | 2 + arch/c6x/include/asm/Kbuild | 1 + arch/c6x/include/asm/signal.h | 17 - arch/c6x/include/asm/unistd.h | 4 - arch/hexagon/include/asm/unistd.h | 5 - arch/openrisc/include/asm/unistd.h| 5 - arch/powerpc/include/asm/Kbuild | 35 - arch/powerpc/include/asm/bootx.h | 123 +-- arch/powerpc/include/asm/cputable.h | 35 +- arch/powerpc/include/asm/elf.h| 311 +--- arch/powerpc/include/asm/kvm_para.h | 70 +- arch/powerpc/include/asm/mman.h | 27 +- arch/powerpc/include/asm/nvram.h | 55 +- arch/powerpc/include/asm/ptrace.h | 242 +- arch/powerpc/include/asm/signal.h | 143 +--- arch/powerpc/include/asm/spu_info.h | 29 +- arch/powerpc/include/asm/swab.h | 15 +- arch/powerpc/include/asm/termios.h| 69 +- arch/powerpc/include/asm/types.h | 30 +- arch/powerpc/include/asm/unistd.h | 374 + arch/powerpc/include/uapi/asm/Kbuild | 41 + arch/powerpc/include/{ = uapi}/asm/auxvec.h | 0 arch/powerpc/include/{ = uapi}/asm/bitsperlong.h | 0 arch/powerpc/include/uapi/asm/bootx.h | 132 arch/powerpc/include/{ = uapi}/asm/byteorder.h | 0 arch/powerpc/include/uapi/asm/cputable.h | 36 + arch/powerpc/include/uapi/asm/elf.h | 307 arch/powerpc/include/{ = uapi}/asm/errno.h | 0 arch/powerpc/include/{ = uapi}/asm/fcntl.h | 0 arch/powerpc/include/{ = uapi}/asm/ioctl.h | 0 arch/powerpc/include/{ = uapi}/asm/ioctls.h | 0 arch/powerpc/include/{ = uapi}/asm/ipcbuf.h | 0 arch/powerpc/include/{ = uapi}/asm/kvm.h | 0 arch/powerpc/include/uapi/asm/kvm_para.h | 90 +++ arch/powerpc/include/{ = uapi}/asm/linkage.h | 0 arch/powerpc/include/uapi/asm/mman.h | 31 + arch/powerpc/include/{ = uapi}/asm/msgbuf.h | 0 arch/powerpc/include/uapi/asm/nvram.h | 62 ++ arch/powerpc/include/{ = uapi}/asm/param.h | 0 arch/powerpc/include/{ = uapi}/asm/poll.h| 0 arch/powerpc/include/{ = uapi}/asm/posix_types.h | 0 arch/powerpc/include/{ = uapi}/asm/ps3fb.h | 0 arch/powerpc/include/uapi/asm/ptrace.h| 259 ++ arch/powerpc/include/{ = uapi}/asm/resource.h| 0 arch/powerpc/include/{ = uapi}/asm/seccomp.h | 0 arch/powerpc/include/{ = uapi}/asm/sembuf.h | 0 arch/powerpc/include/{ = uapi}/asm/setup.h | 0 arch/powerpc/include/{ = uapi}/asm/shmbuf.h | 0 arch/powerpc/include/{ = uapi}/asm/sigcontext.h | 0 arch/powerpc/include/{ = uapi}/asm/siginfo.h | 0 arch/powerpc/include/uapi/asm/signal.h| 145 arch/powerpc/include/{ = uapi}/asm/socket.h | 0 arch/powerpc/include/{ = uapi}/asm/sockios.h | 0 arch/powerpc/include/uapi/asm/spu_info.h | 53 ++ arch/powerpc/include/{ = uapi}/asm/stat.h| 0 arch/powerpc/include/{ = uapi}/asm/statfs.h | 0 arch/powerpc/include/uapi/asm/swab.h | 23 + arch/powerpc/include/{ = uapi}/asm/termbits.h
Re: [PATCH] powerpc: fix system.h fallout in sysdev/scom.c [chroma_defconfig]
Paul Gortmaker paul.gortma...@windriver.com wrote: The following shows up in chroma_defconfig: CC arch/powerpc/sysdev/scom.o arch/powerpc/sysdev/scom.c: In function 'scom_debug_init': arch/powerpc/sysdev/scom.c:182:36: error: 'powerpc_debugfs_root' undeclared (first use in this function) arch/powerpc/sysdev/scom.c:182:36: note: each undeclared identifier is reported only once for each function it appears in make[2]: *** [arch/powerpc/sysdev/scom.o] Error 1 make[1]: *** [arch/powerpc/sysdev/scom.o] Error 2 A bisect leads to commit 9ffc93f203c18a70623f21950f1dd473c9ec48cd Remove all #inclusions of asm/system.h Add the debug header which contains powerpc_debugfs_root. Cc: David Howells dhowe...@redhat.com Signed-off-by: Paul Gortmaker paul.gortma...@windriver.com Acked-by: David Howells dhowe...@redhat.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC/PATCH] mm/futex: Fix futex writes on archs with SW tracking of dirty young
Peter Zijlstra pet...@infradead.org wrote: Subject: mm: Fix fixup_user_fault() for MMU=n In commit 2efaca927 (mm/futex: fix futex writes on archs with SW tracking of dirty young) we forgot about MMU=n. This patch fixes that. Signed-off-by: Peter Zijlstra a.p.zijls...@chello.nl Acked-by: David Howells dhowe...@redhat.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC/PATCH] mm/futex: Fix futex writes on archs with SW tracking of dirty young
Peter Zijlstra pet...@infradead.org wrote: What should nommu do anyways ? it's not like there's much it can do right ? It should never even hit the fault path to start with ... Something like the below makes a nommu arm config build.. David, is this indeed the correct thing to do for nommu? --- Index: linux-2.6/mm/nommu.c === --- linux-2.6.orig/mm/nommu.c +++ linux-2.6/mm/nommu.c @@ -190,6 +190,12 @@ int get_user_pages(struct task_struct *t } EXPORT_SYMBOL(get_user_pages); +int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, + unsigned long address, unsigned int fault_flags) +{ + BUG(); /* nommu should never call this */ +} + /** * follow_pfn - look up PFN at a user virtual address * @vma: memory mapping Or perhaps send SEGV? Can 'address' be bad at this point? Can you inline this for the NOMMU case please? David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] atomic: add *_dec_not_zero
Sven Eckelmann s...@narfation.org wrote: Introduce an *_dec_not_zero operation. Make this a special case of *_add_unless because batman-adv uses atomic_dec_not_zero in different places like re-broadcast queue or aggregation queue management. There are other non-final patches which may also want to use this macro. Reported-by: David S. Miller da...@davemloft.net Signed-off-by: Sven Eckelmann s...@narfation.org Acked-by: David Howells dhowe...@redhat.com [MN10300 and FRV] ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 14/17] Fix powerpc irqflags
This (sub)patch is separated out for reviewing purposes. Once ACK'd it will need to be rolled into the main patch. Cc: b...@kernel.crashing.org Cc: pau...@samba.org Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/include/asm/hw_irq.h| 113 -- arch/powerpc/include/asm/irqflags.h |2 - arch/powerpc/kernel/exceptions-64s.S |4 + arch/powerpc/kernel/irq.c|4 + 4 files changed, 70 insertions(+), 53 deletions(-) diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h index bd100fc..ff08b70 100644 --- a/arch/powerpc/include/asm/hw_irq.h +++ b/arch/powerpc/include/asm/hw_irq.h @@ -16,42 +16,57 @@ extern void timer_interrupt(struct pt_regs *); #ifdef CONFIG_PPC64 #include asm/paca.h -static inline unsigned long local_get_flags(void) +static inline unsigned long arch_local_save_flags(void) { unsigned long flags; - __asm__ __volatile__(lbz %0,%1(13) - : =r (flags) - : i (offsetof(struct paca_struct, soft_enabled))); + asm volatile( + lbz %0,%1(13) + : =r (flags) + : i (offsetof(struct paca_struct, soft_enabled))); return flags; } -static inline unsigned long raw_local_irq_disable(void) +static inline unsigned long arch_local_irq_disable(void) { unsigned long flags, zero; - __asm__ __volatile__(li %1,0; lbz %0,%2(13); stb %1,%2(13) - : =r (flags), =r (zero) - : i (offsetof(struct paca_struct, soft_enabled)) - : memory); + asm volatile( + li %1,0; lbz %0,%2(13); stb %1,%2(13) + : =r (flags), =r (zero) + : i (offsetof(struct paca_struct, soft_enabled)) + : memory); return flags; } -extern void raw_local_irq_restore(unsigned long); +extern void arch_local_irq_restore(unsigned long); extern void iseries_handle_interrupts(void); -#define raw_local_irq_enable() raw_local_irq_restore(1) -#define raw_local_save_flags(flags)((flags) = local_get_flags()) -#define raw_local_irq_save(flags) ((flags) = raw_local_irq_disable()) +static inline void arch_local_irq_enable(void) +{ + arch_local_irq_restore(1); +} + +static inline unsigned long arch_local_irq_save(void) +{ + return arch_local_irq_disable(); +} + +static inline bool arch_irqs_disabled_flags(unsigned long flags) +{ + return flags == 0; +} -#define raw_irqs_disabled()(local_get_flags() == 0) -#define raw_irqs_disabled_flags(flags) ((flags) == 0) +static inline bool arch_irqs_disabled(void) +{ + return arch_irqs_disabled_flags(arch_local_save_flags()); +} #ifdef CONFIG_PPC_BOOK3E -#define __hard_irq_enable()__asm__ __volatile__(wrteei 1: : :memory); -#define __hard_irq_disable() __asm__ __volatile__(wrteei 0: : :memory); +#define __hard_irq_enable()asm volatile(wrteei 1 : : : memory); +#define __hard_irq_disable() asm volatile(wrteei 0 : : : memory); #else #define __hard_irq_enable()__mtmsrd(mfmsr() | MSR_EE, 1) #define __hard_irq_disable() __mtmsrd(mfmsr() ~MSR_EE, 1) @@ -64,64 +79,66 @@ extern void iseries_handle_interrupts(void); get_paca()-hard_enabled = 0; \ } while(0) -#else +#else /* CONFIG_PPC64 */ -#if defined(CONFIG_BOOKE) #define SET_MSR_EE(x) mtmsr(x) -#define raw_local_irq_restore(flags) __asm__ __volatile__(wrtee %0 : : r (flags) : memory) + +static inline unsigned long arch_local_save_flags(void) +{ + return mfmsr(); +} + +static inline void arch_local_irq_restore(unsigned long flags) +{ +#if defined(CONFIG_BOOKE) + asm volatile(wrtee %0 : : r (flags) : memory); #else -#define SET_MSR_EE(x) mtmsr(x) -#define raw_local_irq_restore(flags) mtmsr(flags) + mtmsr(flags); #endif +} -static inline void raw_local_irq_disable(void) +static inline unsigned long arch_local_irq_save(void) { + unsigned long flags = arch_local_save_flags(); #ifdef CONFIG_BOOKE - __asm__ __volatile__(wrteei 0: : :memory); + asm volatile(wrteei 0 : : : memory); #else - unsigned long msr; - - msr = mfmsr(); - SET_MSR_EE(msr ~MSR_EE); + SET_MSR_EE(flags ~MSR_EE); #endif + return flags; } -static inline void raw_local_irq_enable(void) +static inline void arch_local_irq_disable(void) { #ifdef CONFIG_BOOKE - __asm__ __volatile__(wrteei 1: : :memory); + asm volatile(wrteei 0 : : : memory); #else - unsigned long msr; - - msr = mfmsr(); - SET_MSR_EE(msr | MSR_EE); + arch_local_irq_save(); #endif } -static inline void raw_local_irq_save_ptr(unsigned long *flags) +static inline void arch_local_irq_enable(void) { - unsigned long msr; - msr = mfmsr(); - *flags = msr; #ifdef CONFIG_BOOKE - __asm__ __volatile__(wrteei 0: : :memory); + asm volatile(wrteei 1 : : : memory); #else - SET_MSR_EE(msr ~MSR_EE); + unsigned long msr =
Re: Memory Mapping a char array in User Space
Ravi Gupta dceravigu...@gmail.com wrote: My device gets memory map successfully but when I tried to read from it I get garbage value. Is there something that I am missing? For starters, you really should allocate a page for your buffer rather than using kernel static data. mmap() allows access to page-aligned data through multiple-of-page-sized holes only[*]. Not only that, your kernel static map buffer may not necessarily have a struct page covering it, in which case virt_to_page() may not give you anything useful. Furthermore, I don't think *you* should be calling remap_pfn_range(). I think you should be leaving the mapping to the core VM routines. David [*] unless your kernel is CONFIG_MMU=n ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] sched: fix spelling of sibling
Michael Neuling mi...@neuling.org wrote: No logic changes, only spelling. Signed-off-by: Michael Neuling mi...@neuling.org Acked-by: David Howells dhowe...@redhat.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: Fix integer constant warning
Steve Best sfb...@us.ibm.com wrote: -#define KERNELBASE (0xc000) +#define KERNELBASE (0xc000ULL) Is this the right fix? The code producing the warning is subtracting 0xc000 from a 32-bit number: naca = ntohl(*((u_int32_t*) inbuf[0x0C])) - KERNELBASE; which seems distinctly odd. David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: Fix integer constant warning
Josh Boyer jwbo...@linux.vnet.ibm.com wrote: It might not matter, since Paul sent a patch to remove this file entirely. Yeah, I saw that after... David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [Patch 1/4] Allow arch-specific cleanup before breakpoint unregistration
K.Prasad pra...@linux.vnet.ibm.com wrote: My understanding is weak function definitions must appear in a different C file than their call sites to work on some toolchains. Atleast, there are quite a few precedents inside the Linux kernel for __weak functions being invoked from the file in which they are defined (arch_hwblk_init, arch_enable_nonboot_cpus_begin and hw_perf_disable to name a few). Moreover the online GCC docs haven't any such constraints mentioned. I've seen problems in this area. gcc sometimes inlines a weak function that's in the same file as the call point. David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] PPC: Fix zero length strncmp() on powerpc
When strncmp() on powerpc is given a length of zero, it detects this and returns early to make the comparison loop simpler. When it does this, however, it fails to set a return value, and thus returns the address of the first string as the number of the character match. It should return 0 instead in this case. This can be tested by compiling and attempting to load the following module: #include linux/init.h #include linux/module.h char string1[1], string2[1]; size_t count_global = 0; static int __init strncmp_init(void) { string1[0] = string2[0] = 0; if (strncmp(string1, string2, count_global)) { printk(Strncmp Bug!\n); return -EIO; } return -ENOANO; } module_init(strncmp_init); MODULE_LICENSE(GPL); MODULE_DESCRIPTION(Probe strncmp() bug); It should return error No anode on success and I/O error on failure. The module will not be retained. Signed-off-by: David Howells dhowe...@redhat.com --- arch/powerpc/lib/string.S |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/lib/string.S b/arch/powerpc/lib/string.S index 64e2e49..46fe390 100644 --- a/arch/powerpc/lib/string.S +++ b/arch/powerpc/lib/string.S @@ -71,7 +71,7 @@ _GLOBAL(strcmp) _GLOBAL(strncmp) PPC_LCMPI r5,0 - beqlr + beq-2f mtctr r5 addir5,r3,-1 addir4,r4,-1 @@ -82,6 +82,8 @@ _GLOBAL(strncmp) beqlr 1 bdnzt eq,1b blr +2: li r3,0 + blr _GLOBAL(strlen) addir4,r3,-1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v21 001/100] eclone (1/11): Factor out code to allocate pidmap page
With a huge patch series like this, can you post a cover note at the front (usually patch 0) saying what the point of the whole series is? David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 5/7] arch/powerpc/kernel: Use set_cpus_allowed_ptr
Julia Lawall ju...@diku.dk wrote: The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) That URL doesn't appear to work: Not Found The requested URL /) was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.2.8 (Mandriva Linux/PREFORK-6mdv2008.1) Server at coccinelle.lip6.fr Port 80 David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 5/7] arch/powerpc/kernel: Use set_cpus_allowed_ptr
David Howells dhowe...@redhat.com wrote: The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) That URL doesn't appear to work: Not Found The requested URL /) was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.2.8 (Mandriva Linux/PREFORK-6mdv2008.1) Server at coccinelle.lip6.fr Port 80 Actually, it does. It's just that my email client thought that the closing bracket after it was part of the URL:-/ David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: spin_is_locked() broken for uniprocessor?
Thomas Gleixner t...@linutronix.de wrote: which implies to me that spin_is_locked() will always return false. Is this expected behavior. That's wrong. spin_is_locked should always return true on UP. Surely it's not that simple? Maybe spin_is_lock() should be undefined on UP. David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC/PATCH] mm: Pass virtual address to [__]p{te, ud, md}_free_tlb()
Benjamin Herrenschmidt b...@kernel.crashing.org wrote: Upcoming paches to support the new 64-bit BookE powerpc architecture will need to have the virtual address corresponding to PTE page when freeing it, due to the way the HW table walker works. Basically, the TLB can be loaded with large pages that cover the whole virtual space (well, sort-of, half of it actually) represented by a PTE page, and which contain an indirect bit indicating that this TLB entry RPN points to an array of PTEs from which the TLB can then create direct entries. Thus, in order to invalidate those when PTE pages are deleted, we need the virtual address to pass to tlbilx or tlbivax instructions. The old trick of sticking it somewhere in the PTE page struct page sucks too much, the address is almost readily available in all call sites and almost everybody implemets these as macros, so we may as well add the argument everywhere. I added it to the pmd and pud variants for consistency. Signed-off-by: Benjamin Herrenschmidt b...@kernel.crashing.org Acked-by: David Howells dhowe...@redhat.com [MN10300 FRV] ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: Inline Assembly queries
kernel mailz kernelma...@googlemail.com wrote: asm(sync); Isn't gcc free to discard this as it has no dependencies, no indicated side effects, and isn't required to be kept? I think this should probably be: asm volatile(sync); David ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2.6.30-rc5] ehea: fix invalid pointer access
Hannes Hering hannes.her...@linux.vnet.ibm.com wrote: pref = skb_array[x]; - prefetchw(pref); - prefetchw(pref + EHEA_CACHE_LINE); + if (pref) { + prefetchw(pref); + prefetchw(pref + EHEA_CACHE_LINE); Ummm... Is prefetch() or prefetchw() faulting? David ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH] eHEA: Don't do memory allocation under lock if not necessary
In ehea_probe_adapter() the initial memory allocation and initialisation does not need to be done with the ehea_fw_handles.lock semaphore held. Doing so extends the amount of time the lock is held unnecessarily. Signed-off-by: David Howells dhowe...@redhat.com --- drivers/net/ehea/ehea_main.c | 13 ++--- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index dfe9226..34480ae 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c @@ -3370,18 +3370,19 @@ static int __devinit ehea_probe_adapter(struct of_device *dev, ehea_error(Invalid ibmebus device probed); return -EINVAL; } - mutex_lock(ehea_fw_handles.lock); adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); if (!adapter) { - ret = -ENOMEM; dev_err(dev-dev, no mem for ehea_adapter\n); - goto out; + return -ENOMEM; } - list_add(adapter-list, adapter_list); - adapter-ofdev = dev; + adapter-pd = EHEA_PD_ID; + + mutex_lock(ehea_fw_handles.lock); + + list_add(adapter-list, adapter_list); adapter_handle = of_get_property(dev-node, ibm,hea-handle, NULL); @@ -3395,8 +3396,6 @@ static int __devinit ehea_probe_adapter(struct of_device *dev, goto out_free_ad; } - adapter-pd = EHEA_PD_ID; - dev-dev.driver_data = adapter; ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH] eHEA: Don't do memory allocation under lock if not necessary
In ehea_probe_adapter() the initial memory allocation and initialisation does not need to be done with the ehea_fw_handles.lock semaphore held. Doing so extends the amount of time the lock is held unnecessarily. Signed-off-by: David Howells dhowe...@redhat.com --- drivers/net/ehea/ehea_main.c | 13 ++--- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index dfe9226..34480ae 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c @@ -3370,18 +3370,19 @@ static int __devinit ehea_probe_adapter(struct of_device *dev, ehea_error(Invalid ibmebus device probed); return -EINVAL; } - mutex_lock(ehea_fw_handles.lock); adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); if (!adapter) { - ret = -ENOMEM; dev_err(dev-dev, no mem for ehea_adapter\n); - goto out; + return -ENOMEM; } - list_add(adapter-list, adapter_list); - adapter-ofdev = dev; + adapter-pd = EHEA_PD_ID; + + mutex_lock(ehea_fw_handles.lock); + + list_add(adapter-list, adapter_list); adapter_handle = of_get_property(dev-node, ibm,hea-handle, NULL); @@ -3395,8 +3396,6 @@ static int __devinit ehea_probe_adapter(struct of_device *dev, goto out_free_ad; } - adapter-pd = EHEA_PD_ID; - dev-dev.driver_data = adapter; ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH] NOMMU: Rename PowerPC's struct vm_region
Rename PowerPC's struct vm_region so that I can introduce my own global version for NOMMU. It's feasible that the PowerPC version may wish to use my global one instead. The NOMMU vm_region struct defines areas of the physical memory map that are under mmap. This may include chunks of RAM or regions of memory mapped devices, such as flash. It is also used to retain copies of file content so that shareable private memory mappings of files can be made. As such, it may be compatible with what is described in the banner comment for PowerPC's vm_region struct. Signed-off-by: David Howells [EMAIL PROTECTED] --- arch/powerpc/lib/dma-noncoherent.c | 24 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/lib/dma-noncoherent.c b/arch/powerpc/lib/dma-noncoherent.c index 31734c0..a55c6ca 100644 --- a/arch/powerpc/lib/dma-noncoherent.c +++ b/arch/powerpc/lib/dma-noncoherent.c @@ -77,26 +77,26 @@ static DEFINE_SPINLOCK(consistent_lock); * the amount of RAM found at boot time.) I would imagine that get_vm_area() * would have to initialise this each time prior to calling vm_region_alloc(). */ -struct vm_region { +struct ppc_vm_region { struct list_headvm_list; unsigned long vm_start; unsigned long vm_end; }; -static struct vm_region consistent_head = { +static struct ppc_vm_region consistent_head = { .vm_list= LIST_HEAD_INIT(consistent_head.vm_list), .vm_start = CONSISTENT_BASE, .vm_end = CONSISTENT_END, }; -static struct vm_region * -vm_region_alloc(struct vm_region *head, size_t size, gfp_t gfp) +static struct ppc_vm_region * +ppc_vm_region_alloc(struct ppc_vm_region *head, size_t size, gfp_t gfp) { unsigned long addr = head-vm_start, end = head-vm_end - size; unsigned long flags; - struct vm_region *c, *new; + struct ppc_vm_region *c, *new; - new = kmalloc(sizeof(struct vm_region), gfp); + new = kmalloc(sizeof(struct ppc_vm_region), gfp); if (!new) goto out; @@ -130,9 +130,9 @@ vm_region_alloc(struct vm_region *head, size_t size, gfp_t gfp) return NULL; } -static struct vm_region *vm_region_find(struct vm_region *head, unsigned long addr) +static struct ppc_vm_region *ppc_vm_region_find(struct ppc_vm_region *head, unsigned long addr) { - struct vm_region *c; + struct ppc_vm_region *c; list_for_each_entry(c, head-vm_list, vm_list) { if (c-vm_start == addr) @@ -151,7 +151,7 @@ void * __dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp) { struct page *page; - struct vm_region *c; + struct ppc_vm_region *c; unsigned long order; u64 mask = 0x00ff, limit; /* ISA default */ @@ -191,7 +191,7 @@ __dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp) /* * Allocate a virtual address in the consistent mapping region. */ - c = vm_region_alloc(consistent_head, size, + c = ppc_vm_region_alloc(consistent_head, size, gfp ~(__GFP_DMA | __GFP_HIGHMEM)); if (c) { unsigned long vaddr = c-vm_start; @@ -239,7 +239,7 @@ EXPORT_SYMBOL(__dma_alloc_coherent); */ void __dma_free_coherent(size_t size, void *vaddr) { - struct vm_region *c; + struct ppc_vm_region *c; unsigned long flags, addr; pte_t *ptep; @@ -247,7 +247,7 @@ void __dma_free_coherent(size_t size, void *vaddr) spin_lock_irqsave(consistent_lock, flags); - c = vm_region_find(consistent_head, (unsigned long)vaddr); + c = ppc_vm_region_find(consistent_head, (unsigned long)vaddr); if (!c) goto no_area; ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] NOMMU: Rename PowerPC's struct vm_region
Josh Boyer [EMAIL PROTECTED] wrote: Is there a reason you renamed all the function names as well when they are static? Well, static functions can still conflict with a function of the same name that's declared globally in a header file, but mainly because M-x replace-string doesn't differentiate. David ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: Re[2]: [PATCH] fork_init: fix division by zero
Yuri Tikhonov [EMAIL PROTECTED] wrote: Here we believe in preprocessor: since all PAGE_SIZE, 8, and THREAD_SIZE are the constants we expect it will calculate this. The preprocessor shouldn't be calculating this. I believe it will _only_ calculate expressions for #if. In the situation you're referring to, it should perform a substitution and nothing more. The preprocessor doesn't necessarily know how to handle the types involved. In any case, there's an easy way to find out: you can ask the compiler to give you the result of running the source through the preprocessor only. For instance, if you run this: #define PAGE_SIZE 4096 #define THREAD_SIZE 8192 unsigned long mempages; unsigned long jump(void) { unsigned long max_threads; max_threads = mempages * PAGE_SIZE / (8 * THREAD_SIZE); return max_threads; } through gcc -E, you get: # 1 calc.c # 1 built-in # 1 command line # 1 calc.c unsigned long mempages; unsigned long jump(void) { unsigned long max_threads; max_threads = mempages * 4096 / (8 * 8192); return max_threads; } In any case, adding braces as follows probably would be better: + max_threads = mempages * (PAGE_SIZE / (8 * THREAD_SIZE)); I think you mean brackets, not braces '{}'. Right ? Definitely not. I added this function to the above: unsigned long alt(void) { unsigned long max_threads; max_threads = mempages * (PAGE_SIZE / (8 * THREAD_SIZE)); return max_threads; } and ran it through gcc -S -O2 for x86_64: jump: movqmempages(%rip), %rax salq$12, %rax shrq$16, %rax ret alt: xorl%eax, %eax ret Note the difference? In jump(), x86_64 first multiplies mempages by 4096, and _then_ divides by 8*8192. In alt(), it just returns 0 because the compiler realised that you're multiplying by 0. If you're going to bracket the expression, it must be: max_threads = (mempages * PAGE_SIZE) / (8 * THREAD_SIZE); which should be superfluous. E.g. here is the result from this line as produced by cross-gcc 4.2.2: lis r9,0 rlwinm r29,r29,2,16,29 stw r29,0(r9) As you see - only rotate-left, i.e. multiplication to the constant. Ummm... On powerpc, I believe rotate-left would be a division as it does the bit-numbering and the bit direction the opposite way to more familiar CPUs such as x86. David ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: Re[2]: [PATCH] fork_init: fix division by zero
David Howells [EMAIL PROTECTED] wrote: Ummm... On powerpc, I believe rotate-left would be a division as it does the bit-numbering and the bit direction the opposite way to more familiar CPUs such as x86. Actually, I'm not sure that's true. Sometimes powerpc makes my head hurt:-) David ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [patch] mutex: optimise generic mutex implementations
Nick Piggin [EMAIL PROTECTED] wrote: Speed up generic mutex implementations. - atomic operations which both modify the variable and return something imply full smp memory barriers before and after the memory operations involved (failing atomic_cmpxchg, atomic_add_unless, etc don't imply a barrier because they don't modify the target). See Documentation/atomic_ops.txt. So remove extra barriers and branches. - All architectures support atomic_cmpxchg. This has no relation to __HAVE_ARCH_CMPXCHG. We can just take the atomic_cmpxchg path unconditionally This reduces a simple single threaded fastpath lock+unlock test from 590 cycles to 203 cycles on a ppc970 system. Signed-off-by: Nick Piggin [EMAIL PROTECTED] This seems to work on FRV which uses the mutex-dec generic algorithm, though you have to take that with a pinch of salt as I don't have SMP hardware for it. Acked-by: David Howells [EMAIL PROTECTED] ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH] PPC: Fix rtas_log_read()
Fix rtas_log_read() to correctly check its buffer after sleeping. A competing process may have swiped the error we're attempting to retrieve between us being woken up and retaking the lock, but we return an event and account for it anyway without checking. Any positive result from checking rtas_log_size is invalidated when rtasd_log_lock is dropped or if it is not held. It is not correct to rely on userspace doing the right thing by assuming only one userspace process (rtasd) will be attempting read at any one time. Signed-off-by: David Howells [EMAIL PROTECTED] --- arch/powerpc/platforms/pseries/rtasd.c | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/platforms/pseries/rtasd.c b/arch/powerpc/platforms/pseries/rtasd.c index c9ffd8c..1ce132f 100644 --- a/arch/powerpc/platforms/pseries/rtasd.c +++ b/arch/powerpc/platforms/pseries/rtasd.c @@ -298,16 +298,16 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf, spin_lock_irqsave(rtasd_log_lock, s); /* if it's 0, then we know we got the last one (the one in NVRAM) */ - if (rtas_log_size == 0 logging_enabled) + while (rtas_log_size == 0 logging_enabled) { nvram_clear_error_log(); - spin_unlock_irqrestore(rtasd_log_lock, s); - - error = wait_event_interruptible(rtas_log_wait, rtas_log_size); - if (error) - goto out; + spin_unlock_irqrestore(rtasd_log_lock, s); + error = wait_event_interruptible(rtas_log_wait, rtas_log_size); + if (error) + goto out; + spin_lock_irqsave(rtasd_log_lock, s); + } - spin_lock_irqsave(rtasd_log_lock, s); offset = rtas_error_log_buffer_max * (rtas_log_start LOG_NUMBER_MASK); memcpy(tmp, rtas_log_buf[offset], count); ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: checkpatch nits ...
Kevin Diggs [EMAIL PROTECTED] wrote: The entire block is: __asm__ __volatile__ ( addi %0,%3,-1\n andc %1,%3,%0\n cntlzw %1,%1\n subfic %1,%1,31\n cntlzw %0,%2\n: =r(cntlz), =r(cnttz): r(tmp), b(cnttz) ); As long as this has no side effects, the __volatile__ isn't necessary. If the only effect is to produce the specified outputs based on the specified inputs, the code can be moved or eliminated if the outputs aren't used. David ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [2.6 patch] asm/ptrace.h userspace headers cleanup
Adrian Bunk [EMAIL PROTECTED] wrote: This patch contains the following cleanups for the asm/ptrace.h userspace headers: - include/asm-generic/Kbuild.asm already lists ptrace.h, remove the superfluous listings in the Kbuild files of the following architectures: ... - frv ... - don't expose function prototypes and macros to userspace: ... - mn10300 Acked-by: David Howells [EMAIL PROTECTED] (FRV and MN10300) ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: inline assembly
Scott Wood [EMAIL PROTECTED] wrote: int tmp; asm volatile(addi %1, %2, -1; andc %1, %2, %1; cntlzw %1, %1; subfic %0, %1, 31 : =r (j), =r (tmp) : r (i)); Registers are usually assumed to be 'long' in size, so I'd recommend using that rather than 'int' for tmp, though I suspect it'll make little difference (except, perhaps on x86 where you can partially use registers). However, it'd be better to let the compiler do more, by just using the existing cntlzw() function. Look in include/asm-powerpc/bitops.h. There are examples of the things you're trying to do: static __inline__ __attribute__((const)) int __ilog2(unsigned long x) { int lz; asm (PPC_CNTLZL %0,%1 : =r (lz) : r (x)); return BITS_PER_LONG - 1 - lz; } static __inline__ int __ffs(unsigned long x) { return __ilog2(x -x); } Where: asm-compat.h:79:#define PPC_CNTLZL stringify_in_c(cntlzd) asm-compat.h:100:#define PPC_CNTLZL stringify_in_c(cntlzw) Depending on whether you're in 32-bit mode or 64-bit mode. David ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] powerpc/pseries/xcis: ansify
Al Viro [EMAIL PROTECTED] wrote: Signed-off-by: Al Viro [EMAIL PROTECTED] Acked-by: David Howells [EMAIL PROTECTED] ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [patch 01/16] PCI: add generic pci_enable_resources()
Bjorn Helgaas [EMAIL PROTECTED] wrote: Each architecture has its own pcibios_enable_resources() implementation. These differ in many minor ways that have nothing to do with actual architectural differences. Follow-on patches will make most arches use this generic version instead. This version is based on powerpc, which seemed most up-to-date. The only functional difference from the x86 version is that this uses !r-parent to check for resource collisions instead of !r-start r-end. Signed-off-by: Bjorn Helgaas [EMAIL PROTECTED] Acked-by: David Howells [EMAIL PROTECTED] ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [patch 05/16] frv: use generic pci_enable_resources()
Bjorn Helgaas [EMAIL PROTECTED] wrote: Use the generic pci_enable_resources() instead of the arch-specific code. Unlike this arch-specific code, the generic version: - checks PCI_NUM_RESOURCES (11), not 6, resources - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set - skips ROM resources unless IORESOURCE_ROM_ENABLE is set - checks for resource collisions with !r-parent Signed-off-by: Bjorn Helgaas [EMAIL PROTECTED] Acked-by: David Howells [EMAIL PROTECTED] ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [patch 08/16] mn10300: use generic pci_enable_resources()
Bjorn Helgaas [EMAIL PROTECTED] wrote: Use the generic pci_enable_resources() instead of the arch-specific code. Unlike this arch-specific code, the generic version: - checks PCI_NUM_RESOURCES (11), not 6, resources - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set - skips ROM resources unless IORESOURCE_ROM_ENABLE is set - checks for resource collisions with !r-parent Signed-off-by: Bjorn Helgaas [EMAIL PROTECTED] Acked-by: David Howells [EMAIL PROTECTED] ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [RFC 05/10] mn10300: vmlinux.lds.S cleanup - use PAGE_SIZE, PERCPU macroses
[EMAIL PROTECTED] wrote: Subject: [RFC 05/10] mn10300: vmlinux.lds.S cleanup - use PAGE_SIZE, PERCPU macroses X-RedHat-Spam-Score: -1.005 This patch includes page.h header into liker script that allow us to use PAGE_SIZE macro instead of numeric constant Also PERCPU macro is used instead of explicit section definition Signed-off-by: Cyrill Gorcunov [EMAIL PROTECTED] Acked-by: David Howells [EMAIL PROTECTED] ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [patch 6/6] PCI: consolidate several pcibios_enable_resources() implementations
Bjorn Helgaas [EMAIL PROTECTED] wrote: frv: checks only 6 resources at (1), has a different ROM resource check at (4) and (6) that ignores IORESOURCE_ROM_ENABLE ... mn10300: checks only 6 resources at (1), has no IORESOURCE_{IO,MEM} check at (3), has a different ROM resource check at (4) and (6) that ignores IORESOURCE_ROM_ENABLE Both parts: Acked-by: David Howells [EMAIL PROTECTED] ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 1/3] Fix Unlikely(x) == y
Geert Uytterhoeven [EMAIL PROTECTED] wrote: Hence shouldn't we ask the gcc people what's the purpose of __builtin_expect(), if it doesn't live up to its promise? __builtin_expect() is useful on FRV where you _have_ to give each branch and conditional branch instruction a measure of probability whether the branch will be taken. David ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH] [POWERPC] Fix build errors when BLOCK=n
Try the attached. David --- [PATCH] VFS: Make BSG declarations dependent on CONFIG_BLOCK From: David Howells [EMAIL PROTECTED] Make BSG function declarations dependent on CONFIG_BLOCK as they are not compilable if the block layer is compiled out. Signed-off-by: David Howells [EMAIL PROTECTED] --- include/linux/bsg.h |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/include/linux/bsg.h b/include/linux/bsg.h index 60e377b..28f5d44 100644 --- a/include/linux/bsg.h +++ b/include/linux/bsg.h @@ -52,6 +52,7 @@ struct sg_io_v4 { }; #ifdef __KERNEL__ +#ifdef CONFIG_BLOCK #if defined(CONFIG_BLK_DEV_BSG) struct bsg_class_device { @@ -73,6 +74,7 @@ static inline void bsg_unregister_queue(struct request_queue *rq) } #endif +#endif /* CONFIG_BLOCK */ #endif /* __KERNEL__ */ #endif ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev