capstone icon indicating copy to clipboard operation
capstone copied to clipboard

SKIPDATA default length for SYSZ

Open rth7680 opened this issue 6 years ago • 7 comments

The length of a SystemZ instruction is encoded into the top two bits of the first byte of the instruction. The fact that SYSZ skips exactly two bytes for an unknown instruction is less than ideal, and means that we are then out of sync with the intended instruction stream.

rth7680 avatar May 23 '19 02:05 rth7680

This option is to skip data, with assumption that we can decode all instructions.

So change this to 1 byte would fix the problem? Please PR then.

aquynh avatar May 23 '19 02:05 aquynh

There will always be instructions that are new and thus unknown. There are even system specific instructions in use by the Linux kernel which are caught ought by this.

rth7680 avatar May 23 '19 03:05 rth7680

Still, if the instruction size is unknown, we should set this to 1, like in the case of x86.

Please provide the Sysz instruction you mentioned, i will look into it.

aquynh avatar May 23 '19 03:05 aquynh

The size is not unknown, it's in the top two bits of the instruction. Examples include .byte 0xb2, 0x20, 0x00, 0x21 // servc, RRE format, "SCLP service call" .byte 0xb2, 0x5f, 0x00, 0x30 // chsc, RRE format, "CHSC subchannel present on LPAR" .byte 0xeb, 0x24, 0x30, 0x00, 0x00, 0xd1 // sic, RSY(a) format. No docs I can find, but Linux uses it.

rth7680 avatar May 23 '19 03:05 rth7680

What if that is actually data?

aquynh avatar May 23 '19 03:05 aquynh

If it's actually data, then we output e.g. 4 bytes on one .byte line instead of two. No data is lost or omitted.

rth7680 avatar May 23 '19 03:05 rth7680

But if it is not data, and we only skip two bytes, then the next instruction we decode will start in the middle of the previous instruction and we are out of sync with the intended instruction stream. This can make it very hard to figure out what happens after the unknown instruction.

rth7680 avatar May 23 '19 03:05 rth7680