Commit eaee5487 authored by Samuel Holland's avatar Samuel Holland Committed by Palmer Dabbelt

riscv: Use offset_in_page() in text patching functions

This is a bit easier to parse than the equivalent bit manipulation.
Reviewed-by: default avatarBjörn Töpel <bjorn@rivosinc.com>
Signed-off-by: default avatarSamuel Holland <samuel.holland@sifive.com>
Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20240327160520.791322-7-samuel.holland@sifive.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent 51781ce8
...@@ -54,7 +54,7 @@ static __always_inline void *patch_map(void *addr, const unsigned int fixmap) ...@@ -54,7 +54,7 @@ static __always_inline void *patch_map(void *addr, const unsigned int fixmap)
BUG_ON(!page); BUG_ON(!page);
return (void *)set_fixmap_offset(fixmap, page_to_phys(page) + return (void *)set_fixmap_offset(fixmap, page_to_phys(page) +
(uintaddr & ~PAGE_MASK)); offset_in_page(addr));
} }
static void patch_unmap(int fixmap) static void patch_unmap(int fixmap)
...@@ -65,8 +65,8 @@ NOKPROBE_SYMBOL(patch_unmap); ...@@ -65,8 +65,8 @@ NOKPROBE_SYMBOL(patch_unmap);
static int __patch_insn_set(void *addr, u8 c, size_t len) static int __patch_insn_set(void *addr, u8 c, size_t len)
{ {
bool across_pages = (offset_in_page(addr) + len) > PAGE_SIZE;
void *waddr = addr; void *waddr = addr;
bool across_pages = (((uintptr_t)addr & ~PAGE_MASK) + len) > PAGE_SIZE;
/* /*
* Only two pages can be mapped at a time for writing. * Only two pages can be mapped at a time for writing.
...@@ -102,8 +102,8 @@ NOKPROBE_SYMBOL(__patch_insn_set); ...@@ -102,8 +102,8 @@ NOKPROBE_SYMBOL(__patch_insn_set);
static int __patch_insn_write(void *addr, const void *insn, size_t len) static int __patch_insn_write(void *addr, const void *insn, size_t len)
{ {
bool across_pages = (offset_in_page(addr) + len) > PAGE_SIZE;
void *waddr = addr; void *waddr = addr;
bool across_pages = (((uintptr_t) addr & ~PAGE_MASK) + len) > PAGE_SIZE;
int ret; int ret;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment