summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2015-04-15new methods: ->read_iter() and ->write_iter()sandbox/pawelo/kdbus-next-wipAl Viro5-11/+113
Beginning to introduce those. Just the callers for now, and it's clumsier than it'll eventually become; once we finish converting aio_read and aio_write instances, the things will get nicer. For now, these guys are in parallel to ->aio_read() and ->aio_write(); they take iocb and iov_iter, with everything in iov_iter already validated. File offset is passed in iocb->ki_pos, iov/nr_segs - in iov_iter. Main concerns in that series are stack footprint and ability to split the damn thing cleanly. [fix from Peter Ujfalusi <peter.ujfalusi@ti.com> folded] Change-Id: Ib9c6cff05b7ecf8f1052a74c4ec603efb21514e5 Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2015-04-15aio: Kill aio_rw_vect_retry()Kent Overstreet11-90/+28
This code doesn't serve any purpose anymore, since the aio retry infrastructure has been removed. This change should be safe because aio_read/write are also used for synchronous IO, and called from do_sync_read()/do_sync_write() - and there's no looping done in the sync case (the read and write syscalls). Signed-off-by: Kent Overstreet <koverstreet@google.com> Cc: Zach Brown <zab@redhat.com> Cc: Felipe Balbi <balbi@ti.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Jens Axboe <axboe@kernel.dk> Cc: Asai Thambi S P <asamymuthupa@micron.com> Cc: Selvan Mani <smani@micron.com> Cc: Sam Bradshaw <sbradshaw@micron.com> Cc: Jeff Moyer <jmoyer@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Benjamin LaHaise <bcrl@kvack.org> Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
2015-04-15start adding the tag to iov_iterAl Viro5-10/+26
For now, just use the same thing we pass to ->direct_IO() - it's all iovec-based at the moment. Pass it explicitly to iov_iter_init() and account for kvec vs. iovec in there, by the same kludge NFS ->direct_IO() uses. Change-Id: I8187badd197af34d2d9428b0082b14262dce2b78 Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2015-04-15fs: add vfs_iter_{read,write} helpersChristoph Hellwig2-0/+50
Simple helpers that pass an arbitrary iov_iter to filesystems. Change-Id: I71c05364ad7442f974ca232c2deb6dfee5fbe25d Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2015-04-03idr: Add new function idr_is_empty()before-iovAndreas Gruenbacher2-0/+11
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com> Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
2015-04-03Add module param type 'ullong'Hannes Reinecke2-0/+6
Some driver might want to pass in an 64-bit value, so introduce a module param type 'ullong'. Signed-off-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Christoph Hellwig <hch@infradead.org> Reviewed-by: Ewan Milne <emilne@redhat.com> Acked-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-04-03kernel.h: define u8, s8, u32, etc. limitsAlex Elder1-0/+13
Create constants that define the maximum and minimum values representable by the kernel types u8, s8, u16, s16, and so on. Signed-off-by: Alex Elder <elder@linaro.org> Cc: Sage Weil <sage@inktank.com> Cc: David Miller <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-03params: improve standard definitionsFelipe Contreras1-16/+9
We are repeating the functionality of kstrtol in param_set_long, and the same for kstrtoint. We can get rid of the extra code by using the right functions. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-04-03kernel/params: fix handling of signed integer typesJean Delvare1-3/+3
Commit 6072ddc8520b ("kernel: replace strict_strto*() with kstrto*()") broke the handling of signed integer types, fix it. Signed-off-by: Jean Delvare <khali@linux-fr.org> Reported-by: Christian Kujau <lists@nerdbynature.de> Tested-by: Christian Kujau <lists@nerdbynature.de> Cc: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-03kernel: replace strict_strto*() with kstrto*()Jingoo Han3-9/+9
The usage of strict_strto*() is not preferred, because strict_strto*() is obsolete. Thus, kstrto*() should be used. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-03module: fix sprintf format specifier in param_get_byte()Christoph Jaeger1-1/+1
In param_get_byte(), to which the macro STANDARD_PARAM_DEF(byte, ...) expands, "%c" is used to print an unsigned char. So it gets printed as a character what is not intended here. Use "%hhu" instead. [Rusty: note drivers which would be effected: drivers/net/wireless/cw1200/main.c drivers/ntb/ntb_transport.c:68 drivers/scsi/lpfc/lpfc_attr.c drivers/usb/atm/speedtch.c drivers/usb/gadget/g_ffs.c ] Acked-by: Jon Mason <jon.mason@intel.com> (for ntb) Acked-by: Michal Nazarewicz <mina86@mina86.com> (for g_ffs.c) Signed-off-by: Christoph Jaeger <christophjaeger@linux.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-04-03temp fixMaciej Wereski2-4/+4
Change-Id: I4560164cc3ac614dc008e57aa45aeee9fe5f01bc Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
2015-04-02Enable kdbusMaciej Wereski3-0/+3
Change-Id: Ia7048b206143c007624234489687062fe3a3e5d3 Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
2015-04-02samples: kdbus: build kdbus-workers conditionallyDaniel Mack2-1/+8
Give the kdbus sample its own config switch and only build it if it's explicitly switched on. Signed-off-by: Daniel Mack <daniel@zonque.org> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Reported-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: Fix CONFIG_KDBUS help textDaniel Mack1-2/+3
Drop a left-over from the times when documentation lived in a simple text file, which is no longer the case. Mention the auto-generated man-pages and HTML files instead. Reported-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Daniel Mack <daniel@zonque.org> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: connection: fix handling of failed fget()Daniel Mack1-3/+2
The patch 5fc8dd5c84fc: "kdbus: add connection, queue handling and message validation code" from Sep 11, 2014, leads to the following static checker warning: ipc/kdbus/connection.c:2000 kdbus_cmd_send() warn: 'cancel_fd' isn't an ERR_PTR Fix this by checking for NULL pointers returned from fget(). Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: fix header guard nameLucas De Marchi1-3/+3
UAPI headers have a _UAPI_ as prefix, which is removed during headers_install. If it's put as a suffix it will not be removed and will be the only header with UAPI in the header guard macro. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02Documentation/kdbus: replace 'reply_cookie' with 'cookie_reply'Lukasz Skalski1-1/+1
The member field is called 'cookie_reply', fix the documentation which incorrectly used 'reply_cookie'. Signed-off-by: Lukasz Skalski <l.skalski@samsung.com> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02selftests/kdbus: fix gitignoreDavid Herrmann1-3/+1
Drop unused elements from .gitignore (which are leftovers when documentation was placed in the same directory). Add "kdbus-test" to .gitignore, which is the test binary of all kdbus selftests. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02Documentation/kdbus: support quiet buildsDavid Herrmann1-3/+13
Add support for quiet builds, just like Documentation/DocBook/Makefile supports. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02Documentation/kdbus: fix out-of-tree buildsDavid Herrmann1-1/+1
Don't use $(obj) to access source files, but use $(srctree)/$(src)/ instead. This fixes build issues if you use O= with a directory other than the source directory. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02samples/kdbus: drop wrong includeDavid Herrmann1-3/+1
There is no reason to use ./include/uapi/ directly from samples. If your system headers are not up-to-date, you _need_ to run "make headers-install" (which will install them to ./usr/ in your kernel tree) before building the examples. Otherwise, you will get warnings and build failures. Once ./usr/ is updated with the correct headers, it contains everything we need, so drop -Iinclude/uapi from the kdbus-workers CFLAGS. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: fix minor typo in the walk-through exampleNicolas Iooss1-2/+2
s/receveiver/receiver/ Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: samples/kdbus: add -lrtDavid Herrmann1-0/+1
On older systems -lrt is needed for clock_gettime(). Add it to HOSTLOADLIBES of kdbus-workers so it builds fine on those systems. Reported-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02Documentation: kdbus: fix location for generated filesDaniel Mack2-2/+4
The generated files should reside in Documentation/kdbus, not in the top-level of the source tree. Also add a .gitignore file and ignore everything that was built from the XML files. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add selftestsDaniel Mack29-0/+11191
This patch adds an extensive test suite for kdbus that checks the most important code paths in the driver. The idea is to extend the test suite over time. Also, this code can serve as another example for how to use the kernel API from userspace. The code in the kdbus test suite makes use of the ioctl wrappers provided by samples/kdbus/kdbus-api.h. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add walk-through user space exampleDaniel Mack5-1/+1452
Provide a walk-through example that explains how to use the low-level ioctl API that kdbus offers. This example is meant to be useful for developers who want to gain a in-depth understanding of how the kdbus API works by reading a well-documented real-world example. This program computes prime-numbers based on the sieve of Eratosthenes. The master sets up a shared memory region and spawns workers which clear out the non-primes. The master reacts to keyboard input and to client-requests to control what each worker does. Note that this is in no way meant as efficient way to compute primes. It should only serve as example how a master/worker concept can be implemented with kdbus used as control messages. The main process is called the 'master'. It creates a new, private bus which will be used between the master and its workers to communicate. The master then spawns a fixed number of workers. Whenever a worker dies (detected via SIGCHLD), the master spawns a new worker. When done, the master waits for all workers to exit, prints a status report and exits itself. The master process does *not* keep track of its workers. Instead, this example implements a PULL model. That is, the master acquires a well-known name on the bus which each worker uses to request tasks from the master. If there are no more tasks, the master will return an empty task-list, which casues a worker to exit immediately. As tasks can be computationally expensive, we support cancellation. Whenever the master process is interrupted, it will drop its well-known name on the bus. This causes kdbus to broadcast a name-change notification. The workers check for broadcast messages regularly and will exit if they receive one. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add Makefile, Kconfig and MAINTAINERS entryDaniel Mack4-1/+48
This patch hooks up the build system to actually compile the files added by previous patches. It also adds an entry to MAINTAINERS to direct people to Greg KH, David Herrmann, Djalal Harouni and me for questions and patches. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add policy database implementationDaniel Mack2-0/+540
This patch adds the policy database implementation. A policy database restricts the possibilities of connections to own, see and talk to well-known names. It can be associated with a bus (through a policy holder connection) or a custom endpoint. By default, buses have an empty policy database that is augmented on demand when a policy holder connection is instantiated. Policies are set through KDBUS_CMD_HELLO (when creating a policy holder connection), KDBUS_CMD_CONN_UPDATE (when updating a policy holder connection), KDBUS_CMD_EP_MAKE (creating a custom endpoint) or KDBUS_CMD_EP_UPDATE (updating a custom endpoint). In all cases, the name and policy access information is stored in items of type KDBUS_ITEM_NAME and KDBUS_ITEM_POLICY_ACCESS. See kdbus.policy(7) for more details. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add name registry implementationDaniel Mack2-0/+846
This patch adds the name registry implementation. Each bus instantiates a name registry to resolve well-known names into unique connection IDs for message delivery. The registry will be queried when a message is sent with kdbus_msg.dst_id set to KDBUS_DST_ID_NAME, or when a registry dump is requested. It's important to have this registry implemented in the kernel to implement lookups and take-overs in a race-free way. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add code for buses, domains and endpointsDaniel Mack6-0/+1376
Add the logic to handle the following entities: Domain: A domain is an unamed object containing a number of buses. A domain is automatically created when an instance of kdbusfs is mounted, and destroyed when it is unmounted. Every domain offers its own 'control' device node to create buses. Domains are isolated from each other. Bus: A bus is a named object inside a domain. Clients exchange messages over a bus. Multiple buses themselves have no connection to each other; messages can only be exchanged on the same bus. The default entry point to a bus, where clients establish the connection to, is the "bus" device node /sys/fs/kdbus/<bus name>/bus. Common operating system setups create one "system bus" per system, and one "user bus" for every logged-in user. Applications or services may create their own private named buses. Endpoint: An endpoint provides the device node to talk to a bus. Opening an endpoint creates a new connection to the bus to which the endpoint belongs. Every bus has a default endpoint called "bus". A bus can optionally offer additional endpoints with custom names to provide a restricted access to the same bus. Custom endpoints carry additional policy which can be used to give sandboxed processes only a locked-down, limited, filtered access to the same bus. See kdbus(7), kdbus.bus(7), kdbus.endpoint(7) and kdbus.fs(7) for more details. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add code for notifications and matchesDaniel Mack4-0/+872
This patch adds code for matches and notifications. Notifications are broadcast messages generated by the kernel, which notify subscribes when connections are created or destroyed, when well-known-names have been claimed, released or changed ownership, or when reply messages have timed out. Matches are used to tell the kernel driver which broadcast messages a connection is interested in. Matches can either be specific on one of the kernel-generated notification types, or carry a bloom filter mask to match against a message from userspace. The latter is a way to pre-filter messages from other connections in order to mitigate unnecessary wakeups. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add code to gather metadataDaniel Mack2-0/+1221
A connection chooses which metadata it wants to have attached to each message it receives with kdbus_cmd_hello.attach_flags. The metadata will be attached as items to the messages. All metadata refers to information about the sending task at sending time, unless otherwise stated. Also, the metadata is copied, not referenced, so even if the sending task doesn't exist anymore at the time the message is received, the information is still preserved. In traditional D-Bus, userspace tasks like polkit or journald make a live lookup in procfs and sysfs to gain information about a sending task. This is racy, of course, as in a a connection-less system like D-Bus, the originating peer can go away immediately after sending the message. As we're moving D-Bus prmitives into the kernel, we have to provide the same semantics here, and inform the receiving peer on the live credentials of the sending peer. Metadata is collected at the following times. * When a bus is created (KDBUS_CMD_MAKE), information about the calling task is collected. This data is returned by the kernel via the KDBUS_CMD_BUS_CREATOR_INFO call. * When a connection is created (KDBUS_CMD_HELLO), information about the calling task is collected. Alternatively, a privileged connection may provide 'faked' information about credentials, PIDs and security labels which will be stored instead. This data is returned by the kernel as information on a connection (KDBUS_CMD_CONN_INFO). Only metadata that a connection allowed to be sent (by setting its bit in attach_flags_send) will be exported in this way. * When a message is sent (KDBUS_CMD_SEND), information about the sending task and the sending connection are collected. This metadata will be attached to the message when it arrives in the receiver's pool. If the connection sending the message installed faked credentials (see kdbus.connection(7)), the message will not be augmented by any information about the currently sending task. Which metadata items are actually delivered depends on the following sets and masks: (a) the system-wide kmod creds mask (module parameter 'attach_flags_mask') (b) the per-connection send creds mask, set by the connecting client (c) the per-connection receive creds mask, set by the connecting client (d) the per-bus minimal creds mask, set by the bus creator (e) the per-bus owner creds mask, set by the bus creator (f) the mask specified when querying creds of a bus peer (g) the mask specified when querying creds of a bus owner With the following rules: [1] The creds attached to messages are determined as a & b & c. [2] When connecting to a bus (KDBUS_CMD_HELLO), and ~b & d != 0, the call will fail with, -1, and errno is set to ECONNREFUSED. [3] When querying creds of a bus peer, the creds returned are a & b & f. [4] When querying creds of a bus owner, the creds returned are a & e & g. See kdbus.metadata(7) and kdbus.item(7) for more details on which metadata can currently be attached to messages. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add node and filesystem implementationDaniel Mack5-0/+1533
kdbusfs is a filesystem that will expose a fresh kdbus domain context each time it is mounted. Per mount point, there will be a 'control' node, which can be used to create buses. fs.c contains the implementation of that pseudo-fs. Exported inodes of 'file' type have their i_fop set to either kdbus_handle_control_ops or kdbus_handle_ep_ops, depending on their type. The actual dispatching of file operations is done from handle.c node.c is an implementation of a kdbus object that has an id and children, organized in an R/B tree. The tree is used by the filesystem code for lookup and iterator functions, and to deactivate children once the parent is deactivated. Every inode exported by kdbusfs is backed by a kdbus_node, hence it is embedded in struct kdbus_ep, struct kdbus_bus and struct kdbus_domain. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add connection, queue handling and message validation codeDaniel Mack11-1/+4722
This patch adds code to create and destroy connections, to validate incoming messages and to maintain the queue of messages that are associated with a connection. Note that connection and queue have a 1:1 relation, the code is only split in two parts for cleaner separation and better readability. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add connection pool implementationDaniel Mack2-0/+774
A pool for data received from the kernel is installed for every connection of the bus, and it is used to copy data from the kernel to userspace clients, for messages and other information. It is accessed when one of the following ioctls is issued: * KDBUS_CMD_MSG_RECV, to receive a message * KDBUS_CMD_NAME_LIST, to dump the name registry * KDBUS_CMD_CONN_INFO, to retrieve information on a connection The offsets returned by either one of the aforementioned ioctls describe offsets inside the pool. Internally, the pool is organized in slices, that are dynamically allocated on demand. The overall size of the pool is chosen by the connection when it connects to the bus with KDBUS_CMD_HELLO. In order to make the slice available for subsequent calls, KDBUS_CMD_FREE has to be called on the offset. To access the memory, the caller is expected to mmap() it to its task. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add driver skeleton, ioctl entry points and utility functionsDaniel Mack7-0/+1167
Add the basic driver structure. handle.c is the main ioctl command dispatcher that calls into other parts of the driver. main.c contains the code that creates the initial domain at startup, and util.c has utility functions such as item iterators that are shared with other files. limits.h describes limits on things like maximum data structure sizes, number of messages per users and suchlike. Some of the numbers currently picked are rough ideas of what what might be sufficient and are probably rather conservative. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add uapi header fileDaniel Mack2-0/+980
This patch adds the header file which describes the low-level transport protocol used by various ioctls. The header file is located in include/uapi/linux/ as it is shared between kernel and userspace, and it only contains data structure definitions, enums and defines for constants. The low-level kernel API of kdbus is exposed through ioctls, employed on nodes exposed by kdbusfs. We've chosen a ioctl-based implementation over syscalls for various reaons: * The ioctls kdbus offers are completely specific to nodes exposed by kdbusfs and can not be applied to any other file descriptor in a system. * The file descriptors derived from opening nodes in kdbusfs can only be used for poll(), close() and the ioctls described in kdbus.h. * Not all systems will make use of kdbus eventually, and we want to make as many parts of the kernel optional at build time. * We want to build the kdbus code as module, which is impossible to do when implemented with syscalls. * The ioctl dispatching logic does not show up in our performance graphs; its overhead is negligible. * For development, being able to build, load and unload a separate module with a versioned name suffix is essential. Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02kdbus: add documentationDaniel Mack15-1/+7339
kdbus is a system for low-latency, low-overhead, easy to use interprocess communication (IPC). The interface to all functions in this driver is implemented via ioctls on files exposed through a filesystem called 'kdbusfs'. The default mount point of kdbusfs is /sys/fs/kdbus. This patch adds detailed documentation about the kernel level API design. This patch adds a set of comprehensive set of DocBook files which can be turned into man-pages using 'make mandocs', or into HTML files with 'make htmldocs'. Change-Id: Ic99ed66f2e2879b9664f21ed653240b2ebdc6204 Signed-off-by: Daniel Mack <daniel@zonque.org> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Djalal Harouni <tixxdz@opendz.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-02arm: tizen_defconfig: enable Odroid X2/U3 support with single kernel imageMarek Szyprowski1-24/+36
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Change-Id: I92a8db74b9bcfcd55ae8d005f91ed52c844cf833
2015-04-02ARM: dts: exynos4412-trats2: Add 32khz clock property in sound node to ↵Inha Song1-2/+4
control codec_clk32k This patch add 32khz clock property in sound node to control codec_clk32k. Change-Id: Id6c2fdb13433e2c431f530aa48445913c30f6609 Signed-off-by: Inha Song <ideal.song@samsung.com>
2015-04-02ASoC: samsung: Add 32khz clock control logic for codec mclk2Inha Song1-1/+18
This patch add 32khz clock control logic for codec's master clock 2(MCLK2). WM1811 codec can use MCLK1 and MCLK2 as FLL's source clocks. Change-Id: Ifc57ae1772db9a905b0d1c101442ccf649d53c6b Signed-off-by: Inha Song <ideal.song@samsung.com>
2015-03-27sysfs: make sure read buffer is zeroedsandbox/pawelo/kernfs_betterTejun Heo1-1/+2
13c589d5b0ac ("sysfs: use seq_file when reading regular files") switched sysfs from custom read implementation to seq_file to enable later transition to kernfs. After the change, the buffer passed to ->show() is acquired through seq_get_buf(); unfortunately, this introduces a subtle behavior change. Before the commit, the buffer passed to ->show() was always zero as it was allocated using get_zeroed_page(). Because seq_file doesn't clear buffers on allocation and neither does seq_get_buf(), after the commit, depending on the behavior of ->show(), we may end up exposing uninitialized data to userland thus possibly altering userland visible behavior and leaking information. Fix it by explicitly clearing the buffer. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Ron <ron@debian.org> Fixes: 13c589d5b0ac ("sysfs: use seq_file when reading regular files") Cc: stable <stable@vger.kernel.org> # 3.13+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-27sysfs: bail early from kernfs_file_mmap() to avoid spurious lockdep warningTejun Heo2-8/+22
This is v3.14 fix for the same issue that a8b14744429f ("sysfs: give different locking key to regular and bin files") addresses for v3.13. Due to the extensive kernfs reorganization in v3.14 branch, the same fix couldn't be ported as-is. The v3.13 fix was ignored while merging it into v3.14 branch. 027a485d12e0 ("sysfs: use a separate locking class for open files depending on mmap") assigned different lockdep key to sysfs_open_file->mutex depending on whether the file implements mmap or not in an attempt to avoid spurious lockdep warning caused by merging of regular and bin file paths. While this restored some of the original behavior of using different locks (at least lockdep is concerned) for the different clases of files. The restoration wasn't full because now the lockdep key assignment depends on whether the file has mmap or not instead of whether it's a regular file or not. This means that bin files which don't implement mmap will get assigned the same lockdep class as regular files. This is problematic because file_operations for bin files still implements the mmap file operation and checking whether the sysfs file actually implements mmap happens in the file operation after grabbing @sysfs_open_file->mutex. We still end up adding locking dependency from mmap locking to sysfs_open_file->mutex to the regular file mutex which triggers spurious circular locking warning. For v3.13, a8b14744429f ("sysfs: give different locking key to regular and bin files") fixed it by giving sysfs_open_file->mutex different lockdep keys depending on whether the file is regular or bin instead of whether mmap exists or not; however, due to the way sysfs is now layered behind kernfs, this approach is no longer viable. kernfs can tell whether a sysfs node has mmap implemented or not but can't tell whether a bin file from a regular one. This patch updates kernfs such that kernfs_file_mmap() checks SYSFS_FLAG_HAS_MMAP and bail before grabbing sysfs_open_file->mutex so that it doesn't add spurious locking dependency from mmap to sysfs_open_file->mutex and changes sysfs so that it specifies kernfs_ops->mmap iff the sysfs file implements mmap. Combined, this ensures that sysfs_open_file->mutex is grabbed under mmap path iff the sysfs file actually implements mmap. As sysfs_open_file->mutex is already given a different lockdep key if mmap is implemented, this removes the spurious locking dependency. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Dave Jones <davej@redhat.com> Link: http://lkml.kernel.org/g/20131203184324.GA11320@redhat.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-27sysfs, kernfs: remove cross inclusions of internal headersTejun Heo2-3/+0
fs/kernfs/kernfs-internal.h needed to include fs/sysfs/sysfs.h because part of kernfs core implementation was living in sysfs. fs/sysfs/sysfs.h needed to include fs/kernfs/kernfs-internal.h because include/linux/kernfs.h didn't expose enough interface. The separation is complete and neither is true anymore. Remove the cross inclusion and make sysfs a proper user of kernfs. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-27sysfs, kernfs: implement kernfs_ns_enabled()Tejun Heo4-7/+21
fs/sysfs/symlink.c::sysfs_delete_link() tests @sd->s_flags for SYSFS_FLAG_NS. Let's add kernfs_ns_enabled() so that sysfs doesn't have to test sysfs_dirent flag directly. This makes things tidier for kernfs proper too. This is purely cosmetic. v2: To avoid possible NULL deref, use noop dummy implementation which always returns false when !CONFIG_SYSFS. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-27sysfs, kernfs: make sysfs_dirent definition publicTejun Heo3-103/+115
sysfs_dirent includes some information which should be available to kernfs users - the type, flags, name and parent pointer. This patch moves sysfs_dirent definition from kernfs/kernfs-internal.h to include/linux/kernfs.h so that kernfs users can access them. The type part of flags is exported as enum kernfs_node_type, the flags kernfs_node_flag, sysfs_type() and kernfs_enable_ns() are moved to include/linux/kernfs.h and the former is updated to return the enum type. sysfs_dirent->s_parent and ->s_name are marked explicitly as public. This patch doesn't introduce any functional changes. v2: Flags exported too and kernfs_enable_ns() definition moved. v3: While moving kernfs_enable_ns() to include/linux/kernfs.h, v1 and v2 put the definition outside CONFIG_SYSFS replacing the dummy implementation with the actual implementation too. Unfortunately, this can lead to oops when !CONFIG_SYSFS because kernfs_enable_ns() may be called on a NULL @sd and now tries to dereference @sd instead of not doing anything. This issue was reported by Yuanhan Liu. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-27sysfs, kernfs: move mount core code to fs/kernfs/mount.cTejun Heo4-170/+178
Move core mount code to fs/kernfs/mount.c. The respective declarations in fs/sysfs/sysfs.h are moved to fs/kernfs/kernfs-internal.h. This is pure relocation. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-27sysfs, kernfs: prepare mount path for kernfsTejun Heo5-35/+106
We're in the process of separating out core sysfs functionality into kernfs which will deal with sysfs_dirents directly. This patch rearranges mount path so that the kernfs and sysfs parts are separate. * As sysfs_super_info won't be visible outside kernfs proper, kernfs_super_ns() is added to allow kernfs users to access a super_block's namespace tag. * Generic mount operation is separated out into kernfs_mount_ns(). sysfs_mount() now just performs sysfs-specific permission check, acquires namespace tag, and invokes kernfs_mount_ns(). * Generic superblock release is separated out into kernfs_kill_sb() which can be used directly as file_system_type->kill_sb(). As sysfs needs to put the namespace tag, sysfs_kill_sb() wraps kernfs_kill_sb() with ns tag put. * sysfs_dir_cachep init and sysfs_inode_init() are separated out into kernfs_init(). kernfs_init() uses only small amount of memory and trying to handle and propagate kernfs_init() failure doesn't make much sense. Use SLAB_PANIC for sysfs_dir_cachep and make sysfs_inode_init() panic on failure. After this change, kernfs_init() should be called before sysfs_init(), fs/namespace.c::mnt_init() modified accordingly. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: linux-fsdevel@vger.kernel.org Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-27sysfs, kernfs: make super_blocks bind to different kernfs_rootsTejun Heo2-4/+12
kernfs is being updated to allow multiple sysfs_dirent hierarchies so that it can also be used by other users. Currently, sysfs super_blocks are always attached to one kernfs_root - sysfs_root - and distinguished only by their namespace tags. This patch adds sysfs_super_info->root and update sysfs_fill/test_super() so that super_blocks are identified by the combination of both the associated kernfs_root and namespace tag. This allows mounting different kernfs hierarchies. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>