mbox series

[for-5.1,V3,0/7] mips: Add Loongson-3 machine support (with KVM)

Message ID 1588501221-1205-1-git-send-email-chenhc@lemote.com (mailing list archive)
Headers show
Series mips: Add Loongson-3 machine support (with KVM) | expand

Message

chen huacai May 3, 2020, 10:20 a.m. UTC
Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
Loongson-3A R4 is the newest and its ISA is almost the superset of all
others. To reduce complexity, in QEMU we just define two CPU types:

1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
   suitable for TCG because Loongson-3A R1 has fewest ASE.
2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
   suitable for KVM because Loongson-3A R4 has the VZ ASE.

Loongson-3 lacks English documents. I've tried to translated them with
translate.google.com, and the machine translated documents (together
with their original Chinese versions) are available here.

Loongson-3A R1 (Loongson-3A1000)
User Manual Part 1:
http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P1.pdf (Chinese Version)
User Manual Part 2:
http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P2.pdf (Chinese Version)

Loongson-3A R2 (Loongson-3A2000)
User Manual Part 1:
http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese Version)
User Manual Part 2:
http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese Version)

Loongson-3A R3 (Loongson-3A3000)
User Manual Part 1:
http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf (Chinese Version)
User Manual Part 2:
http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf (Chinese Version)

Loongson-3A R4 (Loongson-3A4000)
User Manual Part 1:
http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
User Manual Part 2:
I'm sorry that it is unavailable now.

We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
in this series. And the next series will add QEMU/TCG support (it will
emulate Loongson-3A R1).

We already have a full functional Linux kernel (based on Linux-5.4.x LTS
but not upstream yet) here:

https://github.com/chenhuacai/linux

How to use QEMU/Loongson-3?
1, Download kernel source from the above URL;
2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
3, Boot a Loongson-3A4000 host with this kernel;
4, Build QEMU-5.0.0 with this patchset;
5, modprobe kvm;
6, Use QEMU with TCG (available in future):
       qemu-system-mips64el -M loongson3,accel=tcg -cpu Loongson-3A1000 -kernel <path_to_kernel> -append ... 
   Use QEMU with KVM (available at present): 
       qemu-system-mips64el -M loongson3,accel=kvm -cpu Loongson-3A4000 -kernel <path_to_kernel> -append ... 

   The "-cpu" parameter can be omitted here and QEMU will use the correct type for TCG/KVM automatically.

V1 -> V2:
1, Add a cover letter;
2, Improve CPU definitions;
3, Remove LS7A-related things (Use GPEX instead);
4, Add a description of how to run QEMU/Loongson-3.

V2 -> V3:
1, Fix all possible checkpatch.pl errors and warnings.

Huacai Chen(7):
 configure: Add KVM target support for MIPS64
 hw/mips: Implement the kvm_type() hook in MachineClass
 hw/mips: Add CPU IRQ3 delivery for KVM
 target/mips: Add Loongson-3 CPU definition
 target/mips: Add more CP0 register for save/restor
 hw/mips: Add Loongson-3 machine support (with KVM)
 MAINTAINERS: Add myself as Loongson-3 maintainer

Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
 MAINTAINERS                          |   5 +
 configure                            |   2 +-
 default-configs/mips64el-softmmu.mak |   1 +
 hw/core/Makefile.objs                |   2 +-
 hw/core/null-machine.c               |   4 +
 hw/mips/Kconfig                      |  10 +
 hw/mips/Makefile.objs                |   3 +-
 hw/mips/common.c                     |  31 ++
 hw/mips/mips_int.c                   |   4 +-
 hw/mips/mips_loongson3.c             | 901 +++++++++++++++++++++++++++++++++++
 include/hw/mips/mips.h               |   3 +
 target/mips/cpu.h                    |  28 ++
 target/mips/internal.h               |   2 +
 target/mips/kvm.c                    | 212 +++++++++
 target/mips/machine.c                |   6 +-
 target/mips/mips-defs.h              |   7 +-
 target/mips/translate.c              |   2 +
 target/mips/translate_init.inc.c     |  86 ++++
 18 files changed, 1300 insertions(+), 9 deletions(-)
 create mode 100644 hw/mips/common.c
 create mode 100644 hw/mips/mips_loongson3.c
--
2.7.0

Comments

Yonggang Luo May 3, 2020, 10:42 a.m. UTC | #1
The english version of the reference document is hard to head.
I suggest first convert the chinese version into markdown or alternative
format and
place them at github.
And we then translate the document with google translate.

On Sun, May 3, 2020 at 6:22 PM Huacai Chen <zltjiangshi@gmail.com> wrote:

> Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
> R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
> Loongson-3A R4 is the newest and its ISA is almost the superset of all
> others. To reduce complexity, in QEMU we just define two CPU types:
>
> 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
>    suitable for TCG because Loongson-3A R1 has fewest ASE.
> 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
>    suitable for KVM because Loongson-3A R4 has the VZ ASE.
>
> Loongson-3 lacks English documents. I've tried to translated them with
> translate.google.com, and the machine translated documents (together
> with their original Chinese versions) are available here.
>
> Loongson-3A R1 (Loongson-3A1000)
> User Manual Part 1:
> http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P1.pdf
> (Chinese Version)
> User Manual Part 2:
> http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P2.pdf
> (Chinese Version)
>
> Loongson-3A R2 (Loongson-3A2000)
> User Manual Part 1:
> http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese Version)
> User Manual Part 2:
> http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese Version)
>
> Loongson-3A R3 (Loongson-3A3000)
> User Manual Part 1:
> http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf
> (Chinese Version)
> User Manual Part 2:
> http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf
> (Chinese Version)
>
> Loongson-3A R4 (Loongson-3A4000)
> User Manual Part 1:
> http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
> http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
> User Manual Part 2:
> I'm sorry that it is unavailable now.
>
> We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
> fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
> in this series. And the next series will add QEMU/TCG support (it will
> emulate Loongson-3A R1).
>
> We already have a full functional Linux kernel (based on Linux-5.4.x LTS
> but not upstream yet) here:
>
> https://github.com/chenhuacai/linux
>
> How to use QEMU/Loongson-3?
> 1, Download kernel source from the above URL;
> 2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
> 3, Boot a Loongson-3A4000 host with this kernel;
> 4, Build QEMU-5.0.0 with this patchset;
> 5, modprobe kvm;
> 6, Use QEMU with TCG (available in future):
>        qemu-system-mips64el -M loongson3,accel=tcg -cpu Loongson-3A1000
> -kernel <path_to_kernel> -append ...
>    Use QEMU with KVM (available at present):
>        qemu-system-mips64el -M loongson3,accel=kvm -cpu Loongson-3A4000
> -kernel <path_to_kernel> -append ...
>
>    The "-cpu" parameter can be omitted here and QEMU will use the correct
> type for TCG/KVM automatically.
>
> V1 -> V2:
> 1, Add a cover letter;
> 2, Improve CPU definitions;
> 3, Remove LS7A-related things (Use GPEX instead);
> 4, Add a description of how to run QEMU/Loongson-3.
>
> V2 -> V3:
> 1, Fix all possible checkpatch.pl errors and warnings.
>
> Huacai Chen(7):
>  configure: Add KVM target support for MIPS64
>  hw/mips: Implement the kvm_type() hook in MachineClass
>  hw/mips: Add CPU IRQ3 delivery for KVM
>  target/mips: Add Loongson-3 CPU definition
>  target/mips: Add more CP0 register for save/restor
>  hw/mips: Add Loongson-3 machine support (with KVM)
>  MAINTAINERS: Add myself as Loongson-3 maintainer
>
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> ---
>  MAINTAINERS                          |   5 +
>  configure                            |   2 +-
>  default-configs/mips64el-softmmu.mak |   1 +
>  hw/core/Makefile.objs                |   2 +-
>  hw/core/null-machine.c               |   4 +
>  hw/mips/Kconfig                      |  10 +
>  hw/mips/Makefile.objs                |   3 +-
>  hw/mips/common.c                     |  31 ++
>  hw/mips/mips_int.c                   |   4 +-
>  hw/mips/mips_loongson3.c             | 901
> +++++++++++++++++++++++++++++++++++
>  include/hw/mips/mips.h               |   3 +
>  target/mips/cpu.h                    |  28 ++
>  target/mips/internal.h               |   2 +
>  target/mips/kvm.c                    | 212 +++++++++
>  target/mips/machine.c                |   6 +-
>  target/mips/mips-defs.h              |   7 +-
>  target/mips/translate.c              |   2 +
>  target/mips/translate_init.inc.c     |  86 ++++
>  18 files changed, 1300 insertions(+), 9 deletions(-)
>  create mode 100644 hw/mips/common.c
>  create mode 100644 hw/mips/mips_loongson3.c
> --
> 2.7.0
>
>
no-reply@patchew.org May 3, 2020, 10:49 a.m. UTC | #2
Patchew URL: https://patchew.org/QEMU/1588501221-1205-1-git-send-email-chenhc@lemote.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

Not run: 259
Failures: 192
Failed 1 of 117 iotests
make: *** [check-tests/check-block.sh] Error 1
make: *** Waiting for unfinished jobs....
  TEST    check-qtest-aarch64: tests/qtest/test-hmp
  TEST    check-qtest-aarch64: tests/qtest/qos-test
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=8950e4c4713746e191eb1884fd629535', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-x9_nmvq4/src/docker-src.2020-05-03-06.33.44.10861:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=8950e4c4713746e191eb1884fd629535
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-x9_nmvq4/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    15m24.568s
user    0m8.657s


The full log is available at
http://patchew.org/logs/1588501221-1205-1-git-send-email-chenhc@lemote.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Aleksandar Markovic May 3, 2020, 10:49 a.m. UTC | #3
нед, 3. мај 2020. у 12:21 Huacai Chen <zltjiangshi@gmail.com> је написао/ла:
>
> Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
> R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
> Loongson-3A R4 is the newest and its ISA is almost the superset of all
> others. To reduce complexity, in QEMU we just define two CPU types:
>
> 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
>    suitable for TCG because Loongson-3A R1 has fewest ASE.
> 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
>    suitable for KVM because Loongson-3A R4 has the VZ ASE.
>

Huacai, thanks for putting together v3, which is a little better than v2, and
thanks for addressing my previous suggestions.

Now, give us some time to digest new data on Loongson3.  We will
respond, but it won't happen immediately, which is, you'd agree,
reasonable. Just be patient.

But again, in general, I salute your efforts very much!

Yours, Aleksandar

> Loongson-3 lacks English documents. I've tried to translated them with
> translate.google.com, and the machine translated documents (together
> with their original Chinese versions) are available here.
>
> Loongson-3A R1 (Loongson-3A1000)
> User Manual Part 1:
> http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P1.pdf (Chinese Version)
> User Manual Part 2:
> http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P2.pdf (Chinese Version)
>
> Loongson-3A R2 (Loongson-3A2000)
> User Manual Part 1:
> http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese Version)
> User Manual Part 2:
> http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese Version)
>
> Loongson-3A R3 (Loongson-3A3000)
> User Manual Part 1:
> http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf (Chinese Version)
> User Manual Part 2:
> http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
> http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf (Chinese Version)
>
> Loongson-3A R4 (Loongson-3A4000)
> User Manual Part 1:
> http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
> http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
> User Manual Part 2:
> I'm sorry that it is unavailable now.
>
> We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
> fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
> in this series. And the next series will add QEMU/TCG support (it will
> emulate Loongson-3A R1).
>
> We already have a full functional Linux kernel (based on Linux-5.4.x LTS
> but not upstream yet) here:
>
> https://github.com/chenhuacai/linux
>
> How to use QEMU/Loongson-3?
> 1, Download kernel source from the above URL;
> 2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
> 3, Boot a Loongson-3A4000 host with this kernel;
> 4, Build QEMU-5.0.0 with this patchset;
> 5, modprobe kvm;
> 6, Use QEMU with TCG (available in future):
>        qemu-system-mips64el -M loongson3,accel=tcg -cpu Loongson-3A1000 -kernel <path_to_kernel> -append ...
>    Use QEMU with KVM (available at present):
>        qemu-system-mips64el -M loongson3,accel=kvm -cpu Loongson-3A4000 -kernel <path_to_kernel> -append ...
>
>    The "-cpu" parameter can be omitted here and QEMU will use the correct type for TCG/KVM automatically.
>
> V1 -> V2:
> 1, Add a cover letter;
> 2, Improve CPU definitions;
> 3, Remove LS7A-related things (Use GPEX instead);
> 4, Add a description of how to run QEMU/Loongson-3.
>
> V2 -> V3:
> 1, Fix all possible checkpatch.pl errors and warnings.
>
> Huacai Chen(7):
>  configure: Add KVM target support for MIPS64
>  hw/mips: Implement the kvm_type() hook in MachineClass
>  hw/mips: Add CPU IRQ3 delivery for KVM
>  target/mips: Add Loongson-3 CPU definition
>  target/mips: Add more CP0 register for save/restor
>  hw/mips: Add Loongson-3 machine support (with KVM)
>  MAINTAINERS: Add myself as Loongson-3 maintainer
>
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> ---
>  MAINTAINERS                          |   5 +
>  configure                            |   2 +-
>  default-configs/mips64el-softmmu.mak |   1 +
>  hw/core/Makefile.objs                |   2 +-
>  hw/core/null-machine.c               |   4 +
>  hw/mips/Kconfig                      |  10 +
>  hw/mips/Makefile.objs                |   3 +-
>  hw/mips/common.c                     |  31 ++
>  hw/mips/mips_int.c                   |   4 +-
>  hw/mips/mips_loongson3.c             | 901 +++++++++++++++++++++++++++++++++++
>  include/hw/mips/mips.h               |   3 +
>  target/mips/cpu.h                    |  28 ++
>  target/mips/internal.h               |   2 +
>  target/mips/kvm.c                    | 212 +++++++++
>  target/mips/machine.c                |   6 +-
>  target/mips/mips-defs.h              |   7 +-
>  target/mips/translate.c              |   2 +
>  target/mips/translate_init.inc.c     |  86 ++++
>  18 files changed, 1300 insertions(+), 9 deletions(-)
>  create mode 100644 hw/mips/common.c
>  create mode 100644 hw/mips/mips_loongson3.c
> --
> 2.7.0
chen huacai May 4, 2020, 6:13 a.m. UTC | #4
Hi, Yonggang,

We are planning to translate these manuals to English by human, but it
needs a very long time to complete.

Huacai

On Sun, May 3, 2020 at 6:42 PM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com> wrote:
>
> The english version of the reference document is hard to head.
> I suggest first convert the chinese version into markdown or alternative format and
> place them at github.
> And we then translate the document with google translate.
>
> On Sun, May 3, 2020 at 6:22 PM Huacai Chen <zltjiangshi@gmail.com> wrote:
>>
>> Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
>> R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
>> Loongson-3A R4 is the newest and its ISA is almost the superset of all
>> others. To reduce complexity, in QEMU we just define two CPU types:
>>
>> 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
>>    suitable for TCG because Loongson-3A R1 has fewest ASE.
>> 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
>>    suitable for KVM because Loongson-3A R4 has the VZ ASE.
>>
>> Loongson-3 lacks English documents. I've tried to translated them with
>> translate.google.com, and the machine translated documents (together
>> with their original Chinese versions) are available here.
>>
>> Loongson-3A R1 (Loongson-3A1000)
>> User Manual Part 1:
>> http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
>> http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P1.pdf (Chinese Version)
>> User Manual Part 2:
>> http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
>> http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P2.pdf (Chinese Version)
>>
>> Loongson-3A R2 (Loongson-3A2000)
>> User Manual Part 1:
>> http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
>> http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese Version)
>> User Manual Part 2:
>> http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
>> http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese Version)
>>
>> Loongson-3A R3 (Loongson-3A3000)
>> User Manual Part 1:
>> http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
>> http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf (Chinese Version)
>> User Manual Part 2:
>> http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
>> http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf (Chinese Version)
>>
>> Loongson-3A R4 (Loongson-3A4000)
>> User Manual Part 1:
>> http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
>> http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
>> User Manual Part 2:
>> I'm sorry that it is unavailable now.
>>
>> We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
>> fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
>> in this series. And the next series will add QEMU/TCG support (it will
>> emulate Loongson-3A R1).
>>
>> We already have a full functional Linux kernel (based on Linux-5.4.x LTS
>> but not upstream yet) here:
>>
>> https://github.com/chenhuacai/linux
>>
>> How to use QEMU/Loongson-3?
>> 1, Download kernel source from the above URL;
>> 2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
>> 3, Boot a Loongson-3A4000 host with this kernel;
>> 4, Build QEMU-5.0.0 with this patchset;
>> 5, modprobe kvm;
>> 6, Use QEMU with TCG (available in future):
>>        qemu-system-mips64el -M loongson3,accel=tcg -cpu Loongson-3A1000 -kernel <path_to_kernel> -append ...
>>    Use QEMU with KVM (available at present):
>>        qemu-system-mips64el -M loongson3,accel=kvm -cpu Loongson-3A4000 -kernel <path_to_kernel> -append ...
>>
>>    The "-cpu" parameter can be omitted here and QEMU will use the correct type for TCG/KVM automatically.
>>
>> V1 -> V2:
>> 1, Add a cover letter;
>> 2, Improve CPU definitions;
>> 3, Remove LS7A-related things (Use GPEX instead);
>> 4, Add a description of how to run QEMU/Loongson-3.
>>
>> V2 -> V3:
>> 1, Fix all possible checkpatch.pl errors and warnings.
>>
>> Huacai Chen(7):
>>  configure: Add KVM target support for MIPS64
>>  hw/mips: Implement the kvm_type() hook in MachineClass
>>  hw/mips: Add CPU IRQ3 delivery for KVM
>>  target/mips: Add Loongson-3 CPU definition
>>  target/mips: Add more CP0 register for save/restor
>>  hw/mips: Add Loongson-3 machine support (with KVM)
>>  MAINTAINERS: Add myself as Loongson-3 maintainer
>>
>> Signed-off-by: Huacai Chen <chenhc@lemote.com>
>> ---
>>  MAINTAINERS                          |   5 +
>>  configure                            |   2 +-
>>  default-configs/mips64el-softmmu.mak |   1 +
>>  hw/core/Makefile.objs                |   2 +-
>>  hw/core/null-machine.c               |   4 +
>>  hw/mips/Kconfig                      |  10 +
>>  hw/mips/Makefile.objs                |   3 +-
>>  hw/mips/common.c                     |  31 ++
>>  hw/mips/mips_int.c                   |   4 +-
>>  hw/mips/mips_loongson3.c             | 901 +++++++++++++++++++++++++++++++++++
>>  include/hw/mips/mips.h               |   3 +
>>  target/mips/cpu.h                    |  28 ++
>>  target/mips/internal.h               |   2 +
>>  target/mips/kvm.c                    | 212 +++++++++
>>  target/mips/machine.c                |   6 +-
>>  target/mips/mips-defs.h              |   7 +-
>>  target/mips/translate.c              |   2 +
>>  target/mips/translate_init.inc.c     |  86 ++++
>>  18 files changed, 1300 insertions(+), 9 deletions(-)
>>  create mode 100644 hw/mips/common.c
>>  create mode 100644 hw/mips/mips_loongson3.c
>> --
>> 2.7.0
>>
>
>
> --
>          此致
> 礼
> 罗勇刚
> Yours
>     sincerely,
> Yonggang Luo
Yonggang Luo May 4, 2020, 6:15 a.m. UTC | #5
Yeap, I suggest convert the Chinese version to Markdown or other text
format first,
then we can got help from others to translate those documents

On Mon, May 4, 2020 at 2:06 PM chen huacai <zltjiangshi@gmail.com> wrote:

> Hi, Yonggang,
>
> We are planning to translate these manuals to English by human, but it
> needs a very long time to complete.
>
> Huacai
>
> On Sun, May 3, 2020 at 6:42 PM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com>
> wrote:
> >
> > The english version of the reference document is hard to head.
> > I suggest first convert the chinese version into markdown or alternative
> format and
> > place them at github.
> > And we then translate the document with google translate.
> >
> > On Sun, May 3, 2020 at 6:22 PM Huacai Chen <zltjiangshi@gmail.com>
> wrote:
> >>
> >> Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
> >> R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
> >> Loongson-3A R4 is the newest and its ISA is almost the superset of all
> >> others. To reduce complexity, in QEMU we just define two CPU types:
> >>
> >> 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
> >>    suitable for TCG because Loongson-3A R1 has fewest ASE.
> >> 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
> >>    suitable for KVM because Loongson-3A R4 has the VZ ASE.
> >>
> >> Loongson-3 lacks English documents. I've tried to translated them with
> >> translate.google.com, and the machine translated documents (together
> >> with their original Chinese versions) are available here.
> >>
> >> Loongson-3A R1 (Loongson-3A1000)
> >> User Manual Part 1:
> >> http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
> >>
> http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P1.pdf
> (Chinese Version)
> >> User Manual Part 2:
> >> http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
> >>
> http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P2.pdf
> (Chinese Version)
> >>
> >> Loongson-3A R2 (Loongson-3A2000)
> >> User Manual Part 1:
> >> http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
> >> http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese
> Version)
> >> User Manual Part 2:
> >> http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
> >> http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese
> Version)
> >>
> >> Loongson-3A R3 (Loongson-3A3000)
> >> User Manual Part 1:
> >> http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
> >> http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf
> (Chinese Version)
> >> User Manual Part 2:
> >> http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
> >> http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf
> (Chinese Version)
> >>
> >> Loongson-3A R4 (Loongson-3A4000)
> >> User Manual Part 1:
> >> http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
> >> http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
> >> User Manual Part 2:
> >> I'm sorry that it is unavailable now.
> >>
> >> We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
> >> fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
> >> in this series. And the next series will add QEMU/TCG support (it will
> >> emulate Loongson-3A R1).
> >>
> >> We already have a full functional Linux kernel (based on Linux-5.4.x LTS
> >> but not upstream yet) here:
> >>
> >> https://github.com/chenhuacai/linux
> >>
> >> How to use QEMU/Loongson-3?
> >> 1, Download kernel source from the above URL;
> >> 2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
> >> 3, Boot a Loongson-3A4000 host with this kernel;
> >> 4, Build QEMU-5.0.0 with this patchset;
> >> 5, modprobe kvm;
> >> 6, Use QEMU with TCG (available in future):
> >>        qemu-system-mips64el -M loongson3,accel=tcg -cpu Loongson-3A1000
> -kernel <path_to_kernel> -append ...
> >>    Use QEMU with KVM (available at present):
> >>        qemu-system-mips64el -M loongson3,accel=kvm -cpu Loongson-3A4000
> -kernel <path_to_kernel> -append ...
> >>
> >>    The "-cpu" parameter can be omitted here and QEMU will use the
> correct type for TCG/KVM automatically.
> >>
> >> V1 -> V2:
> >> 1, Add a cover letter;
> >> 2, Improve CPU definitions;
> >> 3, Remove LS7A-related things (Use GPEX instead);
> >> 4, Add a description of how to run QEMU/Loongson-3.
> >>
> >> V2 -> V3:
> >> 1, Fix all possible checkpatch.pl errors and warnings.
> >>
> >> Huacai Chen(7):
> >>  configure: Add KVM target support for MIPS64
> >>  hw/mips: Implement the kvm_type() hook in MachineClass
> >>  hw/mips: Add CPU IRQ3 delivery for KVM
> >>  target/mips: Add Loongson-3 CPU definition
> >>  target/mips: Add more CP0 register for save/restor
> >>  hw/mips: Add Loongson-3 machine support (with KVM)
> >>  MAINTAINERS: Add myself as Loongson-3 maintainer
> >>
> >> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> >> ---
> >>  MAINTAINERS                          |   5 +
> >>  configure                            |   2 +-
> >>  default-configs/mips64el-softmmu.mak |   1 +
> >>  hw/core/Makefile.objs                |   2 +-
> >>  hw/core/null-machine.c               |   4 +
> >>  hw/mips/Kconfig                      |  10 +
> >>  hw/mips/Makefile.objs                |   3 +-
> >>  hw/mips/common.c                     |  31 ++
> >>  hw/mips/mips_int.c                   |   4 +-
> >>  hw/mips/mips_loongson3.c             | 901
> +++++++++++++++++++++++++++++++++++
> >>  include/hw/mips/mips.h               |   3 +
> >>  target/mips/cpu.h                    |  28 ++
> >>  target/mips/internal.h               |   2 +
> >>  target/mips/kvm.c                    | 212 +++++++++
> >>  target/mips/machine.c                |   6 +-
> >>  target/mips/mips-defs.h              |   7 +-
> >>  target/mips/translate.c              |   2 +
> >>  target/mips/translate_init.inc.c     |  86 ++++
> >>  18 files changed, 1300 insertions(+), 9 deletions(-)
> >>  create mode 100644 hw/mips/common.c
> >>  create mode 100644 hw/mips/mips_loongson3.c
> >> --
> >> 2.7.0
> >>
> >
> >
> > --
> >          此致
> > 礼
> > 罗勇刚
> > Yours
> >     sincerely,
> > Yonggang Luo
>
>
>
> --
> Huacai Chen
>
chen huacai May 5, 2020, 7:40 a.m. UTC | #6
Hi, Aleksandar,

On Sun, May 3, 2020 at 6:50 PM Aleksandar Markovic
<aleksandar.qemu.devel@gmail.com> wrote:
>
> нед, 3. мај 2020. у 12:21 Huacai Chen <zltjiangshi@gmail.com> је написао/ла:
> >
> > Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
> > R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
> > Loongson-3A R4 is the newest and its ISA is almost the superset of all
> > others. To reduce complexity, in QEMU we just define two CPU types:
> >
> > 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
> >    suitable for TCG because Loongson-3A R1 has fewest ASE.
> > 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
> >    suitable for KVM because Loongson-3A R4 has the VZ ASE.
> >
>
> Huacai, thanks for putting together v3, which is a little better than v2, and
> thanks for addressing my previous suggestions.
>
> Now, give us some time to digest new data on Loongson3.  We will
> respond, but it won't happen immediately, which is, you'd agree,
> reasonable. Just be patient.
>
> But again, in general, I salute your efforts very much!
>
> Yours, Aleksandar
I'm sorry for this late response because I have done many tests to
reproduce the problem reported at
https://patchew.org/QEMU/1588501221-1205-1-git-send-email-chenhc@lemote.com/,
but I don't have such a failure...

What I have done:
1, "make check" on MIPS64 platform (distro is Fedora28 for Loongson);
2, "make check" on X86_64 platform (distro is RHEL8);
3, "make docker-test-quick@centos7 SHOW_ENV=1 NETWORK=1" on X86_64
platform (distro is RHEL8);
4, "make docker-test-quick@centos7 SHOW_ENV=1 J=n NETWORK=1" on X86_64
platform (distro is RHEL8 and I've tried n=2,3,4....14);

I always get the same result:
Not run: 259
Passed all 117 iotests

And, it seems that my patchset doesn't touch anything about iotests,
so I don't know why the build test fails on iotests 192 (Maybe your
build test has the same problem without my patches).

P.S.: I have found a problem that my patchset has a build failure with
CONFIG_KVM=n, but this is another problem and I will send V4 to fix it
(after collecting all problems in V3).


>
> > Loongson-3 lacks English documents. I've tried to translated them with
> > translate.google.com, and the machine translated documents (together
> > with their original Chinese versions) are available here.
> >
> > Loongson-3A R1 (Loongson-3A1000)
> > User Manual Part 1:
> > http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
> > http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P1.pdf (Chinese Version)
> > User Manual Part 2:
> > http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
> > http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P2.pdf (Chinese Version)
> >
> > Loongson-3A R2 (Loongson-3A2000)
> > User Manual Part 1:
> > http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
> > http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese Version)
> > User Manual Part 2:
> > http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
> > http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese Version)
> >
> > Loongson-3A R3 (Loongson-3A3000)
> > User Manual Part 1:
> > http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
> > http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf (Chinese Version)
> > User Manual Part 2:
> > http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
> > http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf (Chinese Version)
> >
> > Loongson-3A R4 (Loongson-3A4000)
> > User Manual Part 1:
> > http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
> > http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
> > User Manual Part 2:
> > I'm sorry that it is unavailable now.
> >
> > We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
> > fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
> > in this series. And the next series will add QEMU/TCG support (it will
> > emulate Loongson-3A R1).
> >
> > We already have a full functional Linux kernel (based on Linux-5.4.x LTS
> > but not upstream yet) here:
> >
> > https://github.com/chenhuacai/linux
> >
> > How to use QEMU/Loongson-3?
> > 1, Download kernel source from the above URL;
> > 2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
> > 3, Boot a Loongson-3A4000 host with this kernel;
> > 4, Build QEMU-5.0.0 with this patchset;
> > 5, modprobe kvm;
> > 6, Use QEMU with TCG (available in future):
> >        qemu-system-mips64el -M loongson3,accel=tcg -cpu Loongson-3A1000 -kernel <path_to_kernel> -append ...
> >    Use QEMU with KVM (available at present):
> >        qemu-system-mips64el -M loongson3,accel=kvm -cpu Loongson-3A4000 -kernel <path_to_kernel> -append ...
> >
> >    The "-cpu" parameter can be omitted here and QEMU will use the correct type for TCG/KVM automatically.
> >
> > V1 -> V2:
> > 1, Add a cover letter;
> > 2, Improve CPU definitions;
> > 3, Remove LS7A-related things (Use GPEX instead);
> > 4, Add a description of how to run QEMU/Loongson-3.
> >
> > V2 -> V3:
> > 1, Fix all possible checkpatch.pl errors and warnings.
> >
> > Huacai Chen(7):
> >  configure: Add KVM target support for MIPS64
> >  hw/mips: Implement the kvm_type() hook in MachineClass
> >  hw/mips: Add CPU IRQ3 delivery for KVM
> >  target/mips: Add Loongson-3 CPU definition
> >  target/mips: Add more CP0 register for save/restor
> >  hw/mips: Add Loongson-3 machine support (with KVM)
> >  MAINTAINERS: Add myself as Loongson-3 maintainer
> >
> > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > ---
> >  MAINTAINERS                          |   5 +
> >  configure                            |   2 +-
> >  default-configs/mips64el-softmmu.mak |   1 +
> >  hw/core/Makefile.objs                |   2 +-
> >  hw/core/null-machine.c               |   4 +
> >  hw/mips/Kconfig                      |  10 +
> >  hw/mips/Makefile.objs                |   3 +-
> >  hw/mips/common.c                     |  31 ++
> >  hw/mips/mips_int.c                   |   4 +-
> >  hw/mips/mips_loongson3.c             | 901 +++++++++++++++++++++++++++++++++++
> >  include/hw/mips/mips.h               |   3 +
> >  target/mips/cpu.h                    |  28 ++
> >  target/mips/internal.h               |   2 +
> >  target/mips/kvm.c                    | 212 +++++++++
> >  target/mips/machine.c                |   6 +-
> >  target/mips/mips-defs.h              |   7 +-
> >  target/mips/translate.c              |   2 +
> >  target/mips/translate_init.inc.c     |  86 ++++
> >  18 files changed, 1300 insertions(+), 9 deletions(-)
> >  create mode 100644 hw/mips/common.c
> >  create mode 100644 hw/mips/mips_loongson3.c
> > --
> > 2.7.0



--
Huacai Chen
Aleksandar Markovic May 5, 2020, 10:12 a.m. UTC | #7
уторак, 05. мај 2020., chen huacai <zltjiangshi@gmail.com> је написао/ла:

> Hi, Aleksandar,
>
> On Sun, May 3, 2020 at 6:50 PM Aleksandar Markovic
> <aleksandar.qemu.devel@gmail.com> wrote:
> >
> > нед, 3. мај 2020. у 12:21 Huacai Chen <zltjiangshi@gmail.com> је
> написао/ла:
> > >
> > > Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
> > > R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
> > > Loongson-3A R4 is the newest and its ISA is almost the superset of all
> > > others. To reduce complexity, in QEMU we just define two CPU types:
> > >
> > > 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It
> is
> > >    suitable for TCG because Loongson-3A R1 has fewest ASE.
> > > 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It
> is
> > >    suitable for KVM because Loongson-3A R4 has the VZ ASE.
> > >
> >
> > Huacai, thanks for putting together v3, which is a little better than
> v2, and
> > thanks for addressing my previous suggestions.
> >
> > Now, give us some time to digest new data on Loongson3.  We will
> > respond, but it won't happen immediately, which is, you'd agree,
> > reasonable. Just be patient.
> >
> > But again, in general, I salute your efforts very much!
> >
> > Yours, Aleksandar
> I'm sorry for this late response because I have done many tests to
> reproduce the problem reported at
> https://patchew.org/QEMU/1588501221-1205-1-git-send-
> email-chenhc@lemote.com/,
> but I don't have such a failure...
>
> What I have done:
> 1, "make check" on MIPS64 platform (distro is Fedora28 for Loongson);
> 2, "make check" on X86_64 platform (distro is RHEL8);
> 3, "make docker-test-quick@centos7 SHOW_ENV=1 NETWORK=1" on X86_64
> platform (distro is RHEL8);
> 4, "make docker-test-quick@centos7 SHOW_ENV=1 J=n NETWORK=1" on X86_64
> platform (distro is RHEL8 and I've tried n=2,3,4....14);
>
> I always get the same result:
> Not run: 259
> Passed all 117 iotests
>
> And, it seems that my patchset doesn't touch anything about iotests,
> so I don't know why the build test fails on iotests 192 (Maybe your
> build test has the same problem without my patches).
>
>
From time to time, there is some instability in our automatic iotests. You
shouldn't bother too much about it, of course you retest in your
environments, that is good. But, in all likelyhood, your patchset doesn't
really have anything to do with the reported iotest failure.

Truly yours,
Aleksandar



> P.S.: I have found a problem that my patchset has a build failure with
> CONFIG_KVM=n, but this is another problem and I will send V4 to fix it
> (after collecting all problems in V3).
>
>
> >
> > > Loongson-3 lacks English documents. I've tried to translated them with
> > > translate.google.com, and the machine translated documents (together
> > > with their original Chinese versions) are available here.
> > >
> > > Loongson-3A R1 (Loongson-3A1000)
> > > User Manual Part 1:
> > > http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
> > > http://ftp.godson.ac.cn/lemote/Loongson3A1000_
> processor_user_manual_P1.pdf (Chinese Version)
> > > User Manual Part 2:
> > > http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
> > > http://ftp.godson.ac.cn/lemote/Loongson3A1000_
> processor_user_manual_P2.pdf (Chinese Version)
> > >
> > > Loongson-3A R2 (Loongson-3A2000)
> > > User Manual Part 1:
> > > http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
> > > http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese
> Version)
> > > User Manual Part 2:
> > > http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
> > > http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese
> Version)
> > >
> > > Loongson-3A R3 (Loongson-3A3000)
> > > User Manual Part 1:
> > > http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
> > > http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf
> (Chinese Version)
> > > User Manual Part 2:
> > > http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
> > > http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf
> (Chinese Version)
> > >
> > > Loongson-3A R4 (Loongson-3A4000)
> > > User Manual Part 1:
> > > http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
> > > http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
> > > User Manual Part 2:
> > > I'm sorry that it is unavailable now.
> > >
> > > We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
> > > fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
> > > in this series. And the next series will add QEMU/TCG support (it will
> > > emulate Loongson-3A R1).
> > >
> > > We already have a full functional Linux kernel (based on Linux-5.4.x
> LTS
> > > but not upstream yet) here:
> > >
> > > https://github.com/chenhuacai/linux
> > >
> > > How to use QEMU/Loongson-3?
> > > 1, Download kernel source from the above URL;
> > > 2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
> > > 3, Boot a Loongson-3A4000 host with this kernel;
> > > 4, Build QEMU-5.0.0 with this patchset;
> > > 5, modprobe kvm;
> > > 6, Use QEMU with TCG (available in future):
> > >        qemu-system-mips64el -M loongson3,accel=tcg -cpu
> Loongson-3A1000 -kernel <path_to_kernel> -append ...
> > >    Use QEMU with KVM (available at present):
> > >        qemu-system-mips64el -M loongson3,accel=kvm -cpu
> Loongson-3A4000 -kernel <path_to_kernel> -append ...
> > >
> > >    The "-cpu" parameter can be omitted here and QEMU will use the
> correct type for TCG/KVM automatically.
> > >
> > > V1 -> V2:
> > > 1, Add a cover letter;
> > > 2, Improve CPU definitions;
> > > 3, Remove LS7A-related things (Use GPEX instead);
> > > 4, Add a description of how to run QEMU/Loongson-3.
> > >
> > > V2 -> V3:
> > > 1, Fix all possible checkpatch.pl errors and warnings.
> > >
> > > Huacai Chen(7):
> > >  configure: Add KVM target support for MIPS64
> > >  hw/mips: Implement the kvm_type() hook in MachineClass
> > >  hw/mips: Add CPU IRQ3 delivery for KVM
> > >  target/mips: Add Loongson-3 CPU definition
> > >  target/mips: Add more CP0 register for save/restor
> > >  hw/mips: Add Loongson-3 machine support (with KVM)
> > >  MAINTAINERS: Add myself as Loongson-3 maintainer
> > >
> > > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > > ---
> > >  MAINTAINERS                          |   5 +
> > >  configure                            |   2 +-
> > >  default-configs/mips64el-softmmu.mak |   1 +
> > >  hw/core/Makefile.objs                |   2 +-
> > >  hw/core/null-machine.c               |   4 +
> > >  hw/mips/Kconfig                      |  10 +
> > >  hw/mips/Makefile.objs                |   3 +-
> > >  hw/mips/common.c                     |  31 ++
> > >  hw/mips/mips_int.c                   |   4 +-
> > >  hw/mips/mips_loongson3.c             | 901
> +++++++++++++++++++++++++++++++++++
> > >  include/hw/mips/mips.h               |   3 +
> > >  target/mips/cpu.h                    |  28 ++
> > >  target/mips/internal.h               |   2 +
> > >  target/mips/kvm.c                    | 212 +++++++++
> > >  target/mips/machine.c                |   6 +-
> > >  target/mips/mips-defs.h              |   7 +-
> > >  target/mips/translate.c              |   2 +
> > >  target/mips/translate_init.inc.c     |  86 ++++
> > >  18 files changed, 1300 insertions(+), 9 deletions(-)
> > >  create mode 100644 hw/mips/common.c
> > >  create mode 100644 hw/mips/mips_loongson3.c
> > > --
> > > 2.7.0
>
>
>
> --
> Huacai Chen
>
Huacai Chen May 6, 2020, 1:50 a.m. UTC | #8
Hi, Aleksandar,

On Tue, May 5, 2020 at 6:12 PM Aleksandar Markovic
<aleksandar.qemu.devel@gmail.com> wrote:
>
>
>
> уторак, 05. мај 2020., chen huacai <zltjiangshi@gmail.com> је написао/ла:
>>
>> Hi, Aleksandar,
>>
>> On Sun, May 3, 2020 at 6:50 PM Aleksandar Markovic
>> <aleksandar.qemu.devel@gmail.com> wrote:
>> >
>> > нед, 3. мај 2020. у 12:21 Huacai Chen <zltjiangshi@gmail.com> је написао/ла:
>> > >
>> > > Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
>> > > R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
>> > > Loongson-3A R4 is the newest and its ISA is almost the superset of all
>> > > others. To reduce complexity, in QEMU we just define two CPU types:
>> > >
>> > > 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
>> > >    suitable for TCG because Loongson-3A R1 has fewest ASE.
>> > > 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
>> > >    suitable for KVM because Loongson-3A R4 has the VZ ASE.
>> > >
>> >
>> > Huacai, thanks for putting together v3, which is a little better than v2, and
>> > thanks for addressing my previous suggestions.
>> >
>> > Now, give us some time to digest new data on Loongson3.  We will
>> > respond, but it won't happen immediately, which is, you'd agree,
>> > reasonable. Just be patient.
>> >
>> > But again, in general, I salute your efforts very much!
>> >
>> > Yours, Aleksandar
>> I'm sorry for this late response because I have done many tests to
>> reproduce the problem reported at
>> https://patchew.org/QEMU/1588501221-1205-1-git-send-email-chenhc@lemote.com/,
>> but I don't have such a failure...
>>
>> What I have done:
>> 1, "make check" on MIPS64 platform (distro is Fedora28 for Loongson);
>> 2, "make check" on X86_64 platform (distro is RHEL8);
>> 3, "make docker-test-quick@centos7 SHOW_ENV=1 NETWORK=1" on X86_64
>> platform (distro is RHEL8);
>> 4, "make docker-test-quick@centos7 SHOW_ENV=1 J=n NETWORK=1" on X86_64
>> platform (distro is RHEL8 and I've tried n=2,3,4....14);
>>
>> I always get the same result:
>> Not run: 259
>> Passed all 117 iotests
>>
>> And, it seems that my patchset doesn't touch anything about iotests,
>> so I don't know why the build test fails on iotests 192 (Maybe your
>> build test has the same problem without my patches).
>>
>
> From time to time, there is some instability in our automatic iotests. You shouldn't bother too much about it, of course you retest in your environments, that is good. But, in all likelyhood, your patchset doesn't really have anything to do with the reported iotest failure.

Thank you for your help, and here is another question: Could
"target/mips: Support variable page size" series be merged now? This
Loongson-3 series depend on variable page size logically.

>
> Truly yours,
> Aleksandar
>
>
>>
>> P.S.: I have found a problem that my patchset has a build failure with
>> CONFIG_KVM=n, but this is another problem and I will send V4 to fix it
>> (after collecting all problems in V3).
>>
>>
>> >
>> > > Loongson-3 lacks English documents. I've tried to translated them with
>> > > translate.google.com, and the machine translated documents (together
>> > > with their original Chinese versions) are available here.
>> > >
>> > > Loongson-3A R1 (Loongson-3A1000)
>> > > User Manual Part 1:
>> > > http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
>> > > http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P1.pdf (Chinese Version)
>> > > User Manual Part 2:
>> > > http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
>> > > http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P2.pdf (Chinese Version)
>> > >
>> > > Loongson-3A R2 (Loongson-3A2000)
>> > > User Manual Part 1:
>> > > http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
>> > > http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese Version)
>> > > User Manual Part 2:
>> > > http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
>> > > http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese Version)
>> > >
>> > > Loongson-3A R3 (Loongson-3A3000)
>> > > User Manual Part 1:
>> > > http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
>> > > http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf (Chinese Version)
>> > > User Manual Part 2:
>> > > http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
>> > > http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf (Chinese Version)
>> > >
>> > > Loongson-3A R4 (Loongson-3A4000)
>> > > User Manual Part 1:
>> > > http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
>> > > http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
>> > > User Manual Part 2:
>> > > I'm sorry that it is unavailable now.
>> > >
>> > > We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
>> > > fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
>> > > in this series. And the next series will add QEMU/TCG support (it will
>> > > emulate Loongson-3A R1).
>> > >
>> > > We already have a full functional Linux kernel (based on Linux-5.4.x LTS
>> > > but not upstream yet) here:
>> > >
>> > > https://github.com/chenhuacai/linux
>> > >
>> > > How to use QEMU/Loongson-3?
>> > > 1, Download kernel source from the above URL;
>> > > 2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
>> > > 3, Boot a Loongson-3A4000 host with this kernel;
>> > > 4, Build QEMU-5.0.0 with this patchset;
>> > > 5, modprobe kvm;
>> > > 6, Use QEMU with TCG (available in future):
>> > >        qemu-system-mips64el -M loongson3,accel=tcg -cpu Loongson-3A1000 -kernel <path_to_kernel> -append ...
>> > >    Use QEMU with KVM (available at present):
>> > >        qemu-system-mips64el -M loongson3,accel=kvm -cpu Loongson-3A4000 -kernel <path_to_kernel> -append ...
>> > >
>> > >    The "-cpu" parameter can be omitted here and QEMU will use the correct type for TCG/KVM automatically.
>> > >
>> > > V1 -> V2:
>> > > 1, Add a cover letter;
>> > > 2, Improve CPU definitions;
>> > > 3, Remove LS7A-related things (Use GPEX instead);
>> > > 4, Add a description of how to run QEMU/Loongson-3.
>> > >
>> > > V2 -> V3:
>> > > 1, Fix all possible checkpatch.pl errors and warnings.
>> > >
>> > > Huacai Chen(7):
>> > >  configure: Add KVM target support for MIPS64
>> > >  hw/mips: Implement the kvm_type() hook in MachineClass
>> > >  hw/mips: Add CPU IRQ3 delivery for KVM
>> > >  target/mips: Add Loongson-3 CPU definition
>> > >  target/mips: Add more CP0 register for save/restor
>> > >  hw/mips: Add Loongson-3 machine support (with KVM)
>> > >  MAINTAINERS: Add myself as Loongson-3 maintainer
>> > >
>> > > Signed-off-by: Huacai Chen <chenhc@lemote.com>
>> > > ---
>> > >  MAINTAINERS                          |   5 +
>> > >  configure                            |   2 +-
>> > >  default-configs/mips64el-softmmu.mak |   1 +
>> > >  hw/core/Makefile.objs                |   2 +-
>> > >  hw/core/null-machine.c               |   4 +
>> > >  hw/mips/Kconfig                      |  10 +
>> > >  hw/mips/Makefile.objs                |   3 +-
>> > >  hw/mips/common.c                     |  31 ++
>> > >  hw/mips/mips_int.c                   |   4 +-
>> > >  hw/mips/mips_loongson3.c             | 901 +++++++++++++++++++++++++++++++++++
>> > >  include/hw/mips/mips.h               |   3 +
>> > >  target/mips/cpu.h                    |  28 ++
>> > >  target/mips/internal.h               |   2 +
>> > >  target/mips/kvm.c                    | 212 +++++++++
>> > >  target/mips/machine.c                |   6 +-
>> > >  target/mips/mips-defs.h              |   7 +-
>> > >  target/mips/translate.c              |   2 +
>> > >  target/mips/translate_init.inc.c     |  86 ++++
>> > >  18 files changed, 1300 insertions(+), 9 deletions(-)
>> > >  create mode 100644 hw/mips/common.c
>> > >  create mode 100644 hw/mips/mips_loongson3.c
>> > > --
>> > > 2.7.0
>>
>>
>>
>> --
>> Huacai Chen
Best regards,
Huacai
Aleksandar Markovic May 7, 2020, 12:17 p.m. UTC | #9
сре, 6. мај 2020. у 03:43 Huacai Chen <chenhuacai@gmail.com> је написао/ла:
>
> Hi, Aleksandar,
>
> On Tue, May 5, 2020 at 6:12 PM Aleksandar Markovic
> <aleksandar.qemu.devel@gmail.com> wrote:
> >
> >
> >
> > уторак, 05. мај 2020., chen huacai <zltjiangshi@gmail.com> је написао/ла:
> >>
> >> Hi, Aleksandar,
> >>
> >> On Sun, May 3, 2020 at 6:50 PM Aleksandar Markovic
> >> <aleksandar.qemu.devel@gmail.com> wrote:
> >> >
> >> > нед, 3. мај 2020. у 12:21 Huacai Chen <zltjiangshi@gmail.com> је написао/ла:
> >> > >
> >> > > Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
> >> > > R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
> >> > > Loongson-3A R4 is the newest and its ISA is almost the superset of all
> >> > > others. To reduce complexity, in QEMU we just define two CPU types:
> >> > >
> >> > > 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
> >> > >    suitable for TCG because Loongson-3A R1 has fewest ASE.
> >> > > 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
> >> > >    suitable for KVM because Loongson-3A R4 has the VZ ASE.
> >> > >
> >> >
> >> > Huacai, thanks for putting together v3, which is a little better than v2, and
> >> > thanks for addressing my previous suggestions.
> >> >
> >> > Now, give us some time to digest new data on Loongson3.  We will
> >> > respond, but it won't happen immediately, which is, you'd agree,
> >> > reasonable. Just be patient.
> >> >
> >> > But again, in general, I salute your efforts very much!
> >> >
> >> > Yours, Aleksandar
> >> I'm sorry for this late response because I have done many tests to
> >> reproduce the problem reported at
> >> https://patchew.org/QEMU/1588501221-1205-1-git-send-email-chenhc@lemote.com/,
> >> but I don't have such a failure...
> >>
> >> What I have done:
> >> 1, "make check" on MIPS64 platform (distro is Fedora28 for Loongson);
> >> 2, "make check" on X86_64 platform (distro is RHEL8);
> >> 3, "make docker-test-quick@centos7 SHOW_ENV=1 NETWORK=1" on X86_64
> >> platform (distro is RHEL8);
> >> 4, "make docker-test-quick@centos7 SHOW_ENV=1 J=n NETWORK=1" on X86_64
> >> platform (distro is RHEL8 and I've tried n=2,3,4....14);
> >>
> >> I always get the same result:
> >> Not run: 259
> >> Passed all 117 iotests
> >>
> >> And, it seems that my patchset doesn't touch anything about iotests,
> >> so I don't know why the build test fails on iotests 192 (Maybe your
> >> build test has the same problem without my patches).
> >>
> >
> > From time to time, there is some instability in our automatic iotests. You shouldn't bother too much about it, of course you retest in your environments, that is good. But, in all likelyhood, your patchset doesn't really have anything to do with the reported iotest failure.
>
> Thank you for your help, and here is another question: Could
> "target/mips: Support variable page size" series be merged now? This
> Loongson-3 series depend on variable page size logically.
>

Hi, Huacei.

Please be patient. This is a significant series, and we don't do or
have a "fast track" for series of such nature. It might or might not
be that some of the patches will be accepted before the entire series,
but certainly do not rush us. This is not the way to achieve your
goal, let's put it that way. Focus on improving your series. Being
careful with reviewing and upstreaming is actually in your interest.

Yours,
Aleksandar

> >
> > Truly yours,
> > Aleksandar
> >
> >
> >>
> >> P.S.: I have found a problem that my patchset has a build failure with
> >> CONFIG_KVM=n, but this is another problem and I will send V4 to fix it
> >> (after collecting all problems in V3).
> >>
> >>
> >> >
> >> > > Loongson-3 lacks English documents. I've tried to translated them with
> >> > > translate.google.com, and the machine translated documents (together
> >> > > with their original Chinese versions) are available here.
> >> > >
> >> > > Loongson-3A R1 (Loongson-3A1000)
> >> > > User Manual Part 1:
> >> > > http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
> >> > > http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P1.pdf (Chinese Version)
> >> > > User Manual Part 2:
> >> > > http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
> >> > > http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P2.pdf (Chinese Version)
> >> > >
> >> > > Loongson-3A R2 (Loongson-3A2000)
> >> > > User Manual Part 1:
> >> > > http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
> >> > > http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese Version)
> >> > > User Manual Part 2:
> >> > > http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
> >> > > http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese Version)
> >> > >
> >> > > Loongson-3A R3 (Loongson-3A3000)
> >> > > User Manual Part 1:
> >> > > http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
> >> > > http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf (Chinese Version)
> >> > > User Manual Part 2:
> >> > > http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
> >> > > http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf (Chinese Version)
> >> > >
> >> > > Loongson-3A R4 (Loongson-3A4000)
> >> > > User Manual Part 1:
> >> > > http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
> >> > > http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
> >> > > User Manual Part 2:
> >> > > I'm sorry that it is unavailable now.
> >> > >
> >> > > We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
> >> > > fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
> >> > > in this series. And the next series will add QEMU/TCG support (it will
> >> > > emulate Loongson-3A R1).
> >> > >
> >> > > We already have a full functional Linux kernel (based on Linux-5.4.x LTS
> >> > > but not upstream yet) here:
> >> > >
> >> > > https://github.com/chenhuacai/linux
> >> > >
> >> > > How to use QEMU/Loongson-3?
> >> > > 1, Download kernel source from the above URL;
> >> > > 2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
> >> > > 3, Boot a Loongson-3A4000 host with this kernel;
> >> > > 4, Build QEMU-5.0.0 with this patchset;
> >> > > 5, modprobe kvm;
> >> > > 6, Use QEMU with TCG (available in future):
> >> > >        qemu-system-mips64el -M loongson3,accel=tcg -cpu Loongson-3A1000 -kernel <path_to_kernel> -append ...
> >> > >    Use QEMU with KVM (available at present):
> >> > >        qemu-system-mips64el -M loongson3,accel=kvm -cpu Loongson-3A4000 -kernel <path_to_kernel> -append ...
> >> > >
> >> > >    The "-cpu" parameter can be omitted here and QEMU will use the correct type for TCG/KVM automatically.
> >> > >
> >> > > V1 -> V2:
> >> > > 1, Add a cover letter;
> >> > > 2, Improve CPU definitions;
> >> > > 3, Remove LS7A-related things (Use GPEX instead);
> >> > > 4, Add a description of how to run QEMU/Loongson-3.
> >> > >
> >> > > V2 -> V3:
> >> > > 1, Fix all possible checkpatch.pl errors and warnings.
> >> > >
> >> > > Huacai Chen(7):
> >> > >  configure: Add KVM target support for MIPS64
> >> > >  hw/mips: Implement the kvm_type() hook in MachineClass
> >> > >  hw/mips: Add CPU IRQ3 delivery for KVM
> >> > >  target/mips: Add Loongson-3 CPU definition
> >> > >  target/mips: Add more CP0 register for save/restor
> >> > >  hw/mips: Add Loongson-3 machine support (with KVM)
> >> > >  MAINTAINERS: Add myself as Loongson-3 maintainer
> >> > >
> >> > > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> >> > > ---
> >> > >  MAINTAINERS                          |   5 +
> >> > >  configure                            |   2 +-
> >> > >  default-configs/mips64el-softmmu.mak |   1 +
> >> > >  hw/core/Makefile.objs                |   2 +-
> >> > >  hw/core/null-machine.c               |   4 +
> >> > >  hw/mips/Kconfig                      |  10 +
> >> > >  hw/mips/Makefile.objs                |   3 +-
> >> > >  hw/mips/common.c                     |  31 ++
> >> > >  hw/mips/mips_int.c                   |   4 +-
> >> > >  hw/mips/mips_loongson3.c             | 901 +++++++++++++++++++++++++++++++++++
> >> > >  include/hw/mips/mips.h               |   3 +
> >> > >  target/mips/cpu.h                    |  28 ++
> >> > >  target/mips/internal.h               |   2 +
> >> > >  target/mips/kvm.c                    | 212 +++++++++
> >> > >  target/mips/machine.c                |   6 +-
> >> > >  target/mips/mips-defs.h              |   7 +-
> >> > >  target/mips/translate.c              |   2 +
> >> > >  target/mips/translate_init.inc.c     |  86 ++++
> >> > >  18 files changed, 1300 insertions(+), 9 deletions(-)
> >> > >  create mode 100644 hw/mips/common.c
> >> > >  create mode 100644 hw/mips/mips_loongson3.c
> >> > > --
> >> > > 2.7.0
> >>
> >>
> >>
> >> --
> >> Huacai Chen
> Best regards,
> Huacai
Huacai Chen May 8, 2020, 1:41 a.m. UTC | #10
Hi, Aleksandar,

On Thu, May 7, 2020 at 8:18 PM Aleksandar Markovic
<aleksandar.qemu.devel@gmail.com> wrote:
>
> сре, 6. мај 2020. у 03:43 Huacai Chen <chenhuacai@gmail.com> је написао/ла:
> >
> > Hi, Aleksandar,
> >
> > On Tue, May 5, 2020 at 6:12 PM Aleksandar Markovic
> > <aleksandar.qemu.devel@gmail.com> wrote:
> > >
> > >
> > >
> > > уторак, 05. мај 2020., chen huacai <zltjiangshi@gmail.com> је написао/ла:
> > >>
> > >> Hi, Aleksandar,
> > >>
> > >> On Sun, May 3, 2020 at 6:50 PM Aleksandar Markovic
> > >> <aleksandar.qemu.devel@gmail.com> wrote:
> > >> >
> > >> > нед, 3. мај 2020. у 12:21 Huacai Chen <zltjiangshi@gmail.com> је написао/ла:
> > >> > >
> > >> > > Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
> > >> > > R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
> > >> > > Loongson-3A R4 is the newest and its ISA is almost the superset of all
> > >> > > others. To reduce complexity, in QEMU we just define two CPU types:
> > >> > >
> > >> > > 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
> > >> > >    suitable for TCG because Loongson-3A R1 has fewest ASE.
> > >> > > 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
> > >> > >    suitable for KVM because Loongson-3A R4 has the VZ ASE.
> > >> > >
> > >> >
> > >> > Huacai, thanks for putting together v3, which is a little better than v2, and
> > >> > thanks for addressing my previous suggestions.
> > >> >
> > >> > Now, give us some time to digest new data on Loongson3.  We will
> > >> > respond, but it won't happen immediately, which is, you'd agree,
> > >> > reasonable. Just be patient.
> > >> >
> > >> > But again, in general, I salute your efforts very much!
> > >> >
> > >> > Yours, Aleksandar
> > >> I'm sorry for this late response because I have done many tests to
> > >> reproduce the problem reported at
> > >> https://patchew.org/QEMU/1588501221-1205-1-git-send-email-chenhc@lemote.com/,
> > >> but I don't have such a failure...
> > >>
> > >> What I have done:
> > >> 1, "make check" on MIPS64 platform (distro is Fedora28 for Loongson);
> > >> 2, "make check" on X86_64 platform (distro is RHEL8);
> > >> 3, "make docker-test-quick@centos7 SHOW_ENV=1 NETWORK=1" on X86_64
> > >> platform (distro is RHEL8);
> > >> 4, "make docker-test-quick@centos7 SHOW_ENV=1 J=n NETWORK=1" on X86_64
> > >> platform (distro is RHEL8 and I've tried n=2,3,4....14);
> > >>
> > >> I always get the same result:
> > >> Not run: 259
> > >> Passed all 117 iotests
> > >>
> > >> And, it seems that my patchset doesn't touch anything about iotests,
> > >> so I don't know why the build test fails on iotests 192 (Maybe your
> > >> build test has the same problem without my patches).
> > >>
> > >
> > > From time to time, there is some instability in our automatic iotests. You shouldn't bother too much about it, of course you retest in your environments, that is good. But, in all likelyhood, your patchset doesn't really have anything to do with the reported iotest failure.
> >
> > Thank you for your help, and here is another question: Could
> > "target/mips: Support variable page size" series be merged now? This
> > Loongson-3 series depend on variable page size logically.
> >
>
> Hi, Huacei.
>
> Please be patient. This is a significant series, and we don't do or
> have a "fast track" for series of such nature. It might or might not
> be that some of the patches will be accepted before the entire series,
> but certainly do not rush us. This is not the way to achieve your
> goal, let's put it that way. Focus on improving your series. Being
> careful with reviewing and upstreaming is actually in your interest.
Thank your very much. I know I should be patient, and I'm patient
actually. I mention "target/mips: Support variable page size" here
because I forget to add "for-5.1" in that series, I want to know
whether I should resend it.

>
> Yours,
> Aleksandar
>
> > >
> > > Truly yours,
> > > Aleksandar
> > >
> > >
> > >>
> > >> P.S.: I have found a problem that my patchset has a build failure with
> > >> CONFIG_KVM=n, but this is another problem and I will send V4 to fix it
> > >> (after collecting all problems in V3).
> > >>
> > >>
> > >> >
> > >> > > Loongson-3 lacks English documents. I've tried to translated them with
> > >> > > translate.google.com, and the machine translated documents (together
> > >> > > with their original Chinese versions) are available here.
> > >> > >
> > >> > > Loongson-3A R1 (Loongson-3A1000)
> > >> > > User Manual Part 1:
> > >> > > http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
> > >> > > http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P1.pdf (Chinese Version)
> > >> > > User Manual Part 2:
> > >> > > http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
> > >> > > http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P2.pdf (Chinese Version)
> > >> > >
> > >> > > Loongson-3A R2 (Loongson-3A2000)
> > >> > > User Manual Part 1:
> > >> > > http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
> > >> > > http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese Version)
> > >> > > User Manual Part 2:
> > >> > > http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
> > >> > > http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese Version)
> > >> > >
> > >> > > Loongson-3A R3 (Loongson-3A3000)
> > >> > > User Manual Part 1:
> > >> > > http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
> > >> > > http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf (Chinese Version)
> > >> > > User Manual Part 2:
> > >> > > http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
> > >> > > http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf (Chinese Version)
> > >> > >
> > >> > > Loongson-3A R4 (Loongson-3A4000)
> > >> > > User Manual Part 1:
> > >> > > http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
> > >> > > http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
> > >> > > User Manual Part 2:
> > >> > > I'm sorry that it is unavailable now.
> > >> > >
> > >> > > We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
> > >> > > fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
> > >> > > in this series. And the next series will add QEMU/TCG support (it will
> > >> > > emulate Loongson-3A R1).
> > >> > >
> > >> > > We already have a full functional Linux kernel (based on Linux-5.4.x LTS
> > >> > > but not upstream yet) here:
> > >> > >
> > >> > > https://github.com/chenhuacai/linux
> > >> > >
> > >> > > How to use QEMU/Loongson-3?
> > >> > > 1, Download kernel source from the above URL;
> > >> > > 2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
> > >> > > 3, Boot a Loongson-3A4000 host with this kernel;
> > >> > > 4, Build QEMU-5.0.0 with this patchset;
> > >> > > 5, modprobe kvm;
> > >> > > 6, Use QEMU with TCG (available in future):
> > >> > >        qemu-system-mips64el -M loongson3,accel=tcg -cpu Loongson-3A1000 -kernel <path_to_kernel> -append ...
> > >> > >    Use QEMU with KVM (available at present):
> > >> > >        qemu-system-mips64el -M loongson3,accel=kvm -cpu Loongson-3A4000 -kernel <path_to_kernel> -append ...
> > >> > >
> > >> > >    The "-cpu" parameter can be omitted here and QEMU will use the correct type for TCG/KVM automatically.
> > >> > >
> > >> > > V1 -> V2:
> > >> > > 1, Add a cover letter;
> > >> > > 2, Improve CPU definitions;
> > >> > > 3, Remove LS7A-related things (Use GPEX instead);
> > >> > > 4, Add a description of how to run QEMU/Loongson-3.
> > >> > >
> > >> > > V2 -> V3:
> > >> > > 1, Fix all possible checkpatch.pl errors and warnings.
> > >> > >
> > >> > > Huacai Chen(7):
> > >> > >  configure: Add KVM target support for MIPS64
> > >> > >  hw/mips: Implement the kvm_type() hook in MachineClass
> > >> > >  hw/mips: Add CPU IRQ3 delivery for KVM
> > >> > >  target/mips: Add Loongson-3 CPU definition
> > >> > >  target/mips: Add more CP0 register for save/restor
> > >> > >  hw/mips: Add Loongson-3 machine support (with KVM)
> > >> > >  MAINTAINERS: Add myself as Loongson-3 maintainer
> > >> > >
> > >> > > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > >> > > ---
> > >> > >  MAINTAINERS                          |   5 +
> > >> > >  configure                            |   2 +-
> > >> > >  default-configs/mips64el-softmmu.mak |   1 +
> > >> > >  hw/core/Makefile.objs                |   2 +-
> > >> > >  hw/core/null-machine.c               |   4 +
> > >> > >  hw/mips/Kconfig                      |  10 +
> > >> > >  hw/mips/Makefile.objs                |   3 +-
> > >> > >  hw/mips/common.c                     |  31 ++
> > >> > >  hw/mips/mips_int.c                   |   4 +-
> > >> > >  hw/mips/mips_loongson3.c             | 901 +++++++++++++++++++++++++++++++++++
> > >> > >  include/hw/mips/mips.h               |   3 +
> > >> > >  target/mips/cpu.h                    |  28 ++
> > >> > >  target/mips/internal.h               |   2 +
> > >> > >  target/mips/kvm.c                    | 212 +++++++++
> > >> > >  target/mips/machine.c                |   6 +-
> > >> > >  target/mips/mips-defs.h              |   7 +-
> > >> > >  target/mips/translate.c              |   2 +
> > >> > >  target/mips/translate_init.inc.c     |  86 ++++
> > >> > >  18 files changed, 1300 insertions(+), 9 deletions(-)
> > >> > >  create mode 100644 hw/mips/common.c
> > >> > >  create mode 100644 hw/mips/mips_loongson3.c
> > >> > > --
> > >> > > 2.7.0
> > >>
> > >>
> > >>
> > >> --
> > >> Huacai Chen
> > Best regards,
> > Huacai
Aleksandar Markovic May 8, 2020, 4:55 p.m. UTC | #11
нед, 3. мај 2020. у 12:21 Huacai Chen <zltjiangshi@gmail.com> је написао/ла:
>
> Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
> R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
> Loongson-3A R4 is the newest and its ISA is almost the superset of all
> others. To reduce complexity, in QEMU we just define two CPU types:
>
> 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
>    suitable for TCG because Loongson-3A R1 has fewest ASE.
> 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
>    suitable for KVM because Loongson-3A R4 has the VZ ASE.
>

Hi, Huacei,

Just a couple of practicalities. As you know, we can't upstream this
series until correspondent kernel support is upstreamed into kernel.
This is my advice, timing-wise:

- I think it is too late (and not good from testing/risk perspective)
to shoot for integrating your kernel series into kernel 5.7;
- My advice is to try to upstream your kernel series at the beginning
of 5.8 development cycle (which should not be too far)
- Once this is done, it will open the door for integrating this series
into QEMU upstream
- This means that combination of kernel 5.8 and QEMU 5.1 will
hopefully be a working system from Loongson KVM point of view
- This will also mean we will have relatively sufficient time to test,
and possibly fix some new bugs before QEMU 5.1 release.

I hope this tentative plan sounds good to you.

Sincerely,
Aleksandar
chen huacai May 9, 2020, 3:07 a.m. UTC | #12
Hi, Aleksandar,

On Sat, May 9, 2020 at 12:55 AM Aleksandar Markovic
<aleksandar.qemu.devel@gmail.com> wrote:
>
> нед, 3. мај 2020. у 12:21 Huacai Chen <zltjiangshi@gmail.com> је написао/ла:
> >
> > Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
> > R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
> > Loongson-3A R4 is the newest and its ISA is almost the superset of all
> > others. To reduce complexity, in QEMU we just define two CPU types:
> >
> > 1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
> >    suitable for TCG because Loongson-3A R1 has fewest ASE.
> > 2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
> >    suitable for KVM because Loongson-3A R4 has the VZ ASE.
> >
>
> Hi, Huacei,
>
> Just a couple of practicalities. As you know, we can't upstream this
> series until correspondent kernel support is upstreamed into kernel.
> This is my advice, timing-wise:
>
> - I think it is too late (and not good from testing/risk perspective)
> to shoot for integrating your kernel series into kernel 5.7;
> - My advice is to try to upstream your kernel series at the beginning
> of 5.8 development cycle (which should not be too far)
> - Once this is done, it will open the door for integrating this series
> into QEMU upstream
> - This means that combination of kernel 5.8 and QEMU 5.1 will
> hopefully be a working system from Loongson KVM point of view
> - This will also mean we will have relatively sufficient time to test,
> and possibly fix some new bugs before QEMU 5.1 release.
>
> I hope this tentative plan sounds good to you.
OK, I will try to upstream kernel series at first, and send a V4 of
qemu series after that.
>
> Sincerely,
> Aleksandar