diff --git a/0036-target-loongarch-kvm-Fix-VM-recovery-from-disk-failu.patch b/0036-target-loongarch-kvm-Fix-VM-recovery-from-disk-failu.patch new file mode 100644 index 0000000000000000000000000000000000000000..70007479a596fb4717c73715e816350fd398b8e7 --- /dev/null +++ b/0036-target-loongarch-kvm-Fix-VM-recovery-from-disk-failu.patch @@ -0,0 +1,42 @@ +From d93c003720daea0d50dd6bfacce3e01dec6fd6ba Mon Sep 17 00:00:00 2001 +From: Song Gao +Date: Wed, 8 May 2024 10:47:32 +0800 +Subject: [PATCH] target/loongarch/kvm: Fix VM recovery from disk failures + +vmstate does not save kvm_state_conter, +which can cause VM recovery from disk to fail. + +Signed-off-by: Song Gao +Acked-by: Peter Xu +Message-Id: <20240508024732.3127792-1-gaosong@loongson.cn> +--- + target/loongarch/machine.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/target/loongarch/machine.c b/target/loongarch/machine.c +index 1c4e01d076..5a7df713e2 100644 +--- a/target/loongarch/machine.c ++++ b/target/loongarch/machine.c +@@ -125,8 +125,8 @@ const VMStateDescription vmstate_tlb = { + /* LoongArch CPU state */ + const VMStateDescription vmstate_loongarch_cpu = { + .name = "cpu", +- .version_id = 1, +- .minimum_version_id = 1, ++ .version_id = 2, ++ .minimum_version_id = 2, + .fields = (VMStateField[]) { + VMSTATE_UINTTL_ARRAY(env.gpr, LoongArchCPU, 32), + VMSTATE_UINTTL(env.pc, LoongArchCPU), +@@ -191,6 +191,8 @@ const VMStateDescription vmstate_loongarch_cpu = { + VMSTATE_STRUCT_ARRAY(env.tlb, LoongArchCPU, LOONGARCH_TLB_MAX, + 0, vmstate_tlb, LoongArchTLB), + ++ VMSTATE_UINT64(kvm_state_counter, LoongArchCPU), ++ + VMSTATE_END_OF_LIST() + }, + .subsections = (const VMStateDescription*[]) { +-- +2.33.0 + diff --git a/0037-target-loongarch-kvm-fpu-save-the-vreg-registers-hig.patch b/0037-target-loongarch-kvm-fpu-save-the-vreg-registers-hig.patch new file mode 100644 index 0000000000000000000000000000000000000000..085408481c00a05b8383ab702e4adcdeb71eb862 --- /dev/null +++ b/0037-target-loongarch-kvm-fpu-save-the-vreg-registers-hig.patch @@ -0,0 +1,43 @@ +From acc4c06ed8e754f73974bddc39a877f6b5dea867 Mon Sep 17 00:00:00 2001 +From: Song Gao +Date: Tue, 14 May 2024 19:07:52 +0800 +Subject: [PATCH 2/2] target/loongarch/kvm: fpu save the vreg registers high + 192bit + +On kvm side, get_fpu/set_fpu save the vreg registers high 192bits, +but QEMU missing. + +Signed-off-by: Song Gao +Reviewed-by: Bibo Mao +Message-Id: <20240514110752.989572-1-gaosong@loongson.cn> +--- + target/loongarch/kvm/kvm.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c +index bc75552d0f..8e6e27c8bf 100644 +--- a/target/loongarch/kvm/kvm.c ++++ b/target/loongarch/kvm/kvm.c +@@ -436,6 +436,9 @@ static int kvm_loongarch_get_regs_fp(CPUState *cs) + env->fcsr0 = fpu.fcsr; + for (i = 0; i < 32; i++) { + env->fpr[i].vreg.UD[0] = fpu.fpr[i].val64[0]; ++ env->fpr[i].vreg.UD[1] = fpu.fpr[i].val64[1]; ++ env->fpr[i].vreg.UD[2] = fpu.fpr[i].val64[2]; ++ env->fpr[i].vreg.UD[3] = fpu.fpr[i].val64[3]; + } + for (i = 0; i < 8; i++) { + env->cf[i] = fpu.fcc & 0xFF; +@@ -455,6 +458,9 @@ static int kvm_loongarch_put_regs_fp(CPUState *cs) + fpu.fcc = 0; + for (i = 0; i < 32; i++) { + fpu.fpr[i].val64[0] = env->fpr[i].vreg.UD[0]; ++ fpu.fpr[i].val64[1] = env->fpr[i].vreg.UD[1]; ++ fpu.fpr[i].val64[2] = env->fpr[i].vreg.UD[2]; ++ fpu.fpr[i].val64[3] = env->fpr[i].vreg.UD[3]; + } + + for (i = 0; i < 8; i++) { +-- +2.34.1 + diff --git a/qemu.spec b/qemu.spec index e42f0414f58c46c96e03ddfdad2d0eeef6ccd97c..03a27014a4b818b04d86e1d8ca6dbac9d4420549 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,4 +1,4 @@ -%define anolis_release 13 +%define anolis_release 14 %bcond_with check @@ -300,6 +300,9 @@ Patch0034: 0034-target-loongarch-Fix-qemu-system-loongarch64-assert-.patch Patch0035: 0035-newfeature-support-vpsp.patch +Patch0036: 0036-target-loongarch-kvm-Fix-VM-recovery-from-disk-failu.patch +Patch0037: 0037-target-loongarch-kvm-fpu-save-the-vreg-registers-hig.patch + Patch1001: 1001-i386-cpu-Clear-FEAT_XSAVE_XSS_LO-HI-leafs-when-CPUID.patch Patch1002: 1002-i386-cpu-Mask-with-XCR0-XSS-mask-for-FEAT_XSAVE_XCR0.patch Patch1003: 1003-i386-cpuid-Decrease-cpuid_i-when-skipping-CPUID-leaf.patch @@ -973,8 +976,6 @@ Requires: %{name}-system-loongarch64-core = %{EVR} This package provides the QEMU system emulator for Loongson boards. %package system-loongarch64-core -Requires: seabios-bin -Requires: sgabios-bin Requires: seavgabios-bin %if %{have_edk2} Requires: edk2-loongarch64 @@ -1916,6 +1917,11 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %endif %changelog +* Wed May 22 2024 Song Gao -2.8.2.0-14 +- Patch0036: 0036-target-loongarch-kvm-Fix-VM-recovery-from-disk-failu.patch +- Patch0037: 0037-target-loongarch-kvm-fpu-save-the-vreg-registers-hig.patch + (Fix migration bugs and remove unused requires) + * Mon May 20 2024 Song Gao -2.8.2.0-13 - Fix system-loongarch64-core requires