bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gnumach: vm_allocate_contiguous: Allow small power 2 alignments


From: Damien Zammit
Subject: [PATCH] gnumach: vm_allocate_contiguous: Allow small power 2 alignments
Date: Sun, 21 Aug 2022 06:58:54 +0000

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.

---
 vm/vm_user.c | 4 ++++
 1 file changed, 4 insertions(+)

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;
--
2.34.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]