Skip to content

Commit eaee548

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
riscv: Use offset_in_page() in text patching functions
This is a bit easier to parse than the equivalent bit manipulation. Reviewed-by: Björn Töpel <[email protected]> Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 51781ce commit eaee548

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/riscv/kernel/patch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static __always_inline void *patch_map(void *addr, const unsigned int fixmap)
5454
BUG_ON(!page);
5555

5656
return (void *)set_fixmap_offset(fixmap, page_to_phys(page) +
57-
(uintaddr & ~PAGE_MASK));
57+
offset_in_page(addr));
5858
}
5959

6060
static void patch_unmap(int fixmap)
@@ -65,8 +65,8 @@ NOKPROBE_SYMBOL(patch_unmap);
6565

6666
static int __patch_insn_set(void *addr, u8 c, size_t len)
6767
{
68+
bool across_pages = (offset_in_page(addr) + len) > PAGE_SIZE;
6869
void *waddr = addr;
69-
bool across_pages = (((uintptr_t)addr & ~PAGE_MASK) + len) > PAGE_SIZE;
7070

7171
/*
7272
* Only two pages can be mapped at a time for writing.
@@ -102,8 +102,8 @@ NOKPROBE_SYMBOL(__patch_insn_set);
102102

103103
static int __patch_insn_write(void *addr, const void *insn, size_t len)
104104
{
105+
bool across_pages = (offset_in_page(addr) + len) > PAGE_SIZE;
105106
void *waddr = addr;
106-
bool across_pages = (((uintptr_t) addr & ~PAGE_MASK) + len) > PAGE_SIZE;
107107
int ret;
108108

109109
/*

0 commit comments

Comments
 (0)