Message ID | 20220106094200.1801206-2-gaosong@loongson.cn |
---|---|
State | New |
Headers | show |
Series | Add LoongArch linux-user emulation support | expand |
On 1/6/22 17:41, Song Gao wrote: > This patch gives an introduction to the LoongArch target. > > Signed-off-by: Song Gao<gaosong@loongson.cn> > Signed-off-by: Xiaojuan Yang<yangxiaojuan@loongson.cn> > Reviewed-by: Richard Henderson<richard.henderson@linaro.org> > --- > MAINTAINERS | 5 +++ > target/loongarch/README | 77 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 82 insertions(+) > create mode 100644 target/loongarch/README > > diff --git a/MAINTAINERS b/MAINTAINERS > index f871d759fd..2df0d4a7c2 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -213,6 +213,11 @@ S: Maintained > F: target/hppa/ > F: disas/hppa.c > > +LoongArch TCG CPUS "TCG CPUs" -- notice the case for the plural "s". > +M: Song Gao<gaosong@loongson.cn> > +S: Maintained > +F: target/loongarch/ > + > M68K TCG CPUs > M: Laurent Vivier<laurent@vivier.eu> > S: Maintained > diff --git a/target/loongarch/README b/target/loongarch/README > new file mode 100644 > index 0000000000..d5780c5918 > --- /dev/null > +++ b/target/loongarch/README > @@ -0,0 +1,77 @@ > +- Introduction > + > + LoongArch is the general processor architecture of Loongson. > + > + The following versions of the LoongArch core are supported > + core: 3A5000 > +https://github.com/loongson/LoongArch-Documentation/releases/download/2021.08.17/LoongArch-Vol1-v1.00-EN.pdf > + > + We can get the latest loongarch documents athttps://github.com/loongson/LoongArch-Documentation/tags. > + > + > +- Linux-user emulation > + > + We already support Linux user emulation. We can use LoongArch cross-tools to build LoongArch executables on X86 machines, > + and We can also use qemu-loongarch64 to run LoongArch executables. > + > + 1. Install LoongArch cross-tools on X86 machines. > + > + Download cross-tools. > + > + wgethttps://github.com/loongson/build-tools/releases/latest/download/loongarch64-clfs-20211202-cross-tools.tar.xz > + > + tar -vxf loongarch64-clfs-20211202-cross-tools.tar.xz -C /opt > + > + Config cross-tools env. > + > + . setenv.sh > + > + setenv.sh: > + > + #!/bin/sh > + set -x > + CC_PREFIX=/opt/cross-tools > + > + export PATH=$CC_PREFIX/bin:$PATH > + export LD_LIBRARY_PATH=$CC_PREFIX/lib:$LD_LIBRARY_PATH > + export LD_LIBRARY_PATH=$CC_PREFIX/loongarch64-unknown-linux-gnu/lib/:$LD_LIBRARY_PATH > + set +x > + > + 2. Test tests/tcg/multiarch. > + > + ./configure --disable-rdma --disable-pvrdma --prefix=/usr \ > + --target-list="loongarch64-linux-user" \ > + --disable-libiscsi --disable-libnfs --disable-libpmem \ > + --disable-glusterfs --enable-libusb --enable-usb-redir \ > + --disable-opengl --disable-xen --enable-spice --disable-werror \ > + --enable-debug --disable-capstone --disable-kvm --enable-profiler > + > + cd build/ > + > + make && make check-tcg > + > + 3. Run LoongArch system basic command with loongarch-clfs-system. > + > + Download clfs-system. > + > + wgethttps://github.com/loongson/build-tools/releases/latest/download/loongarch64-clfs-system-2021-12-02.tar.bz2 > + > + tar -vxf loongarch64-clfs-system-2021-12-02.tar.bz2 -C /opt/clfs > + ln -s /opt/clfs/ /opt/clfs/tls Command with dubious intention -- are you working around some kind of LIBPATH priority problem? TLS shouldn't be involved at this level, yet I remotely remember that library search paths similar to "/usr/lib/tls" were a thing long ago... > + > + Config env. > + > + cp /opt/clfs/lib64/ld-linux-loongarch64.so.1 /lib64 > + > + export LD_LIBRARY_PATH="/opt/clfs/lib64" > + > + Run LoongArch system basic command. > + > + ./qemu-loongarch64 /opt/clfs/usr/bin/bash > + ./qemu-loongarch64 /opt/clfs/usr/bin/ls > + ./qemu-loongarch64 /opt/clfs/usr/bin/pwd > + ... > + > + > +- Note. > + We can get the latest LoongArch documents or LoongArch tools athttps://github.com/loongson/ I'm afraid this README would require some re-writing due to the amount of Chinglish involved, but that's possibly okay after merging. (I don't have the time to rewrite this for you currently, so just a mild rant for now.)
diff --git a/MAINTAINERS b/MAINTAINERS index f871d759fd..2df0d4a7c2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -213,6 +213,11 @@ S: Maintained F: target/hppa/ F: disas/hppa.c +LoongArch TCG CPUS +M: Song Gao <gaosong@loongson.cn> +S: Maintained +F: target/loongarch/ + M68K TCG CPUs M: Laurent Vivier <laurent@vivier.eu> S: Maintained diff --git a/target/loongarch/README b/target/loongarch/README new file mode 100644 index 0000000000..d5780c5918 --- /dev/null +++ b/target/loongarch/README @@ -0,0 +1,77 @@ +- Introduction + + LoongArch is the general processor architecture of Loongson. + + The following versions of the LoongArch core are supported + core: 3A5000 + https://github.com/loongson/LoongArch-Documentation/releases/download/2021.08.17/LoongArch-Vol1-v1.00-EN.pdf + + We can get the latest loongarch documents at https://github.com/loongson/LoongArch-Documentation/tags. + + +- Linux-user emulation + + We already support Linux user emulation. We can use LoongArch cross-tools to build LoongArch executables on X86 machines, + and We can also use qemu-loongarch64 to run LoongArch executables. + + 1. Install LoongArch cross-tools on X86 machines. + + Download cross-tools. + + wget https://github.com/loongson/build-tools/releases/latest/download/loongarch64-clfs-20211202-cross-tools.tar.xz + + tar -vxf loongarch64-clfs-20211202-cross-tools.tar.xz -C /opt + + Config cross-tools env. + + . setenv.sh + + setenv.sh: + + #!/bin/sh + set -x + CC_PREFIX=/opt/cross-tools + + export PATH=$CC_PREFIX/bin:$PATH + export LD_LIBRARY_PATH=$CC_PREFIX/lib:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH=$CC_PREFIX/loongarch64-unknown-linux-gnu/lib/:$LD_LIBRARY_PATH + set +x + + 2. Test tests/tcg/multiarch. + + ./configure --disable-rdma --disable-pvrdma --prefix=/usr \ + --target-list="loongarch64-linux-user" \ + --disable-libiscsi --disable-libnfs --disable-libpmem \ + --disable-glusterfs --enable-libusb --enable-usb-redir \ + --disable-opengl --disable-xen --enable-spice --disable-werror \ + --enable-debug --disable-capstone --disable-kvm --enable-profiler + + cd build/ + + make && make check-tcg + + 3. Run LoongArch system basic command with loongarch-clfs-system. + + Download clfs-system. + + wget https://github.com/loongson/build-tools/releases/latest/download/loongarch64-clfs-system-2021-12-02.tar.bz2 + + tar -vxf loongarch64-clfs-system-2021-12-02.tar.bz2 -C /opt/clfs + ln -s /opt/clfs/ /opt/clfs/tls + + Config env. + + cp /opt/clfs/lib64/ld-linux-loongarch64.so.1 /lib64 + + export LD_LIBRARY_PATH="/opt/clfs/lib64" + + Run LoongArch system basic command. + + ./qemu-loongarch64 /opt/clfs/usr/bin/bash + ./qemu-loongarch64 /opt/clfs/usr/bin/ls + ./qemu-loongarch64 /opt/clfs/usr/bin/pwd + ... + + +- Note. + We can get the latest LoongArch documents or LoongArch tools at https://github.com/loongson/