[PATCH] kernel: events: use offset_in_page macro
From: Xu Wang
Date: Tue May 12 2020 - 22:30:14 EST
Use offset_in_page macro instead of (addr & ~PAGE_MASK).
Signed-off-by: Xu Wang <vulab@xxxxxxxxxxx>
---
kernel/events/uprobes.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index ece7e13..1552ef1 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -250,14 +250,14 @@ bool __weak is_trap_insn(uprobe_opcode_t *insn)
static void copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len)
{
void *kaddr = kmap_atomic(page);
- memcpy(dst, kaddr + (vaddr & ~PAGE_MASK), len);
+ memcpy(dst, kaddr + offset_in_page(vaddr), len);
kunmap_atomic(kaddr);
}
static void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len)
{
void *kaddr = kmap_atomic(page);
- memcpy(kaddr + (vaddr & ~PAGE_MASK), src, len);
+ memcpy(kaddr + offset_in_page(vaddr), src, len);
kunmap_atomic(kaddr);
}
@@ -393,7 +393,7 @@ __update_ref_ctr(struct mm_struct *mm, unsigned long vaddr, short d)
}
kaddr = kmap_atomic(page);
- ptr = kaddr + (vaddr & ~PAGE_MASK);
+ ptr = kaddr + offset_in_page(vaddr);
if (unlikely(*ptr + d < 0)) {
pr_warn("ref_ctr going negative. vaddr: 0x%lx, "
--
2.7.4