[PATCH] target/loongarch: Remove TLB entry in vmstate

Bibo Mao posted 1 patch 1 month, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260929034252.712482-1-maobibo@loongson.cn
Maintainers: Song Gao <17746591750@163.com>, Bibo Mao <maobibo@loongson.cn>, Xianglai Li <lixianglai@loongson.cn>
target/loongarch/machine.c | 35 -----------------------------------
1 file changed, 35 deletions(-)
[PATCH] target/loongarch: Remove TLB entry in vmstate
Posted by Bibo Mao 1 month, 3 weeks ago
The content of TLB entry may change if LVZ is added, TLB table can
re-establish from empty state after VM migration. There will be
compatible issue if TLB entry is removed in vmstate, however it is
only affect TCG mode.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 target/loongarch/machine.c | 35 -----------------------------------
 1 file changed, 35 deletions(-)

diff --git a/target/loongarch/machine.c b/target/loongarch/machine.c
index 931a5ca5ba..952c5497af 100644
--- a/target/loongarch/machine.c
+++ b/target/loongarch/machine.c
@@ -175,38 +175,6 @@ static const VMStateDescription vmstate_pmu = {
     },
 };
 
-#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
-static bool tlb_needed(void *opaque)
-{
-    return tcg_enabled();
-}
-
-/* TLB state */
-static const VMStateDescription vmstate_tlb_entry = {
-    .name = "cpu/tlb_entry",
-    .version_id = 0,
-    .minimum_version_id = 0,
-    .fields = (const VMStateField[]) {
-        VMSTATE_UINT64(tlb_misc, LoongArchTLB),
-        VMSTATE_UINT64(tlb_entry0, LoongArchTLB),
-        VMSTATE_UINT64(tlb_entry1, LoongArchTLB),
-        VMSTATE_END_OF_LIST()
-    }
-};
-
-static const VMStateDescription vmstate_tlb = {
-    .name = "cpu/tlb",
-    .version_id = 0,
-    .minimum_version_id = 0,
-    .needed = tlb_needed,
-    .fields = (const VMStateField[]) {
-        VMSTATE_STRUCT_ARRAY(env.tlb, LoongArchCPU, LOONGARCH_TLB_MAX,
-                             0, vmstate_tlb_entry, LoongArchTLB),
-        VMSTATE_END_OF_LIST()
-    }
-};
-#endif
-
 /* LoongArch CPU state */
 const VMStateDescription vmstate_loongarch_cpu = {
     .name = "cpu",
@@ -283,9 +251,6 @@ const VMStateDescription vmstate_loongarch_cpu = {
         &vmstate_fpu,
         &vmstate_lsx,
         &vmstate_lasx,
-#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
-        &vmstate_tlb,
-#endif
         &vmstate_lbt,
         &vmstate_msgint,
         &vmstate_pmu,

base-commit: 81ce3a87737aa50716c42db8886082d12783e0a1
-- 
2.54.0
Re: [PATCH] target/loongarch: Remove TLB entry in vmstate
Posted by lixianglai 1 month, 1 week ago
Hi Bibo Mao:
> The content of TLB entry may change if LVZ is added, TLB table can
> re-establish from empty state after VM migration. There will be
> compatible issue if TLB entry is removed in vmstate, however it is
> only affect TCG mode.
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
>   target/loongarch/machine.c | 35 -----------------------------------
>   1 file changed, 35 deletions(-)
>
> diff --git a/target/loongarch/machine.c b/target/loongarch/machine.c
> index 931a5ca5ba..952c5497af 100644
> --- a/target/loongarch/machine.c
> +++ b/target/loongarch/machine.c
> @@ -175,38 +175,6 @@ static const VMStateDescription vmstate_pmu = {
>       },
>   };
>   
> -#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
> -static bool tlb_needed(void *opaque)
> -{
> -    return tcg_enabled();
> -}
> -
> -/* TLB state */
> -static const VMStateDescription vmstate_tlb_entry = {
> -    .name = "cpu/tlb_entry",
> -    .version_id = 0,
> -    .minimum_version_id = 0,
> -    .fields = (const VMStateField[]) {
> -        VMSTATE_UINT64(tlb_misc, LoongArchTLB),
> -        VMSTATE_UINT64(tlb_entry0, LoongArchTLB),
> -        VMSTATE_UINT64(tlb_entry1, LoongArchTLB),
> -        VMSTATE_END_OF_LIST()
> -    }
> -};
> -
> -static const VMStateDescription vmstate_tlb = {
> -    .name = "cpu/tlb",
> -    .version_id = 0,
> -    .minimum_version_id = 0,
> -    .needed = tlb_needed,
> -    .fields = (const VMStateField[]) {
> -        VMSTATE_STRUCT_ARRAY(env.tlb, LoongArchCPU, LOONGARCH_TLB_MAX,
> -                             0, vmstate_tlb_entry, LoongArchTLB),
> -        VMSTATE_END_OF_LIST()
> -    }
> -};
> -#endif
> -
>   /* LoongArch CPU state */
>   const VMStateDescription vmstate_loongarch_cpu = {
>       .name = "cpu",
> @@ -283,9 +251,6 @@ const VMStateDescription vmstate_loongarch_cpu = {
>           &vmstate_fpu,
>           &vmstate_lsx,
>           &vmstate_lasx,
> -#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
> -        &vmstate_tlb,
> -#endif
>           &vmstate_lbt,
>           &vmstate_msgint,
>           &vmstate_pmu,
>
> base-commit: 81ce3a87737aa50716c42db8886082d12783e0a1
Reviewed-by:  Xianglai Li <lixianglai@loongson.cn>