Advertisement

High-Performance RISC-V Emulation

  • Leandro LuporiEmail author
  • Vanderson Martins do RosarioEmail author
  • Edson BorinEmail author
Conference paper
  • 23 Downloads
Part of the Communications in Computer and Information Science book series (CCIS, volume 1171)

Abstract

RISC-V is an open ISA that has been calling the attention worldwide by its fast growth and adoption. It is already supported by GCC, Clang and the Linux Kernel. However, none of the currently available RISC-V emulators are capable of providing good, near-native, emulation performance. Thus, in this work, we investigate if faster emulators for RISC-V could be created. Since Dynamic Binary Translation (DBT) is the most common, and fastest, technique to implement emulators, we focus our investigation on the quality of the translated code, arguably the most important source of overhead when emulating code with DBT. To this end, we implemented and evaluated a LLVM-based Static Binary Translation (SBT) engine to investigate whether or not it is possible to produce high-quality translations from RISC-V to x86 and ARM. We explored different translation techniques and managed to design an SBT engine that produces translated code that is only 1.2x/1.3x slower than native x86/ARM code, which supports the claim that it is possible to build near-native RISC-V emulators for x86 and ARM hosts. We also analyze the main sources of overheads, compare the code produced by our SBT against the code produced by a popular DBT and provide insights on the potential performance impact of the proposed techniques on DBTs.

Keywords

RISC-V Binary translation LLVM Emulation 

Notes

Acknowledgments

We would like to thank CNPq (Grant #: 313012/2017-2), CAPES (PROCAD 2966/2014), and the São Paulo Research Foundation, FAPESP (Grant #: 2013/08293-7) for supporting this research.

References

  1. 1.
    Auler, R., Borin, E.: The case for flexible ISAs: unleashing hardware and software. In: SBAC-PAD 2017 (2017)Google Scholar
  2. 2.
    Baraz, L., et al.: IA-32 execution layer: a two-phase dynamic translator designed to support IA-32 applications on Itanium®-based systems. In: 36th MICRO (2003)Google Scholar
  3. 3.
    Bellard, F.: TinyEMU. https://bellard.org/tinyemu. Accessed 27 Oct 2018
  4. 4.
    Bellard, F.: QEMU, a fast and portable dynamic translator. In: USENIX, FREENIX Track (2005)Google Scholar
  5. 5.
    Böhm, I., von Koch, T.J.E., Kyle, S.C., Franke, B., Topham, N.: Generalized just-in-time trace compilation using a parallel task farm in a dynamic binary translator. ACM SIGPLAN Not. 46(6), 74–85 (2011)CrossRefGoogle Scholar
  6. 6.
    Borin, E., Wu, Y.: Characterization of DBT overhead. In: 2009 IEEE International Symposium on Workload Characterization (2009)Google Scholar
  7. 7.
    Cesar, D., Auler, R., Dalibera, R., Rigo, S., Borin, E., Araujo, G.: Modeling virtual machines misprediction overhead. In: 2013 IISWC (2013)Google Scholar
  8. 8.
    Cifuentes, C., Malhotra, V.M.: Binary translation: static, dynamic, retargetable? In: ICSM (1996)Google Scholar
  9. 9.
    Clark, M., Hoult, B.: rv8: a high performance RISC-V to x86 binary translator. In: 1st CARRV (2017)Google Scholar
  10. 10.
    RISC-V Foundation. http://riscv.org/risc-v-foundation. Accessed 21 Oct 2018
  11. 11.
    RISC-V Foundation: RISC-V QEMU. https://github.com/riscv/riscv-qemu. Accessed 21 Oct 2018
  12. 12.
    RISC-V Foundation: RISCV-angel. https://github.com/riscv/riscv-angel. Accessed 24 Oct 2019
  13. 13.
    RISC-V Foundation: Spike RISC-V ISA simulator. https://github.com/riscv/riscv-isa-sim. Accessed 24 Jan 2019
  14. 14.
    Gomes, G.F.T., Borin, E.: Indirect branch emulation techniques in virtual machines. Dissertation, University of Campinas (2014)Google Scholar
  15. 15.
    Guthaus, M.R., Ringenberg, J.S., Ernst, D., Austin, T.M., Mudge, T., Brown, R.B.: Mibench: a free, commercially representative embedded benchmark suite. In: WWC-4 (2001)Google Scholar
  16. 16.
    Hong, D.Y., et al.: HQEMU: a multi-threaded and retargetable dynamic binary translator on multicores. In: CGO 2012 (2012)Google Scholar
  17. 17.
    Ilbeyi, B., Lockhart, D., Batten, C.: Pydgin for RISC-V: a fast and productive instruction-set simulator. In: 3rd CARRV (2016)Google Scholar
  18. 18.
    Lawton, K.P.: Bochs: a portable PC emulator for Unix/x. Linux J. 1996(29es), 7 (1996)Google Scholar
  19. 19.
    Lupori, L., do Rosario, V.M., Borin, E.: Towards a high-performance RISC-V emulator. In: WSCAD 2018 (2018)Google Scholar
  20. 20.
    Probst, M.: Dynamic binary translation. In: UKUUG (2002)Google Scholar
  21. 21.
    Roelke, A., Stan, M.R.: RISC5: implementing the RISC-V ISA in Gem5. In: 1st CARRV (2017)Google Scholar
  22. 22.
    Salgado, F., Gomes, T., Pinto, S., Cabral, J., Tavares, A.: Condition codes evaluation on dynamic binary translation for embedded platforms. IEEE Embed. Syst. Lett. 9(3), 89–92 (2017)CrossRefGoogle Scholar
  23. 23.
    Shen, B.Y., Chen, J.Y., Hsu, W.C., Yang, W.: LLBT: an LLVM-based static binary translator. In: CASES 2012 (2012)Google Scholar
  24. 24.
    Smith, J., Nair, R.: Virtual Machines: Versatile Platforms for Systems and Processes. Elsevier, Amsterdam (2005)zbMATHGoogle Scholar
  25. 25.
    Imperas Software: Imperas RISC-V solutions. https://www.imperas.com/imperas-riscv-solutions. Accessed 02 Dec 2018
  26. 26.
    Imperas Software: OVP simulator for RISC-V. https://github.com/riscv/riscv-ovpsim. Accessed 02 Dec 2018
  27. 27.
    Ta, T., Cheng, L., Batten, C.: Simulating multi-core RISC-V systems in Gem5. In: 1st CARRV (2018)Google Scholar
  28. 28.
    Waterman, A., Lee, Y., Patterson, D.A., Asanovi, K.: The RISC-V instruction set manual. Volume 1: user-level ISA, version 2.0. Technical report, EECS Department, University of California, Berkeley (2014)Google Scholar
  29. 29.
    Zhang, X., Guo, Q., Chen, Y., Chen, T., Hu, W.: HERMES: a fast cross-ISA binary translator with post-optimization. In: CG0 2015 (2015)Google Scholar

Copyright information

© Springer Nature Switzerland AG 2020

Authors and Affiliations

  1. 1.Institute of ComputingUNICAMPCampinasBrazil

Personalised recommendations