[PATCH 0/4] target/loongarch: add LVZ support for TCG

SignKirigami posted 4 patches 1 week, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/cover.1779171125.git.prcups@krgm.moe
Maintainers: Song Gao <gaosong@loongson.cn>
target/loongarch/cpu-csr.h                    |  42 ++
target/loongarch/cpu-mmu.h                    |  37 +-
target/loongarch/cpu.c                        | 132 ++++
target/loongarch/cpu.h                        | 125 +++-
target/loongarch/cpu_helper.c                 | 119 ++--
target/loongarch/csr.c                        | 122 ++++
target/loongarch/csr.h                        |   3 +
target/loongarch/disas.c                      |  10 +
target/loongarch/insns.decode                 |  17 +
target/loongarch/internals.h                  |   8 +-
target/loongarch/kvm/kvm.c                    |   1 +
target/loongarch/machine.c                    | 249 ++++---
target/loongarch/tcg/constant_timer.c         |  62 +-
target/loongarch/tcg/csr_helper.c             | 127 +++-
target/loongarch/tcg/helper.h                 |  30 +-
.../tcg/insn_trans/trans_privileged.c.inc     | 353 +++++++++-
target/loongarch/tcg/op_helper.c              |  83 ++-
target/loongarch/tcg/tcg_cpu.c                | 182 +++--
target/loongarch/tcg/tcg_loongarch.h          |   6 +-
target/loongarch/tcg/tlb_helper.c             | 629 +++++++++++++-----
target/loongarch/tcg/translate.c              |   6 +-
target/loongarch/translate.h                  |   2 +
22 files changed, 1909 insertions(+), 436 deletions(-)
[PATCH 0/4] target/loongarch: add LVZ support for TCG
Posted by SignKirigami 1 week, 4 days ago
This patch implements Loongson VirtualiZation (LVZ) extension support for LoongArch's TCG target. With this patch, it is now possible to start a nested KVM-accelerated virtual machine on a TCG-emulated virtual machine.

Cc: Bibo Mao <maobibo@loongson.cn>
Cc: xianglai li <lixianglai@loongson.cn>
Signed-off-by: SignKirigami <prcups@krgm.moe>
Signed-off-by: Hengyu Yu <yuhengyu25@mails.ucas.ac.cn>

SignKirigami (4):
  target/loongarch: add LVZ CPU state and CSR metadata
  target/loongarch: add LVZ guest runtime support
  target/loongarch: translate LVZ CSR and trap instructions
  target/loongarch: virtualize guest TLB and address translation

 target/loongarch/cpu-csr.h                    |  42 ++
 target/loongarch/cpu-mmu.h                    |  37 +-
 target/loongarch/cpu.c                        | 132 ++++
 target/loongarch/cpu.h                        | 125 +++-
 target/loongarch/cpu_helper.c                 | 119 ++--
 target/loongarch/csr.c                        | 122 ++++
 target/loongarch/csr.h                        |   3 +
 target/loongarch/disas.c                      |  10 +
 target/loongarch/insns.decode                 |  17 +
 target/loongarch/internals.h                  |   8 +-
 target/loongarch/kvm/kvm.c                    |   1 +
 target/loongarch/machine.c                    | 249 ++++---
 target/loongarch/tcg/constant_timer.c         |  62 +-
 target/loongarch/tcg/csr_helper.c             | 127 +++-
 target/loongarch/tcg/helper.h                 |  30 +-
 .../tcg/insn_trans/trans_privileged.c.inc     | 353 +++++++++-
 target/loongarch/tcg/op_helper.c              |  83 ++-
 target/loongarch/tcg/tcg_cpu.c                | 182 +++--
 target/loongarch/tcg/tcg_loongarch.h          |   6 +-
 target/loongarch/tcg/tlb_helper.c             | 629 +++++++++++++-----
 target/loongarch/tcg/translate.c              |   6 +-
 target/loongarch/translate.h                  |   2 +
 22 files changed, 1909 insertions(+), 436 deletions(-)

-- 
2.52.0
Re: [PATCH 0/4] target/loongarch: add LVZ support for TCG
Posted by Bibo Mao 1 week, 2 days ago

On 2026/5/19 下午2:30, SignKirigami wrote:
> This patch implements Loongson VirtualiZation (LVZ) extension support for LoongArch's TCG target. With this patch, it is now possible to start a nested KVM-accelerated virtual machine on a TCG-emulated virtual machine.

Hi SignKirigami,

I suggest minimal support with LVZ at beginning, such as no PTW, no 
machine state save/restore etc. Just CPU virtualization and simple 
memory virtualization is enough.

Regards
Bibo Mao
> 
> Cc: Bibo Mao <maobibo@loongson.cn>
> Cc: xianglai li <lixianglai@loongson.cn>
> Signed-off-by: SignKirigami <prcups@krgm.moe>
> Signed-off-by: Hengyu Yu <yuhengyu25@mails.ucas.ac.cn>
> 
> SignKirigami (4):
>    target/loongarch: add LVZ CPU state and CSR metadata
>    target/loongarch: add LVZ guest runtime support
>    target/loongarch: translate LVZ CSR and trap instructions
>    target/loongarch: virtualize guest TLB and address translation
> 
>   target/loongarch/cpu-csr.h                    |  42 ++
>   target/loongarch/cpu-mmu.h                    |  37 +-
>   target/loongarch/cpu.c                        | 132 ++++
>   target/loongarch/cpu.h                        | 125 +++-
>   target/loongarch/cpu_helper.c                 | 119 ++--
>   target/loongarch/csr.c                        | 122 ++++
>   target/loongarch/csr.h                        |   3 +
>   target/loongarch/disas.c                      |  10 +
>   target/loongarch/insns.decode                 |  17 +
>   target/loongarch/internals.h                  |   8 +-
>   target/loongarch/kvm/kvm.c                    |   1 +
>   target/loongarch/machine.c                    | 249 ++++---
>   target/loongarch/tcg/constant_timer.c         |  62 +-
>   target/loongarch/tcg/csr_helper.c             | 127 +++-
>   target/loongarch/tcg/helper.h                 |  30 +-
>   .../tcg/insn_trans/trans_privileged.c.inc     | 353 +++++++++-
>   target/loongarch/tcg/op_helper.c              |  83 ++-
>   target/loongarch/tcg/tcg_cpu.c                | 182 +++--
>   target/loongarch/tcg/tcg_loongarch.h          |   6 +-
>   target/loongarch/tcg/tlb_helper.c             | 629 +++++++++++++-----
>   target/loongarch/tcg/translate.c              |   6 +-
>   target/loongarch/translate.h                  |   2 +
>   22 files changed, 1909 insertions(+), 436 deletions(-)
> 


Re: [PATCH 0/4] target/loongarch: add LVZ support for TCG
Posted by SignKirigami 1 week, 4 days ago
Please disregard my previous patch series[1][2][3][4][5][6]. This was my first time using git send-email and my provider messed up the threads (the cover letter also accidentally reused a previous Message-ID, causing it to be grouped into the wrong thread[7]).

I sincerely apologize for the noise and confusion.

....

[1]: https://lore.kernel.org/qemu-devel/734d561d-4a8c-4235-b55d-1387020f8a62@mtasv.net/T/#t
[2]: https://lore.kernel.org/qemu-devel/ff838e8c-8f44-446d-915d-cfb2ce869a5c@mtasv.net/T/#u
[3]: https://lore.kernel.org/qemu-devel/ac715039-55b0-400d-bd78-32ff7ec889c8@mtasv.net/T/#t
[4]: https://lore.kernel.org/qemu-devel/75d2c4d9-aa2e-4660-9a47-1cf0f8a23f7b@mtasv.net/T/#u
[5]: https://lore.kernel.org/qemu-devel/28e575ca-c2bc-4ff5-b686-0459f743ec65@mtasv.net/T/#u
[6]: https://lore.kernel.org/qemu-devel/f9750959-4b07-45b5-a834-89c4f825184b@mtasv.net/T/#t
[7]: https://lore.kernel.org/qemu-devel/cover.1779171125.git.prcups@krgm.moe/T/#t

于 2026年5月19日 GMT+08:00 14:30:39,SignKirigami <prcups@krgm.moe> 写道:
>This patch implements Loongson VirtualiZation (LVZ) extension support for LoongArch's TCG target. With this patch, it is now possible to start a nested KVM-accelerated virtual machine on a TCG-emulated virtual machine.
>
>Cc: Bibo Mao <maobibo@loongson.cn>
>Cc: xianglai li <lixianglai@loongson.cn>
>Signed-off-by: SignKirigami <prcups@krgm.moe>
>Signed-off-by: Hengyu Yu <yuhengyu25@mails.ucas.ac.cn>
>
>SignKirigami (4):
>  target/loongarch: add LVZ CPU state and CSR metadata
>  target/loongarch: add LVZ guest runtime support
>  target/loongarch: translate LVZ CSR and trap instructions
>  target/loongarch: virtualize guest TLB and address translation
>
> target/loongarch/cpu-csr.h                    |  42 ++
> target/loongarch/cpu-mmu.h                    |  37 +-
> target/loongarch/cpu.c                        | 132 ++++
> target/loongarch/cpu.h                        | 125 +++-
> target/loongarch/cpu_helper.c                 | 119 ++--
> target/loongarch/csr.c                        | 122 ++++
> target/loongarch/csr.h                        |   3 +
> target/loongarch/disas.c                      |  10 +
> target/loongarch/insns.decode                 |  17 +
> target/loongarch/internals.h                  |   8 +-
> target/loongarch/kvm/kvm.c                    |   1 +
> target/loongarch/machine.c                    | 249 ++++---
> target/loongarch/tcg/constant_timer.c         |  62 +-
> target/loongarch/tcg/csr_helper.c             | 127 +++-
> target/loongarch/tcg/helper.h                 |  30 +-
> .../tcg/insn_trans/trans_privileged.c.inc     | 353 +++++++++-
> target/loongarch/tcg/op_helper.c              |  83 ++-
> target/loongarch/tcg/tcg_cpu.c                | 182 +++--
> target/loongarch/tcg/tcg_loongarch.h          |   6 +-
> target/loongarch/tcg/tlb_helper.c             | 629 +++++++++++++-----
> target/loongarch/tcg/translate.c              |   6 +-
> target/loongarch/translate.h                  |   2 +
> 22 files changed, 1909 insertions(+), 436 deletions(-)
>
>-- 
>2.52.0
>
Re: [PATCH 0/4] target/loongarch: add LVZ support for TCG
Posted by Daniel P. Berrangé 1 week, 4 days ago
On Tue, May 19, 2026 at 04:09:32PM +0800, SignKirigami wrote:
> Please disregard my previous patch series[1][2][3][4][5][6].
> This was my first time using git send-email and my provider
> messed up the threads (the cover letter also accidentally
> reused a previous Message-ID, causing it to be grouped into
> the wrong thread[7]).

FWIW, personally I can recommend using the "git-publish" tool
for sending patch series as it makes it (mostly) foolproof.

Assuming you've got your work on a branch and keep using the
same branch across multiple postings of a piece of work, then
running 'git-publish' with no arguments will "do the right
thing(tm)", includign:

 * Format a mail for every patch on that branch vs master
 * Add a cover letter automatically if there are 2+ patches
 * Use MAINTAINERS to automatically CC (mostly) the right people
 * Keep track of patch versions, incrementing after each posting
 * Remember the cover letter text across each posting
 * Send to qemu-devel by default

The only config task for git-publish is to have the global
git "sendemail.smtpserver" option set, which you'll have already
done for git send-email.

There is more guidance on submitting patches at:

https://www.qemu.org/docs/master/devel/submitting-a-patch.html#submitting-your-patches


> I sincerely apologize for the noise and confusion.

No problem.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
Re: [PATCH 0/4] target/loongarch: add LVZ support for TCG
Posted by Bibo Mao 1 week, 4 days ago

On 2026/5/19 下午4:09, SignKirigami wrote:
> Please disregard my previous patch series[1][2][3][4][5][6]. This was my 
> first time using git send-email and my provider messed up the threads 
> (the cover letter also accidentally reused a previous Message-ID, 
> causing it to be grouped into the wrong thread[7]).
you can send the patchset to you only in order to test git send-mail 
command, or git send-mail --dry-run.

It is not enough to spit into 4 patches still, I guess it will take 
several months to merge this huge patch. Just be patient and not be such 
a hurry :), otherwise there will be lost of problems, code cleanup or 
bugfix.

Regards
Bibo Mao
> 
> I sincerely apologize for the noise and confusion.
> 
> ....
> 
> [1]: 
> https://lore.kernel.org/qemu-devel/734d561d-4a8c-4235-b55d-1387020f8a62@mtasv.net/T/#t
> [2]: 
> https://lore.kernel.org/qemu-devel/ff838e8c-8f44-446d-915d-cfb2ce869a5c@mtasv.net/T/#u
> [3]: 
> https://lore.kernel.org/qemu-devel/ac715039-55b0-400d-bd78-32ff7ec889c8@mtasv.net/T/#t
> [4]: 
> https://lore.kernel.org/qemu-devel/75d2c4d9-aa2e-4660-9a47-1cf0f8a23f7b@mtasv.net/T/#u
> [5]: 
> https://lore.kernel.org/qemu-devel/28e575ca-c2bc-4ff5-b686-0459f743ec65@mtasv.net/T/#u
> [6]: 
> https://lore.kernel.org/qemu-devel/f9750959-4b07-45b5-a834-89c4f825184b@mtasv.net/T/#t
> [7]: 
> https://lore.kernel.org/qemu-devel/cover.1779171125.git.prcups@krgm.moe/T/#t
> 
> 
> 于 2026年5月19日 GMT+08:00 14:30:39,SignKirigami <prcups@krgm.moe> 写道:
> 
>     This patch implements Loongson VirtualiZation (LVZ) extension
>     support for LoongArch's TCG target. With this patch, it is now
>     possible to start a nested KVM-accelerated virtual machine on a
>     TCG-emulated virtual machine.
> 
>     Cc: Bibo Mao <maobibo@loongson.cn>
>     Cc: xianglai li <lixianglai@loongson.cn>
>     Signed-off-by: SignKirigami <prcups@krgm.moe>
>     Signed-off-by: Hengyu Yu <yuhengyu25@mails.ucas.ac.cn>
> 
>     SignKirigami (4):
>     target/loongarch: add LVZ CPU state and CSR metadata
>     target/loongarch: add LVZ guest runtime support
>     target/loongarch: translate LVZ CSR and trap instructions
>     target/loongarch: virtualize guest TLB and address translation
> 
>     target/loongarch/cpu-csr.h | 42 ++
>     target/loongarch/cpu-mmu.h | 37 +-
>     target/loongarch/cpu.c | 132 ++++
>     target/loongarch/cpu.h | 125 +++-
>     target/loongarch/cpu_helper.c | 119 ++--
>     target/loongarch/csr.c | 122 ++++
>     target/loongarch/csr.h | 3 +
>     target/loongarch/disas.c | 10 +
>     target/loongarch/insns.decode | 17 +
>     target/loongarch/internals.h | 8 +-
>     target/loongarch/kvm/kvm.c | 1 +
>     target/loongarch/machine.c | 249 ++++---
>     target/loongarch/tcg/constant_timer.c | 62 +-
>     target/loongarch/tcg/csr_helper.c | 127 +++-
>     target/loongarch/tcg/helper.h | 30 +-
>     .../tcg/insn_trans/trans_privileged.c.inc | 353 +++++++++-
>     target/loongarch/tcg/op_helper.c | 83 ++-
>     target/loongarch/tcg/tcg_cpu.c | 182 +++--
>     target/loongarch/tcg/tcg_loongarch.h | 6 +-
>     target/loongarch/tcg/tlb_helper.c | 629 +++++++++++++-----
>     target/loongarch/tcg/translate.c | 6 +-
>     target/loongarch/translate.h | 2 +
>     22 files changed, 1909 insertions(+), 436 deletions(-)
>