]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
10 years agoctf: write the CTF files for standalone modules to a subdir of the module dir
Nick Alcock [Fri, 7 Sep 2012 19:26:17 +0000 (20:26 +0100)]
ctf: write the CTF files for standalone modules to a subdir of the module dir

Writing all ctf to the .ctf subdirectory of the kernel directory is problematic
when building standalone modules, when the kernel directory may be unwritable.
So write it to the .ctf subdirectory of the module directory in this case
as well.  (The old .ctf relative path was hardwired into dwarf2ctf, so this
too is changed to accept the path to write the CTF files to as the first
parameter, in both non-standalone and standalone mode.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: unnamed structure/union support
Nick Alcock [Wed, 29 Aug 2012 13:18:57 +0000 (14:18 +0100)]
ctf: unnamed structure/union support

Since neither CTF nor DTrace userspace have support for unnamed structure/union
members, we have to cheat a bit.  We can model an unnamed structure member as
being precisely equivalent to simply naming the structure members in the
enclosing structure, with their offsets biased by the offset of the unnamed
member in its enclosing structure.  An unnamed union is the same, excepting the
overlapping offsets, which we don't need to pay any attention to since we
already get all our offset information directly from the debugging information
anyway.

So we handle this by detecting an anonymous member after offset computation,
skipping to its type DIE's first child (if any), and calling die_to_ctf()
directly with that child, so that die_to_ctf() works over the anonymous member's
members as if they were members of the enclosing structure, skipping all the
usual addition of that structure as a CTF entity in its own right.  We handle
the offset biasing by adding a parent_bias to die_to_ctf() and all CTF
construction functions, and adding that bias to all structure member offsets.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: recurse_ctf() -> die_to_ctf()
Nick Alcock [Wed, 29 Aug 2012 11:27:06 +0000 (12:27 +0100)]
ctf: recurse_ctf() -> die_to_ctf()

This function is badly named: sure, it's recursive, but so are half a dozen
other functions in dwarf2ctf.  Its callers do not care that it is recursive:
they care that its function is to translate a DWARF DIE to CTF.

So rename it accordingly.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: fix the signed-modules case
Nick Alcock [Fri, 10 Aug 2012 22:52:19 +0000 (23:52 +0100)]
ctf: fix the signed-modules case

The code in Makefile.modpost's module-ctf-flags variable which computes the name
of the CTF file, given the name of the kernel module being linked, was torpedoed
by the name of the unsigned module that is linked when module signing is in use.
So introduce a new ctf-module-name variable that substitutes the name
appropriately given the state of module signing.

Also, fix up some related places where I used spaces instead of tabs by mistake.

(3.6: most signed-modules code omitted, but a bit of supporting code remains
 in readiness for signed modules in 3.7.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: correctly propagate IDs for array types
Nick Alcock [Thu, 9 Aug 2012 23:54:55 +0000 (00:54 +0100)]
ctf: correctly propagate IDs for array types

We were constructing things of array type wrongly, for a rather interesting
reason.

DWARF describes an array by putting its base type in the parent DIE, then
describing its bounds in the child DIE.  Unfortunately, this puts us in an
unfortunate position: we always visit the parent before its children (so we can
build things like structures before filling their members in) -- but you can't
build a CTF array without knowing what its bounds are ('flexible' is not the
same as 'we don't know yet') -- and we *do* need the base type to be constructed
anyway.  So we constructed the base type when working over the parent DIE, then
wrapped an array around it when we visited the children where the dimensions
were described (possibly more than one for a multidimensional array: though GCC
happens not to emit those for C, it is permitted to, and handling it is easy, so
we do).  Unfortunately, recurse_ctf() throws away the type ID returned from
child DIEs, so the CTF ID that gets stashed for assignment to things of that
array type (when they are looked up via lookup_ctf_type()) turns out not to be
an array type at all, but the base type!

So we add an optional override parameter to recurse_ctf() and to all the
construction functions: it is passed only by recursive recurse_ctf() calls (when
processing child DIEs): it is set nonzero by construction functions that wrap
and replace the ID from their parent DIE, and when it is set, the type ID
returned by the construction function replaces the type ID that recurse_ctf()
passes back to its parent.  Now assemble_ctf_array_dimension() just needs to
set this override parameter, and all is well.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: fix off-by-one in emitted array bounds
Nick Alcock [Thu, 9 Aug 2012 23:33:14 +0000 (00:33 +0100)]
ctf: fix off-by-one in emitted array bounds

We were treating arrays described by DW_AT_count and DW_AT_upper_bound
identically, but in a language like C with zero-based arrays they are not:
DW_AT_upper_bound does not give the number of members unless you add one
to it.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: fix tiny comment typo
Nick Alcock [Tue, 7 Aug 2012 08:47:09 +0000 (09:47 +0100)]
dtrace: fix tiny comment typo

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: blacklist certain modules from deduplication
Nick Alcock [Tue, 7 Aug 2012 08:46:38 +0000 (09:46 +0100)]
ctf: blacklist certain modules from deduplication

sound/pci/ens1371.c #includes another file, ens1370.c, with a #define
that changes the definition, but not name, of a single structure.

While this grotesquerie is permitted in C, there's no way that translation units
that engage in it can be permitted to share types with other translation units.
More specifically, types defined in such TUs must not be permitted to transform
a non-shared type to shared by virtue of their being detected in such TUs.

I'd like to detect the redefined structures themselves, but since the
preprocessor trickery leaves no mark in the DWARF another pass would be
necessary just to detect this. It's easier -- and faster -- to introduce a
blacklist of modules that do things like this and simply turn deduplication
scanning off for these modules. (Because they are still allowed to reuse
duplicates found in other modules, this does not increase their size
appreciably.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: include enumeration types inside functions
Nick Alcock [Mon, 6 Aug 2012 18:06:38 +0000 (19:06 +0100)]
ctf: include enumeration types inside functions

Like structures and unions, enumerations are a named type in their own
namespace: like structures and unions, arrays and other types based on such
types are represented by a DWARF DIE outside all functions. So the duplicate
detector must treat them like structures and unions, and include them even
if they are inside functions.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: new IO and sched provider probes
Kris Van Hees [Mon, 6 Aug 2012 09:01:08 +0000 (05:01 -0400)]
dtrace: new IO and sched provider probes

New IO provider probes: start, done, wait-start, wait-done

New sched provider probes: enqueue, dequeue, wakeup, preempt, remain-cpu,
change-pri, surrender

(Note that the preempt probe currently passes a debugging argument that
will be removed in the future to match the argument-less version in the
documentation.)

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: fix to handle multiple SDT-based probes in a single function
Kris Van Hees [Wed, 1 Aug 2012 14:05:30 +0000 (10:05 -0400)]
dtrace: fix to handle multiple SDT-based probes in a single function

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: require assembler symbol stripping and debug info
Nick Alcock [Tue, 31 Jul 2012 17:35:57 +0000 (18:35 +0100)]
dtrace: require assembler symbol stripping and debug info

The former is needed because dt_module.c doesn't know how to ignore assembler
labels when reading module symbol data: the latter because dwarf2ctf reads the
types out of debug info.

Use select rather than require because both of these requirements are distinctly
non-obvious and we don't want to force people to hunt about for them.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: fix array dimensions
Nick Alcock [Tue, 31 Jul 2012 17:33:58 +0000 (18:33 +0100)]
ctf: fix array dimensions

Due to a premature optimization (in, admittedly, speed-critical code) and
mistakenly forgetting that dwarf_formudata() does not return its result like
dwarf_whatform(), all arrays were considered to be flexible arrays of unknown
dimension.

Also, the type ID representation for arrays was uniquely ugly in that it lacked
a trailing space after the close ].

(Both fixed.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: change the name of the CTF section in kernel modules
Nick Alcock [Mon, 30 Jul 2012 21:33:44 +0000 (22:33 +0100)]
ctf: change the name of the CTF section in kernel modules

Since we have broken backward-compatibility with Solaris libctf and changed the
magic number in CTF files, we should change the name of the section they are
written to. .dtrace_ctf seems like a good idea (which means that shared types
will now be found in the .dtrace_ctf.dtrace_ctf section, rather than, as
before, .SUNW_ctf.dtrace_ctf).

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: fix a bug in the SDT probe location generator
Kris Van Hees [Mon, 30 Jul 2012 19:03:45 +0000 (15:03 -0400)]
dtrace: fix a bug in the SDT probe location generator

The generator could accidentally add the address of a non-function
identifier to the SDT list (e.g. watchdog occurs both in the
uninitialised data section (BSS) and the text section).

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agoctf: major duplicate detection fixes
Nick Alcock [Mon, 30 Jul 2012 18:21:15 +0000 (19:21 +0100)]
ctf: major duplicate detection fixes

The duplicate detector had numerous faults.  Among the situations it couldn't
handle:

 - a shared structure 'struct foo' visible in both opaque and non-opaque form,
   with an identically-sized array, pointer, or other entity referring to that
   type in both modules where the type was visible only as an opaque type and
   types where it was visible non-opaquely.

 - any situation in which a member of a shared structure points to a structure
   which would not be shared but for that (and so on, for as many repeated
   points-tos as one wishes)

 - situations in which structures had anonymous structures contained within
   themselves that were used as types for members within the outermost
   structure, whether or not either was shared, e.g.

   struct foo {
       struct {
           int womble;
       } *baz;
   };

   In this situation, the innermost struct would not be noted by the duplicate
   detector, which would lead to a failure to assemble the type later on, as CTF
   assembly can't tell what CTF file it belongs in.

A large-scale rewrite was needed for this, transforming the duplicate detector
from a three-pass scheme with one sharer-of-all-obviously-duplicated-types
running first and last and one detector of transparent/opaque struct/union
aliasing running in the middle, into a scheme where the sharer-of-all runs once,
then the alias detector runs repeatedly, sharing opaque types for which the
corresponding transparent types are already shared, and recursively sharing
transparent types for which the opaque ones are already shared: in the latter
case, it triggers another rerun of the alias detector, in case that recursive
sharing run marks more structures as shared (opaque or transparent).

Worse yet, when we mark a type 'struct foo' as shared, this may not be enough --
there may be types which use that type as a base type which should also be
shared. So the alias detector now runs over not just all structures and unions
but all types which have structures and unions as an ultimate base type,
checking at each level of descent towards the structure whether sharing is
required, and recursively sharing everything from that level down if such is
needed.  (This is done with a type_id() callback, like everything that
involves descending DWARF type use/def chains.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: optimize type_id() and fix array dimension lookup
Nick Alcock [Mon, 30 Jul 2012 18:08:49 +0000 (19:08 +0100)]
ctf: optimize type_id() and fix array dimension lookup

type_id() is the single hottest hot spot in dwarf2ctf, and had a number of
more or less severe performance problems:

 - we were calling str_append() where str_appendn() would do, incurring more
   realloc()s and strlen()s than necessary.

 - when calling type_id() for types such as structure members that have the same
   type-id representation as their reffed type, we were calling the hook
   function even though it's already been called with that ID by our recursive
   call on the reffed type.  Some hook functions are quite expensive, so this
   is probably a bad idea.

 - we were calling realpath() once per call, although a very limited number of
   input arguments are expected (one per translation unit) and the mapping from
   input to output never changes.  This is a perfect candidate for caching.

The latter in particular has a vast impact on dwarf2ctf performance, reducing it
by around 80% in my tests.

str_append() and str_appendn() themselves were suboptimal, taking the length of
their arguments more times than necessary and calling realloc() more often than
required (once per argument after the first in the case of str_appendn().)
Now that we are using str_appendn() more heavily, this becomes a significant
contributor to runtime, so this is fixed too.

Further, array dimension lookup (both in type_id() and in
assemble_ctf_array_dimension()) was broken due to looping past the first array
dimension without looking at it.  This tended to cause false sharing of
actually-distinct types (all one-dimensional arrays were treated as the same
type regardless of dimension, and since C only has one-dimensional arrays...)

We also add some comments noting that the format of type_id() and the
by-hand-constructed type IDs in the alias fixup code must be kept aligned, since
the breakage when this is not so is quite obscure and hard to figure out.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: changed the logic for determining SDT probe point locations
Kris Van Hees [Sun, 29 Jul 2012 08:30:18 +0000 (04:30 -0400)]
dtrace: changed the logic for determining SDT probe point locations

The previous version did not account for probes that might be placed in
non-.text segments.  New code also avoids extra passes that were not necessary.

Added on-cpu and off-cpu sched probes.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agoctf: store away the types and names of non-static global variables
Nick Alcock [Sat, 28 Jul 2012 11:50:44 +0000 (12:50 +0100)]
ctf: store away the types and names of non-static global variables

The critical part of this change is assemble_ctf_variable(), which calls the new
ctf_add_variable() function to add a variable and its type information to the
appropriate CTF file (as determined by the deduplication pass).

Because we scan all scopes to detect non-opaque definitions of structures,
unions and enums used opaquely at global scope, and the functions called for
each DIE we understand tend to be quite expensive, we also introduce an
additional filtration mechanism (the 'assembly filter') to prevent DWARF tree
walks from calling an assembly function for DIEs we are not interested in.

We don't provide as much information to the assembly filter as to the assembly
function itself -- just the DIE and its parent DIE -- but that is enough to
prevent the assembly function from being called not only for variables but also
for base types, arrays, crv-qualified types, and pointer types at non-global
scope -- none of which we are interested in, since we care only about named
structures/unions/enums at non-global scope, and e.g.

typedef struct foo {
 ...
} *bar;

is represented as *three* DWARF nodes at the same level, one for 'struct foo',
one for a pointer to it, and one for a typedef of that.  So there is no danger
that avoiding processing for such types will miss the structures we are
interested in.

For variables, we filter out all 'uninteresting' types using a new filter
function which rules out not only 'variables' with no name, static variables,
and variables at non-global scope, but also a large number of specifically-
named global variables introduced by macros to cover facilities as diverse as
tracepoints and the kernel symbol table.  There is no chance that DTrace users
would want to look at these variables, so we don't need to store them in the
CTF.  (We don't need to consider points-to relationships for variables, unlike
types, so that consideration does not apply.)

DTrace userspace contains a similar list to avoid reading in uninteresting lines
from /proc/kallmodsyms, but the two need not be synchronized: CTF for variables
that DTrace is filtering out will simply never be consulted, and variables that
DTrace does not filter out but that have been filtered out by dwarf2ctf will
have no CTF and will simply be rejected at parsing time.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: set the name of the parent of child modules to "dtrace_ctf"
Nick Alcock [Wed, 25 Jul 2012 20:07:21 +0000 (21:07 +0100)]
ctf: set the name of the parent of child modules to "dtrace_ctf"

This is possible now that libdtrace-ctf has grown the ctf_parent_name_set()
function.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: clarify comments, improve a type name
Nick Alcock [Wed, 25 Jul 2012 20:06:28 +0000 (21:06 +0100)]
ctf: clarify comments, improve a type name

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: force dtrace_ctf.ko to be loaded whenever dtrace.ko is
Nick Alcock [Fri, 20 Jul 2012 22:00:07 +0000 (23:00 +0100)]
ctf: force dtrace_ctf.ko to be loaded whenever dtrace.ko is

DTrace userspace makes the simplifying assumption that dtrace_ctf.ko (containing
the CTF for the kernel, for built-in modules, and for shared types, but no code)
is always loaded whenever DTrace is usable.  (The CTF itself is in a non-loaded
section, but having dtrace_ctf.ko in the list of loaded modules means that we
can eliminate an annoying set of dtrace_ctf-related special case.)

We do this by introducing a dummy function dtrace_ctf_forceload() into the
dtrace_ctf module, which DTrace then calls: depmod will then arrange for
dtrace_ctf to be loaded when we need it.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: generate CTF information for the kernel
Nick Alcock [Fri, 11 May 2012 15:59:13 +0000 (16:59 +0100)]
ctf: generate CTF information for the kernel

This introdues a new tool, dwarf2ctf, which runs at modpost time whenever any
module or any part of the core kernel is changed, extracting the debugging
information from the kernel build tree, deduplicating it, and emitting it in
Sun's Compact Type Format into gzipped files in a new .ctf directory.  These
files are then linked into the kernel modules as new sections named .SUNW_ctf.

One file is emitted per kernel module, whether builtin or no, as well as one
file for types that are used by no modules, and one file for types shared
between more than one of the other files.  As the built-in modules and shared
types have no module of their own to go into, they are placed in a new
dtrace_ctf.ko module (which serves no other purpose: loading it is useless).
DTrace userspace will no longer start if this module is not present.

Due to the extensive sharing of types, dwarf2ctf must run whenever any object
files at all are changed, and may trigger relinks of modules that you would not
otherwise think had changed.

Standalone modules also have CTF generated for them, but never share types with
any other modules.

Because dwarf2ctf is slow enough to be annoying when running frequent kernel
builds to debug some unrelated problem, a new CONFIG_DT_DISABLE_CTF debugging
configuraton option is added, which suppresses CTF generation entirely.

This commit introduces new kernel build-time dependencies on elfutils and the
new libdtrace-ctf package (shared with dtrace userspace).  No new runtime
dependencies are introduced.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agokallsyms: provide symbol sizes in /proc/kallmodsyms
Nick Alcock [Fri, 29 Jun 2012 20:06:28 +0000 (21:06 +0100)]
kallsyms: provide symbol sizes in /proc/kallmodsyms

For modules, we can simply extract these sizes from the module symtab; for core
kernel symbols, we must do subtraction as get_symbol_pos() did: this is now
abstracted into a new get_symbol_size().

Because /proc/kallmodsyms contains *all* symbols, where get_symbol_pos() was
normally only called for a small subset of symbols, this exercises this code
like never before, and has revealed a bug: the size of __per_cpu_end was being
returned as a ludicrously vast value, because the next symbol after
__per_cpu_end is far up the address space, in the kernel proper. Fixing this by
forcing a size of zero for __per_cpu_end is easy enough.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoctf: add a dummy dtrace_ctf.ko module
Nick Alcock [Wed, 20 Jun 2012 18:43:22 +0000 (19:43 +0100)]
ctf: add a dummy dtrace_ctf.ko module

Without this, the latest dtrace userspace will not start.
(This will soon be filled with cross-module and core-kernel CTF data.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agokallsyms: fix /proc/kallmodsyms population bugs
Nick Alcock [Mon, 18 Jun 2012 15:57:59 +0000 (16:57 +0100)]
kallsyms: fix /proc/kallmodsyms population bugs

scripts/kallsyms was failing to identify variables local to modules as being in
those modules, which is unfortunate because a large number of DTrace module
references are to data symbols.

This is easily enough fixed by recording variable references as well as function
references, which was all we were tracking before this. Alas, this breaks our
heuristic that symbols whose names are seen more than once must be outside all
modules, because external variable references can be seen multiple times inside
a single module even when the thing they are a reference to is also inside that
module.  The fix to this is to differentiate between 'names seen in this module'
and 'names seen in prior modules', recording newly-seen names in the former list
and moving them en masse to the latter when we switch from scanning one module
to scanning another.  We can then define a symbol as being 'not in any module'
iff it is seen while present in the names-seen-in-prior-modules list: a symbol
that is seen repeatedly but only inside a single module's object file is still
considered to be part of that module under this scheme.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agokallsyms: work in a clean tree, and a non-modular tree.
Nick Alcock [Mon, 14 May 2012 10:24:44 +0000 (11:24 +0100)]
kallsyms: work in a clean tree, and a non-modular tree.

kallsyms nowadays relies upon modules.builtin, so we must make sure that
modules.builtin is there before kallsyms runs.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agokallsyms: work with older glibc.
Nick Alcock [Mon, 14 May 2012 10:22:32 +0000 (11:22 +0100)]
kallsyms: work with older glibc.

Before glibc 2.10, getline() was under _GNU_SOURCE.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agokallsyms: add /proc/kallmodsyms
Nick Alcock [Fri, 11 May 2012 20:21:33 +0000 (21:21 +0100)]
kallsyms: add /proc/kallmodsyms

This procfile (controlled by CONFIG_KALLSYMS), introduces a new
/proc/kallmodsyms whose contents are the same as /proc/kallsyms, except that the
module name is provided even for built-in modules, as long as they could
potentially have been built as separate kernel modules.  DTrace will use it in
future to allow users to use the same module names in their D scripts regardless
of whether the modules are built-in or not in the kernel they happen to be
running.

This is done by scanning the object files named in the builtin.modules file
using libelf, extracting their function symbols, pruning out any symbols which
appear in more than one builtin module (since these are probably out-of-line
copies of inline functions in common kernel header files), then emitting the
names of all the modules in a new kallsyms_modules symbol and pointing at the
appropriate modules in a kallsyms_symbol_modules symbol which maps 1:1 to the
contents of kallsyms_addresses (thus, one kallsyms_symbol entry per kernel
symbol in /proc/kallsyms).  Always-built-in functions have a corresponding
kallsyms_symbol_modules index of zero.

This is not terribly space-efficient: the kallsyms_symbol_modules symbol is
quite large (~250K, mostly zeroes, four bytes per kernel symbol), but reducing
this requires some other way to signal that a symbol is not present in a module.
It is much smaller than even the compressed representation of the symbol names.

Possible future enhancements, low priority:
 - use a home-cooked hashtable rather than glib (pointless unless dwarf2ctf is
   similarly rejigged)
 - use nm rather than elfutils (liable to be quite a lot slower)
 - find a more robust way of detecting inlined functions, not fooled by
   out-of-line copies of inlined functions which happen to be used by
   only one module
 - shrink the kernel symbol space consumption, perhaps by using shorts rather
   than longs for the module offsets (65536Kb of module names should be enough
   for anybody)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: add sched-tick SDT probe and FBT probe point discovery/creation
Kris Van Hees [Thu, 19 Apr 2012 21:19:40 +0000 (17:19 -0400)]
dtrace: add sched-tick SDT probe and FBT probe point discovery/creation

Move code around for the kernel pseudo-module handling since it gets used
by both the SDT code and the FBT code.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: use new mutex_owned(), not mutex_is_locked()
Kris Van Hees [Tue, 7 Feb 2012 09:31:48 +0000 (04:31 -0500)]
dtrace: use new mutex_owned(), not mutex_is_locked()

This is used in our implementation of the Solaris MUTEX_HELD() macro.
The former was merely testing whether the mutex was locked, whereas
the real test needed here is whether the mutex is held by the current thread.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: fix signed division and modulo operations in DIF
Kris Van Hees [Tue, 17 Jan 2012 20:03:17 +0000 (15:03 -0500)]
dtrace: fix signed division and modulo operations in DIF

Ensure that SDT probe points are patched with a NOP sequence at boot time.

Remove debugging output during SDT registration.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: initialize the insn length in the right branch of the die notifier
Nick Alcock [Tue, 17 Jan 2012 13:46:02 +0000 (13:46 +0000)]
dtrace: initialize the insn length in the right branch of the die notifier

Absent this fix, dtrace will crash on any platform *except* for a buggy Xen.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: ensure that the trap handler is regisstered only once
Kris Van Hees [Thu, 12 Jan 2012 14:25:35 +0000 (09:25 -0500)]
dtrace: ensure that the trap handler is regisstered only once

Register with first use.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: install the die notifier hook whenever DTrace is enabled
Kris Van Hees [Wed, 11 Jan 2012 06:18:41 +0000 (01:18 -0500)]
dtrace: install the die notifier hook whenever DTrace is enabled

Page fault and general protection fault handling depends on it, and that
is needed for safe memory access support in DTrace.

Work around an apparent bug in Xen where an invalid opcode fault is delivered
as a general protection failure instead.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: support for page fault and general protection fault detection
Kris Van Hees [Wed, 14 Dec 2011 05:09:14 +0000 (00:09 -0500)]
dtrace: support for page fault and general protection fault detection

This ensures that DTrace memory access faults are non-fatal.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: fix incorrect probe point name
Kris Van Hees [Tue, 13 Dec 2011 22:08:10 +0000 (17:08 -0500)]
dtrace: fix incorrect probe point name

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: add lwp-exit and lwp-create SDT probe points
Kris Van Hees [Tue, 13 Dec 2011 21:58:43 +0000 (16:58 -0500)]
dtrace: add lwp-exit and lwp-create SDT probe points

Change the DRELOC tag in make output to DT-SDT.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: SDT implementation
Kris Van Hees [Mon, 5 Dec 2011 20:01:27 +0000 (15:01 -0500)]
dtrace: SDT implementation

This adds core kernel support for providing a list of static probe
points for the kernel pseudo-module, dtrace SDT meta-provider support, ...
Also a new script (dtrace_sdt.sh) to extract locations of SDT probe points in
the core kernel.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: process the SDT probe point info early in boot
Kris Van Hees [Mon, 14 Nov 2011 15:17:45 +0000 (10:17 -0500)]
dtrace: process the SDT probe point info early in boot

If DTrace SDT support has been enabled (built-in or as module),
process the SDT probe point info early at boot time (before SMP is actually
enabled).  For now, provide some verbose info on the probe points getting
resolved.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: fix resolving addresses of relocation records for SDT probe points
Kris Van Hees [Fri, 11 Nov 2011 07:34:04 +0000 (02:34 -0500)]
dtrace: fix resolving addresses of relocation records for SDT probe points

The addresses were being calculated based on the wrong starting point (_stext
whereas it ought to be _text), and the base was not taken into account.
Fixed the writing of NOPs in the location of the probe point calls, since
the existing case was causing kernel paging faults.  Made the add_nops()
function in alternative.c non-static so it can be used in sdt_register.
Use add_nops() to select the most appropriate NOP sequence for replacing the
probe point call, and write the NOPs using text_poke().

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: fix cyclic allocation
Kris Van Hees [Thu, 3 Nov 2011 17:59:00 +0000 (13:59 -0400)]
dtrace: fix cyclic allocation

Fixed the allocation of cyclics that was the cause of some obscure crashes
during the testsuite execution.  Problem was that cyclics were being allocated
in chunks, with a new array being allocated as (prev-size + chink-size), and
then the old entries being copied over.  However, because the hrtimer struct is
embedded in the cyclic struct, this meant that hrtimer structs were being moved
outside the hrtimer code.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: stub-based syscall tracing
Kris Van Hees [Thu, 27 Oct 2011 14:39:19 +0000 (10:39 -0400)]
dtrace: stub-based syscall tracing

Due to the need for specialized code handling (mainly passing in a pt_regs
structure as one of the arguments), some syscalls are called through a stub
in assembly code.

We duplicate the stub cdode in dtrace_stubs_x86_64.S, but instead of calling
the actual syscall implementation code call our own syscall-specific handler,
which ensures that entry and return probes are called as enabled, and then
call the underlying implementation directly for handling the syscall.

Also removed debugging output that is no longer relevant (code cleanup).

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: migrate stacktrace dumping and move headers about: fix reloc overrun
Kris Van Hees [Fri, 14 Oct 2011 02:42:27 +0000 (22:42 -0400)]
dtrace: migrate stacktrace dumping and move headers about: fix reloc overrun

Stacktrace dumping has been moved to the GPL-licensed dtrace_os.c because it
depends on a symbol that is exported as GPL-only.  Functionality in dtrace_isa
that requires stacktrace dumping can now use dtrace_stacktrace().

The GPL-licensed dtrace_os.h C header file is now made available through the
/include/linux hierarchy, and it is included in dtrace.h.

Fixed a bug in dtrace_relocs.c where section names where copied into a memory
area that was 1 byte short, causing various unpleasant forms of behaviour.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: move cyclic.h into include/linux
Nick Alcock [Tue, 4 Oct 2011 11:58:17 +0000 (12:58 +0100)]
dtrace: move cyclic.h into include/linux

This is so that things in dtrace/ can pick it up.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: finish GPL/CDDL splitting work
Nick Alcock [Mon, 3 Oct 2011 16:20:15 +0000 (17:20 +0100)]
dtrace: finish GPL/CDDL splitting work

kernel/dtrace and all that it #includes is now GPLv2, with the aid of a new
systrace_os.h header containing the subset of systrace.h needed by the GPL shim.
Conversely, dtrace/ is entirely CDDL.

dtrace_ioctl.h is now an exported, header in include/linux/, to ease future
sharing by the userspace side. It is probably not copyrightable (as is essential
for interoperability and contains no creative elements), but if it has any license
at all it is GPLv2 like the other headers in that directory (many of which are
include them.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: fix GPL and CDDL copyright notices
Nick Alcock [Fri, 30 Sep 2011 18:29:33 +0000 (19:29 +0100)]
dtrace: fix GPL and CDDL copyright notices

The stuff in kernel/dtrace gets just a (C) line: dual-licensed parts will need
further adjustment.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: Migrate to a standalone module, situated at the top level of the tree
Nick Alcock [Fri, 30 Sep 2011 17:55:09 +0000 (18:55 +0100)]
dtrace: Migrate to a standalone module, situated at the top level of the tree

Built via a simple 'make' if you're already running this kernel, or via 'make
KERNELDIR=/path/to/kernel/top/level' otherwise. Installed via 'make install'.

A specfile creating a standalone source rpm (which depends on the kernel source
RPM) will be added soon.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: changes in how we collect the names of system calls
Kris Van Hees [Tue, 20 Sep 2011 06:56:56 +0000 (02:56 -0400)]
dtrace: changes in how we collect the names of system calls

We used to use the ftrace syscall meta info and the nr-to-meta functionality.
Now we populate the systrace info structure statically at kernel compile time.
This means that the DTrace code no longer depends on ftrace.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: add dtrace_gethrtime() and fix walltimestamp.
Kris Van Hees [Thu, 8 Sep 2011 15:13:26 +0000 (11:13 -0400)]
dtrace: add dtrace_gethrtime() and fix walltimestamp.

The walltimestamp is required to be the time in nanoseconds since the epoch,
not the time in nanoseconds since boot or since dtrace invocation.

So we no longer need dtrace_mstate.dtms_walltimestamp, nor the flag used to
track its updating: but we *do* need a new way to get the time that is safe
for non-GPL use.

This fixes test/act/time.d (which is the only test that checks if walltimestamp
not only exists but returns the right value).

Orabug: 18376038

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Acked-by: Jerry Snitselaar <jerry.snitselaar@oracle.com>
10 years agodtrace: syscall entry/return probes.
Kris Van Hees [Wed, 31 Aug 2011 03:28:03 +0000 (23:28 -0400)]
dtrace: syscall entry/return probes.

Makes the sys call table writable, and replaces the function pointer
for select syscalls with the address of a wrapper function to enable
entry and return probe firing.

Fix for address range checking for copyin(str) operations and relatives.
It was using an incorrect boundary address, causing problems for some cases.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: conflict with CONFIG_DEBUG_LOCK_ALLOC
Nick Alcock [Thu, 11 Aug 2011 15:48:19 +0000 (16:48 +0100)]
dtrace: conflict with CONFIG_DEBUG_LOCK_ALLOC

DTrace breaks when CONFIG_DEBUG_LOCK_ALLOC as this pulls in GPLONLY functions.
Block this combination.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: update sdt provider (sdt_mod.c) with lots of functions
Randy Dunlap [Fri, 15 Jul 2011 16:44:43 +0000 (09:44 -0700)]
dtrace: update sdt provider (sdt_mod.c) with lots of functions

NOTES:
- module loadcnt may need more work.
- kernel_searchsym() is incomplete (see FIXMEs).

Add sdt_subr.c and build it in Makefile.

Add str_impl.h for internal sdt use.

Add more fields to linux/module.h for static probe bookkeeping.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
10 years agodtrace: add dtrace_module_loaded() and dtrace_module_unloaded()
Randy Dunlap [Fri, 15 Jul 2011 16:37:44 +0000 (09:37 -0700)]
dtrace: add dtrace_module_loaded() and dtrace_module_unloaded()

Give the static probes in the kernel image a module name of
  "kernel_builtins" and a module state of LIVE.

Fix an extra-paren typo in dtrace_dev.c.

NOTE:  This is incomplete.  There are a few TBDs and FIXMEs
  in this patch.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
10 years agodtrace: added CONFIG_DT_DEBUG_MUTEX option
Kris Van Hees [Wed, 20 Jul 2011 07:06:47 +0000 (03:06 -0400)]
dtrace: added CONFIG_DT_DEBUG_MUTEX option

This option enables printing all locations where a mutex is locked
and unlocked.

Implemented aggregations using the idr mechanism rather than the
Solaris-based 1-byte allocation technique to get unique IDs.
Various cleanup and small changes.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: turn on gcov profiling in the kernel/dtrace directory by default
Nick Alcock [Thu, 14 Jul 2011 17:12:29 +0000 (18:12 +0100)]
dtrace: turn on gcov profiling in the kernel/dtrace directory by default

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: add dt_test provider.
Kris Van Hees [Thu, 14 Jul 2011 17:59:39 +0000 (13:59 -0400)]
dtrace: add dt_test provider.

Adding framework for a test provider that fires a specific probe on request.
Adding previously missing (and unused) exported functions:

dtrace_invalidate()
dtrace_attached()
dtrace_condense()
drace_probe_arg()

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: add Documentation/dtrace_static_probes.txt
Randy Dunlap [Tue, 28 Jun 2011 15:37:28 +0000 (08:37 -0700)]
dtrace: add Documentation/dtrace_static_probes.txt

This is a directory of all static probes in the kernel tree.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
10 years agodtrace: remove incorrect header comments and copyright
Randy Dunlap [Tue, 28 Jun 2011 15:36:00 +0000 (08:36 -0700)]
dtrace: remove incorrect header comments and copyright

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
10 years agodtrace: build sdt_register.c into the kernel
Nick Alcock [Tue, 28 Jun 2011 13:15:18 +0000 (14:15 +0100)]
dtrace: build sdt_register.c into the kernel

This allows DTrace to be built as a module again.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: add missing include needed for DTrace probes
Nick Alcock [Tue, 28 Jun 2011 12:17:42 +0000 (13:17 +0100)]
dtrace: add missing include needed for DTrace probes

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agodtrace: convert relative probepoint relocation addresses to absolute
Randy Dunlap [Tue, 28 Jun 2011 00:17:17 +0000 (17:17 -0700)]
dtrace: convert relative probepoint relocation addresses to absolute

This should have been done by the top-level Makefile, but it must
have a dependency problem since the generated vmlinux_info.S has
the correct info in it but the vmlinux_info.o file does not AND
the .S file was created AFTER the .o file.

Also convert calls to dtrace stub RETs to NOPs.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
10 years agodtrace: add some dtrace static probes that are easy to trigger
Randy Dunlap [Tue, 28 Jun 2011 00:01:46 +0000 (17:01 -0700)]
dtrace: add some dtrace static probes that are easy to trigger

See the static probes directory listing for a summary of
all dtrace static probes.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
10 years agodtrace: add FTRACE dependency
Kris Van Hees [Tue, 28 Jun 2011 18:53:46 +0000 (14:53 -0400)]
dtrace: add FTRACE dependency

Added dependency for FTRACE and FTRACE_SYSCALLS for the SYSTRACE provider.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: Remove debugging statements
Kris Van Hees [Wed, 15 Jun 2011 14:41:11 +0000 (10:41 -0400)]
dtrace: Remove debugging statements

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: fix unintended dependency on section ordering
Randy Dunlap [Mon, 13 Jun 2011 20:20:51 +0000 (13:20 -0700)]
dtrace: fix unintended dependency on section ordering

Reduce the unintended ordering dependency (_text before _stext)
when scanning the relocs info file.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
10 years agodtrace: minimal cyclic implementation and debug code.
Kris Van Hees [Mon, 13 Jun 2011 18:53:27 +0000 (14:53 -0400)]
dtrace: minimal cyclic implementation and debug code.

Adding debug code to track probe processing through BEGIN probe enabling.
Adding minimal implementation of cyclic functionality (based on hrtimer) as an
additional to the core kernel, linked in when dtrace is enabled (be it as
module, or compiled in).  Exports cyclic_add() and cyclic_remove().
Removed former cyclic stub implementation (cyclic.c).

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: DT_SYSTRACE should not depend on FTRACE_SYSCALLS.
Kris Van Hees [Tue, 24 May 2011 01:42:48 +0000 (21:42 -0400)]
dtrace: DT_SYSTRACE should not depend on FTRACE_SYSCALLS.

The systrace provider depends on the FTRACE_SYSCALLS kernel feature.
The systrace provider is actually called syscall on Solaris, so it has been
renamed on the Linux side (i.e. it registers itself as syscall).
Added some debug statements to track probe searches better.
The probes/probematch ioctl handling should return -ESRCH when the last hit
has been returned already.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: fix off-by-one reading relocation info.
Randy Dunlap [Fri, 10 Jun 2011 20:33:24 +0000 (13:33 -0700)]
dtrace: fix off-by-one reading relocation info.

Reading the dtrace relocation info table could fail on a
boundary condition. Fix by counting the string terminator (null)
byte.  Now works for my 4 test cases.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
10 years agodtrace: use _stext in dtrace_relocs.
Randy Dunlap [Tue, 7 Jun 2011 16:46:30 +0000 (09:46 -0700)]
dtrace: use _stext in dtrace_relocs.

Read and use the _stext value for adding to relative relocation
info to make it absolute.
This works for my 4 test cases.  It was derived by examination
and discovery.  There could be cases where it does not work,
e.g. in other text sections.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
10 years agodtrace: Fix compilation when modular.
Kris Van Hees [Fri, 20 May 2011 00:36:06 +0000 (20:36 -0400)]
dtrace: Fix compilation when modular.

Removed || CONFIG_DT_SDT_MODULE from conditional surrounding call to
dtrace_register_builtins() because that function does not exist in the
kernel proper when DTrace is compiled as kernel modules.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
10 years agodtrace: systrace should depend on FTRACE_SYSCALLS.
Randy Dunlap [Thu, 19 May 2011 17:08:27 +0000 (10:08 -0700)]
dtrace: systrace should depend on FTRACE_SYSCALLS.

This is because systrace uses syscall_nr_to_meta, which is only available
when FTRACE_SYSCALLS is enabled.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
10 years agodtrace: Initial import of kernelspace code.
Nick Alcock [Thu, 12 May 2011 22:46:51 +0000 (15:46 -0700)]
dtrace: Initial import of kernelspace code.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
10 years agoLinux 4.1 v4.1 v4.1test
Linus Torvalds [Mon, 22 Jun 2015 05:05:43 +0000 (22:05 -0700)]
Linux 4.1

10 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Linus Torvalds [Sun, 21 Jun 2015 00:26:01 +0000 (17:26 -0700)]
Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending

Pull scsi target fixes from Nicholas Bellinger:
 "Apologies for the late pull request.

  Here are the outstanding target-pending fixes for v4.1 code.

  The series contains three patches from Sagi + Co that address a few
  iser-target issues that have been uncovered during recent testing at
  Mellanox.

  Patch #1 has a v3.16+ stable tag, and #2-3 have v3.10+ stable tags"

* git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending:
  iser-target: Fix possible use-after-free
  iser-target: release stale iser connections
  iser-target: Fix variable-length response error completion

10 years agoMerge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
Linus Torvalds [Sat, 20 Jun 2015 20:54:22 +0000 (13:54 -0700)]
Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux

Pull drm fixes from Dave Airlie:
 "A smattering of fixes,

  mgag200:
      don't accept modes that aren't aligned properly as hw can't do it

  i915:
      two regression fixes

  radeon:
      one query to allow userspace fixes
      one oops fixer for older hw with new options enabled"

* 'drm-fixes' of git://people.freedesktop.org/~airlied/linux:
  drm/radeon: don't probe MST on hw we don't support it on
  drm/radeon: Add RADEON_INFO_VA_UNMAP_WORKING query
  drm/mgag200: Reject non-character-cell-aligned mode widths
  Revert "drm/i915: Don't skip request retirement if the active list is empty"
  drm/i915: Always reset vma->ggtt_view.pages cache on unbinding

10 years agoMerge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Fri, 19 Jun 2015 17:36:50 +0000 (07:36 -1000)]
Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux

Pull clk fixes from Michael Turquette:
 "Very late clk regression fixes for the ARM-based AT91 platform.

  These went unnoticed by me until recently, hence the late pull
  request"

* tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
  clk: at91: fix h32mx prototype inclusion in pmc header
  clk: at91: trivial: typo in peripheral clock description
  clk: at91: fix PERIPHERAL_MAX_SHIFT definition
  clk: at91: pll: fix input range validity check

10 years agoMerge tag 'sound-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Linus Torvalds [Fri, 19 Jun 2015 17:34:14 +0000 (07:34 -1000)]
Merge tag 'sound-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
 "Nothing looks scary, just a few usual HD-audio regression fixes and
  fixup, in addition to a minor Kconfig dependency fix for the old MIPS
  drivers"

* tag 'sound-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
  ALSA: hda - Fix unused label skip_i915
  ALSA: hda - Fix noisy outputs on Dell XPS13 (2015 model)
  ALSA: mips: let SND_SGI_O2 select SND_PCM
  ALSA: hda - Fix audio crackles on Dell Latitude E7x40
  ALSA: hda - adding a DAC/pin preference map for a HP Envy TS machine

10 years agoMerge branch 'ccf/atmel-fixes-for-4.1' of https://github.com/bbrezillon/linux-at91...
Michael Turquette [Fri, 19 Jun 2015 14:37:14 +0000 (07:37 -0700)]
Merge branch 'ccf/atmel-fixes-for-4.1' of https://github.com/bbrezillon/linux-at91 into clk-fixes

10 years agoclk: at91: fix h32mx prototype inclusion in pmc header
Nicolas Ferre [Thu, 28 May 2015 13:07:21 +0000 (15:07 +0200)]
clk: at91: fix h32mx prototype inclusion in pmc header

Trivial fix that prevents to compile this pmc clock driver if h32mx clock is
present but smd clock isn't.

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Fixes: bcc5fd49a0fd ("clk: at91: add a driver for the h32mx clock")
Cc: <stable@vger.kernel.org> # 3.18+
10 years agoclk: at91: trivial: typo in peripheral clock description
Nicolas Ferre [Wed, 17 Jun 2015 13:22:51 +0000 (15:22 +0200)]
clk: at91: trivial: typo in peripheral clock description

Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
10 years agoclk: at91: fix PERIPHERAL_MAX_SHIFT definition
Boris Brezillon [Thu, 28 May 2015 12:01:08 +0000 (14:01 +0200)]
clk: at91: fix PERIPHERAL_MAX_SHIFT definition

Fix the PERIPHERAL_MAX_SHIFT definition (3 instead of 4) and adapt the
round_rate and set_rate logic accordingly.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reported-by: "Wu, Songjun" <Songjun.Wu@atmel.com>
10 years agoclk: at91: pll: fix input range validity check
Boris Brezillon [Fri, 27 Mar 2015 22:53:15 +0000 (23:53 +0100)]
clk: at91: pll: fix input range validity check

The PLL impose a certain input range to work correctly, but it appears that
this input range does not apply on the input clock (or parent clock) but
on the input clock after it has passed the PLL divisor.
Fix the implementation accordingly.

Cc: <stable@vger.kernel.org> # v3.14+
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reported-by: Jonas Andersson <jonas@microbit.se>
10 years agoMerge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
Linus Torvalds [Fri, 19 Jun 2015 03:02:27 +0000 (17:02 -1000)]
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c documentation fix from Wolfram Sang:
 "Here is a small documentation fix for I2C.

  We already had a user who unsuccessfully tried to get the new slave
  framework running with the currently broken example.  So, before this
  happens again, I'd like to have this how-to-use section fixed for 4.1
  already.  So that no more hacking time is wasted"

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  i2c: slave: fix the example how to instantiate from userspace

10 years agorevert "cpumask: don't perform while loop in cpumask_next_and()"
Andrew Morton [Thu, 18 Jun 2015 18:01:11 +0000 (11:01 -0700)]
revert "cpumask: don't perform while loop in cpumask_next_and()"

Revert commit 534b483a86e6 ("cpumask: don't perform while loop in
cpumask_next_and()").

This was a minor optimization, but it puts a `struct cpumask' on the
stack, which consumes too much stack space.

Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Reported-by: Peter Zijlstra <peterz@infradead.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Amir Vadai <amirv@mellanox.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
10 years agoMerge tag 'drm-intel-fixes-2015-06-18' of git://anongit.freedesktop.org/drm-intel...
Dave Airlie [Fri, 19 Jun 2015 01:58:39 +0000 (11:58 +1000)]
Merge tag 'drm-intel-fixes-2015-06-18' of git://anongit.freedesktop.org/drm-intel into drm-fixes

one fix, one revert
* tag 'drm-intel-fixes-2015-06-18' of git://anongit.freedesktop.org/drm-intel:
  Revert "drm/i915: Don't skip request retirement if the active list is empty"
  drm/i915: Always reset vma->ggtt_view.pages cache on unbinding

10 years agoMerge branch 'drm-fixes-4.1' of git://people.freedesktop.org/~deathsimple/linux into...
Dave Airlie [Fri, 19 Jun 2015 01:55:29 +0000 (11:55 +1000)]
Merge branch 'drm-fixes-4.1' of git://people.freedesktop.org/~deathsimple/linux into drm-fixes

two radeon fixes
one MST fix,
one query addition, destined for stable, and to fix a regression
* 'drm-fixes-4.1' of git://people.freedesktop.org/~deathsimple/linux:
  drm/radeon: don't probe MST on hw we don't support it on
  drm/radeon: Add RADEON_INFO_VA_UNMAP_WORKING query

10 years agodrm/radeon: don't probe MST on hw we don't support it on
Dave Airlie [Thu, 18 Jun 2015 04:29:18 +0000 (14:29 +1000)]
drm/radeon: don't probe MST on hw we don't support it on

If you do radeon.mst=1 on a gpu without mst hw, and then
plug some mst hw it will oops instead of falling back.

So check we have DCE5 at least before proceeding.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
10 years agodrm/radeon: Add RADEON_INFO_VA_UNMAP_WORKING query
Michel Dänzer [Tue, 16 Jun 2015 08:28:16 +0000 (17:28 +0900)]
drm/radeon: Add RADEON_INFO_VA_UNMAP_WORKING query

This tells userspace that it's safe to use the RADEON_VA_UNMAP operation
of the DRM_RADEON_GEM_VA ioctl.

Cc: stable@vger.kernel.org
(NOTE: Backporting this commit requires at least backports of commits
26d4d129b6042197b4cbc8341c0618f99231af2f,
48afbd70ac7b6aa62e8d452091023941d8085f8a and
c29c0876ec05d51a93508a39b90b92c29ba6423d as well, otherwise using
RADEON_VA_UNMAP runs into trouble)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
10 years agoMerge tag 'trace-fix-filter-4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Thu, 18 Jun 2015 06:56:57 +0000 (20:56 -1000)]
Merge tag 'trace-fix-filter-4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing filter fix from Steven Rostedt:
 "Vince Weaver reported a warning when he added perf event filters into
  his fuzzer tests.  There's a missing check of balanced operations when
  parenthesis are used, and this triggers a WARN_ON() and when reading
  the failure, the filter reports no failure occurred.

  The operands were not being checked if they match, this adds that"

* tag 'trace-fix-filter-4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  tracing: Have filter check for balanced ops

10 years agoMerge git://git.kernel.org/pub/scm/virt/kvm/kvm
Linus Torvalds [Thu, 18 Jun 2015 06:54:47 +0000 (20:54 -1000)]
Merge git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm bugfix from Marcelo Tosatti:
 "Rrestore APIC migration functionality"

* git://git.kernel.org/pub/scm/virt/kvm/kvm:
  KVM: x86: fix lapic.timer_mode on restore

10 years agoKconfig: disable Media Controller for DVB
Mauro Carvalho Chehab [Tue, 16 Jun 2015 09:26:59 +0000 (06:26 -0300)]
Kconfig: disable Media Controller for DVB

Since when we start discussions about the usage Media Controller for
complex hardware, one thing become clear: the way it is, MC fails to
map anything different than capture/output/m2m video-only streaming.

The point is that MC has entities named as devnodes, but the only
devnode used (before the DVB patches) is MEDIA_ENT_T_DEVNODE_V4L.
Due to the way MC got implemented, however, this entity actually
doesn't represent the devnode, but the hardware I/O engine that
receives data via DMA.

By coincidence, such DMA is associated with the V4L device node
on webcam hardware, but this is not true even for other V4L2
devices. For example, on USB hardware, the DMA is done via the
USB controller. The data passes though a in-kernel filter that
strips off the URB headers. Other V4L2 devices like radio may not
even have DMA. When it have, the DMA is done via ALSA, and not
via the V4L devnode.

In other words, MC is broken as a whole, but tagging it as BROKEN
right now would do more harm than good.

So, instead, let's mark, for now, the DVB part as broken and
block all new changes to MC while we fix this mess, whith
we hopefully will do for the next Kernel version.

Requested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
10 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Linus Torvalds [Thu, 18 Jun 2015 06:49:26 +0000 (20:49 -1000)]
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto fixes from Herbert Xu:
 "This fixes the following issues:

   - Crash in caam hash due to uninitialised buffer lengths.

   - Alignment issue in caam RNG that may lead to non-random output"

* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
  crypto: caam - fix RNG buffer cache alignment
  crypto: caam - improve initalization for context state saves

10 years agomm: shmem_zero_setup skip security check and lockdep conflict with XFS
Hugh Dickins [Sun, 14 Jun 2015 16:48:09 +0000 (09:48 -0700)]
mm: shmem_zero_setup skip security check and lockdep conflict with XFS

It appears that, at some point last year, XFS made directory handling
changes which bring it into lockdep conflict with shmem_zero_setup():
it is surprising that mmap() can clone an inode while holding mmap_sem,
but that has been so for many years.

Since those few lockdep traces that I've seen all implicated selinux,
I'm hoping that we can use the __shmem_file_setup(,,,S_PRIVATE) which
v3.13's commit c7277090927a ("security: shmem: implement kernel private
shmem inodes") introduced to avoid LSM checks on kernel-internal inodes:
the mmap("/dev/zero") cloned inode is indeed a kernel-internal detail.

This also covers the !CONFIG_SHMEM use of ramfs to support /dev/zero
(and MAP_SHARED|MAP_ANONYMOUS).  I thought there were also drivers
which cloned inode in mmap(), but if so, I cannot locate them now.

Reported-and-tested-by: Prarit Bhargava <prarit@redhat.com>
Reported-and-tested-by: Daniel Wagner <wagi@monom.org>
Reported-and-tested-by: Morten Stevens <mstevens@fedoraproject.org>
Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
10 years agoi2c: slave: fix the example how to instantiate from userspace
Wolfram Sang [Mon, 15 Jun 2015 17:51:46 +0000 (19:51 +0200)]
i2c: slave: fix the example how to instantiate from userspace

I copied the wrong shell code into the documentation. Sorry to all who
tried to get sense out of this current example :/ Slight rewording while
we are here.

Reported-by: Tim Bakker <bakkert@mymail.vcu.edu>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Cc: stable@kernel.org
10 years agotracing: Have filter check for balanced ops
Steven Rostedt [Mon, 15 Jun 2015 21:50:25 +0000 (17:50 -0400)]
tracing: Have filter check for balanced ops

When the following filter is used it causes a warning to trigger:

 # cd /sys/kernel/debug/tracing
 # echo "((dev==1)blocks==2)" > events/ext4/ext4_truncate_exit/filter
-bash: echo: write error: Invalid argument
 # cat events/ext4/ext4_truncate_exit/filter
((dev==1)blocks==2)
^
parse_error: No error

 ------------[ cut here ]------------
 WARNING: CPU: 2 PID: 1223 at kernel/trace/trace_events_filter.c:1640 replace_preds+0x3c5/0x990()
 Modules linked in: bnep lockd grace bluetooth  ...
 CPU: 3 PID: 1223 Comm: bash Tainted: G        W       4.1.0-rc3-test+ #450
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v02.05 05/07/2012
  0000000000000668 ffff8800c106bc98 ffffffff816ed4f9 ffff88011ead0cf0
  0000000000000000 ffff8800c106bcd8 ffffffff8107fb07 ffffffff8136b46c
  ffff8800c7d81d48 ffff8800d4c2bc00 ffff8800d4d4f920 00000000ffffffea
 Call Trace:
  [<ffffffff816ed4f9>] dump_stack+0x4c/0x6e
  [<ffffffff8107fb07>] warn_slowpath_common+0x97/0xe0
  [<ffffffff8136b46c>] ? _kstrtoull+0x2c/0x80
  [<ffffffff8107fb6a>] warn_slowpath_null+0x1a/0x20
  [<ffffffff81159065>] replace_preds+0x3c5/0x990
  [<ffffffff811596b2>] create_filter+0x82/0xb0
  [<ffffffff81159944>] apply_event_filter+0xd4/0x180
  [<ffffffff81152bbf>] event_filter_write+0x8f/0x120
  [<ffffffff811db2a8>] __vfs_write+0x28/0xe0
  [<ffffffff811dda43>] ? __sb_start_write+0x53/0xf0
  [<ffffffff812e51e0>] ? security_file_permission+0x30/0xc0
  [<ffffffff811dc408>] vfs_write+0xb8/0x1b0
  [<ffffffff811dc72f>] SyS_write+0x4f/0xb0
  [<ffffffff816f5217>] system_call_fastpath+0x12/0x6a
 ---[ end trace e11028bd95818dcd ]---

Worse yet, reading the error message (the filter again) it says that
there was no error, when there clearly was. The issue is that the
code that checks the input does not check for balanced ops. That is,
having an op between a closed parenthesis and the next token.

This would only cause a warning, and fail out before doing any real
harm, but it should still not caues a warning, and the error reported
should work:

 # cd /sys/kernel/debug/tracing
 # echo "((dev==1)blocks==2)" > events/ext4/ext4_truncate_exit/filter
-bash: echo: write error: Invalid argument
 # cat events/ext4/ext4_truncate_exit/filter
((dev==1)blocks==2)
^
parse_error: Meaningless filter expression

And give no kernel warning.

Link: http://lkml.kernel.org/r/20150615175025.7e809215@gandalf.local.home
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: stable@vger.kernel.org # 2.6.31+
Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Tested-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
10 years agoALSA: hda - Fix unused label skip_i915
Takashi Iwai [Tue, 16 Jun 2015 10:23:36 +0000 (12:23 +0200)]
ALSA: hda - Fix unused label skip_i915

When CONFIG_SND_HDA_I915=n, we get a compile warning:
  sound/pci/hda/hda_intel.c: In function ‘azx_probe_continue’:
  sound/pci/hda/hda_intel.c:1882:2: warning: label ‘skip_i915’ defined but not used [-Wunused-label]

Fix it by putting again ifdef to it.  Sigh.

Fixes: bf06848bdbe5 ('ALSA: hda - Continue probing even if i915 binding fails')
Reported-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
10 years agocrypto: caam - fix RNG buffer cache alignment
Steve Cornelius [Mon, 15 Jun 2015 23:52:59 +0000 (16:52 -0700)]
crypto: caam - fix RNG buffer cache alignment

The hwrng output buffers (2) are cast inside of a a struct (caam_rng_ctx)
allocated in one DMA-tagged region. While the kernel's heap allocator
should place the overall struct on a cacheline aligned boundary, the 2
buffers contained within may not necessarily align. Consenquently, the ends
of unaligned buffers may not fully flush, and if so, stale data will be left
behind, resulting in small repeating patterns.

This fix aligns the buffers inside the struct.

Note that not all of the data inside caam_rng_ctx necessarily needs to be
DMA-tagged, only the buffers themselves require this. However, a fix would
incur the expense of error-handling bloat in the case of allocation failure.

Cc: stable@vger.kernel.org
Signed-off-by: Steve Cornelius <steve.cornelius@freescale.com>
Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
10 years agocrypto: caam - improve initalization for context state saves
Steve Cornelius [Mon, 15 Jun 2015 23:52:56 +0000 (16:52 -0700)]
crypto: caam - improve initalization for context state saves

Multiple function in asynchronous hashing use a saved-state block,
a.k.a. struct caam_hash_state, which holds a stash of information
between requests (init/update/final). Certain values in this state
block are loaded for processing using an inline-if, and when this
is done, the potential for uninitialized data can pose conflicts.
Therefore, this patch improves initialization of state data to
prevent false assignments using uninitialized data in the state block.

This patch addresses the following traceback, originating in
ahash_final_ctx(), although a problem like this could certainly
exhibit other symptoms:

kernel BUG at arch/arm/mm/dma-mapping.c:465!
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = 80004000
[00000000] *pgd=00000000
Internal error: Oops: 805 [#1] PREEMPT SMP
Modules linked in:
CPU: 0    Not tainted  (3.0.15-01752-gdd441b9-dirty #40)
PC is at __bug+0x1c/0x28
LR is at __bug+0x18/0x28
pc : [<80043240>]    lr : [<8004323c>]    psr: 60000013
sp : e423fd98  ip : 60000013  fp : 0000001c
r10: e4191b84  r9 : 00000020  r8 : 00000009
r7 : 88005038  r6 : 00000001  r5 : 2d676572  r4 : e4191a60
r3 : 00000000  r2 : 00000001  r1 : 60000093  r0 : 00000033
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 10c53c7d  Table: 1000404a  DAC: 00000015
Process cryptomgr_test (pid: 1306, stack limit = 0xe423e2f0)
Stack: (0xe423fd98 to 0xe4240000)
fd80:                                                       11807fd1 80048544
fda0: 88005000 e4191a00 e5178040 8039dda0 00000000 00000014 2d676572 e4191008
fdc0: 88005018 e4191a60 00100100 e4191a00 00000000 8039ce0c e423fea8 00000007
fde0: e4191a00 e4227000 e5178000 8039ce18 e419183c 80203808 80a94a44 00000006
fe00: 00000000 80207180 00000000 00000006 e423ff08 00000000 00000007 e5178000
fe20: e41918a4 80a949b4 8c4844e2 00000000 00000049 74227000 8c4844e2 00000e90
fe40: 0000000e 74227e90 ffff8c58 80ac29e0 e423fed4 8006a350 8c81625c e423ff5c
fe60: 00008576 e4002500 00000003 00030010 e4002500 00000003 e5180000 e4002500
fe80: e5178000 800e6d24 007fffff 00000000 00000010 e4001280 e4002500 60000013
fea0: 000000d0 804df078 00000000 00000000 00000000 00000000 00000000 00000000
fec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
fee0: 00000000 00000000 e4227000 e4226000 e4753000 e4752000 e40a5000 e40a4000
ff00: e41e7000 e41e6000 00000000 00000000 00000000 e423ff14 e423ff14 00000000
ff20: 00000400 804f9080 e5178000 e4db0b40 00000000 e4db0b80 0000047c 00000400
ff40: 00000000 8020758c 00000400 ffffffff 0000008a 00000000 e4db0b40 80206e00
ff60: e4049dbc 00000000 00000000 00000003 e423ffa4 80062978 e41a8bfc 00000000
ff80: 00000000 e4049db4 00000013 e4049db0 00000013 00000000 00000000 00000000
ffa0: e4db0b40 e4db0b40 80204cbc 00000013 00000000 00000000 00000000 80204cfc
ffc0: e4049da0 80089544 80040a40 00000000 e4db0b40 00000000 00000000 00000000
ffe0: e423ffe0 e423ffe0 e4049da0 800894c4 80040a40 80040a40 00000000 00000000
[<80043240>] (__bug+0x1c/0x28) from [<80048544>] (___dma_single_dev_to_cpu+0x84)
[<80048544>] (___dma_single_dev_to_cpu+0x84/0x94) from [<8039dda0>] (ahash_fina)
[<8039dda0>] (ahash_final_ctx+0x180/0x428) from [<8039ce18>] (ahash_final+0xc/0)
[<8039ce18>] (ahash_final+0xc/0x10) from [<80203808>] (crypto_ahash_op+0x28/0xc)
[<80203808>] (crypto_ahash_op+0x28/0xc0) from [<80207180>] (test_hash+0x214/0x5)
[<80207180>] (test_hash+0x214/0x5b8) from [<8020758c>] (alg_test_hash+0x68/0x8c)
[<8020758c>] (alg_test_hash+0x68/0x8c) from [<80206e00>] (alg_test+0x7c/0x1b8)
[<80206e00>] (alg_test+0x7c/0x1b8) from [<80204cfc>] (cryptomgr_test+0x40/0x48)
[<80204cfc>] (cryptomgr_test+0x40/0x48) from [<80089544>] (kthread+0x80/0x88)
[<80089544>] (kthread+0x80/0x88) from [<80040a40>] (kernel_thread_exit+0x0/0x8)
Code: e59f0010 e1a01003 eb126a8d e3a03000 (e5833000)
---[ end trace d52a403a1d1eaa86 ]---

Cc: stable@vger.kernel.org
Signed-off-by: Steve Cornelius <steve.cornelius@freescale.com>
Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
10 years agoKVM: x86: fix lapic.timer_mode on restore
Radim Krčmář [Fri, 5 Jun 2015 18:57:41 +0000 (20:57 +0200)]
KVM: x86: fix lapic.timer_mode on restore

lapic.timer_mode was not properly initialized after migration, which
broke few useful things, like login, by making every sleep eternal.

Fix this by calling apic_update_lvtt in kvm_apic_post_state_restore.

There are other slowpaths that update lvtt, so this patch makes sure
something similar doesn't happen again by calling apic_update_lvtt
after every modification.

Cc: stable@vger.kernel.org
Fixes: f30ebc312ca9 ("KVM: x86: optimize some accesses to LVTT and SPIV")
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>