1. 20 Feb, 2023 4 commits
    • Baolin Wang's avatar
      mm: change to return bool for folio_isolate_lru() · be2d5756
      Baolin Wang authored
      Patch series "Change the return value for page isolation functions", v3.
      
      Now the page isolation functions did not return a boolean to indicate
      success or not, instead it will return a negative error when failed
      to isolate a page. So below code used in most places seem a boolean
      success/failure thing, which can confuse people whether the isolation
      is successful.
      
      if (folio_isolate_lru(folio))
              continue;
      
      Moreover the page isolation functions only return 0 or -EBUSY, and
      most users did not care about the negative error except for few users,
      thus we can convert all page isolation functions to return a boolean
      value, which can remove the confusion to make code more clear.
      
      No functional changes intended in this patch series.
      
      
      This patch (of 4):
      
      Now the folio_isolate_lru() did not return a boolean value to indicate
      isolation success or not, however below code checking the return value can
      make people think that it was a boolean success/failure thing, which makes
      people easy to make mistakes (see the fix patch[1]).
      
      if (folio_isolate_lru(folio))
      	continue;
      
      Thus it's better to check the negative error value expilictly returned by
      folio_isolate_lru(), which makes code more clear per Linus's
      suggestion[2].  Moreover Matthew suggested we can convert the isolation
      functions to return a boolean[3], since most users did not care about the
      negative error value, and can also remove the confusing of checking return
      value.
      
      So this patch converts the folio_isolate_lru() to return a boolean value,
      which means return 'true' to indicate the folio isolation is successful,
      and 'false' means a failure to isolation.  Meanwhile changing all users'
      logic of checking the isolation state.
      
      No functional changes intended.
      
      [1] https://lore.kernel.org/all/20230131063206.28820-1-Kuan-Ying.Lee@mediatek.com/T/#u
      [2] https://lore.kernel.org/all/CAHk-=wiBrY+O-4=2mrbVyxR+hOqfdJ=Do6xoucfJ9_5az01L4Q@mail.gmail.com/
      [3] https://lore.kernel.org/all/Y+sTFqwMNAjDvxw3@casper.infradead.org/
      
      Link: https://lkml.kernel.org/r/cover.1676424378.git.baolin.wang@linux.alibaba.com
      Link: https://lkml.kernel.org/r/8a4e3679ed4196168efadf7ea36c038f2f7d5aa9.1676424378.git.baolin.wang@linux.alibaba.comSigned-off-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
      Reviewed-by: default avatarSeongJae Park <sj@kernel.org>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Muchun Song <muchun.song@linux.dev>
      Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: Roman Gushchin <roman.gushchin@linux.dev>
      Cc: Shakeel Butt <shakeelb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      be2d5756
    • Arnd Bergmann's avatar
      objtool: add UACCESS exceptions for __tsan_volatile_read/write · d5d46924
      Arnd Bergmann authored
      A lot of the tsan helpers are already excempt from the UACCESS warnings,
      but some more functions were added that need the same thing:
      
      kernel/kcsan/core.o: warning: objtool: __tsan_volatile_read16+0x0: call to __tsan_unaligned_read16() with UACCESS enabled
      kernel/kcsan/core.o: warning: objtool: __tsan_volatile_write16+0x0: call to __tsan_unaligned_write16() with UACCESS enabled
      vmlinux.o: warning: objtool: __tsan_unaligned_volatile_read16+0x4: call to __tsan_unaligned_read16() with UACCESS enabled
      vmlinux.o: warning: objtool: __tsan_unaligned_volatile_write16+0x4: call to __tsan_unaligned_write16() with UACCESS enabled
      
      As Marco points out, these functions don't even call each other
      explicitly but instead gcc (but not clang) notices the functions
      being identical and turns one symbol into a direct branch to the
      other.
      
      Link: https://lkml.kernel.org/r/20230215130058.3836177-4-arnd@kernel.org
      Fixes: 75d75b7a ("kcsan: Support distinguishing volatile accesses")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarMarco Elver <elver@google.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      d5d46924
    • Arnd Bergmann's avatar
      kmsan: disable ftrace in kmsan core code · e75a6988
      Arnd Bergmann authored
      objtool warns about some suspicous code inside of kmsan:
      
      vmlinux.o: warning: objtool: __msan_metadata_ptr_for_load_n+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_metadata_ptr_for_store_n+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_metadata_ptr_for_load_1+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_metadata_ptr_for_store_1+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_metadata_ptr_for_load_2+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_metadata_ptr_for_store_2+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_metadata_ptr_for_load_4+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_metadata_ptr_for_store_4+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_metadata_ptr_for_load_8+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_metadata_ptr_for_store_8+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_instrument_asm_store+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_chain_origin+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_poison_alloca+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_warning+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: __msan_get_context_state+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: kmsan_copy_to_user+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: kmsan_unpoison_memory+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: kmsan_unpoison_entry_regs+0x4: call to __fentry__() with UACCESS enabled
      vmlinux.o: warning: objtool: kmsan_report+0x4: call to __fentry__() with UACCESS enabled
      
      The Makefile contained a line to turn off ftrace for the entire directory,
      but this does not work. Replace it with individual lines, matching the
      approach in kasan.
      
      Link: https://lkml.kernel.org/r/20230215130058.3836177-3-arnd@kernel.orgSigned-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Fixes: f80be457 ("kmsan: add KMSAN runtime core")
      Acked-by: default avatarAlexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      e75a6988
    • Arnd Bergmann's avatar
      kasan: mark addr_has_metadata __always_inline · 9701c9ff
      Arnd Bergmann authored
      Patch series "objtool warning fixes", v2.
      
      These are three of the easier fixes for objtool warnings around
      kasan/kmsan/kcsan.  I dropped one patch since Peter had come up with a
      better fix, and adjusted the changelog text based on feedback.
      
      
      This patch (of 3):
      
      When the compiler decides not to inline this function, objtool complains
      about incorrect UACCESS state:
      
      mm/kasan/generic.o: warning: objtool: __asan_load2+0x11: call to addr_has_metadata() with UACCESS enabled
      
      Link: https://lore.kernel.org/all/20230208164011.2287122-1-arnd@kernel.org/
      Link: https://lkml.kernel.org/r/20230215130058.3836177-2-arnd@kernel.orgSigned-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarMarco Elver <elver@google.com>
      Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      9701c9ff
  2. 17 Feb, 2023 34 commits
  3. 13 Feb, 2023 2 commits