From: Brendan Shephard Date: Mon, 15 Dec 2025 08:34:16 +0000 (+1000) Subject: drm/nova: Align GEM memory allocation to system page size X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=255153afbcfdcf30d20048fb76a6d9418537b5d9;p=thirdparty%2Fkernel%2Flinux.git drm/nova: Align GEM memory allocation to system page size Use page::page_align for GEM object memory allocation to ensure the allocation is page aligned. This is important on systems where the default page size is not 4k. Such as 16k or 64k aarch64 systems. This change uses the updated page_align() function which returns Option for overflow safety. (See "rust: Return Option from page_align and ensure no usize overflow"). Signed-off-by: Brendan Shephard Link: https://patch.msgid.link/20251215083416.266469-1-bshephar@bne-home.net [ Import page module only. - Danilo ] Signed-off-by: Danilo Krummrich --- diff --git a/drivers/gpu/drm/nova/gem.rs b/drivers/gpu/drm/nova/gem.rs index 2760ba4f3450b..6ccfa5da57617 100644 --- a/drivers/gpu/drm/nova/gem.rs +++ b/drivers/gpu/drm/nova/gem.rs @@ -3,6 +3,7 @@ use kernel::{ drm, drm::{gem, gem::BaseObject}, + page, prelude::*, sync::aref::ARef, }; @@ -27,11 +28,10 @@ impl gem::DriverObject for NovaObject { impl NovaObject { /// Create a new DRM GEM object. pub(crate) fn new(dev: &NovaDevice, size: usize) -> Result>> { - let aligned_size = size.next_multiple_of(1 << 12); - - if size == 0 || size > aligned_size { + if size == 0 { return Err(EINVAL); } + let aligned_size = page::page_align(size).ok_or(EINVAL)?; gem::Object::new(dev, aligned_size) }