summary refs log tree commit diff stats
path: root/target/loongarch/machine.c
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2024-09-29 15:04:05 +0800
committerSong Gao <gaosong@loongson.cn>2024-11-02 15:20:41 +0800
commita45df286013270868e6d6e94c287dff19339a4b4 (patch)
treee77acf3be0b1c0255da6ce9fb0d9380c07bca899 /target/loongarch/machine.c
parentc23a53d89429d9181bc0423e2708851b02b9ff4a (diff)
downloadfocaccia-qemu-a45df286013270868e6d6e94c287dff19339a4b4.tar.gz
focaccia-qemu-a45df286013270868e6d6e94c287dff19339a4b4.zip
target/loongarch: Implement lbt registers save/restore function
Six registers scr0 - scr3, eflags and ftop are added in percpu vmstate.
And two functions kvm_loongarch_get_lbt/kvm_loongarch_put_lbt are added
to save/restore lbt registers.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20240929070405.235200-3-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
Diffstat (limited to 'target/loongarch/machine.c')
-rw-r--r--target/loongarch/machine.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/target/loongarch/machine.c b/target/loongarch/machine.c
index 08a7fa5370..3d5c84ae9c 100644
--- a/target/loongarch/machine.c
+++ b/target/loongarch/machine.c
@@ -110,6 +110,29 @@ static const VMStateDescription vmstate_lasx = {
     },
 };
 
+static bool lbt_needed(void *opaque)
+{
+    LoongArchCPU *cpu = opaque;
+
+    return !!FIELD_EX64(cpu->env.cpucfg[2], CPUCFG2, LBT_ALL);
+}
+
+static const VMStateDescription vmstate_lbt = {
+    .name = "cpu/lbt",
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .needed = lbt_needed,
+    .fields = (const VMStateField[]) {
+        VMSTATE_UINT64(env.lbt.scr0,   LoongArchCPU),
+        VMSTATE_UINT64(env.lbt.scr1,   LoongArchCPU),
+        VMSTATE_UINT64(env.lbt.scr2,   LoongArchCPU),
+        VMSTATE_UINT64(env.lbt.scr3,   LoongArchCPU),
+        VMSTATE_UINT32(env.lbt.eflags, LoongArchCPU),
+        VMSTATE_UINT32(env.lbt.ftop,   LoongArchCPU),
+        VMSTATE_END_OF_LIST()
+    },
+};
+
 #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 static bool tlb_needed(void *opaque)
 {
@@ -219,6 +242,7 @@ const VMStateDescription vmstate_loongarch_cpu = {
 #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
         &vmstate_tlb,
 #endif
+        &vmstate_lbt,
         NULL
     }
 };