Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146516824
D55560.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D55560.id.diff
View Options
diff --git a/sys/net/vnet.c b/sys/net/vnet.c
--- a/sys/net/vnet.c
+++ b/sys/net/vnet.c
@@ -171,11 +171,17 @@
#define VNET_MODMIN (8 * PAGE_SIZE)
#define VNET_SIZE roundup2(VNET_BYTES, PAGE_SIZE)
+/*
+ * Ensure space allocated by vnet_data_alloc() is suitably aligned for any
+ * object.
+ */
+#define VNET_DATAALIGN _Alignof(__max_align_t)
+
/*
* Space to store virtualized global variables from loadable kernel modules,
* and the free list to manage it.
*/
-VNET_DEFINE_STATIC(char, modspace[VNET_MODMIN] __aligned(__alignof(void *)));
+VNET_DEFINE_STATIC(char, modspace[VNET_MODMIN] __aligned(VNET_DATAALIGN));
/*
* A copy of the initial values of all virtualized global variables.
@@ -385,7 +391,7 @@
void *s;
s = NULL;
- size = roundup2(size, sizeof(void *));
+ size = roundup2(size, VNET_DATAALIGN);
sx_xlock(&vnet_data_free_lock);
TAILQ_FOREACH(df, &vnet_data_free_head, vnd_link) {
if (df->vnd_len < size)
@@ -403,6 +409,8 @@
}
sx_xunlock(&vnet_data_free_lock);
+ KASSERT(((uintptr_t)s & (VNET_DATAALIGN - 1)) == 0,
+ ("unaligned vnet alloc %p", s));
return (s);
}
@@ -417,7 +425,7 @@
uintptr_t start;
uintptr_t end;
- size = roundup2(size, sizeof(void *));
+ size = roundup2(size, VNET_DATAALIGN);
start = (uintptr_t)start_arg;
end = start + size;
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 4, 7:46 AM (14 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29111768
Default Alt Text
D55560.id.diff (1 KB)
Attached To
Mode
D55560: vnet: Ensure space allocated by vnet_data_alloc() is properly aligned
Attached
Detach File
Event Timeline
Log In to Comment