Port-amiga archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Possible problem with accessing DVDs larger than 4GB

On Mon, February 25, 2013 08:47, Frank Wille wrote:
> sorry for the late reply. But I had to find somebody with a DVD drive on
his Amiga first. :)
> On Wed, 13 Feb 2013 17:54:13 -0000
> "Mark" <markk%clara.co.uk@localhost> wrote:
>> Testing NetBSD 6.0.1 with emulated SCSI or ATAPI DVD drive, when you
>> to access a DVD which is larger than 4GB (2^32 bytes), the accessible
range is truncated modulo 2^32.
>> ...
> We did the test with A4000 IDE, and after running for more than three
hours the 4GB barrier definitely had been crossed:
> 2173887+0 records in
> 2173887+0 records out
> 4452120576 bytes transferred in 7266.108 secs (612724 bytes/sec)

Thanks very much for taking the time to do that!

I figured out the cause of the problem, which was in WinUAE after all. In
the WinUAE source, blkdev_cdimage.cpp, there was this line:
        cdu->cdsize = cdu->toc[cdu->tracks].address * cdu->blocksize;

The type of cdu->cdsize is uae_u64, but cdu->toc[cdu->tracks].address and
cdu->blocksize are both int. That statement casts the result to uae_u64
after working it out as a (32-bit) int, hence the truncation modulo 2^32.

Quite a hard bug to figure out, not only because I'm no C expert. Running
the Debian 3.1r8 installer, that works fine with the DVD connected via
ATAPI, but has the same truncation bug connecting over SCSI. I assume the
Debian ATAPI driver doesn't prevent out-of-bounds accesses, but the SCSI
driver does. So actually attempting to read the ATAPI DVD past the bogus
READ CAPACITY value did work there.

Anyway. Continuing with the testing WinUAE with NetBSD theme, there's
another issue I have come across. Again, I'd like to know whether this
happens on real hardware.

I've been using an emulated A3000/040/SCSI CD drive config. With that,
booting NetBSD 6.0.1 and doing
  # dd if=/dev/cd0c of=temp.bin bs=2048
fails to read the last sector of the CD; e.g. if the CD has 19057 sectors,
dd only reads 19056. (For faster testing you can add a skip= argument to
dd, to skip most of the disc.)

(Also, the NetBSD SCSI CD code seems quite sub-optimal, in that it appears
to issue separate READ 10 commands for every sector, even if you pass a
bs=32768 argument to dd.)

-- Mark

Home | Main Index | Thread Index | Old Index