Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Phil Thompson <phil@river-bank.demon.co.uk>
To: linux-mips@oss.sgi.com
Subject: pgd_init() Patch
Date: Mon, 28 Jan 2002 13:36:39 +0000	[thread overview]
Message-ID: <3C5553E7.7DFDBB55@river-bank.demon.co.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

While trying to understand the changes needed for discontiguous memory I
came across this...

In paging_init() there are two calls to pgd_init()...

        /* Initialize the entire pgd.  */
        pgd_init((unsigned long)swapper_pg_dir);
        pgd_init((unsigned long)swapper_pg_dir + PAGE_SIZE / 2);

...where the assumption seems to be that the PGD is one page and each
call initialises half of it. Most of the CPU implementations of
pgd_init() nearly do this because they initialise USER_PTRS_PER_PGD
entries. The problems with this are...

- pg-r3k.c and pg-r4k.S don't use USER_PTRS_PER_PGD and initialise a
page's worth each time. This means the second call to pgd_init()
initialises half a page's worth of memory after the end of
swapper_pg_dir.

- USER_PTRS_PER_PGD is defined as TASK_SIZE/PGDIR_SIZE. However,
because, TASK_SIZE is actually defined as one less that the maximum task
size there is a rounding error that means that USER_PTRS_PER_PGD works
out at 511 rather than 512. This means that entries 511 and 1023 of
swapper_pg_dir don't get initialised.

The corresponding mips64 code has only the first call to pgd_init() and
each implementation of pgd_init() initialises PTRS_PER_PGD entries,
where PTRS_PER_PGD is simple defined as 1024.

The attached patch applies the mips64 approach to the mips code.

Should USER_PTRS_PER_PGD be defined as (TASK_SIZE/PGDIR_SIZE) + 1?

Phil

[-- Attachment #2: mm.patch --]
[-- Type: text/plain, Size: 2116 bytes --]

diff -ruN mm.orig/c-sb1.c mm/c-sb1.c
--- mm.orig/c-sb1.c	Wed Dec 12 16:25:01 2001
+++ mm/c-sb1.c	Mon Jan 28 12:37:20 2002
@@ -44,7 +44,7 @@
 	unsigned long *p = (unsigned long *) page;
 	int i;
 
-	for (i = 0; i < USER_PTRS_PER_PGD; i+=8) {
+	for (i = 0; i < PTRS_PER_PGD; i+=8) {
 		p[i + 0] = (unsigned long) invalid_pte_table;
 		p[i + 1] = (unsigned long) invalid_pte_table;
 		p[i + 2] = (unsigned long) invalid_pte_table;
diff -ruN mm.orig/init.c mm/init.c
--- mm.orig/init.c	Fri Jan 25 14:17:12 2002
+++ mm/init.c	Mon Jan 28 12:37:36 2002
@@ -152,7 +152,6 @@
 
 	/* Initialize the entire pgd.  */
 	pgd_init((unsigned long)swapper_pg_dir);
-	pgd_init((unsigned long)swapper_pg_dir + PAGE_SIZE / 2);
 
 	max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
 	low = max_low_pfn;
diff -ruN mm.orig/pg-mips32.c mm/pg-mips32.c
--- mm.orig/pg-mips32.c	Tue Oct 23 02:02:46 2001
+++ mm/pg-mips32.c	Mon Jan 28 12:37:56 2002
@@ -127,7 +127,7 @@
 	unsigned long *p = (unsigned long *) page;
 	int i;
 
-	for(i = 0; i < USER_PTRS_PER_PGD; i+=8) {
+	for(i = 0; i < PTRS_PER_PGD; i+=8) {
 		p[i + 0] = (unsigned long) invalid_pte_table;
 		p[i + 1] = (unsigned long) invalid_pte_table;
 		p[i + 2] = (unsigned long) invalid_pte_table;
diff -ruN mm.orig/pg-r5432.c mm/pg-r5432.c
--- mm.orig/pg-r5432.c	Tue Oct 23 02:02:46 2001
+++ mm/pg-r5432.c	Mon Jan 28 12:38:30 2002
@@ -104,7 +104,7 @@
 	unsigned long *p = (unsigned long *) page;
 	int i;
 
-	for(i = 0; i < USER_PTRS_PER_PGD; i+=8) {
+	for(i = 0; i < PTRS_PER_PGD; i+=8) {
 		p[i + 0] = (unsigned long) invalid_pte_table;
 		p[i + 1] = (unsigned long) invalid_pte_table;
 		p[i + 2] = (unsigned long) invalid_pte_table;
diff -ruN mm.orig/pg-rm7k.c mm/pg-rm7k.c
--- mm.orig/pg-rm7k.c	Tue Oct 23 02:02:46 2001
+++ mm/pg-rm7k.c	Mon Jan 28 12:38:38 2002
@@ -107,7 +107,7 @@
 	unsigned long *p = (unsigned long *) page;
 	int i;
 
-	for (i = 0; i < USER_PTRS_PER_PGD; i+=8) {
+	for (i = 0; i < PTRS_PER_PGD; i+=8) {
 		p[i + 0] = (unsigned long) invalid_pte_table;
 		p[i + 1] = (unsigned long) invalid_pte_table;
 		p[i + 2] = (unsigned long) invalid_pte_table;

             reply	other threads:[~2002-01-28 14:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-28 13:36 Phil Thompson [this message]
2002-01-28 19:53 ` pgd_init() Patch Geert Uytterhoeven
2002-01-28 20:03   ` Pete Popov
2002-01-28 20:04   ` Jun Sun
2002-01-28 20:26     ` Geert Uytterhoeven

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=3C5553E7.7DFDBB55@river-bank.demon.co.uk \
    --to=phil@river-bank.demon.co.uk \
    --cc=linux-mips@oss.sgi.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