Merge branch 'mana-shared-6.2' of https://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / mm / mmu_gather.c
index a71924bd38c0de1b734016300a96da047d126a51..add4244e5790df28140b8ea7e41125be37b59fbb 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/gfp.h>
 #include <linux/highmem.h>
 #include <linux/kernel.h>
+#include <linux/kmsan-checks.h>
 #include <linux/mmdebug.h>
 #include <linux/mm_types.h>
 #include <linux/mm_inline.h>
@@ -265,6 +266,15 @@ void tlb_flush_mmu(struct mmu_gather *tlb)
 static void __tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
                             bool fullmm)
 {
+       /*
+        * struct mmu_gather contains 7 1-bit fields packed into a 32-bit
+        * unsigned int value. The remaining 25 bits remain uninitialized
+        * and are never used, but KMSAN updates the origin for them in
+        * zap_pXX_range() in mm/memory.c, thus creating very long origin
+        * chains. This is technically correct, but consumes too much memory.
+        * Unpoisoning the whole structure will prevent creating such chains.
+        */
+       kmsan_unpoison_memory(tlb, sizeof(*tlb));
        tlb->mm = mm;
        tlb->fullmm = fullmm;