mm: kmsan: use helper macro offset_in_page()
authorZhangPeng <zhangpeng362@huawei.com>
Thu, 27 Jul 2023 01:16:11 +0000 (09:16 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 21 Aug 2023 20:37:29 +0000 (13:37 -0700)
Use helper macro offset_in_page() to improve code readability.  No
functional modification involved.

Link: https://lkml.kernel.org/r/20230727011612.2721843-3-zhangpeng362@huawei.com
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Marco Elver <elver@google.com>
Cc: Nanyong Sun <sunnanyong@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/kmsan/hooks.c
mm/kmsan/shadow.c

index 4e3c3e6..5d6e2de 100644 (file)
@@ -339,7 +339,7 @@ void kmsan_handle_dma(struct page *page, size_t offset, size_t size,
         * internal KMSAN checks.
         */
        while (size > 0) {
-               page_offset = addr % PAGE_SIZE;
+               page_offset = offset_in_page(addr);
                to_go = min(PAGE_SIZE - page_offset, (u64)size);
                kmsan_handle_dma_page((void *)addr, to_go, dir);
                addr += to_go;
index c7de991..9669942 100644 (file)
@@ -145,7 +145,7 @@ void *kmsan_get_metadata(void *address, bool is_origin)
                return NULL;
        if (!page_has_metadata(page))
                return NULL;
-       off = addr % PAGE_SIZE;
+       off = offset_in_page(addr);
 
        return (is_origin ? origin_ptr_for(page) : shadow_ptr_for(page)) + off;
 }