Assert that the size in mappages() is always positive
If va % PGSIZE == 0 and size == 0, we have last < a at the start of the loop so we might never terminate. That being said, this particular case couldn't be triggered for now.
This commit is contained in:
parent
f55def8a64
commit
9195142959
|
@ -140,13 +140,16 @@ mappages(pagetable_t pagetable, uint64 va, uint64 size, uint64 pa, int perm)
|
||||||
uint64 a, last;
|
uint64 a, last;
|
||||||
pte_t *pte;
|
pte_t *pte;
|
||||||
|
|
||||||
|
if(size == 0)
|
||||||
|
panic("mappages: size");
|
||||||
|
|
||||||
a = PGROUNDDOWN(va);
|
a = PGROUNDDOWN(va);
|
||||||
last = PGROUNDDOWN(va + size - 1);
|
last = PGROUNDDOWN(va + size - 1);
|
||||||
for(;;){
|
for(;;){
|
||||||
if((pte = walk(pagetable, a, 1)) == 0)
|
if((pte = walk(pagetable, a, 1)) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
if(*pte & PTE_V)
|
if(*pte & PTE_V)
|
||||||
panic("remap");
|
panic("mappages: remap");
|
||||||
*pte = PA2PTE(pa) | perm | PTE_V;
|
*pte = PA2PTE(pa) | perm | PTE_V;
|
||||||
if(a == last)
|
if(a == last)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue