mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Tom Spink" <tspink@gmail.com>
To: "Jeff Dike" <jdike@addtoit.com>
Cc: "linux-os (Dick Johnson)" <linux-os@analogic.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: UML fails to locate address space
Date: Wed, 21 May 2008 13:04:21 +0100	[thread overview]
Message-ID: <7b9198260805210504h278f014s5aba720360ac02ab@mail.gmail.com> (raw)
In-Reply-To: <7b9198260805210502i316c9e38lcc9b5561045dd5d@mail.gmail.com>

2008/5/21 Tom Spink <tspink@gmail.com>:
> 2008/5/21 Jeff Dike <jdike@addtoit.com>:
>> On Tue, May 20, 2008 at 05:54:34PM -0400, linux-os (Dick Johnson) wrote:
>>> Okay, then instead of putting a NULL in the "hint" to mmap() try
>>> something else (0x1000?). That may help.
>>
>> You don't seem to have followed the thread.  For UML, the address
>> isn't a hint - it's a requirement.  Tossing random numbers into your
>> code until a particular test works isn't really the way to go.  In
>> this case, we are looking at mmap_min_addr being set at 0x10000, but
>> which may be set to 0x20000 someplace else.
>>
>>                    Jeff
>>
>
> Hi Jeff,
>
> Here is the revised version - I cheered Dijkstra up by getting rid of that goto.
>
> -- Tom
>

Oh No! I forgot to get rid of those nasty includes.... Take 2....

-- Tom

--

From: Tom Spink <tspink@gmail.com>
Date: Wed, 21 May 2008 00:53:54 +0100
Subject: [PATCH] Locate the bottom of the address space

This patch makes os_get_task_size locate the bottom of the address space,
as well as the top.  This is for systems which put a lower limit on mmap
addresses.  It works by manually scanning pages from zero onwards until a
valid page is found.

Because the bottom of the address space may not be zero, it's not sufficient
to assume the top of the address space is the size of the address space.  The
size is the difference between the top address and bottom address.

Signed-off-by: Tom Spink <tspink@gmail.com>
---
 arch/um/os-Linux/sys-i386/task_size.c |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/arch/um/os-Linux/sys-i386/task_size.c
b/arch/um/os-Linux/sys-i386/task_size.c
index ccb49b0..13db95a 100644
--- a/arch/um/os-Linux/sys-i386/task_size.c
+++ b/arch/um/os-Linux/sys-i386/task_size.c
@@ -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);

 	/*
@@ -93,13 +93,26 @@ unsigned long os_get_task_size(void)
 		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);

 	/* This could happen with a 4G/4G split */
+	original = bottom;
 	if (page_ok(top))
 		goto out;

@@ -117,8 +130,7 @@ out:
 		perror("os_get_task_size");
 		exit(1);
 	}
-	top <<= UM_KERN_PAGE_SHIFT;
-	printf("0x%x\n", top);
+	printf("0x%x\n", top << UM_KERN_PAGE_SHIFT);

-	return top;
+	return (top - original) << UM_KERN_PAGE_SHIFT;
 }
-- 
1.5.4.3

  reply	other threads:[~2008-05-21 12:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-20 11:08 Tom Spink
2008-05-20 13:52 ` Jeff Dike
2008-05-20 13:59   ` Tom Spink
2008-05-20 16:10     ` Jeff Dike
2008-05-20 16:43       ` Tom Spink
2008-05-20 17:56         ` Jeff Dike
2008-05-20 18:01           ` Tom Spink
2008-05-20 19:24             ` Jeff Dike
2008-05-20 19:42               ` Tom Spink
2008-05-20 21:27                 ` Jeff Dike
2008-05-20 22:03                   ` Tom Spink
2008-05-20 23:57                     ` Tom Spink
2008-05-21  1:58                       ` Jeff Dike
2008-05-20 15:22   ` linux-os (Dick Johnson)
2008-05-20 17:35     ` Jeff Dike
2008-05-20 21:54       ` linux-os (Dick Johnson)
2008-05-21  2:15         ` Jeff Dike
2008-05-21 12:02           ` Tom Spink
2008-05-21 12:04             ` Tom Spink [this message]
2008-05-21 17:58               ` Jeff Dike
2008-05-21 19:01                 ` Tom Spink
2008-05-20 21:58       ` linux-os (Dick Johnson)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7b9198260805210504h278f014s5aba720360ac02ab@mail.gmail.com \
    --to=tspink@gmail.com \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-os@analogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®