· 3 min read · Gaia Lab

Guessing an instruction set blind

Inside the modem there are several DSPs with no manual. We reconstructed their instruction repertoire from static analysis alone and brought it to radare2.

Inside the modem, besides the main processor, there are several DSPs. They do the heavy work of the physical layer: filtering, channel estimation, decoding. And for the largest of them there is no public instruction manual. Nor did we have a board on which to run its code.

The question was easy to state and hard to answer: can you work out what each instruction does by looking only at the bytes?

A corpus, not a handful of examples #

The first thing was to build the corpus: cut the binary into functions and the functions into 16-bit units. Ours had 5,392 functions, 1.39 million units and 471,907 instruction packets. Everything that came later was measured on the whole corpus, not on hand-picked examples. A rule that works on ten instructions is an anecdote; on 780,000 it is a fact.

Three oracles #

Without being able to run the code, the only way to validate a hypothesis is to check it against something independent. We had three:

  • The symbol table that ships with the firmware: name, start and end of each function. Thousands of functions with a known outline.
  • Known source code: the modem’s C library is newlib, which is open, and several voice codecs are public reference. For strlen, malloc or a codec we know what the compiler asked for.
  • A second build of the same firmware for another device: the same code at other addresses.

How a hypothesis is tested #

The first finding was not semantic but structural: it is a VLIW machine, several operations packed together and executed in parallel, and a bit in each unit marks “here the packet closes”. How do you prove that without a manual? With an oracle: branches must land at the start of a packet. With that rule, 98% of jump targets land on a boundary; cutting at random, 60%. That difference is the proof.

Every form that entered the table carries its confidence level, and the document explains which oracle backs it.

The result #

All of this lives in a radare2 plugin that adds the modem architectures, with their instruction tables and their disassembler. The whole method —and the numbers— is published in case anyone wants to argue with the inference: How did we infer the ISA? .

With the repertoire in hand, the DSP stopped being a blob and became code that can be read. And there the last idea of the series appeared.

Final instalment: an SDR inside the phone.

Glossary #

  • DSP (Digital Signal Processor): a processor specialised in signal computation: filters, correlations, decoding.
  • VLIW (Very Long Instruction Word): an architecture that packs several operations into one instruction and runs them in parallel.
  • ISA (Instruction Set Architecture): a processor’s instruction repertoire: which operations it understands and how they are encoded.
  • newlib : a small C library, common in device firmware.
  • codec : an algorithm that compresses and decompresses voice or video.