Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 97795
b: refs/heads/master
c: 40fb16a
h: refs/heads/master
i:
  97793: fc338c6
  97791: 9c65fb1
v: v3
  • Loading branch information
Tom Spink authored and Linus Torvalds committed Jun 6, 2008
1 parent 6cdb14a commit 50e4c9c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9f31287b443f30a591539e448fb628e3827a8f61
refs/heads/master: 40fb16a360d9c6459afee91dc793c1e3374feb94
2 changes: 1 addition & 1 deletion trunk/arch/um/include/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,6 @@ extern int os_arch_prctl(int pid, int code, unsigned long *addr);
extern int get_pty(void);

/* sys-$ARCH/task_size.c */
extern unsigned long os_get_task_size(void);
extern unsigned long os_get_top_address(void);

#endif
2 changes: 1 addition & 1 deletion trunk/arch/um/kernel/um_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ int __init linux_main(int argc, char **argv)
if (have_root == 0)
add_arg(DEFAULT_COMMAND_LINE);

host_task_size = os_get_task_size();
host_task_size = os_get_top_address();
/*
* TASK_SIZE needs to be PGDIR_SIZE aligned or else exit_mmap craps
* out
Expand Down
31 changes: 23 additions & 8 deletions trunk/arch/um/os-Linux/sys-i386/task_size.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static int page_ok(unsigned long page)
return ok;
}

unsigned long os_get_task_size(void)
unsigned long os_get_top_address(void)
{
struct sigaction sa, old;
unsigned long bottom = 0;
Expand All @@ -76,9 +76,9 @@ unsigned long os_get_task_size(void)
* hosts, but shouldn't hurt otherwise.
*/
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);

/*
Expand All @@ -89,16 +89,31 @@ unsigned long os_get_task_size(void)
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_NODEFER;
if (sigaction(SIGSEGV, &sa, &old)) {
perror("os_get_task_size");
perror("os_get_top_address");
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);
}

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 */
if (page_ok(top))
goto out;
Expand All @@ -114,7 +129,7 @@ unsigned long os_get_task_size(void)
out:
/* Restore the old SIGSEGV handling */
if (sigaction(SIGSEGV, &old, NULL)) {
perror("os_get_task_size");
perror("os_get_top_address");
exit(1);
}
top <<= UM_KERN_PAGE_SHIFT;
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/um/os-Linux/sys-x86_64/task_size.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
unsigned long os_get_task_size(unsigned long shift)
unsigned long os_get_top_address(unsigned long shift)
{
/* The old value of CONFIG_TOP_ADDR */
return 0x7fc0000000;
Expand Down

0 comments on commit 50e4c9c

Please sign in to comment.