Subject: new mremap(2): relax alignment restrictions?
To: None <tech-kern@netbsd.org>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-kern
Date: 07/24/2007 19:06:04
This is a multipart MIME message.

--==_Exmh_50414324063700
Content-Type: text/plain; charset=us-ascii


Hi -
NetBSD's new mremap(2) does not only require the start address
of the memory range to be page aligned, but additionally the
old and new sizes to be multiple of the page size.
This differs from the Linux behaviour, and it is also
inconsistent to mmap(2) which rounds up implicitely.
The selftest of Python's "mmapmodule" fails on NetBSD for
this reason.
How about the appended patch?

best regards
Matthias



Forschungszentrum Juelich GmbH
52425 Juelich

Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDirig'in Baerbel Brumme-Bothe
Vorstand: Prof. Dr. Achim Bachem (Vorsitzender), Dr. Ulrich Krafft (stellv. 
Vorsitzender)

--==_Exmh_50414324063700
Content-Type: text/plain ; name="mremap.txt"; charset=us-ascii
Content-Description: mremap.txt
Content-Disposition: attachment; filename="mremap.txt"

#
# old_revision [8bfb323896c8df125c804a7b8b5fecd5e61651f5]
#
# patch "sys/uvm/uvm_mremap.c"
#  from [d974599d2f4c9c127ad1353fc486eb886f29e69d]
#    to [5c0cc66e902469916989b7375489a81dc3ff8d38]
#
============================================================
--- sys/uvm/uvm_mremap.c	d974599d2f4c9c127ad1353fc486eb886f29e69d
+++ sys/uvm/uvm_mremap.c	5c0cc66e902469916989b7375489a81dc3ff8d38
@@ -269,6 +269,9 @@ sys_mremap(struct lwp *l, void *v, regis
 		goto done;
 	}
 
+	oldsize = round_page(oldsize);
+	newsize = round_page(newsize);
+
 	p = l->l_proc;
 	map = &p->p_vmspace->vm_map;
 	error = uvm_mremap(map, oldva, oldsize, map, &newva, newsize, p,

--==_Exmh_50414324063700--