cvs commit: src/sys/pci agp.c
Hiroki Sato
hrs at FreeBSD.org
Thu Oct 26 20:39:51 UTC 2006
Seigo Tanimura <tanimura at FreeBSD.org> wrote
in <200610150504.k9F548ld008933 at repoman.freebsd.org>:
ta> tanimura 2006-10-15 05:04:07 UTC
ta>
ta> FreeBSD src repository
ta>
ta> Modified files:
ta> sys/pci agp.c
ta> Log:
ta> Fix the wraparound of memsize >=2GB.
ta>
ta> Revision Changes Path
ta> 1.54 +3 -2 src/sys/pci/agp.c
I have doubt about this change because int memsize->u_int memsize
does not solve the problem directly; memsize never occurs wraparound
actually and an implicit cast to unsigned int just makes the problem
invisible. The questionable code fragment in agp.c is the following:
memsize = ptoa(Maxmem) >> 20;
for (i = 0; i < agp_max_size; i++) {
if (memsize <= agp_max[i][0])
break;
}
ptoa(Maxmem)>>20 will occur a wraparound problem when Maxmem>=2GB, so
this part should be fixed instead. BTW, this should be a problem
only on i386 since the definition of ptoa() is "#define ptoa(x) ((x)
<< PAGE_SHIFT)". The other platforms use a cast like "#define
ptoa(x) ((unsigned long)(x) << PAGE_SHIFT)".
I think it can be solved by using "ptoa((unsigned long)Maxmem)" or
so, but I am not sure if this is reasonable because there are more
notional types like vm_paddr_t. If "#define ptoa(x) ((vm_paddr_t)(x)
<< PAGE_SHIFT)" works fine on all platforms, it looks more reasonable
to me, but I have a misunderstanding?
--
| Hiroki SATO
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-src/attachments/20061026/92bf34a1/attachment.pgp
More information about the cvs-src
mailing list