Skip to content
Snippets Groups Projects
  1. Nov 07, 2023
  2. Sep 21, 2023
  3. Sep 06, 2023
    • Qing Zhang's avatar
      LoongArch: Add KASAN (Kernel Address Sanitizer) support · 5aa4ac64
      Qing Zhang authored
      
      1/8 of kernel addresses reserved for shadow memory. But for LoongArch,
      There are a lot of holes between different segments and valid address
      space (256T available) is insufficient to map all these segments to kasan
      shadow memory with the common formula provided by kasan core, saying
      (addr >> KASAN_SHADOW_SCALE_SHIFT) + KASAN_SHADOW_OFFSET
      
      So LoongArch has a arch-specific mapping formula, different segments are
      mapped individually, and only limited space lengths of these specific
      segments are mapped to shadow.
      
      At early boot stage the whole shadow region populated with just one
      physical page (kasan_early_shadow_page). Later, this page is reused as
      readonly zero shadow for some memory that kasan currently don't track.
      After mapping the physical memory, pages for shadow memory are allocated
      and mapped.
      
      Functions like memset()/memcpy()/memmove() do a lot of memory accesses.
      If bad pointer passed to one of these function it is important to be
      caught. Compiler's instrumentation cannot do this since these functions
      are written in assembly.
      
      KASan replaces memory functions with manually instrumented variants.
      Original functions declared as weak symbols so strong definitions in
      mm/kasan/kasan.c could replace them. Original functions have aliases
      with '__' prefix in names, so we could call non-instrumented variant
      if needed.
      
      Signed-off-by: default avatarQing Zhang <zhangqing@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      5aa4ac64
    • Feiyang Chen's avatar
      LoongArch: Allow building with kcov coverage · 2363088e
      Feiyang Chen authored
      
      Add ARCH_HAS_KCOV and HAVE_GCC_PLUGINS to the LoongArch Kconfig. And
      also disable instrumentation of vdso.
      
      Signed-off-by: default avatarFeiyang Chen <chenfeiyang@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      2363088e
    • Qing Zhang's avatar
      LoongArch: Add basic KGDB & KDB support · e14dd076
      Qing Zhang authored
      
      KGDB is intended to be used as a source level debugger for the Linux
      kernel. It is used along with gdb to debug a Linux kernel. GDB can be
      used to "break in" to the kernel to inspect memory, variables and regs
      similar to the way an application developer would use GDB to debug an
      application. KDB is a frontend of KGDB which is similar to GDB.
      
      By now, in addition to the generic KGDB features, the LoongArch KGDB
      implements the following features:
      - Hardware breakpoints/watchpoints;
      - Software single-step support for KDB.
      
      Signed-off-by: Qing Zhang <zhangqing@loongson.cn>   # Framework & CoreFeature
      Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn> # BreakPoint & SingleStep
      Signed-off-by: Hui Li <lihui@loongson.cn>           # Some Minor Improvements
      Signed-off-by: Randy Dunlap <rdunlap@infradead.org> # Some Build Error Fixes
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      e14dd076
  4. Sep 05, 2023
  5. Sep 04, 2023
  6. Sep 02, 2023
    • Stefan Roesch's avatar
      proc/ksm: add ksm stats to /proc/pid/smaps · 8b479335
      Stefan Roesch authored
      With madvise and prctl KSM can be enabled for different VMA's.  Once it is
      enabled we can query how effective KSM is overall.  However we cannot
      easily query if an individual VMA benefits from KSM.
      
      This commit adds a KSM section to the /prod/<pid>/smaps file.  It reports
      how many of the pages are KSM pages.  Note that KSM-placed zeropages are
      not included, only actual KSM pages.
      
      Here is a typical output:
      
      7f420a000000-7f421a000000 rw-p 00000000 00:00 0
      Size:             262144 kB
      KernelPageSize:        4 kB
      MMUPageSize:           4 kB
      Rss:               51212 kB
      Pss:                8276 kB
      Shared_Clean:        172 kB
      Shared_Dirty:      42996 kB
      Private_Clean:       196 kB
      Private_Dirty:      7848 kB
      Referenced:        15388 kB
      Anonymous:         51212 kB
      KSM:               41376 kB
      LazyFree:              0 kB
      AnonHugePages:         0 kB
      ShmemPmdMapped:        0 kB
      FilePmdMapped:         0 kB
      Shared_Hugetlb:        0 kB
      Private_Hugetlb:       0 kB
      Swap:             202016 kB
      SwapPss:            3882 kB
      Locked:                0 kB
      THPeligible:    0
      ProtectionKey:         0
      ksm_state:          0
      ksm_skip_base:      0
      ksm_skip_count:     0
      VmFlags: rd wr mr mw me nr mg anon
      
      This information also helps with the following workflow:
      - First enable KSM for all the VMA's of a process with prctl.
      - Then analyze with the above smaps report which VMA's benefit the most
      - Change the application (if possible) to add the corresponding madvise
      calls for the VMA's that benefit the most
      
      [shr@devkernel.io: v5]
        Link: https://lkml.kernel.org/r/20230823170107.1457915-1-shr@devkernel.io
      Link: https://lkml.kernel.org/r/20230822180539.1424843-1-shr@devkernel.io
      
      
      Signed-off-by: default avatarStefan Roesch <shr@devkernel.io>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Rik van Riel <riel@surriel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8b479335
  7. Sep 01, 2023
  8. Aug 31, 2023
  9. Aug 30, 2023
  10. Aug 29, 2023
  11. Aug 28, 2023
Loading