Skip to content

m68k: read and write the VBR register - #2456

Open
bacescuandrei wants to merge 1 commit into
unicorn-engine:devfrom
bacescuandrei:fix/m68k-vbr
Open

bacescuandrei wants to merge 1 commit into
unicorn-engine:devfrom
bacescuandrei:fix/m68k-vbr

Conversation

@bacescuandrei

Copy link
Copy Markdown

UC_M68K_REG_CR_VBR is declared in m68k.h, but neither reg_read nor reg_write in qemu/target/m68k/unicorn.c handled it. Accesses were a no-op that printed the deprecation warning ("Your register accessing on id 21 is deprecated…"). Setting the vector base therefore had no effect: exceptions and movec %vbr used whatever env->vbr held, and the value could not be read back. Both accessors now map it to env->vbr, unmasked, which is how QEMU's movec helpers treat it.

test_vbr in tests/unit/test_m68k.c runs on an M68040 in supervisor mode. It writes VBR through the API and reads it back. It then runs movec %vbr, %d0 to check that the CPU sees that value, and movec %d1, %vbr to check that a value the CPU writes can be read through the API.

Without the change, all three checks fail (and the warning is printed). With it, test_m68k passes. Built with UNICORN_ARCH=m68k.

I found this with a scan that round-trips every UC_*_REG_* id of each architecture through uc_reg_write/uc_reg_read on current dev. Apart from register fields that are masked by design, VBR was the m68k register that didn't round-trip.

UC_M68K_REG_CR_VBR is declared but neither reg_read nor reg_write handled it, so accesses were a no-op (with the deprecation warning) and exceptions used whatever vector base the CPU had.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant