From a14feb6ffadd6902ba09f23122beda08beb970ad Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Sun, 21 Aug 2022 06:58:54 +0000 Subject: gnumach: vm_allocate_contiguous: Allow small power 2 alignments This allows contiguous allocations aligned to values smaller than one page, but still a power of 2, by forcing the alignment to be to the nearest page. This works because PAGE_SIZE is a power of two. Message-Id: <20220821065732.269573-1-damien@zamaudio.com> --- vm/vm_user.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'vm') diff --git a/vm/vm_user.c b/vm/vm_user.c index ad1fa75d..3ef64dfc 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -590,6 +590,10 @@ kern_return_t vm_allocate_contiguous( if (palign == 0) palign = PAGE_SIZE; + /* FIXME: Allows some small alignments less than page size */ + if ((palign < PAGE_SIZE) && (PAGE_SIZE % palign == 0)) + palign = PAGE_SIZE; + /* FIXME */ if (palign != PAGE_SIZE) return KERN_INVALID_ARGUMENT; -- cgit v1.2.3