pc64: fix segattach
the comment about Physseg.size being in pages is wrong, change type to uintptr and correct the comment. change the length parameter of segattach() and isoverlap() to uintptr as well. segments can grow over 4GB in pc64 now and globalsegattach() in devsegment calculates len argument of isoverlap() by s->top - s->bot. note that the syscall still takes 32bit ulong argument for the length! check for integer overflow in segattach(), make sure segment goes not beyond USTKTOP. change PTEMAPMEM constant to uvlong as it is used to calculate SEGMAXSIZE.
This commit is contained in:
parent
06c8a5b391
commit
316d8ad76b
5 changed files with 11 additions and 12 deletions
|
@ -558,7 +558,7 @@ out:
|
|||
}
|
||||
|
||||
Segment*
|
||||
isoverlap(Proc *p, uintptr va, int len)
|
||||
isoverlap(Proc *p, uintptr va, uintptr len)
|
||||
{
|
||||
int i;
|
||||
Segment *ns;
|
||||
|
@ -621,7 +621,7 @@ isphysseg(char *name)
|
|||
}
|
||||
|
||||
uintptr
|
||||
segattach(Proc *p, ulong attr, char *name, uintptr va, ulong len)
|
||||
segattach(Proc *p, ulong attr, char *name, uintptr va, uintptr len)
|
||||
{
|
||||
int sno;
|
||||
Segment *s, *os;
|
||||
|
@ -671,13 +671,12 @@ segattach(Proc *p, ulong attr, char *name, uintptr va, ulong len)
|
|||
error(Enovmem);
|
||||
va -= len;
|
||||
}
|
||||
va &= ~(BY2PG-1);
|
||||
} else {
|
||||
va &= ~(BY2PG-1);
|
||||
if(va == 0 || va >= USTKTOP)
|
||||
error(Ebadarg);
|
||||
}
|
||||
|
||||
va &= ~(BY2PG-1);
|
||||
if(va == 0 || (va+len) > USTKTOP || (va+len) < va)
|
||||
error(Ebadarg);
|
||||
|
||||
if(isoverlap(p, va, len) != nil)
|
||||
error(Esoverlap);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue