Fixed write enabling of the kernel text section. The overlap

checking was mostly wrong at the boundaries.  For the lower limit,
VM_MIN_KERNEL_ADDRESS was used instead of btext and there was an
off-by-(`size' - 1) error.  For the upper limit, &etext was used
instead of etext and there was an off-by-1 error.  The bugs were
harmless because `size' is not too large and some memory is mapped
just beyond the ends.  We still depend on the former to avoid
having to handle the case where the memory range covers the whole
text section, and on the latter to prevent problems when we map
just beyond an end to allow writing an address range that overlaps
the end.

Fixed placement of a nearby comment.
This commit is contained in:
bde 1997-11-20 18:09:36 +00:00
parent 3fd2fb7377
commit f87b3adf93
2 changed files with 10 additions and 14 deletions

View File

@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* $Id: db_interface.c,v 1.36 1997/08/07 05:15:46 dyson Exp $
* $Id: db_interface.c,v 1.37 1997/10/27 17:23:12 bde Exp $
*/
/*
@ -41,7 +41,6 @@
#endif
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <ddb/ddb.h>
@ -247,17 +246,16 @@ db_write_bytes(addr, size, data)
db_nofault = &db_jmpbuf;
if (addr >= VM_MIN_KERNEL_ADDRESS &&
addr <= round_page((vm_offset_t)&etext)) {
if (addr > trunc_page((vm_offset_t)btext) - size &&
addr < round_page((vm_offset_t)etext)) {
ptep0 = pmap_pte(kernel_pmap, addr);
oldmap0 = *ptep0;
*ptep0 |= PG_RW;
/* Map another page if the data crosses a page boundary. */
if ((*ptep0 & PG_PS) == 0) {
addr1 = trunc_page(addr + size - 1);
/* Map another page if the data crosses a page boundary. */
if (trunc_page(addr) != addr1) {
ptep1 = pmap_pte(kernel_pmap, addr1);
oldmap1 = *ptep1;

View File

@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* $Id: db_interface.c,v 1.36 1997/08/07 05:15:46 dyson Exp $
* $Id: db_interface.c,v 1.37 1997/10/27 17:23:12 bde Exp $
*/
/*
@ -41,7 +41,6 @@
#endif
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <ddb/ddb.h>
@ -247,17 +246,16 @@ db_write_bytes(addr, size, data)
db_nofault = &db_jmpbuf;
if (addr >= VM_MIN_KERNEL_ADDRESS &&
addr <= round_page((vm_offset_t)&etext)) {
if (addr > trunc_page((vm_offset_t)btext) - size &&
addr < round_page((vm_offset_t)etext)) {
ptep0 = pmap_pte(kernel_pmap, addr);
oldmap0 = *ptep0;
*ptep0 |= PG_RW;
/* Map another page if the data crosses a page boundary. */
if ((*ptep0 & PG_PS) == 0) {
addr1 = trunc_page(addr + size - 1);
/* Map another page if the data crosses a page boundary. */
if (trunc_page(addr) != addr1) {
ptep1 = pmap_pte(kernel_pmap, addr1);
oldmap1 = *ptep1;