git: e6cdeb9d9187 - releng/14.1 - linuxkpi: Fix set_memory_*
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 12 May 2024 15:58:01 UTC
The branch releng/14.1 has been updated by tijl: URL: https://cgit.FreeBSD.org/src/commit/?id=e6cdeb9d91875773a64ef61b5a9dcfb0ded90799 commit e6cdeb9d91875773a64ef61b5a9dcfb0ded90799 Author: Tijl Coosemans <tijl@FreeBSD.org> AuthorDate: 2024-05-03 13:27:29 +0000 Commit: Tijl Coosemans <tijl@FreeBSD.org> CommitDate: 2024-05-12 15:55:14 +0000 linuxkpi: Fix set_memory_* set_memory_* is currently implemented using PHYS_TO_DMAP but not all architectures have a DMAP. Looking at how this function is used the given address isn't physical but virtual so the PHYS_TO_DMAP call can simply be removed. Also cast numpages before shifting it to avoid overflow. Reviewed by: kib, markj Approved by: re (cperciva) Differential Revision: https://reviews.freebsd.org/D45057 (cherry picked from commit 7206f7c619912bdd4d54dd539824733eae50c3a9) (cherry picked from commit 147ea7d4092f4b08411724bd501283a281ffa34e) --- sys/compat/linuxkpi/common/include/asm/set_memory.h | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/asm/set_memory.h b/sys/compat/linuxkpi/common/include/asm/set_memory.h index 69f659001c60..1019aaf264a0 100644 --- a/sys/compat/linuxkpi/common/include/asm/set_memory.h +++ b/sys/compat/linuxkpi/common/include/asm/set_memory.h @@ -34,26 +34,20 @@ static inline int set_memory_uc(unsigned long addr, int numpages) { - vm_offset_t va; vm_size_t len; - va = PHYS_TO_DMAP(addr); - len = numpages << PAGE_SHIFT; - - return (-pmap_change_attr(va, len, VM_MEMATTR_UNCACHEABLE)); + len = (vm_size_t)numpages << PAGE_SHIFT; + return (-pmap_change_attr(addr, len, VM_MEMATTR_UNCACHEABLE)); } static inline int set_memory_wc(unsigned long addr, int numpages) { #ifdef VM_MEMATTR_WRITE_COMBINING - vm_offset_t va; vm_size_t len; - va = PHYS_TO_DMAP(addr); - len = numpages << PAGE_SHIFT; - - return (-pmap_change_attr(va, len, VM_MEMATTR_WRITE_COMBINING)); + len = (vm_size_t)numpages << PAGE_SHIFT; + return (-pmap_change_attr(addr, len, VM_MEMATTR_WRITE_COMBINING)); #else return (set_memory_uc(addr, numpages)); #endif @@ -62,13 +56,10 @@ set_memory_wc(unsigned long addr, int numpages) static inline int set_memory_wb(unsigned long addr, int numpages) { - vm_offset_t va; vm_size_t len; - va = PHYS_TO_DMAP(addr); - len = numpages << PAGE_SHIFT; - - return (-pmap_change_attr(va, len, VM_MEMATTR_WRITE_BACK)); + len = (vm_size_t)numpages << PAGE_SHIFT; + return (-pmap_change_attr(addr, len, VM_MEMATTR_WRITE_BACK)); } static inline int