[PATCH 2/11] QEMU/KVM: Cleanup and improve kvm_load/save_registers usage

Jan Kiszka
2008-05-26T22:10:57Z

Remove redundant checkes for kvm_enabled() on register updates between
userspace and kvm kernel driver. Ensure register update across all CPUs
on "info cpus" monitor command.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
---
qemu/gdbstub.c | 12 ++++--------
qemu/monitor.c | 4 ++--
2 files changed, 6 insertions(+), 10 deletions(-)

Index: b/qemu/monitor.c
===================================================================
--- a/qemu/monitor.c
+++ b/qemu/monitor.c
@@ -286,8 +286,7 @@ static CPUState *mon_get_cpu(void)
mon_set_cpu(0);
}

- if (kvm_enabled())
- kvm_save_registers(mon_cpu);
+ kvm_save_registers(mon_cpu);

return mon_cpu;
}
@@ -315,6 +314,7 @@ static void do_info_cpus(void)
mon_get_cpu();

for(env = first_cpu; env != NULL; env = env->next_cpu) {
+ kvm_save_registers(env);
term_printf("%c CPU #%d:",
(env == mon_cpu) ? '*' : ' ',
env->cpu_index);
Index: b/qemu/gdbstub.c
===================================================================
--- a/qemu/gdbstub.c
+++ b/qemu/gdbstub.c
@@ -904,8 +904,7 @@ static int gdb_handle_packet(GDBState *s
addr = strtoull(p, (char **)&p, 16);
#if defined(TARGET_I386)
env->eip = addr;
- if (kvm_enabled())
- kvm_load_registers(env);
+ kvm_load_registers(env);
#elif defined (TARGET_PPC)
env->nip = addr;
#elif defined (TARGET_SPARC)
@@ -928,8 +927,7 @@ static int gdb_handle_packet(GDBState *s
addr = strtoull(p, (char **)&p, 16);
#if defined(TARGET_I386)
env->eip = addr;
- if (kvm_enabled())
- kvm_load_registers(env);
+ kvm_load_registers(env);
#elif defined (TARGET_PPC)
env->nip = addr;
#elif defined (TARGET_SPARC)
@@ -973,8 +971,7 @@ static int gdb_handle_packet(GDBState *s
}
break;
case 'g':
- if (kvm_enabled())
- kvm_save_registers(env);
+ kvm_save_registers(env);
reg_size = cpu_gdb_read_registers(env, mem_buf);
memtohex(buf, mem_buf, reg_size);
put_packet(s, buf);
@@ -984,8 +981,7 @@ static int gdb_handle_packet(GDBState *s
len = strlen(p) / 2;
hextomem((uint8_t *)registers, p, len);
cpu_gdb_write_registers(env, mem_buf, len);
- if (kvm_enabled())
- kvm_load_registers(env);
+ kvm_load_registers(env);
put_packet(s, "OK");
break;