English Amiga Board


Go Back   English Amiga Board > Support > support.WinUAE

 
 
Thread Tools
Old 01 February 2019, 23:47   #1
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 47
Posts: 2,872
log write to custom registers with out of bounds addresses

I've tried to write an address in fastmem into audio register and nothing appeared in the log.


Code:
    lea $7F000000,A0
    move.l  A0,$DFF0A0

Is it possible to get a logged "wrong write" to a custom register pointer?


If I try to play some sound data which is in fast memory, it won't work, but it's difficult to track it down.
jotd is offline  
Old 02 February 2019, 09:51   #2
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,354
It can't be logged by default because any program that only works with chip ram only would flood the log but logging 10-30 first errors should be fine.
Toni Wilen is offline  
Old 02 February 2019, 10:29   #3
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 47
Posts: 2,872
Toni, first my example is bad because this register isn't a pointer, but I meant: "log writes to custom chip address where a pointer to chip is required but a fastmem/illegal address is supplied instead".

The test is fairly easy: 0 < ptr < chipsize is ok, others aren't. Of course, you can overtake chipmem by writing an address close to chip max and a big length too. That would be the icing on the cake.

Currently whdload has those features but need MMU and sometimes there are corner cases (Self-modifying code + JIT : no MMU).

It would be cool even if the debugger stopped on those writes, like memory watches.

Why am I asking this?

Well I've done some "chipmem only" => "fastmem" hacks for some games:

- Chaos Engine CD32
- Ultimate Body Blows
- Beneath a steel sky

Those hacks allow to relocate code in fastmem for programs which lazily used one big MEMF_CHIP segment (CD32 versions...). If you ignore this chip flag, since the game relies on that, you potentially get gfx & sfx buffers in fast memory now.

I remember relocating all data pointers back to chipmem (using disassembly and a script) but you can miss some. And it's easy when you have executable (with reloc information) but not when the code isn't really relocatable (like Red Zone for instance, that I'm planning to move to fastmem for a while, a 3D game running only on chipmem, whaaaaaat???)
jotd is offline  
Old 02 February 2019, 11:02   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,354
$dff0a0 surely is a DMA pointer register?

The point of my reply is that there should not be any situations where by default every frame adds one or more log messages continuously. It must only happen in some very abnormal situation. Running chip ram only program with fast ram is not abnormal enough.

Anyway, following features added:

- log message when CPU or copper writes to DMA pointer high word and value is outside of Chip RAM space. Stops logging after 100 messages. Note that this can log false positives if program writes garbage to non-active DMA pointer (even KS 1.3 does it at boot to dff084..)
- if memwatch points are enabled and new log mode is enabled ("w l"), any DMA read or write outside of chip ram gets logged. DMA pointer register, memory address, last value written (CPU/Copper) to register and last PC or Copper pointer when last written are included. I don't think there is much use to break to debugger automatically in this situation because it is already too late..
Toni Wilen is offline  
Old 02 February 2019, 12:53   #5
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 47
Posts: 2,872
that's just awesome is it available right now?
jotd is offline  
Old 02 February 2019, 13:46   #6
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,354
The usual url: http://www.winuae.net/files/b/winuae.7z

I also added custom register unaligned word access and byte access logging. Filters out usual $dff006.b and $dff002.b which are too commonly used.

EDIT: I can also add other similar validations if needed.

EDIT2: Fixed xDAT vs xPT checks.

Last edited by Toni Wilen; 02 February 2019 at 14:12.
Toni Wilen is offline  
Old 02 February 2019, 14:15   #7
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 47
Posts: 2,872
Awesome as always. thanks a lot.
jotd is offline  
Old 02 February 2019, 17:58   #8
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,354
Update:

- non-existing (non-existing or registers that are for example AGA only but config is not AGA) custom registers are logged. (TODO: check if undefined bits are set?)
- writing to read-only register or reading from write-only logged.
- last written value fixed.
- if copper does invalid access, include correct copper list address.

All above logging options are now enabled with "w l", including previous "log 100 first only".
Toni Wilen is offline  
Old 02 February 2019, 18:20   #9
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 47
Posts: 2,872
yeah! with "w l" I get an invalid memory issue, which probably explains the trashed sound.

Code:
57-617 [6316 000-220]: DMA DAT 00ca, PT 00c0 accessed invalid memory 0ff46fc2. Init: 00000ff4, PC/COP=0ff467a6

code:
      0FF467A6 2d7a ff44 00c0           MOVE.L (PC,$ff44) == $0ff466ec [0ff46faa],(A6,$00c0) == $00dff0c0
Awesome!
jotd is offline  
Old 02 February 2019, 21:55   #10
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,354
Nice.

More validation added: log message if writing to existing write-only custom register and written value has one or more unused bits set (dmacon, ddfstrt/stop if OCS/ECS difference and so on..).

Unfortunately this can causes false positives, for example move.w #$7fff,$dff096 technically has unused bits set.
Toni Wilen is offline  
Old 03 February 2019, 00:23   #11
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 47
Posts: 2,872
This will help to fix a lot of strange issues in games. I can write a script to filter out uninsteresting things from the log.
jotd is offline  
Old 03 February 2019, 14:25   #12
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,354
Added CIA checks: mirror CIA access, unused register 11, non-byte access, invalid (both or neither CIA is selected).
Custom register check new feature: mirror custom register accesses are reported.
Toni Wilen is offline  
Old 03 February 2019, 14:43   #13
ross
Sum, ergo Cogito

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,457
Nice additions for debugging!

Thanks.
ross is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
WinUae 4.0.0, HD tried to Seek out of Bounds Marty2AGA support.WinUAE 4 21 June 2018 22:36
Hardfile tried to seek out of bounds Leandro Jardim support.WinUAE 9 11 October 2011 18:27
Devpac and assembling for absolute addresses h0ffman Coders. General 10 21 March 2011 20:12
Checking custom registers in a game/demo Photon support.WinUAE 19 24 November 2009 17:03

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.07397 seconds with 13 queries