NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.3k stars 5.84k forks source link

SVD file parser or converter to pspec #728

Open fanoush opened 5 years ago

fanoush commented 5 years ago

Is your feature request related to a problem? Please describe. There are many ARM SoCs with many hardware registers which is impossible to support in ghidra. However there is often standardized SVD description file with all the info for specific chip, e.g. nordic semiconductor has this as part of SDK see SVD files in https://github.com/NordicSemiconductor/nrfx/tree/master/mdk also more info here https://www.keil.com/pack/doc/CMSIS/SVD/html/svd_Format_pg.html https://github.com/ARM-software/CMSIS_5/tree/develop/Device/ARM

Describe the solution you'd like Either ghidra could load SVD file directly or there could be converter to pspec file, not sure which one makes better sense or is easier.

esaulenka commented 5 years ago

FYI: there is a lot of SVD files: https://github.com/posborne/cmsis-svd

emteere commented 5 years ago

I like the idea of parsing the SVD files directly for ARM. Are the SVD files used for any other processors, or just ARM? Extracting the information into PSPEC files seems reasonable as the all the information for the variants and the number of pspec files aren't too large. The information could get stale if it was extracted, and the license on the data would have to allow including it in a distribution.

Having an analyzer that reads the database directly along with a script to load an individual SVD might be another way to go. The analyzer would need a way to identify or set the variant automatically, which would be problematic.

There has been discussions about using the data type archive to house some of this information as well. Variants of the OS and syscall numbers across kernel versions have similar issues with variant explosion, although the SVD information is still more closely tied to the processor.

fanoush commented 5 years ago

Are the SVD files used for any other processors, or just ARM

I suppose just ARM Cortex ones as CMSIS-SVD means Cortex Microcontroller Software Interface Standard - System View Description. Also here https://www.keil.com/pack/doc/CMSIS/SVD/html/index.html it says

The CMSIS System View Description format(CMSIS-SVD) formalizes the description of the system contained in Arm Cortex-M processor-based microcontrollers, in particular, the memory mapped registers of peripherals. The detail contained in system view descriptions is comparable to the data in device reference manuals. The information ranges from high level functional descriptions of a peripheral all the way down to the definition and purpose of an individual bit field in a memory mapped register.

mumbel commented 5 years ago

https://leveldown.de/blog/svd-loader/

https://github.com/leveldown-security/SVD-Loader-Ghidra

mumbel commented 4 years ago

https://www.youtube.com/watch?v=ImSXkn3GAE8

"PERCH is a tool that adds a new peripheral layer to Ghidra. The parsing of Trace32's .per files enables the augmentation of Ghidra projects with labeled MMIO mappings from thousands of different processors."