Skip to content
Snippets Groups Projects
  1. Jun 24, 2023
  2. Jun 19, 2023
    • Petr Mladek's avatar
      watchdog/hardlockup: define HARDLOCKUP_DETECTOR_ARCH · 7ca8fe94
      Petr Mladek authored
      The HAVE_ prefix means that the code could be enabled. Add another
      variable for HAVE_HARDLOCKUP_DETECTOR_ARCH without this prefix.
      It will be set when it should be built. It will make it compatible
      with the other hardlockup detectors.
      
      The change allows to clean up dependencies of PPC_WATCHDOG
      and HAVE_HARDLOCKUP_DETECTOR_PERF definitions for powerpc.
      
      As a result HAVE_HARDLOCKUP_DETECTOR_PERF has the same dependencies
      on arm, x86, powerpc architectures.
      
      Link: https://lkml.kernel.org/r/20230616150618.6073-7-pmladek@suse.com
      
      
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      7ca8fe94
    • Petr Mladek's avatar
      watchdog/sparc64: define HARDLOCKUP_DETECTOR_SPARC64 · 47f4cb43
      Petr Mladek authored
      The HAVE_ prefix means that the code could be enabled. Add another
      variable for HAVE_HARDLOCKUP_DETECTOR_SPARC64 without this prefix.
      It will be set when it should be built. It will make it compatible
      with the other hardlockup detectors.
      
      Before, it is far from obvious that the SPARC64 variant is actually used:
      
      $> make ARCH=sparc64 defconfig
      $> grep HARDLOCKUP_DETECTOR .config
      CONFIG_HAVE_HARDLOCKUP_DETECTOR_BUDDY=y
      CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64=y
      
      After, it is more clear:
      
      $> make ARCH=sparc64 defconfig
      $> grep HARDLOCKUP_DETECTOR .config
      CONFIG_HAVE_HARDLOCKUP_DETECTOR_BUDDY=y
      CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64=y
      CONFIG_HARDLOCKUP_DETECTOR_SPARC64=y
      
      Link: https://lkml.kernel.org/r/20230616150618.6073-6-pmladek@suse.com
      
      
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      47f4cb43
    • Petr Mladek's avatar
      watchdog/hardlockup: make HAVE_NMI_WATCHDOG sparc64-specific · a5fcc236
      Petr Mladek authored
      There are several hardlockup detector implementations and several Kconfig
      values which allow selection and build of the preferred one.
      
      CONFIG_HARDLOCKUP_DETECTOR was introduced by the commit 23637d47
      ("lockup_detector: Introduce CONFIG_HARDLOCKUP_DETECTOR") in v2.6.36.
      It was a preparation step for introducing the new generic perf hardlockup
      detector.
      
      The existing arch-specific variants did not support the to-be-created
      generic build configurations, sysctl interface, etc. This distinction
      was made explicit by the commit 4a7863cc ("x86, nmi_watchdog:
      Remove ARCH_HAS_NMI_WATCHDOG and rely on CONFIG_HARDLOCKUP_DETECTOR")
      in v2.6.38.
      
      CONFIG_HAVE_NMI_WATCHDOG was introduced by the commit d314d74c
      ("nmi watchdog: do not use cpp symbol in Kconfig") in v3.4-rc1. It replaced
      the above mentioned ARCH_HAS_NMI_WATCHDOG. At that time, it was still used
      by three architectures, namely blackfin, mn10300, and sparc.
      
      The support for blackfin and mn10300 architectures has been completely
      dropped some time ago. And sparc is the only architecture with the historic
      NMI watchdog at the moment.
      
      And the old sparc implementation is really special. It is always built on
      sparc64. It used to be always enabled until the commit 7a5c8b57
      ("sparc: implement watchdog_nmi_enable and watchdog_nmi_disable") added
      in v4.10-rc1.
      
      There are only few locations where the sparc64 NMI watchdog interacts
      with the generic hardlockup detectors code:
      
        + implements arch_touch_nmi_watchdog() which is called from the generic
          touch_nmi_watchdog()
      
        + implements watchdog_hardlockup_enable()/disable() to support
          /proc/sys/kernel/nmi_watchdog
      
        + is always preferred over other generic watchdogs, see
          CONFIG_HARDLOCKUP_DETECTOR
      
        + includes asm/nmi.h into linux/nmi.h because some sparc-specific
          functions are needed in sparc-specific code which includes
          only linux/nmi.h.
      
      The situation became more complicated after the commit 05a4a952
      ("kernel/watchdog: split up config options") and commit 2104180a
      ("powerpc/64s: implement arch-specific hardlockup watchdog") in v4.13-rc1.
      They introduced HAVE_HARDLOCKUP_DETECTOR_ARCH. It was used for powerpc
      specific hardlockup detector. It was compatible with the perf one
      regarding the general boot, sysctl, and programming interfaces.
      
      HAVE_HARDLOCKUP_DETECTOR_ARCH was defined as a superset of
      HAVE_NMI_WATCHDOG. It made some sense because all arch-specific
      detectors had some common requirements, namely:
      
        + implemented arch_touch_nmi_watchdog()
        + included asm/nmi.h into linux/nmi.h
        + defined the default value for /proc/sys/kernel/nmi_watchdog
      
      But it actually has made things pretty complicated when the generic
      buddy hardlockup detector was added. Before the generic perf detector
      was newer supported together with an arch-specific one. But the buddy
      detector could work on any SMP system. It means that an architecture
      could support both the arch-specific and buddy detector.
      
      As a result, there are few tricky dependencies. For example,
      CONFIG_HARDLOCKUP_DETECTOR depends on:
      
        ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH
      
      The problem is that the very special sparc implementation is defined as:
      
        HAVE_NMI_WATCHDOG && !HAVE_HARDLOCKUP_DETECTOR_ARCH
      
      Another problem is that the meaning of HAVE_NMI_WATCHDOG is far from clear
      without reading understanding the history.
      
      Make the logic less tricky and more self-explanatory by making
      HAVE_NMI_WATCHDOG specific for the sparc64 implementation. And rename it to
      HAVE_HARDLOCKUP_DETECTOR_SPARC64.
      
      Note that HARDLOCKUP_DETECTOR_PREFER_BUDDY, HARDLOCKUP_DETECTOR_PERF,
      and HARDLOCKUP_DETECTOR_BUDDY may conflict only with
      HAVE_HARDLOCKUP_DETECTOR_ARCH. They depend on HARDLOCKUP_DETECTOR
      and it is not longer enabled when HAVE_NMI_WATCHDOG is set.
      
      Link: https://lkml.kernel.org/r/20230616150618.6073-5-pmladek@suse.com
      
      
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      a5fcc236
    • Petr Mladek's avatar
      watchdog/hardlockup: make the config checks more straightforward · 1356d0b9
      Petr Mladek authored
      There are four possible variants of hardlockup detectors:
      
        + buddy: available when SMP is set.
      
        + perf: available when HAVE_HARDLOCKUP_DETECTOR_PERF is set.
      
        + arch-specific: available when HAVE_HARDLOCKUP_DETECTOR_ARCH is set.
      
        + sparc64 special variant: available when HAVE_NMI_WATCHDOG is set
      	and HAVE_HARDLOCKUP_DETECTOR_ARCH is not set.
      
      The check for the sparc64 variant is more complicated because
      HAVE_NMI_WATCHDOG is used to #ifdef code used by both arch-specific
      and sparc64 specific variant. Therefore it is automatically
      selected with HAVE_HARDLOCKUP_DETECTOR_ARCH.
      
      This complexity is partly hidden in HAVE_HARDLOCKUP_DETECTOR_NON_ARCH.
      It reduces the size of some checks but it makes them harder to follow.
      
      Finally, the other temporary variable HARDLOCKUP_DETECTOR_NON_ARCH
      is used to re-compute HARDLOCKUP_DETECTOR_PERF/BUDDY when the global
      HARDLOCKUP_DETECTOR switch is enabled/disabled.
      
      Make the logic more straightforward by the following changes:
      
        + Better explain the role of HAVE_HARDLOCKUP_DETECTOR_ARCH and
          HAVE_NMI_WATCHDOG in comments.
      
        + Add HAVE_HARDLOCKUP_DETECTOR_BUDDY so that there is separate
          HAVE_* for all four hardlockup detector variants.
      
          Use it in the other conditions instead of SMP. It makes it
          clear that it is about the buddy detector.
      
        + Open code HAVE_HARDLOCKUP_DETECTOR_NON_ARCH in HARDLOCKUP_DETECTOR
          and HARDLOCKUP_DETECTOR_PREFER_BUDDY. It helps to understand
          the conditions between the four hardlockup detector variants.
      
        + Define the exact conditions when HARDLOCKUP_DETECTOR_PERF/BUDDY
          can be enabled. It explains the dependency on the other
          hardlockup detector variants.
      
          Also it allows to remove HARDLOCKUP_DETECTOR_NON_ARCH by using "imply".
          It triggers re-evaluating HARDLOCKUP_DETECTOR_PERF/BUDDY when
          the global HARDLOCKUP_DETECTOR switch is changed.
      
        + Add dependency on HARDLOCKUP_DETECTOR so that the affected variables
          disappear when the hardlockup detectors are disabled.
      
          Another nice side effect is that HARDLOCKUP_DETECTOR_PREFER_BUDDY
          value is not preserved when the global switch is disabled.
          The user has to make the decision again when it gets re-enabled.
      
      Link: https://lkml.kernel.org/r/20230616150618.6073-3-pmladek@suse.com
      
      
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      1356d0b9
    • Petr Mladek's avatar
      watchdog/hardlockup: sort hardlockup detector related config values a logical way · 4917a25f
      Petr Mladek authored
      Patch series "watchdog/hardlockup: Cleanup configuration of hardlockup
      detectors", v2.
      
      Clean up watchdog Kconfig after introducing the buddy detector.
      
      
      This patch (of 6):
      
      There are four possible variants of hardlockup detectors:
      
        + buddy: available when SMP is set.
      
        + perf: available when HAVE_HARDLOCKUP_DETECTOR_PERF is set.
      
        + arch-specific: available when HAVE_HARDLOCKUP_DETECTOR_ARCH is set.
      
        + sparc64 special variant: available when HAVE_NMI_WATCHDOG is set
      	and HAVE_HARDLOCKUP_DETECTOR_ARCH is not set.
      
      Only one hardlockup detector can be compiled in. The selection is done
      using quite complex dependencies between several CONFIG variables.
      The following patches will try to make it more straightforward.
      
      As a first step, reorder the definitions of the various CONFIG variables.
      The logical order is:
      
         1. HAVE_* variables define available variants. They are typically
            defined in the arch/ config files.
      
         2. HARDLOCKUP_DETECTOR y/n variable defines whether the hardlockup
            detector is enabled at all.
      
         3. HARDLOCKUP_DETECTOR_PREFER_BUDDY y/n variable defines whether
            the buddy detector should be preferred over the perf one.
            Note that the arch specific variants are always preferred when
            available.
      
         4. HARDLOCKUP_DETECTOR_PERF/BUDDY variables define whether the given
            detector is enabled in the end.
      
         5. HAVE_HARDLOCKUP_DETECTOR_NON_ARCH and HARDLOCKUP_DETECTOR_NON_ARCH
            are temporary variables that are going to be removed in
            a followup patch.
      
      This is a preparation step for further cleanup. It will change the logic
      without shuffling the definitions.
      
      This change temporary breaks the C-like ordering where the variables are
      declared or defined before they are used. It is not really needed for
      Kconfig. Also the following patches will rework the logic so that
      the ordering will be C-like in the end.
      
      The patch just shuffles the definitions. It should not change the existing
      behavior.
      
      Link: https://lkml.kernel.org/r/20230616150618.6073-1-pmladek@suse.com
      Link: https://lkml.kernel.org/r/20230616150618.6073-2-pmladek@suse.com
      
      
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      4917a25f
    • Douglas Anderson's avatar
      watchdog/buddy: simplify the dependency for HARDLOCKUP_DETECTOR_PREFER_BUDDY · 7ece48b7
      Douglas Anderson authored
      The dependency for HARDLOCKUP_DETECTOR_PREFER_BUDDY was more complicated
      than it needed to be.  If the "perf" detector is available and we have SMP
      then we have a choice, so enable the config based on just those two config
      items.
      
      Link: https://lkml.kernel.org/r/20230526184139.8.I49d5b483336b65b8acb1e5066548a05260caf809@changeid
      
      
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Suggested-by: default avatarPetr Mladek <pmladek@suse.com>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      7ece48b7
  3. Jun 10, 2023
    • Douglas Anderson's avatar
      watchdog/hardlockup: detect hard lockups using secondary (buddy) CPUs · 1f423c90
      Douglas Anderson authored
      Implement a hardlockup detector that doesn't doesn't need any extra
      arch-specific support code to detect lockups.  Instead of using something
      arch-specific we will use the buddy system, where each CPU watches out for
      another one.  Specifically, each CPU will use its softlockup hrtimer to
      check that the next CPU is processing hrtimer interrupts by verifying that
      a counter is increasing.
      
      NOTE: unlike the other hard lockup detectors, the buddy one can't easily
      show what's happening on the CPU that locked up just by doing a simple
      backtrace.  It relies on some other mechanism in the system to get
      information about the locked up CPUs.  This could be support for NMI
      backtraces like [1], it could be a mechanism for printing the PC of locked
      CPUs at panic time like [2] / [3], or it could be something else.  Even
      though that means we still rely on arch-specific code, this arch-specific
      code seems to often be implemented even on architectures that don't have a
      hardlockup detector.
      
      This style of hardlockup detector originated in some downstream Android
      trees and has been rebased on / carried in ChromeOS trees for quite a long
      time for use on arm and arm64 boards.  Historically on these boards we've
      leveraged mechanism [2] / [3] to get information about hung CPUs, but we
      could move to [1].
      
      Although the original motivation for the buddy system was for use on
      systems without an arch-specific hardlockup detector, it can still be
      useful to use even on systems that _do_ have an arch-specific hardlockup
      detector.  On x86, for instance, there is a 24-part patch series [4] in
      progress switching the arch-specific hard lockup detector from a scarce
      perf counter to a less-scarce hardware resource.  Potentially the buddy
      system could be a simpler alternative to free up the perf counter but
      still get hard lockup detection.
      
      Overall, pros (+) and cons (-) of the buddy system compared to an
      arch-specific hardlockup detector (which might be implemented using
      perf):
      + The buddy system is usable on systems that don't have an
        arch-specific hardlockup detector, like arm32 and arm64 (though it's
        being worked on for arm64 [5]).
      + The buddy system may free up scarce hardware resources.
      + If a CPU totally goes out to lunch (can't process NMIs) the buddy
        system could still detect the problem (though it would be unlikely
        to be able to get a stack trace).
      + The buddy system uses the same timer function to pet the hardlockup
        detector on the running CPU as it uses to detect hardlockups on
        other CPUs. Compared to other hardlockup detectors, this means it
        generates fewer interrupts and thus is likely better able to let
        CPUs stay idle longer.
      - If all CPUs are hard locked up at the same time the buddy system
        can't detect it.
      - If we don't have SMP we can't use the buddy system.
      - The buddy system needs an arch-specific mechanism (possibly NMI
        backtrace) to get info about the locked up CPU.
      
      [1] https://lore.kernel.org/r/20230419225604.21204-1-dianders@chromium.org
      [2] https://issuetracker.google.com/172213129
      [3] https://docs.kernel.org/trace/coresight/coresight-cpu-debug.html
      [4] https://lore.kernel.org/lkml/20230301234753.28582-1-ricardo.neri-calderon@linux.intel.com/
      [5] https://lore.kernel.org/linux-arm-kernel/20220903093415.15850-1-lecopzer.chen@mediatek.com/
      
      Link: https://lkml.kernel.org/r/20230519101840.v5.14.I6bf789d21d0c3d75d382e7e51a804a7a51315f2c@changeid
      
      
      Signed-off-by: default avatarColin Cross <ccross@android.com>
      Signed-off-by: default avatarMatthias Kaehlcke <mka@chromium.org>
      Signed-off-by: default avatarGuenter Roeck <groeck@chromium.org>
      Signed-off-by: default avatarTzung-Bi Shih <tzungbi@chromium.org>
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Daniel Thompson <daniel.thompson@linaro.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masayoshi Mizuma <msys.mizuma@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Pingfan Liu <kernelfans@gmail.com>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
      Cc: Ricardo Neri <ricardo.neri@intel.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Stephen Boyd <swboyd@chromium.org>
      Cc: Sumit Garg <sumit.garg@linaro.org>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      1f423c90
    • Arnd Bergmann's avatar
      decompressor: provide missing prototypes · 00444448
      Arnd Bergmann authored
      The entry points for the decompressor don't always have a prototype
      included in the .c file:
      
      lib/decompress_inflate.c:42:17: error: no previous prototype for '__gunzip' [-Werror=missing-prototypes]
      lib/decompress_unxz.c:251:17: error: no previous prototype for 'unxz' [-Werror=missing-prototypes]
      lib/decompress_unzstd.c:331:17: error: no previous prototype for 'unzstd' [-Werror=missing-prototypes]
      
      Include the correct headers for unxz and unzstd, and mark the inflate
      function above as unconditionally 'static' to avoid these warnings.
      
      Link: https://lkml.kernel.org/r/20230517131936.936840-1-arnd@kernel.org
      
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Nick Terrell <terrelln@fb.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      00444448
    • Arnd Bergmann's avatar
      kunit: include debugfs header file · 23108f6a
      Arnd Bergmann authored
      An extra #include statement is needed to ensure the prototypes for debugfs
      interfaces are visible, avoiding this warning:
      
      lib/kunit/debugfs.c:28:6: error: no previous prototype for 'kunit_debugfs_cleanup' [-Werror=missing-prototypes]
      lib/kunit/debugfs.c:33:6: error: no previous prototype for 'kunit_debugfs_init' [-Werror=missing-prototypes]
      lib/kunit/debugfs.c:102:6: error: no previous prototype for 'kunit_debugfs_create_suite' [-Werror=missing-prototypes]
      lib/kunit/debugfs.c:118:6: error: no previous prototype for 'kunit_debugfs_destroy_suite' [-Werror=missing-prototypes]
      
      Link: https://lkml.kernel.org/r/20230517131102.934196-10-arnd@kernel.org
      
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Dennis Zhou <dennis@kernel.org>
      Cc: Eric Paris <eparis@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rafael J. Wysocki <rafael@kernel.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      23108f6a
    • Arnd Bergmann's avatar
      lib: devmem_is_allowed: include linux/io.h · 6b76ca2a
      Arnd Bergmann authored
      The devmem_is_allowed() function is defined in a file of the same name,
      but the declaration is in asm/io.h, which is not included there, causing a
      W=1 warning:
      
      lib/devmem_is_allowed.c:20:5: error: no previous prototype for 'devmem_is_allowed' [-Werror=missing-prototypes]
      
      Include the appropriate header to avoid the warning.
      
      Link: https://lkml.kernel.org/r/20230517131102.934196-6-arnd@kernel.org
      
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Dennis Zhou <dennis@kernel.org>
      Cc: Eric Paris <eparis@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rafael J. Wysocki <rafael@kernel.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      6b76ca2a
    • Alexey Dobriyan's avatar
      add intptr_t · 3db55767
      Alexey Dobriyan authored
      Add signed intptr_t given that a) it is standard type and b) uintptr_t is
      in tree.
      
      Link: https://lkml.kernel.org/r/ed66b9e4-1fb7-45be-9bb9-d4bc291c691f@p183
      
      
      Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      3db55767
  4. May 22, 2023
  5. May 17, 2023
  6. May 09, 2023
  7. May 03, 2023
    • Kefeng Wang's avatar
      mm: hwpoison: coredump: support recovery from dump_user_range() · 245f0922
      Kefeng Wang authored
      dump_user_range() is used to copy the user page to a coredump file, but if
      a hardware memory error occurred during copy, which called from
      __kernel_write_iter() in dump_user_range(), it crashes,
      
        CPU: 112 PID: 7014 Comm: mca-recover Not tainted 6.3.0-rc2 #425
      
        pc : __memcpy+0x110/0x260
        lr : _copy_from_iter+0x3bc/0x4c8
        ...
        Call trace:
         __memcpy+0x110/0x260
         copy_page_from_iter+0xcc/0x130
         pipe_write+0x164/0x6d8
         __kernel_write_iter+0x9c/0x210
         dump_user_range+0xc8/0x1d8
         elf_core_dump+0x308/0x368
         do_coredump+0x2e8/0xa40
         get_signal+0x59c/0x788
         do_signal+0x118/0x1f8
         do_notify_resume+0xf0/0x280
         el0_da+0x130/0x138
         el0t_64_sync_handler+0x68/0xc0
         el0t_64_sync+0x188/0x190
      
      Generally, the '->write_iter' of file ops will use copy_page_from_iter()
      and copy_page_from_iter_atomic(), change memcpy() to copy_mc_to_kernel()
      in both of them to handle #MC during source read, which stop coredump
      processing and kill the task instead of kernel panic, but the source
      address may not always a user address, so introduce a new copy_mc flag in
      struct iov_iter{} to indicate that the iter could do a safe memory copy,
      also introduce the helpers to set/cleck the flag, for now, it's only used
      in coredump's dump_user_range(), but it could expand to any other
      scenarios to fix the similar issue.
      
      Link: https://lkml.kernel.org/r/20230417045323.11054-1-wangkefeng.wang@huawei.com
      
      
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: Tong Tiangen <tongtiangen@huawei.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      245f0922
  8. May 02, 2023
  9. Apr 26, 2023
  10. Apr 24, 2023
  11. Apr 21, 2023
  12. Apr 18, 2023
  13. Apr 17, 2023
  14. Apr 16, 2023
  15. Apr 15, 2023
    • Thomas Gleixner's avatar
      debugobject: Prevent init race with static objects · 63a75969
      Thomas Gleixner authored
      
      Statically initialized objects are usually not initialized via the init()
      function of the subsystem. They are special cased and the subsystem
      provides a function to validate whether an object which is not yet tracked
      by debugobjects is statically initialized. This means the object is started
      to be tracked on first use, e.g. activation.
      
      This works perfectly fine, unless there are two concurrent operations on
      that object. Schspa decoded the problem:
      
      T0 	          	    	    T1
      
      debug_object_assert_init(addr)
        lock_hash_bucket()
        obj = lookup_object(addr);
        if (!obj) {
        	unlock_hash_bucket();
      	- > preemption
      			            lock_subsytem_object(addr);
      				      activate_object(addr)
      				      lock_hash_bucket();
      				      obj = lookup_object(addr);
      				      if (!obj) {
      				    	unlock_hash_bucket();
      					if (is_static_object(addr))
      					   init_and_track(addr);
      				      lock_hash_bucket();
      				      obj = lookup_object(addr);
      				      obj->state = ACTIVATED;
      				      unlock_hash_bucket();
      
      				    subsys function modifies content of addr,
      				    so static object detection does
      				    not longer work.
      
      				    unlock_subsytem_object(addr);
      				    
              if (is_static_object(addr)) <- Fails
      
      	  debugobject emits a warning and invokes the fixup function which
      	  reinitializes the already active object in the worst case.
      
      This race exists forever, but was never observed until mod_timer() got a
      debug_object_assert_init() added which is outside of the timer base lock
      held section right at the beginning of the function to cover the lockless
      early exit points too.
      
      Rework the code so that the lookup, the static object check and the
      tracking object association happens atomically under the hash bucket
      lock. This prevents the issue completely as all callers are serialized on
      the hash bucket lock and therefore cannot observe inconsistent state.
      
      Fixes: 3ac7fe5a ("infrastructure to debug (dynamic) objects")
      Reported-by: default avatar <syzbot+5093ba19745994288b53@syzkaller.appspotmail.com>
      Debugged-by: default avatarSchspa Shi <schspa@gmail.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Link: https://syzkaller.appspot.com/bug?id=22c8a5938eab640d1c6bcc0e3dc7be519d878462
      Link: https://lore.kernel.org/lkml/20230303161906.831686-1-schspa@gmail.com
      Link: https://lore.kernel.org/r/87zg7dzgao.ffs@tglx
      63a75969
  16. Apr 13, 2023
  17. Apr 12, 2023
Loading