1. 13 8月, 2020 11 次提交
  2. 10 8月, 2020 2 次提交
    • M
      kbuild: trace functions in subdirectories of lib/ · b16838c6
      Masahiro Yamada 提交于
      ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE)
      
      exists here in sub-directories of lib/ to keep the behavior of
      commit 2464a609 ("ftrace: do not trace library functions").
      
      Since that commit, not only the objects in lib/ but also the ones in
      the sub-directories are excluded from ftrace (although the commit
      description did not explicitly mention this).
      
      However, most of library functions in sub-directories are not so hot.
      Re-add them to ftrace.
      
      Going forward, only the objects right under lib/ will be excluded.
      
      Cc: Ingo Molnar <mingo@kernel.org>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      b16838c6
    • M
      kbuild: introduce ccflags-remove-y and asflags-remove-y · 15d5761a
      Masahiro Yamada 提交于
      CFLAGS_REMOVE_<file>.o filters out flags when compiling a particular
      object, but there is no convenient way to do that for every object in
      a directory.
      
      Add ccflags-remove-y and asflags-remove-y to make it easily.
      
      Use ccflags-remove-y to clean up some Makefiles.
      
      The add/remove order works as follows:
      
       [1] KBUILD_CFLAGS specifies compiler flags used globally
      
       [2] ccflags-y adds compiler flags for all objects in the
           current Makefile
      
       [3] ccflags-remove-y removes compiler flags for all objects in the
           current Makefile (New feature)
      
       [4] CFLAGS_<file> adds compiler flags per file.
      
       [5] CFLAGS_REMOVE_<file> removes compiler flags per file.
      
      Having [3] before [4] allows us to remove flags from most (but not all)
      objects in the current Makefile.
      
      For example, kernel/trace/Makefile removes $(CC_FLAGS_FTRACE)
      from all objects in the directory, then adds it back to
      trace_selftest_dynamic.o and CFLAGS_trace_kprobe_selftest.o
      
      The same applies to lib/livepatch/Makefile.
      
      Please note ccflags-remove-y has no effect to the sub-directories.
      In contrast, the previous notation got rid of compiler flags also from
      all the sub-directories.
      
      The following are not affected because they have no sub-directories:
      
        arch/arm/boot/compressed/
        arch/powerpc/xmon/
        arch/sh/
        kernel/trace/
      
      However, lib/ has several sub-directories.
      
      To keep the behavior, I added ccflags-remove-y to all Makefiles
      in subdirectories of lib/, except the following:
      
        lib/vdso/Makefile        - Kbuild does not descend into this Makefile
        lib/raid/test/Makefile   - This is not used for the kernel build
      
      I think commit 2464a609 ("ftrace: do not trace library functions")
      excluded too much. In the next commit, I will remove ccflags-remove-y
      from the sub-directories of lib/.
      Suggested-by: NSami Tolvanen <samitolvanen@google.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Acked-by: Brendan Higgins <brendanhiggins@google.com> (KUnit)
      Tested-by: NAnders Roxell <anders.roxell@linaro.org>
      15d5761a
  3. 08 8月, 2020 8 次提交
  4. 04 8月, 2020 1 次提交
  5. 01 8月, 2020 3 次提交
  6. 31 7月, 2020 3 次提交
  7. 30 7月, 2020 2 次提交
    • L
      random32: remove net_rand_state from the latent entropy gcc plugin · 83bdc727
      Linus Torvalds 提交于
      It turns out that the plugin right now ends up being really unhappy
      about the change from 'static' to 'extern' storage that happened in
      commit f227e3ec ("random32: update the net random state on interrupt
      and activity").
      
      This is probably a trivial fix for the latent_entropy plugin, but for
      now, just remove net_rand_state from the list of things the plugin
      worries about.
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Cc: Emese Revfy <re.emese@gmail.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Willy Tarreau <w@1wt.eu>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      83bdc727
    • W
      random32: update the net random state on interrupt and activity · f227e3ec
      Willy Tarreau 提交于
      This modifies the first 32 bits out of the 128 bits of a random CPU's
      net_rand_state on interrupt or CPU activity to complicate remote
      observations that could lead to guessing the network RNG's internal
      state.
      
      Note that depending on some network devices' interrupt rate moderation
      or binding, this re-seeding might happen on every packet or even almost
      never.
      
      In addition, with NOHZ some CPUs might not even get timer interrupts,
      leaving their local state rarely updated, while they are running
      networked processes making use of the random state.  For this reason, we
      also perform this update in update_process_times() in order to at least
      update the state when there is user or system activity, since it's the
      only case we care about.
      Reported-by: NAmit Klein <aksecurity@gmail.com>
      Suggested-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NWilly Tarreau <w@1wt.eu>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f227e3ec
  8. 29 7月, 2020 5 次提交
  9. 27 7月, 2020 2 次提交
  10. 25 7月, 2020 1 次提交
  11. 24 7月, 2020 2 次提交
    • J
      dyndbg: export ddebug_exec_queries · 4c0d7782
      Jim Cromie 提交于
      Export ddebug_exec_queries() for use by modules.
      
      This will allow module authors to control all their *pr_debug*s
      dynamically.  And since ddebug_exec_queries() is what implements
      "echo $query >control", it gives the same per-callsite control.
      
      Virtues of this:
      - simplicity. just an export.
      - full control over any/all subsets of callsites.
      - same "query/command-string" in code and console
      - full callsite selectivity with module file line format
      
      Format in particular deserves special attention; it is where
      low-hanging fruit will be found.
      
      Consider: drivers/gpu/drm/amd/display/include/logger_types.h:
      
        #define DC_LOG_SURFACE(...)          pr_debug("[SURFACE]:"__VA_ARGS__)
        #define DC_LOG_HW_LINK_TRAINING(...) pr_debug("[HW_LINK_TRAINING]:"__VA_ARGS__)
        .. 9 more ..
      
      Thats 11 string prefixes, used in 804 places in drivers/gpu/**
      Clearly this is a systematized classification of those callsites.
      And one I'd expect to see repeated often.
      
      Using ddebug_exec_queries(), authors can select on those prefixes
      as a unitary set, equivalent to:
      
          echo "module=MODULE_NAME format=^[SURFACE]: +p" >control
      
      Trivially, those sets can be subsected with the other query terms too,
      say file=foo, should the author see fit.
      
      Perhaps as important, users can modify the set of enabled callsites,
      presumably to aid debugging by enabling helpful debug callsites, and
      disabling those that just clutter the info.
      
      Authors could even alter [fmlt] flags, though I dont see a good reason
      why they would.  Perhaps harnessed by bug-logging automation to get
      fuller, or more minimal bug-reports.
      
      DRM
      
      drm has both drm.debug, which defines 32 categories of drm_printk
      logging, and entirely separate uses of pr_debug, which are dynamic on
      this i915 laptop, running mainline.  So I can observe and report on
      both.
      
      The i915 driver has 118 dyndbg callsites, with following
      "classifications" defined in drivers/gpu/drm/i915/gvt/**
      
      $ grep 915 /proc/dynamic_debug/control | cut -d= -f2 | cut -d: -f1,2 | sort -u
      _ "gvt: cmd
      _ "gvt: core
      _ "gvt: dpy
      _ "gvt: el
      _ "gvt: irq
      _ "gvt: mm
      _ "gvt: mmio
      _ "gvt: render
      _ "gvt: sched
      _ "%s for root hub!\012"
      _ "Vendor defined info completion code %u\012"
      
      This classification is entirely out-of-band for control by drm.debug,
      and is only available to root user at the console.  But module authors
      can activate them with ddebug_exec_queries(sprintf("format=^%s +p")),
      and then decide how to expose the groups to the user for max utility.
      
      drm.debug
      
      drm.debug has 32 bit-flags, and matching enum drm_debug_category
      values to classify the ~2943 DRM_DEBUG*() callsites in drivers/gpu
      
      The drm.debug callback could invoke ddebug_exec_queries() with 32
      different hardcoded query strings, needing only (bit) ? " +p" : " -p"
      added.
      
      I briefly enabled drm.debug=0xff on my i915 laptop, which yielded
      these unique prefixes: (dmesg | cut -c17- | cut -d\] -f1 | sort -u)
      
      [drm:drm_atomic_check_only [drm
      [drm:drm_atomic_get_crtc_state [drm
      [drm:drm_atomic_get_plane_state [drm
      [drm:drm_atomic_nonblocking_commit [drm
      [drm:drm_atomic_set_fb_for_plane [drm
      [drm:drm_atomic_state_default_clear [drm
      [drm:__drm_atomic_state_free [drm
      [drm:drm_atomic_state_init [drm
      [drm:drm_crtc_vblank_helper_get_vblank_timestamp_internal [drm
      [drm:drm_handle_vblank [drm
      [drm:drm_ioctl [drm
      [drm:drm_mode_addfb2 [drm
      [drm:drm_mode_object_get [drm
      [drm:drm_mode_object_put.part.0 [drm
      [drm:drm_update_vblank_count [drm
      [drm:drm_vblank_enable [drm
      [drm:drm_vblank_restore [drm
      [drm:vblank_disable_fn [drm
      i915 0000:00:02.0: [drm:gen9_set_dc_state [i915
      i915 0000:00:02.0: [drm:intel_atomic_get_global_obj_state [i915
      i915 0000:00:02.0: [drm:__intel_display_power_get_domain.part.0 [i915
      i915 0000:00:02.0: [drm:__intel_display_power_put_domain [i915
      i915 0000:00:02.0: [drm:intel_plane_atomic_calc_changes [i915
      i915 0000:00:02.0: [drm:skl_enable_dc6 [i915
      
      Several good format=^prefixes are apparent there, and some misses.
      
       ^[drm:drm_atomic_	# misses: [drm:__drm_atomic_state_free [drm
       ^[drm:drm_ioctl
       ^[drm:drm_mode
       ^[drm:drm_vblank_	# misses: [drm:drm_update_vblank_count & [drm:vblank_disable_fn
      
      Its not a perfect 1:1 single format-match per class, but the misses
      above can be covered with 1 & 2 additional queries, which can be
      concatenated together with ";" separators and submitted with 1 call.
      
      Benefits:
      
      For drm, adapting DRM_DEBUG to use dynamic-debug inside could
      replicate (and thereby obsolete) lots of bit-checking in current
      DRM_DEBUG callsites, at least with JUMP_LABEL optimized code.
      ddebug_exec_queries() and a handful of fixed query-strings can select
      and thereby control the already classified callsites.
      
      With the classes mapped to queries, the enum type and parameter can be
      eliminated (folded away with macro magic), at least for DYNAMIC_DEBUG
      & JUMP_LABEL builds.
      
      Is it safe ?
      
      ddebug_exec_queries() is currently exposed to user space in
      several limited ways;
      
      1 it is called from module-load callback, where it implements the
        $modname.dyndbg=+p "fake" parameter provided to all modules.
      
      2 it handles query input via >control directly
      
      IOW, it is "fully" exposed to local root user; exposing the same
      functionality to other kernel modules is no additional risk.
      
      The other standard issue to check is locking:
      
      dyndbg has a single mutex, taken by ddebug_change to handle >control,
      and by ddebug_proc_(start|stop) to span `cat control`.  Queries
      submitted via export will typically have module specified, which
      dramatically cuts the scan by ddebug_change vs "module=* +p".
      ISTM this proposed export presents no locking problems.
      
      TLDR;
      
      It would be interesting to see how drm.dyndbg=$QUERY and
      drm.debug=$HEXY would interact; it might be order dependent, as
      if given as modprobe args or in /etc/modprobe.d/
      
      Acked-by: <jbaron@akamai.com>
      Signed-off-by: NJim Cromie <jim.cromie@gmail.com>
      Link: https://lore.kernel.org/r/20200719231058.1586423-19-jim.cromie@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4c0d7782
    • J
      dyndbg: shorten our logging prefix, drop __func__ · 5aa9ffbb
      Jim Cromie 提交于
      For log-message output, reduce column space consumed by current
      pr_fmt by dropping __func__ and shortening "dynamic_debug" to
      "dyndbg".  This improves readability on narrow consoles, and better
      matches other kernel boot info messages.
      
      Acked-by: <jbaron@akamai.com>
      Signed-off-by: NJim Cromie <jim.cromie@gmail.com>
      Link: https://lore.kernel.org/r/20200719231058.1586423-18-jim.cromie@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5aa9ffbb