check for alignment just once

This commit is contained in:
Robert Morris 2021-08-10 07:12:41 -04:00
parent 3b3f83f100
commit 6de0381d61

View file

@ -52,7 +52,7 @@ exec(char *path, char **argv)
if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0) if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
goto bad; goto bad;
sz = sz1; sz = sz1;
if(ph.vaddr % PGSIZE != 0) if((ph.vaddr % PGSIZE) != 0)
goto bad; goto bad;
if(loadseg(pagetable, ph.vaddr, ip, ph.off, ph.filesz) < 0) if(loadseg(pagetable, ph.vaddr, ip, ph.off, ph.filesz) < 0)
goto bad; goto bad;
@ -138,9 +138,6 @@ loadseg(pagetable_t pagetable, uint64 va, struct inode *ip, uint offset, uint sz
uint i, n; uint i, n;
uint64 pa; uint64 pa;
if((va % PGSIZE) != 0)
panic("loadseg: va must be page aligned");
for(i = 0; i < sz; i += PGSIZE){ for(i = 0; i < sz; i += PGSIZE){
pa = walkaddr(pagetable, va + i); pa = walkaddr(pagetable, va + i);
if(pa == 0) if(pa == 0)