From: Jeff Dike <jdike@addtoit.com>
To: torvalds@osdl.org
Cc: Bodo Stroesser <bstroesser@fujitsu-siemens.com>,
akpm@osdl.org, linux-kernel@vger.kernel.org,
user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] [PATCH 9/9] UML - Fix rounding bug in tlb flushing
Date: Wed, 09 Mar 2005 21:16:53 -0500 [thread overview]
Message-ID: <200503100216.j2A2GrDN015259@ccure.user-mode-linux.org> (raw)
From: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
fix_range_common and flush_tlb_kernel_range_common don't work correctly,
if a PGD (or PUD or PMD) is not present and start_addr (resp. start) is not
aligned to a PGD boundary (or PUD or PMD boundary).
Signed-off-by: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Index: linux-2.6.11/arch/um/kernel/tlb.c
===================================================================
--- linux-2.6.11.orig/arch/um/kernel/tlb.c 2005-03-08 23:46:28.000000000 -0500
+++ linux-2.6.11/arch/um/kernel/tlb.c 2005-03-09 00:03:30.000000000 -0500
@@ -15,6 +15,8 @@
#include "mem_user.h"
#include "os.h"
+#define ADD_ROUND(n, inc) (((n) + (inc)) & ~((inc) - 1))
+
void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
unsigned long end_addr, int force, int data,
void (*do_ops)(int, struct host_vm_op *, int))
@@ -33,46 +35,46 @@
for(addr = start_addr; addr < end_addr;){
npgd = pgd_offset(mm, addr);
if(!pgd_present(*npgd)){
+ end = ADD_ROUND(addr, PGDIR_SIZE);
+ if(end > end_addr)
+ end = end_addr;
if(force || pgd_newpage(*npgd)){
- end = addr + PGDIR_SIZE;
- if(end > end_addr)
- end = end_addr;
op_index = add_munmap(addr, end - addr, ops,
op_index, last_op, data,
do_ops);
pgd_mkuptodate(*npgd);
}
- addr += PGDIR_SIZE;
+ addr = end;
continue;
}
npud = pud_offset(npgd, addr);
if(!pud_present(*npud)){
+ end = ADD_ROUND(addr, PUD_SIZE);
+ if(end > end_addr)
+ end = end_addr;
if(force || pud_newpage(*npud)){
- end = addr + PUD_SIZE;
- if(end > end_addr)
- end = end_addr;
op_index = add_munmap(addr, end - addr, ops,
op_index, last_op, data,
do_ops);
pud_mkuptodate(*npud);
}
- addr += PUD_SIZE;
+ addr = end;
continue;
}
npmd = pmd_offset(npud, addr);
if(!pmd_present(*npmd)){
+ end = ADD_ROUND(addr, PMD_SIZE);
+ if(end > end_addr)
+ end = end_addr;
if(force || pmd_newpage(*npmd)){
- end = addr + PMD_SIZE;
- if(end > end_addr)
- end = end_addr;
op_index = add_munmap(addr, end - addr, ops,
op_index, last_op, data,
do_ops);
pmd_mkuptodate(*npmd);
}
- addr += PMD_SIZE;
+ addr = end;
continue;
}
@@ -122,52 +124,52 @@
for(addr = start; addr < end;){
pgd = pgd_offset(mm, addr);
if(!pgd_present(*pgd)){
+ last = ADD_ROUND(addr, PGDIR_SIZE);
+ if(last > end)
+ last = end;
if(pgd_newpage(*pgd)){
updated = 1;
- last = addr + PGDIR_SIZE;
- if(last > end)
- last = end;
err = os_unmap_memory((void *) addr,
last - addr);
if(err < 0)
panic("munmap failed, errno = %d\n",
-err);
}
- addr += PGDIR_SIZE;
+ addr = last;
continue;
}
pud = pud_offset(pgd, addr);
if(!pud_present(*pud)){
+ last = ADD_ROUND(addr, PUD_SIZE);
+ if(last > end)
+ last = end;
if(pud_newpage(*pud)){
updated = 1;
- last = addr + PUD_SIZE;
- if(last > end)
- last = end;
err = os_unmap_memory((void *) addr,
last - addr);
if(err < 0)
panic("munmap failed, errno = %d\n",
-err);
}
- addr += PUD_SIZE;
+ addr = last;
continue;
}
pmd = pmd_offset(pud, addr);
if(!pmd_present(*pmd)){
+ last = ADD_ROUND(addr, PMD_SIZE);
+ if(last > end)
+ last = end;
if(pmd_newpage(*pmd)){
updated = 1;
- last = addr + PMD_SIZE;
- if(last > end)
- last = end;
err = os_unmap_memory((void *) addr,
last - addr);
if(err < 0)
panic("munmap failed, errno = %d\n",
-err);
}
- addr += PMD_SIZE;
+ addr = last;
continue;
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
reply other threads:[~2005-03-09 23:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200503100216.j2A2GrDN015259@ccure.user-mode-linux.org \
--to=jdike@addtoit.com \
--cc=akpm@osdl.org \
--cc=bstroesser@fujitsu-siemens.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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