ARMv8-a架构Raspbian编译PTEditor模块遇kmap_atomic隐式声明错误求助
kmap_atomic Implicit Declaration Error on ARMv8-a (Raspbian Buster) This error pops up because kmap_atomic isn't required (and isn't exposed) on ARM64/ARMv8-a architectures. Unlike x86, ARM64's memory model keeps kernel page table pages permanently mapped in the virtual address space—so you don't need a temporary atomic mapping to access them.
Here's how to fix the issue while keeping cross-architecture compatibility:
Update the
__pte_mapmacro
Replace your existing macro with a conditional version that handles both x86 and ARM64:#ifdef CONFIG_ARM64 #define __pte_map(pmd) ((pte_t *)pmd_page_vaddr(*(pmd))) #else #define __pte_map(pmd) (pte_t *)kmap_atomic(pmd_page(*(pmd))) #endifpmd_page_vaddr()directly returns the virtual address of the page referenced by the PMD entry, which works natively on ARM64 without needingkmap_atomic.Clean up the unmap macro (if used)
If your code includes a__pte_unmapmacro to pair withkmap_atomic, add a conditional for ARM64 too (since no unmap operation is needed here):#ifdef CONFIG_ARM64 #define __pte_unmap(pte) do { } while (0) #else #define __pte_unmap(pte) kunmap_atomic(pte) #endifDouble-check your build configuration
Ensure your Makefile targets ARM64 correctly. If cross-compiling, set these variables:ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-If building directly on the Raspberry Pi running Raspbian Buster, just make sure
ARCH=arm64is set in your build command or Makefile.
This change will keep your module working on x86 while resolving the ARMv8-a compilation error.
内容的提问来源于stack exchange,提问作者alireza sadeghpour

