git: 7206f7c61991 - main - linuxkpi: Fix set_memory_*
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 03 May 2024 13:36:05 UTC
The branch main has been updated by tijl: URL: https://cgit.FreeBSD.org/src/commit/?id=7206f7c619912bdd4d54dd539824733eae50c3a9 commit 7206f7c619912bdd4d54dd539824733eae50c3a9 Author: Tijl Coosemans <tijl@FreeBSD.org> AuthorDate: 2024-05-03 13:27:29 +0000 Commit: Tijl Coosemans <tijl@FreeBSD.org> CommitDate: 2024-05-03 13:27:29 +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 MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D45057 --- 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