Go to file
Yu Yin de89896908 LATX, fix: add TCSETS2.
This is a supplement to commit 0033e7f:

    LATX, fix: add TCGETS2 and HIDRAW* ioctls~
2025-07-30 20:01:40 -07:00
.github Build(deps): Bump actions/attest-build-provenance from 2.3.0 to 2.4.0 2025-06-12 19:50:21 +08:00
accel LATX, fix: Remove TU_UNLINK_STUB_INVALID 2025-07-08 18:56:22 +08:00
authz authz-simple: Check that 'identity' property is set 2020-11-18 10:51:35 +00:00
crypto LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
default-configs hw/ppc: Add emulation of Genesi/bPlan Pegasos II 2021-05-04 11:41:25 +10:00
disas LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
docs LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
fpu LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
hw LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
include LATX, fix: Remove TU_UNLINK_STUB_INVALID 2025-07-08 18:56:22 +08:00
latxbuild LATX, feat: Add low memory mode. 2025-07-07 15:46:34 +08:00
linux-headers LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
linux-user LATX, fix: add TCSETS2. 2025-07-30 20:01:40 -07:00
meson@5685dc35f0 LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
nbd nbd: server: Report holes for raw images 2021-03-08 13:08:45 -06:00
plugins LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
python Python: close the log file kept by QEMUMachine before reading it 2021-02-15 21:40:16 -05:00
qapi LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
qobject LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
qom LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
scripts scripts: fix generation update-binfmts templates 2021-05-03 10:07:41 +02:00
scsi scsi: fix sense code for EREMOTEIO 2021-03-16 14:30:30 -04:00
semihosting Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
storage-daemon qsd: Document FUSE exports 2021-03-29 18:28:33 +02:00
stubs LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
subprojects/libvhost-user LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
target LATX, fix: fix ptn cdq idiv 2025-07-21 18:33:36 -07:00
tcg LATX, feat: Using adaptive code buffer in low memory mode. 2025-07-08 11:39:23 +08:00
trace LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
util LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
.cirrus.yml cirrus.yml: Update the FreeBSD task to version 12.2 2021-03-24 14:25:34 +00:00
.dir-locals.el Add .dir-locals.el file to configure emacs coding style 2015-10-08 19:46:01 +03:00
.editorconfig .editorconfig: update the automatic mode setting for Emacs 2021-03-10 15:34:11 +00:00
.exrc qemu: add .exrc 2012-09-07 09:02:44 +03:00
.gdbinit .gdbinit: load QEMU sub-commands when gdb starts 2017-06-07 14:38:45 +01:00
.gitattributes maint: Tell git that *.py files should use python diff hunks 2021-02-15 22:13:34 -05:00
.gitignore feat: Try to use Github Actions 2025-05-16 09:21:20 +08:00
.gitmodules LATX, clean: Remove some submodules from configure 2025-03-28 11:15:10 +08:00
.gitpublish Add a git-publish configuration file 2018-03-05 09:03:17 +00:00
.mailmap MAINTAINERS: chenhc@lemote.com -> chenhuacai@kernel.org 2020-12-13 16:00:58 +01:00
.patchew.yml ci: store Patchew configuration in the tree 2019-06-03 14:03:02 +02:00
.readthedocs.yml readthedocs: build with Python 3.6 2020-10-05 16:30:45 +01:00
.travis.yml travis.yml: Limit simultaneous jobs to 3 2021-02-19 06:31:40 +01:00
COPYING COPYING: update from FSF 2008-10-12 17:54:42 +00:00
COPYING.LIB COPYING.LIB: Synchronize the LGPL 2.1 with the version from gnu.org 2019-01-30 11:01:22 +01:00
Kconfig semihosting: Move hw/semihosting/ -> semihosting/ 2021-03-10 15:34:12 +00:00
Kconfig.host multi-process: Add config option for multi-process QEMU 2021-02-09 20:53:56 +00:00
LICENSE tcg/LICENSE: Remove out of date claim about TCG subdirectory licensing 2019-11-11 15:11:21 +01:00
MAINTAINERS ppc patch queue 2021-05-04 2021-05-05 20:29:14 +01:00
Makefile LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
README.en.rst LATX, doc: update README with AOSC package requirements 2025-07-20 19:58:11 -07:00
README.rst LATX, doc: update README with AOSC package requirements 2025-07-20 19:58:11 -07:00
VERSION LATX Version 1.6.1 2025-05-09 15:16:47 +08:00
block.c Do not include sysemu/sysemu.h if it's not really necessary 2021-05-02 17:24:50 +02:00
blockdev-nbd.c qemu-nbd: Use SOMAXCONN for socket listen() backlog 2021-02-12 07:42:08 -06:00
blockdev.c block: bdrv_append(): don't consume reference 2021-04-30 12:27:47 +02:00
blockjob.c block: drop ctx argument from bdrv_root_attach_child 2021-04-30 12:27:47 +02:00
configure Add avx support 2025-07-07 17:48:40 +08:00
cpu.c LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
cpus-common.c overall/alpha tcg cpus|hppa: Fix Lesser GPL version number 2020-11-15 16:43:54 +01:00
disas.c LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
gdbstub.c Do not include sysemu/sysemu.h if it's not really necessary 2021-05-02 17:24:50 +02:00
gitdm.config contrib: gitdm: add a mapping for Janus Technologies 2019-03-12 19:31:29 +00:00
hmp-commands-info.hx migrate: remove QMP/HMP commands for speed, downtime and cache size 2021-03-18 09:22:55 +00:00
hmp-commands.hx block: Remove monitor command block_passwd 2021-03-23 22:31:56 +01:00
iothread.c multi-process: define MPQemuMsg format and transmission functions 2021-02-10 09:23:28 +00:00
job-qmp.c qapi: Use QAPI_LIST_APPEND in trivial cases 2021-01-28 08:08:45 +01:00
job.c job: Allow complete for jobs on standby 2021-04-09 18:00:29 +02:00
latx-new.lds LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
latx-x86_64-new.lds LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
latx-x86_64.lds LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
latx.lds LATX, init: LATX user-level binary translator 2025-03-21 15:26:22 +08:00
memory_ldst.c.inc fuzz: ignore address_space_map is_write flag 2021-02-08 14:43:54 +01:00
meson.build LATX, fix: keep HAVE_DRM_H to support drm ioctls 2025-06-03 14:25:28 +08:00
meson_options.txt build: Remove autogenerated version header and use meson option 2025-05-13 09:03:55 +08:00
module-common.c all: Clean up includes 2016-02-04 17:41:30 +00:00
os-posix.c os: deprecate the -enable-fips option and QEMU's FIPS enforcement 2021-01-29 17:07:53 +00:00
os-win32.c vl: relocate paths to data directories 2020-09-30 19:11:36 +02:00
page-vary-common.c exec: Build page-vary-common.c with -fno-lto 2021-03-23 19:36:47 -06:00
page-vary.c exec: Build page-vary-common.c with -fno-lto 2021-03-23 19:36:47 -06:00
qemu-bridge-helper.c qemu-bridge-helper: relocate path to default ACL 2020-09-30 19:11:36 +02:00
qemu-edid.c qemu-edid: drop cast 2020-10-14 06:05:56 +02:00
qemu-img-cmds.hx qemu-img: add support for rate limit in qemu-img convert 2020-10-27 15:26:20 +01:00
qemu-img.c qemu-img convert: Unshare write permission for source 2021-04-30 12:27:48 +02:00
qemu-io-cmds.c qemu-io: add preallocate mode parameter for truncate command 2020-12-18 12:35:55 +01:00
qemu-io.c qemu-io: Use user_creatable_process_cmdline() for --object 2021-03-19 10:17:14 +01:00
qemu-keymap.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
qemu-nbd.c qemu-nbd: Use user_creatable_process_cmdline() for --object 2021-03-19 10:17:14 +01:00
qemu-options-wrapper.h qemu-img: remove references to GEN_DOCS 2018-05-20 08:35:54 +03:00
qemu-options.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
qemu-options.hx docs: More precisely describe memory-backend-*::id's user 2021-05-03 10:07:41 +02:00
qemu.nsi nsis: adjust for new MinGW paths 2021-01-23 15:55:05 -05:00
qemu.sasl Default to GSSAPI (Kerberos) instead of DIGEST-MD5 for SASL 2017-05-09 14:41:47 +01:00
replication.c replication: Introduce new APIs to do replication operation 2016-09-13 11:00:56 +01:00
replication.h Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
thunk.c overall usermode...: Fix Lesser GPL version number 2020-11-15 16:43:40 +01:00
trace-events trace-events: Fix attribution of trace points to source 2020-09-09 17:17:58 +01:00
version.rc configure: remove CONFIG_FILEVERSION and CONFIG_PRODUCTVERSION 2021-01-02 21:03:37 +01:00

README.rst

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

===========
LATX (Loongson Architecture Translator for x86)
===========

LATXLoongson Architecture Translator for x86即龙芯 x86 架构转译器,是
一个面向 LoongArch 架构的高性能用户级二进制翻译器,用于在龙芯(龙架构)系
统上高效地运行 32/64 位 x86 应用程序。

LATX 基于 QEMU 6 版本开发并进行了深度优化,性能相比原生 QEMU 有显著提升。
项目利用龙架构的各指令集扩展(如向量扩展和二进制转译指令集)对 X86 指令集
进行了高效翻译并采用了AOTAhead-of-Time )预编译、运行时库直通等关键优
化技术,其中库直通优化思想借鉴及引用了 box64 项目的部分源码。


`See the English Version Here >> <README.en.rst>`_


项目背景
========

在 LoongArch 架构生态建设过程中,运行已有的 x86 程序存在兼容性和性能瓶颈,
原生 QEMU 等模拟器在性能和兼容性上并不能完全满足需求。因此,我们在 QEMU 6
的基础上进行了二次开发,通过引入预编译、库直通以及其他针对性优化,大幅减少
了指令翻译和执行的开销,努力实现“更快、更稳定、更兼容”的目标。

历史演进
========

项目历经多个开发阶段:

- **2021 年**:项目启动,完成 LATX 到 QEMU 6 的移植Q3 项目进入 Alpha 阶段。
- **2022 年**支持库直通等优化Q3 项目进入到 Beta 阶段。
- **2023 年**:持续完善系统调用等接口的支持,以及更细致的指令优化。
- **2024 年**:项目进入到 RC 阶段。


项目结构
========

**为保证历史代码呈现的更为简洁,我们在该仓库中将 LATX 的近两千次提交合并为一次提交。**

下面是本项目的主要目录结构:

.. code-block:: text

   lat
   ├── ...
   ├── latxbuild/                           # 编译脚本
   ├── target/
   │   └── i386/
   │       └── latx/
   │           └── context/                 # 库直通相关
   │           └── convert.py               # 生成 LA 指令函数模板
   │           └── ir1/
   │               └── ir1.c                # IR1x86 指令 IR 表示
   │           └── ir2/
   │               └── ir2.c                # IR2LA 指令 IR 表示
   │               └── ir2-relocate.c       # label 处理等逻辑
   │               └── la-append.c          # 项目编译后由 convert.py 生成
   │               └── ir2-assemble.c
   │           └── latx-options.c           # LATX 功能选项设置
   │           └── optimization/
   │               └── flag-reduction.c     # TB 内 eflags 消除优化
   │               └── hbr.c                # 寄存器高位计算优化
   │               └── imm-cache.c          # 立即数加载优化
   │               └── insts-pattern.c      # 语义级指令组合优化翻译
   │               └── ir1-optimization.c   # IR1 层面优化扫描函数
   │               └── ir2-optimization.c   # IR2 层面指令调度函数
   │               └── tu.c                 # TU 翻译单元优化
   │               └── ...
   │           └── sbt/                     # AOT 相关
   │           └── translator/              # 翻译函数
   │               └── tr-logic.c           # 逻辑运算指令翻译函数
   │               └── tr-arith.c           # 算术运算指令翻译函数
   │               └── ...
   │           └── wrapper/                 # 库直通相关
   │           └── ...
   ├── ...
   └── README.rst                           # 本文档


主要贡献人员
============

有非常多的伙伴对本项目的成长做出了贡献,下面是代码提交量 Top10 的贡献人员。

1. **Lu Zeng <luzeng87@gmail.com>**

   - 项目 Owner发起并领导着整体设计与架构
   - 推动性能优化的方案、评估与落地
   - 贡献众多兼容性与优化工作

2. **Hanlu Li <heuleehanlu@gmail.com>**

   - 项目 Maintainer
   - 16K 兼容方案影子页模块的作者
   - 贡献众多兼容性与优化工作

3. **Wenqiang Wei <weiwenqiang@mail.ustc.edu.cn>**

   - AOT 模块开发者之一,该模块的维护者
   - TU 优化开发者之一,该优化的维护者
   - 影子页模块维护者

4. **Jing Li <654224414@qq.com>**

   - AOT 早期开发者
   - 库直通模块维护者

5. **Qi Hu <spcreply@outlook.com>**

   - eflags 消除相关优化主要作者

6. **Yanzhi Lan <lanyanzhi19@mails.ucas.ac.cn>**

   - TU 优化开发者之一
   - 贡献很多指令级优化

7. **Chaoyi Liu <lcy285183897@gmail.com>**

   - insts-pattern 优化维护者
   - 指令级测试负责人

8. **Jinyang Shen <2509109915@qq.com>**

   - 早期开发人员
   - Capstone 模块部分优化工作

9. **Rengan Yue <y347812075@163.com>**

   - 软浮点模块及相关优化维护者

10. **Xiaotian Wu <yetist@gmail.com>**
    
    - 新世界适配

同时感谢在文档编写、社区管理、流程搭建、版本测试等方面做出贡献的所有伙伴。

编译
====

STEP1:


.. code-block:: bash

    git clone --depth=1 --recursive https://github.com/lat-opensource/lat
    cd lat


STEP2:

- debian

.. code-block:: bash

    apt install -y git ninja-build libssl-dev libc6 gcc g++ pkg-config libglib2.0-dev libdrm-dev lsb-release make python3-setuptools

- Arch Linux

.. code-block:: bash

    pacman -S --noconfirm ninja gcc pkgconf python3 python-setuptools openssl-static openssl

- 安同 OS (AOSC OS)

.. code-block:: bash

    oma install -y gcc nettle pcre2 libffi gnutls glib zlib glib-static libgcrypt-static libgpg-error-static libnfs-static pcre-static zlib-static zstd-static openssl-static pkg-config ninja


STEP3:

.. code-block:: bash

    ./latxbuild/build-release.sh


未来规划TODO
===============

项目未来的优化与完善方向包括但不限于:

- [ ] 支持更复杂的 x86 指令集扩展(如 AVX。
- [ ] 进一步提升库直通优化的覆盖范围。
- [ ] 提供详细的性能分析工具链,帮助开发者快速定位性能瓶颈。
- [ ] 维护更详细的文档与使用指南。

欢迎大家通过 Issues 等方式讨论新特性需求、Bug 反馈以及优化思路。我们期待更
多开发者与社区力量的加入,一同推进 LoongArch  生态建设!

许可证
======

本项目基于 QEMU 源代码进行二次开发,原始项目遵循 GNU 通用公共许可证第 2 版
GNU General Public License, version 2简称 GPLv2发布。

因此,本项目同样遵循 GPLv2 协议。

致谢
====

特别鸣谢 QEMU 项目与 box64 项目及开发者,他们的开源成果为本项目提供了宝贵
的参考与支持。

------------

如有任何问题或建议,欢迎通过 Issue 与我们交流!