Package: glibc / 2.28-10

hurd-i386/tg-bigmem.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Subject: [PATCH] Allow the kernel to start earlier than VM_MAX_ADDRESS

VM_MAX_ADDRESS shouldn't be hardcoded in libc, the kernel should be able to
decide about it dynamically. This fixes glibc into supporting that. It's however
a bit hackish.

---
 sysdeps/mach/hurd/dl-sysdep.c |   26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -87,12 +87,28 @@ static void fmh(void) {
 	max=a; break;}
       fmha=a+=fmhs;}
     if (err) assert(err==KERN_NO_SPACE);
-    if (!fmha)fmhs=0;else{
-    fmhs=max-fmha;
-    err = __vm_map (__mach_task_self (),
-		    &fmha, fmhs, 0, 0, MACH_PORT_NULL, 0, 1,
-		    VM_PROT_NONE, VM_PROT_NONE, VM_INHERIT_COPY);
-    assert_perror(err);}
+    if (!fmha)
+      fmhs=0;
+    else
+      while (1) {
+	fmhs=max-fmha;
+	if (fmhs == 0)
+	  break;
+	err = __vm_map (__mach_task_self (),
+			&fmha, fmhs, 0, 0, MACH_PORT_NULL, 0, 1,
+			VM_PROT_NONE, VM_PROT_NONE, VM_INHERIT_COPY);
+	if (!err)
+	  break;
+	if (err != KERN_INVALID_ADDRESS && err != KERN_NO_SPACE)
+	  assert_perror(err);
+	vm_address_t new_max = (max - 1) & 0xf0000000U;
+	if (new_max >= max) {
+	  fmhs = 0;
+	  fmha = 0;
+	  break;
+	}
+	max = new_max;
+      }
   }
 /* XXX loser kludge for vm_map kernel bug */
 #endif