Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151184429
D46657.id143296.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D46657.id143296.diff
View Options
diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h
--- a/sys/compat/linuxkpi/common/include/linux/slab.h
+++ b/sys/compat/linuxkpi/common/include/linux/slab.h
@@ -41,6 +41,8 @@
MALLOC_DECLARE(M_KMALLOC);
+void *lkpi_mallocarray(size_t, size_t, gfp_t);
+
#define kmalloc(size, flags) lkpi_kmalloc(size, flags)
#define kvmalloc(size, flags) kmalloc(size, flags)
#define kvzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO)
@@ -121,7 +123,7 @@
kcalloc(size_t n, size_t size, gfp_t flags)
{
flags |= __GFP_ZERO;
- return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags)));
+ return (lkpi_mallocarray(n, size, linux_check_m_flags(flags)));
}
static inline void *
@@ -154,7 +156,7 @@
static inline void *
kmalloc_array(size_t n, size_t size, gfp_t flags)
{
- return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags)));
+ return (lkpi_mallocarray(n, size, linux_check_m_flags(flags)));
}
static inline void *
@@ -167,7 +169,7 @@
static inline void *
kvmalloc_array(size_t n, size_t size, gfp_t flags)
{
- return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags)));
+ return (lkpi_mallocarray(n, size, linux_check_m_flags(flags)));
}
static inline void *
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -2710,8 +2710,8 @@
boot_cpu_data.x86_model = CPUID_TO_MODEL(cpu_id);
boot_cpu_data.x86_vendor = x86_vendor;
- __cpu_data = mallocarray(mp_maxid + 1,
- sizeof(*__cpu_data), M_KMALLOC, M_WAITOK | M_ZERO);
+ __cpu_data = lkpi_mallocarray(mp_maxid + 1,
+ sizeof(*__cpu_data), M_WAITOK | M_ZERO);
CPU_FOREACH(i) {
__cpu_data[i].x86_clflush_size = cpu_clflush_line_size;
__cpu_data[i].x86_max_cores = mp_ncpus;
@@ -2753,8 +2753,8 @@
* This is used by cpumask_of() (and possibly others in the future) for,
* e.g., drivers to pass hints to irq_set_affinity_hint().
*/
- static_single_cpu_mask = mallocarray(mp_maxid + 1,
- sizeof(static_single_cpu_mask), M_KMALLOC, M_WAITOK | M_ZERO);
+ static_single_cpu_mask = lkpi_mallocarray(mp_maxid + 1,
+ sizeof(static_single_cpu_mask), M_WAITOK | M_ZERO);
/*
* When the number of CPUs reach a threshold, we start to save memory
@@ -2773,9 +2773,9 @@
* (_BITSET_BITS / 8)' bytes (for comparison with the
* overlapping scheme).
*/
- static_single_cpu_mask_lcs = mallocarray(mp_ncpus,
+ static_single_cpu_mask_lcs = lkpi_mallocarray(mp_ncpus,
sizeof(*static_single_cpu_mask_lcs),
- M_KMALLOC, M_WAITOK | M_ZERO);
+ M_WAITOK | M_ZERO);
sscm_ptr = static_single_cpu_mask_lcs;
CPU_FOREACH(i) {
diff --git a/sys/compat/linuxkpi/common/src/linux_slab.c b/sys/compat/linuxkpi/common/src/linux_slab.c
--- a/sys/compat/linuxkpi/common/src/linux_slab.c
+++ b/sys/compat/linuxkpi/common/src/linux_slab.c
@@ -260,3 +260,12 @@
llist_add(addr, &linux_kfree_async_list);
taskqueue_enqueue(linux_irq_work_tq, &linux_kfree_async_task);
}
+
+void *
+lkpi_mallocarray(size_t n, size_t size, gfp_t flags)
+{
+ if (WOULD_OVERFLOW(n, size))
+ panic("%s: %zu * %zu overflowed", __func__, n, size);
+
+ return (__kmalloc(size * n, flags));
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 7, 4:18 PM (9 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31041559
Default Alt Text
D46657.id143296.diff (3 KB)
Attached To
Mode
D46657: LinuxKPI: switch mallocarray to an lpi implementation using __kmalloc()
Attached
Detach File
Event Timeline
Log In to Comment