|
@@ -63,7 +63,7 @@ static int page_ok(unsigned long page)
|
|
return ok;
|
|
return ok;
|
|
}
|
|
}
|
|
|
|
|
|
-unsigned long os_get_task_size(void)
|
|
|
|
|
|
+unsigned long os_get_top_address(void)
|
|
{
|
|
{
|
|
struct sigaction sa, old;
|
|
struct sigaction sa, old;
|
|
unsigned long bottom = 0;
|
|
unsigned long bottom = 0;
|
|
@@ -76,9 +76,9 @@ unsigned long os_get_task_size(void)
|
|
* hosts, but shouldn't hurt otherwise.
|
|
* hosts, but shouldn't hurt otherwise.
|
|
*/
|
|
*/
|
|
unsigned long top = 0xffffd000 >> UM_KERN_PAGE_SHIFT;
|
|
unsigned long top = 0xffffd000 >> UM_KERN_PAGE_SHIFT;
|
|
- unsigned long test;
|
|
|
|
|
|
+ unsigned long test, original;
|
|
|
|
|
|
- printf("Locating the top of the address space ... ");
|
|
|
|
|
|
+ printf("Locating the bottom of the address space ... ");
|
|
fflush(stdout);
|
|
fflush(stdout);
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -89,16 +89,31 @@ unsigned long os_get_task_size(void)
|
|
sigemptyset(&sa.sa_mask);
|
|
sigemptyset(&sa.sa_mask);
|
|
sa.sa_flags = SA_NODEFER;
|
|
sa.sa_flags = SA_NODEFER;
|
|
if (sigaction(SIGSEGV, &sa, &old)) {
|
|
if (sigaction(SIGSEGV, &sa, &old)) {
|
|
- perror("os_get_task_size");
|
|
|
|
|
|
+ perror("os_get_top_address");
|
|
exit(1);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
|
|
- if (!page_ok(bottom)) {
|
|
|
|
- fprintf(stderr, "Address 0x%x no good?\n",
|
|
|
|
- bottom << UM_KERN_PAGE_SHIFT);
|
|
|
|
|
|
+ /* Manually scan the address space, bottom-up, until we find
|
|
|
|
+ * the first valid page (or run out of them).
|
|
|
|
+ */
|
|
|
|
+ for (bottom = 0; bottom < top; bottom++) {
|
|
|
|
+ if (page_ok(bottom))
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* If we've got this far, we ran out of pages. */
|
|
|
|
+ if (bottom == top) {
|
|
|
|
+ fprintf(stderr, "Unable to determine bottom of address "
|
|
|
|
+ "space.\n");
|
|
exit(1);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ printf("0x%x\n", bottom << UM_KERN_PAGE_SHIFT);
|
|
|
|
+ printf("Locating the top of the address space ... ");
|
|
|
|
+ fflush(stdout);
|
|
|
|
+
|
|
|
|
+ original = bottom;
|
|
|
|
+
|
|
/* This could happen with a 4G/4G split */
|
|
/* This could happen with a 4G/4G split */
|
|
if (page_ok(top))
|
|
if (page_ok(top))
|
|
goto out;
|
|
goto out;
|
|
@@ -114,7 +129,7 @@ unsigned long os_get_task_size(void)
|
|
out:
|
|
out:
|
|
/* Restore the old SIGSEGV handling */
|
|
/* Restore the old SIGSEGV handling */
|
|
if (sigaction(SIGSEGV, &old, NULL)) {
|
|
if (sigaction(SIGSEGV, &old, NULL)) {
|
|
- perror("os_get_task_size");
|
|
|
|
|
|
+ perror("os_get_top_address");
|
|
exit(1);
|
|
exit(1);
|
|
}
|
|
}
|
|
top <<= UM_KERN_PAGE_SHIFT;
|
|
top <<= UM_KERN_PAGE_SHIFT;
|