I'm writing a x86_64 kernel module targeting Linux v3-v4 which uses set_memory_rw()
on an address of a kernel symbol. While the call works I'm getting a warning without any explanation:
[ 596.183643] ------------[ cut here ]------------
[ 596.183667] WARNING: at arch/x86/mm/pageattr.c:962 change_page_attr_set_clr+0x2ca/0x450()
Previously I was using a different method which called virt_to_page()
and then set_pages_rw()
. However as the kernel source states this is a deprecated API and it recommends using set_memory_rw()
instead
These APIs should be considered deprecated and are likely going to be removed in the future. [...] Specifically, many users of the old APIs had a virtual address, called virt_to_page() or vmalloc_to_page() on that address to get a struct page* that the old API required. To convert these cases, use set_memory_*() on the original virtual address, do not use these functions.
Can anyone explain what is the problem here?
I think I'm tripping this check, which suggests I can just add *addr &= PAGE_MASK;
but I don't want to do it blindly.