-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shannon: Cortex-A Support (e.g S5123) #8
Comments
Hi! Thanks for your interest in FirmWire. Naturally, we would be very interested in also supporting 5G modems. For the quote you are referring to: This initial assessment was purely based on static analysis, and we could confirm that the core structure of the baseband RTOS did not change significantly. |
hi all I'd be happy to contribute and work together on Cortex-A support, I'll be allocating time for a PoC post-REcon. |
@guysrd awesome! we would be happy to work with you to get this supported. here's a rough list of all of the things off the top of my head that need to be changed to bring Cortex-A support.
|
Hi @grant-h see you soon |
Hi! Any update on this issue? This is something I would like to take a look at as well. I happily discuss it further. |
Hi! Thanks for your hard work! |
The firmware would need to be emulated using aarch64 but in ARM execution mode. I also had the same question regarding starting in ARM mode instead of aarch64. Someone with more panda/qemu experience can likely quickly answer this one |
Hi! Disabling QEMU A64 mode (and thus start in a32) only works with KVM enabled, which is not what we want. (https://qemu-project.gitlab.io/qemu/system/arm/cpu-features.html) Setting the AA64nAA32 signal did not work in qemu, nor did setting the reset management register and reboot work. (If you run into gdb showing wrong register values, that can be fixed by synchronizing the A64 QEMU registers with A32 before reading the registers via gdb) Once I got more time I will continue with the emulation of the S5123 |
Do you have any ideas to solve it? I also have the same question regarding starting in ARM mode instead of aarch64 on the Cortex-a55. Please let me know if you have good ideas. |
Hi, I looked at this issue and would like contribute. AFAIK, the S5123AP is compiled for ARMv8 architecture in AArch32 state. On the other hand, the ARM target in Panda has not been updated since 2021, and as mentioned in other comments above, the most recent QEMU supports AArch32 only when using the KVM accelerator which might not be an option for our purpose. I tried emulating an S5123AP baseband using the current ARM target (I think it supports ARMv7 ISA). The problem is there are some new instructions that the current ARM target cannot translate. For example, here is an undefined instruction in QEMU debug (
Ghidra disassembler (Language:
From what I have seen, the rest of new instructions that cause the emulator (in ARM mode) to raise undefined instruction exception are coprocessor instructions. Do you have any suggestions on how to proceed with this issue? Thanks. |
Hi, Sorry for the delay in responding. Great to hear that you are making progress on it! I wonder if changing the Arm Target for avatar/panda could already solve the issue, as it may bring the correct feature flags to the CPU definition used by panda. Either way, to add additional instruction, you'd need to modify the target/arm/translate.c file. Also note that this translation and the disassembler of QEMU/Panda are two independent modules; Hence, even if in_asm shows undefined, it may be that the instruction is executed under the hood. Right now, I'm unfortunately rather busy and can't look into this myself; nonetheless, is there somewhere a private/public fork I could look at to help once the time has come? |
@mariusmue thank you. I agree with updating the Arm Target. I have a private fork. I will push my changes in the next few days and let you know. |
I did the following: Add CPU definitions to panda. See also https://github.com/Michel-de-Boer-dev/panda/tree/AArch64, although it is quite a mess. I am not sure how many ARMv8.x features are used, but porting all instructions seems to be quite a lot of work. Instead, If you have any questions feel free to send a DM. |
Thx very much for the tips. I am also researching how to make firmwire support S5xxx shannon firmware. |
Hi @liuyb1988, I mostly found it by reading the ARM documentation and applying it myself. Injection of the assembly code is done in firmwire itself. When initializing Panda/Avatar, I added a new memory range, copy the assembly code there, then set the program counter to that memory. However, A LOT of work is needed before S5xxx is fully supported. Given the amount of people interested in this, I am planning on continuing developing and researching this topic with a team after I finish my current baseband research. Yours sincerely, |
@Michel-de-Boer-dev Yours sincerely |
@Michel-de-Boer-dev |
Edit: Original message: |
Awesome work. Switching to Aarch32 by modifying the qemu code seems like a good idea indeed. I would love to hear more about your research, or discuss possible ways to team up. |
How is the progress on this ticket going? -- I'd be happy to help out however I can to help speed things up since I'm interested in using this tool in the near future. Is the main consesus (If I'm understanding correctly) that the newer generation shannon modems run on aarch32 variant that doesnt play nicely with QEMU? |
The current generation indeed uses aarch32, which is supported in upstream QEMU, and already has been ported partly in my fork. Booting in Aarch32 also kind of works, but not all instructions are supported (especially the armv8.2 stuff). A lot of reversing and porting peripherals is still needed. I am not sure of the progress from @n0123maker and @Hackheadache. I would love to get into contact with them to ensure we can prevent working on the same thing in parallel, doing double work. For what would you like to use the tool in the near future? Yours sincerely, |
Hi @Michel-de-Boer-dev , Okay that sounds good. Yeah as soon the the work that has already been done between the three of you has already been identified I'd definitely be interested in helping with porting. I'm interested in looking at the newer Shannon 5G modems that seem to not be compatible with Firmwire atm. I'm particularly interested in having some runtime introspection as most of my research is centered around static analysis, which is very slow and painstaking. |
Unfortunately I haven't been able to make some progress lately. I basically made it until the point the Virtual Memory System is being set up in the boot code. I saw you already parsed some structures regarding this topic. Best regards. |
Thanks for your hard work.
I could see the below information from your paper, but I couldn't find the suporting S5123 chipset in FirmWire.
"Supporting 5G Basebands. During our research, we also performed an initial assessment of Samsung’s 5G modem (the S5123 chipset)."
Do you have any plan to update for supporting S5123 chipset including cortex-A seriese?
The text was updated successfully, but these errors were encountered: