2022-01-21 04:15:36 +00:00
|
|
|
# Jacking (Jazelle hacking (Jean gazelle hacking))
|
|
|
|
|
|
|
|
**Jazelle reverse engineering effort**
|
|
|
|
|
|
|
|
not the first one, but hopefully one that properly documents some stuff
|
|
|
|
|
|
|
|
## Workflow
|
|
|
|
|
2022-01-29 20:25:33 +00:00
|
|
|
### Cypress FX3
|
2022-01-21 04:15:36 +00:00
|
|
|
|
|
|
|
```
|
2022-01-29 20:25:33 +00:00
|
|
|
$ # compile:
|
2022-01-21 04:15:36 +00:00
|
|
|
$ make
|
2022-01-29 20:25:33 +00:00
|
|
|
$ # launch OpenOCD background process (needs to be done once):
|
|
|
|
$ make openocd-launch
|
|
|
|
$ # run & debug code
|
|
|
|
$ make openocd-load && make gdb
|
2022-01-21 04:15:36 +00:00
|
|
|
```
|
|
|
|
|
2022-01-29 20:25:33 +00:00
|
|
|
Needs an `arm-none-eabi` toolchain, and OpenOCD.
|
|
|
|
|
|
|
|
### Raspberry Pi v1.x bare-metal
|
|
|
|
|
|
|
|
```
|
|
|
|
$ # compile:
|
|
|
|
$ make -C rpi/
|
|
|
|
$ # now copy rpi/rpi.img to your microSD card and name it "kernel.img".
|
|
|
|
$ # alternatively, use OpenOCD again:
|
|
|
|
$ make launch-openocd
|
|
|
|
$ make openocd-load && make gdb
|
|
|
|
```
|
|
|
|
|
|
|
|
Needs an `arm-none-eabi` toolchain, and optionally OpenOCD. Output is written
|
|
|
|
to the UART on pin 8 (TX).
|
|
|
|
|
|
|
|
Most likely won't work on a v2 or higher.
|
2022-01-21 04:15:36 +00:00
|
|
|
|
2022-01-29 20:25:33 +00:00
|
|
|
### Linux userspace
|
2022-01-21 04:15:36 +00:00
|
|
|
|
2022-01-29 20:25:33 +00:00
|
|
|
Currently only tested on a Raspberry Pi v1.2 B+. May also work on Linux running
|
|
|
|
on a Zynq.
|
2022-01-21 04:15:36 +00:00
|
|
|
|
|
|
|
```
|
2022-01-29 20:25:33 +00:00
|
|
|
$ # native compilation:
|
|
|
|
CFLAGS=-mtune=native make -C linux
|
|
|
|
$ # cross-compilation: (change the -march depending on your target)
|
|
|
|
CC=arm-linux-gnueabihf-gcc CFLAGS=-march=arm1176jzf-s make -C linux
|
|
|
|
$ # run it
|
|
|
|
$ linux/jazelle
|
2022-01-21 04:15:36 +00:00
|
|
|
```
|
|
|
|
|
2022-01-29 20:25:33 +00:00
|
|
|
Requires an `arm-linux-gnueabihf` toolchain.
|
|
|
|
|
|
|
|
### Xilinx Zynq bare-metal
|
|
|
|
|
|
|
|
***NOTE: HIGHLY EXPERIMENTAL!***
|
2022-01-21 04:15:36 +00:00
|
|
|
|
|
|
|
```
|
2022-01-29 20:25:33 +00:00
|
|
|
$ make -C zynq jazelle.o
|
2022-01-21 04:15:36 +00:00
|
|
|
```
|
|
|
|
|
2022-01-29 20:25:33 +00:00
|
|
|
Then link `zynq/jazelle.o` into an XSDK/Vitis project. If things break, the
|
|
|
|
first thing you should try is replacing the cache routines with the ones from
|
|
|
|
the Xilinx libraries.
|
|
|
|
|
|
|
|
Requires an `arm-none-eabi` toolchain.
|
|
|
|
|
|
|
|
### Other ports
|
|
|
|
|
|
|
|
There are still several platforms out there which (most likely) can also run
|
|
|
|
Jazelle, but that don't have a port yet. See the [TODO](#TODO) header.
|
|
|
|
|
2022-01-21 04:15:36 +00:00
|
|
|
## Credits
|
|
|
|
|
|
|
|
FX3 base code: gratuitously stolen from https://github.com/zeldin/fx3lafw/
|
|
|
|
|
2022-01-29 20:25:33 +00:00
|
|
|
Cache manipulation code was inspired by code from libnds (ARM9), libn3ds
|
|
|
|
(ARM11), and Xilinx' embeddedsw (Cortex-A9).
|
|
|
|
|
2022-01-21 04:15:36 +00:00
|
|
|
Jazelle info this project is based on:
|
|
|
|
* https://hackspire.org/index.php/Jazelle
|
|
|
|
* https://github.com/SonoSooS/libjz
|
2022-01-21 04:19:51 +00:00
|
|
|
|
|
|
|
## TODO
|
|
|
|
|
|
|
|
* Figure out Jazelle stuff:
|
2022-01-22 01:16:16 +00:00
|
|
|
* [ ] Which bytecode instructions are supported on which Jazelle versions?
|
|
|
|
* [x] How exactly does the stack work? (When a handler function is being called)
|
|
|
|
* [ ] How exactly does the Jazelle status register work?
|
|
|
|
* [ ] What control registers are there that influence the execution?
|
|
|
|
* [ ] Is it possible to force execute a certain instruction using the handler
|
|
|
|
instead of the default in-hardware execution?
|
2022-01-29 20:25:33 +00:00
|
|
|
* Apparently not?
|
2022-01-22 01:16:16 +00:00
|
|
|
* [ ] ...
|
2022-01-29 20:25:33 +00:00
|
|
|
* [x] How does one call regular ARM/Thumb code from inside Jazelle?
|
|
|
|
* invokeXYZ instruction implementation: check method reference string, do
|
|
|
|
things based on that
|
2022-01-22 01:16:16 +00:00
|
|
|
* [ ] ...
|
|
|
|
* [ ] Verify what Hackspire and libjz have, to check if it is correct
|
|
|
|
* [ ] Look at what Hackspire and libjz don't have and try to complete it
|
2022-01-29 20:25:33 +00:00
|
|
|
* Ports:
|
|
|
|
* [ ] TI Nspire
|
|
|
|
* [x] Cypress FX3
|
|
|
|
* [x] Raspberry Pi v1 baremetal
|
|
|
|
* [x] Linux userspace
|
|
|
|
* [ ] Linux kernel module
|
|
|
|
* [ ] 3DS homebrew
|
|
|
|
* [ ] Xilinx Zynq
|
|
|
|
* [ ] BeagleBoard/BeagleBone/PocketBeagle? (any OMAP or TI Sitara AM335x,
|
|
|
|
most likely not the AM572x-based ones, and definitely not the BeagleV)
|
|
|
|
* ...
|