From 0097858dc7073d3103c6e8b088c58fd8436ddcee Mon Sep 17 00:00:00 2001 From: Ryan Neph Date: Wed, 11 Aug 2021 17:39:58 -0700 Subject: [PATCH] vkr: enforce ring control vars are 32-bit aligned Signed-off-by: Ryan Neph Reviewed-by: Chia-I Wu --- src/venus/vkr_transport.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/venus/vkr_transport.c b/src/venus/vkr_transport.c index 5de7c59..fa3fa64 100644 --- a/src/venus/vkr_transport.c +++ b/src/venus/vkr_transport.c @@ -177,6 +177,13 @@ validate_ring_layout(const struct vkr_ring_layout *layout, size_t buf_size) regions[i]->offset, regions[i]->size); return false; } + + if (regions[i]->offset & 0x3) { + vkr_log("ring buffer control variable (offset=%lu, size=%lu) must be" + " 32-bit aligned in shared memory layout", + regions[i]->offset, regions[i]->size); + return false; + } } /* assumes region->size == 0 is valid */