5 ms·
Associated GitHub repository with more information: https://github.com/cattius/opcodetester https://github.com/cattius/opcodetester I know next to nothing abou
by saagarjha 7y ago
Associated GitHub repository with more information: https://github.com/cattius/opcodetester https://github.com/cattius/opcodetester
I know next to nothing about processors at this level, but I wonder if it would be possible for a skilled engineer to try to find these instructions by scrutinizing the actual physical instruction decoder on the chip and/or inspect the processor's microcode. Are these things possible to do? If they are, is it feasible to reverse engineer them?
- jfkebwjsbx 7y agoTheoretically possible, practically impossible. For two reasons: the equipment needed (extremely expensive) and the complexity of the task (transistors are placed by software, not humans anymore).
- saagarjha 7y agoWhat kind of complexity are we looking at, roughly? Surely someone with deep pockets and the necessary expertise would be interested in trying to find these kinds of things, no?
- jfkebwjsbx 7y agoI am no EE, but even if you had the tools it is harder than reverse engineering any software. At least with software you can go step by step and inspect the memory at the very least. With hardware you would have to take into account the entire chip state and routing.
- alxlaz 7y agoA modern CPU has a transistor count in the billions/low tens of billions. I haven't really thought about it but I'm tempted to say that looking at the decoder stage(s) alone won't do. Undocumented operation doesn't have to be in the form of an entire undocumented instruction. You could design the device so that the "right thing" would happen simply by scheduling the right instruction, with the right arguments, under the right conditions (the right execution unit, the right amount of pipeline clog etc.). The whole thing is significantly more complex than the "fetch-decode-execute" diagrams would have you believe -- execution isn't strictly sequential, executing exactly the same instruction won't cause the exact same transistors to "fire" each time etc.. So the level of complexity is pretty daunting. IMHO if you want to find out undocumented behaviour that was deliberately introduced, you're better off looking at other methods, no matter how deep your pockets are.
- dmitrygr 7y ago> A modern CPU has a transistor count in the billions/low tens of billions A large percentage of that is simply 6T/cell SRAM L1/L2/etc cache though
- alxlaz 7y agoCertainly. But even those can be routed so that the WR signal for a particular address also doubles as half of the AND input which causes a read from another range to always return zero, for example. (That's not an "undocumented opcode", of course, but it can be used maliciously). It's certainly not easy to do this kind of meaningful obfuscation though, especially between different blocks, since different blocks are usually in different clock domains, too. Edit: sorry, my neurons got all jumbled and I was thinking of a far more general case, i.e. undocumented behaviour in general, not just undocumented instructions. Indeed, only a relatively small subset of all these transistors is relevant in terms of undocumented instructions specifically.
- deleted 7y ago[deleted]
- userbinator 7y agotransistors are placed by software, not humans anymore If anything I'd say that makes it even easier to reverse-engineer, since the layout is far more regular. There are some public tools to do this already - here's one that immediately comes to mind: https://degate.org/ https://degate.org/
- caleb-allen 7y agoThis was also linked elsewhere but a security researcher was able to identify a significant number of undocumented instructions: https://www.youtube.com/watch?v=KrksBdWcZgQ https://www.youtube.com/watch?v=KrksBdWcZgQ
- cat_easdon 7y agoA team from Ruhr University Bochum reverse-engineered the microcode for the AMD K8 and K10 to implement custom microcode programs, they describe how they reverse-engineered the ROM here: https://www.syssec.ruhr-uni-bochum.de/media/emma/veroeffentlichungen/2018/08/20/constructive_ucode-CCS18.pdf https://www.syssec.ruhr-uni-bochum.de/media/emma/veroeffentl.... The problem with reverse-engineering on newer CPUs is that on both Intel and AMD the updates are now protected with cryptographic authentication, so you can't run arbitrary custom microcode to aid in understanding what it does. And as others have mentioned, the hardware complexity and small feature sizes make reverse-engineering the microcode engine or ROM by physical inspection much harder than on the K8. I expect it will be achieved at some point, though.
- jfkebwjsbx 7y agoEven if you manage to understand the microcode, there could be custom behavior in the hardware logic, right? So I would guess studying the microcode does not lead to proving there is nothing else going on. I am no EE, though.
- cat_easdon 7y agoYeah, that's right - you could prove the absence of malicious microcode, but not the absence of hardware trojans, implants, etc. There are also the embedded microcontrollers to deal with (e.g. the Management Engine, Innovation Engine, and Power Management Controller on Intel).
- paulmd 7y agoRyzenfall and Masterkey together provide a complete break of the PSP authentication with arbitrary code execution if you are running a vulnerable AGESA. You will of course have to flash downwards to a vulnerable version but it should give you what you need. Also, as this was fixed prior to Zen2 then you wouldn’t be able to test their newer chips. Basically AMD has a buffer overflow in a SMM call and they conveniently signed an empty PSP module payload that will be executed nevertheless. https://youtu.be/QuqefIZrRWc https://youtu.be/QuqefIZrRWc
- CodeArtisan 7y agoYes it is, see https://arstechnica.com/gaming/2017/07/mame-devs-are-cracking-open-arcade-chips-to-get-around-drm/ https://arstechnica.com/gaming/2017/07/mame-devs-are-crackin... or http://www.visual6502.org/ http://www.visual6502.org/ but next CPUs will have vertically stacked circuitry making reverse engineering much more harder (impossible?). https://en.wikipedia.org/wiki/Three-dimensional_integrated_circuit https://en.wikipedia.org/wiki/Three-dimensional_integrated_c... https://en.wikichip.org/wiki/intel/foveros https://en.wikichip.org/wiki/intel/foveros
- yjftsjthsd-h 7y agoWhy would stacking layers make it impossible? The process will be destructive, but I would expect it to work.
- plutonorm 7y agoHow would you ensure you only etched away the layers you were interested in?
- userbinator 7y agoIt's already possible to delayer pretty accurately --- see the visual6502 project linked above.
- deleted 7y ago[deleted]