qemu-kvm: Cleanup and switch to upstream - Part I
cover qemu-kvm: Cleanup and switch to upstream - Part I
All required bits for this cleanup of qemu-kvm are now upstream and merged back - it's time to start the show. There are now 65 patches in my queue, and I'm planning for at least 4 rounds.
This first part primarily aims at using upstream kvm_arch_init. Further highlights are:
- switch to upstream CPU register get/put
- switch to upstream kvmclock
- sustainable breakage of IA64
Please review/merge.
Jan Kiszka (19):
qemu-kvm: Switch to upstream mp_state functions
qemu-kvm: x86: Use upstream kvmclock device
Revert "introduce VMSTATE_U64"
qemu-kvm: x86: Drop MSR reset
qemu-kvm: Use upstream VCPU reset services
qemu-kvm: Use upstream vcpu initialization
qemu-kvm: Start using qemu-thread services
qemu-kvm: Use upstream kvm_arch_get/put_registers
qemu-kvm: Use upstream state synchronization services
qemu-kvm: Drop remaining libkvm fragments
qemu-kvm: Drop some more unused code
qemu-kvm: Drop some obsolete/unused fields from kvm_context
qemu-kvm: Refactor in-kernel irqchip and pit control
qemu-kvm: Fold kvm_create into kvm_create_context
qemu-kvm: Fold kvm_arch_qemu_create_context into kvm_arch_create
qemu-kvm: Push PIT reinjection control into x86 code
qemu-kvm: Replace kvm_show_regs/code with cpu_dump_state
qemu-kvm: Fold kvm_init_coalesced_mmio into kvm_create_context
qemu-kvm: x86: Use kvm_arch_init
configure | 1 + cpu-defs.h | 1 - hw/hw.h | 13 -- hw/pc_piix.c | 2 - kvm-all.c | 18 +- qemu-kvm-ia64.c | 6 +- qemu-kvm-x86.c | 503 +------------------------------------------------ qemu-kvm.c | 381 +++++++------------------------------- qemu-kvm.h | 265 +-------------------------- savevm.c | 23 --- target-i386/kvm.c | 37 +++- target-i386/libkvm.h | 28 --- target-ppc/libkvm.c | 102 ---------- target-ppc/libkvm.h | 36 ---- 14 files changed, 116 insertions(+), 1300 deletions(-) delete mode 100644 target-i386/libkvm.h delete mode 100644 target-ppc/libkvm.c delete mode 100644 target-ppc/libkvm.h
PATCH 1/19 qemu-kvm: Switch to upstream mp_state functions
From: Jan Kiszka <[email protected]>
They are now equivalent to qemu-kvm's version (minus the obsolete feature check).
--- qemu-kvm-x86.c | 40 ++-------------------------------------- target-i386/kvm.c | 2 -- 2 files changed, 2 insertions(+), 40 deletions(-)
qemu-kvm-x86.c +2 -38
@@ -546,42 +546,6 @@ int kvm_arch_qemu_create_context(void)return 0 ; } -static void kvm_arch_save_mpstate (CPUState *env) -{ -#ifdef KVM_CAP_MP_STATE -int r; -struct kvm_mp_state mp_state; - - r =kvm_get_mpstate (env, &mp_state); -if (r <0 ) { - env->mp_state =-1 ; - }else { - env->mp_state = mp_state.mp_state; -if (kvm_irqchip_in_kernel ()) { - env->halted = (env->mp_state ==KVM_MP_STATE_HALTED ); - } - } -#else - env->mp_state =-1 ; -#endif -} - -static void kvm_arch_load_mpstate (CPUState *env) -{ -#ifdef KVM_CAP_MP_STATE -struct kvm_mp_state mp_state; - -/* -* -1 indicates that the host did not support GET_MP_STATE ioctl, -* so don't touch it. -*/ -if (env->mp_state !=-1 ) { - mp_state.mp_state = env->mp_state; -kvm_set_mpstate (env, &mp_state); - } -#endif -} -#define XSAVE_CWD_RIP 2#define XSAVE_CWD_RDP 4#define XSAVE_MXCSR 6
@@ -609,7 +573,7 @@ void kvm_arch_load_regs(CPUState *env, int level) }if (level >=KVM_PUT_RESET_STATE ) { -kvm_arch_load_mpstate (env); +kvm_put_mp_state (env);kvm_load_lapic (env); }if (level ==KVM_PUT_FULL_STATE ) {
@@ -643,7 +607,7 @@ void kvm_arch_save_regs(CPUState *env)perror ("kvm_get_msrs FAILED" ); } -kvm_arch_save_mpstate (env); +kvm_get_mp_state (env);kvm_save_lapic (env);kvm_get_vcpu_events (env);kvm_get_debugregs (env);
target-i386/kvm.c +0 -2
@@ -1280,7 +1280,6 @@ static int kvm_get_msrs(CPUState *env)return 0 ; } -#ifdef OBSOLETE_KVM_IMPL static int kvm_put_mp_state (CPUState *env) {struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
@@ -1303,7 +1302,6 @@ static int kvm_get_mp_state(CPUState *env) }return 0 ; } -#endif static int kvm_put_vcpu_events (CPUState *env,int level) {
Signature · 1 line
1.7.1
PATCH 2/19 qemu-kvm: x86: Use upstream kvmclock device
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Upstream kvmclock device is actually more advanced these days while using a compatible vmstate. Time to switch over.
--- hw/pc_piix.c | 2 -- qemu-kvm-x86.c | 37 ------------------------------------- 2 files changed, 0 insertions(+), 39 deletions(-)
hw/pc_piix.c +0 -2
@@ -94,11 +94,9 @@ static void pc_init1(ram_addr_t ram_size,pc_cpus_init (cpu_model); -#ifdef OBSOLETE_KVM_IMPL if (kvmclock_enabled) {kvmclock_create (); } -#endif /* allocate ram and load rom/bios */ pc_memory_init(ram_size, kernel_filename, kernel_cmdline, initrd_filename,
qemu-kvm-x86.c +0 -37
@@ -478,37 +478,6 @@ static int kvm_enable_tpr_access_reporting(CPUState *env) }#endif -#ifdef KVM_CAP_ADJUST_CLOCK -static struct kvm_clock_data kvmclock_data; - -static void kvmclock_pre_save (void *opaque) -{ -struct kvm_clock_data *cl = opaque; - -kvm_vm_ioctl (kvm_state,KVM_GET_CLOCK , cl); -} - -static int kvmclock_post_load (void *opaque,int version_id) -{ -struct kvm_clock_data *cl = opaque; - -return kvm_vm_ioctl (kvm_state,KVM_SET_CLOCK , cl); -} - -static const VMStateDescription vmstate_kvmclock= { - .name ="kvmclock" , - .version_id =1 , - .minimum_version_id =1 , - .minimum_version_id_old =1 , - .pre_save = kvmclock_pre_save, - .post_load = kvmclock_post_load, - .fields = (VMStateField []) { - VMSTATE_U64(clock, struct kvm_clock_data), -VMSTATE_END_OF_LIST () - } -}; -#endif -int kvm_arch_qemu_create_context (void ) {int r;
@@ -532,12 +501,6 @@ int kvm_arch_qemu_create_context(void)return -1 ; } -#ifdef KVM_CAP_ADJUST_CLOCK -if (kvm_check_extension (kvm_state,KVM_CAP_ADJUST_CLOCK )) { -vmstate_register (NULL ,0 , &vmstate_kvmclock, &kvmclock_data); - } -#endif - r =kvm_set_boot_cpu_id (0 );if (r <0 && r != -ENOSYS ) {return r;
Signature · 1 line
1.7.1
PATCH 3/19 Revert "introduce VMSTATE_U64"
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This reverts commit e4d6d49061b45e7134437cdd5bae2d443eedc3bc.
It's no longer used.
Conflicts:
savevm.c
--- hw/hw.h | 13 ------------- savevm.c | 23 ----------------------- 2 files changed, 0 insertions(+), 36 deletions(-)
hw/hw.h +0 -13
@@ -353,10 +353,6 @@ extern const VMStateInfo vmstate_info_uint16;extern const VMStateInfo vmstate_info_uint32;extern const VMStateInfo vmstate_info_uint64; -#ifdef __linux__ -extern const VMStateInfo vmstate_info_u64; -#endif -extern const VMStateInfo vmstate_info_timer;extern const VMStateInfo vmstate_info_ptimer;extern const VMStateInfo vmstate_info_buffer;
@@ -766,15 +762,6 @@ extern const VMStateDescription vmstate_ptimer;#define VMSTATE_UINT64 (_f, _s) \ VMSTATE_UINT64_V(_f, _s, 0) -/* This is needed because on linux __u64 is unsigned long long -and on glibc uint64_t is unsigned long on 64 bits */ -#ifdef __linux__ -#define VMSTATE_U64_V (_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_u64, __u64) -#define VMSTATE_U64 (_f, _s) \ - VMSTATE_U64_V(_f, _s, 0) -#endif -#define VMSTATE_UINT8_EQUAL (_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t)
savevm.c +0 -23
@@ -925,29 +925,6 @@ const VMStateInfo vmstate_info_uint64 = { .put = put_uint64, }; -/* 64 bit linux kernel unsigned int */ - -#ifdef __linux__ -static int get_u64 (QEMUFile *f,void *pv,size_t size) -{ -uint64_t *v = pv; -qemu_get_be64s (f, v); -return 0 ; -} - -static void put_u64 (QEMUFile *f,void *pv,size_t size) -{ -uint64_t *v = pv; -qemu_put_be64s (f, v); -} - -const VMStateInfo vmstate_info_u64 = { - .name ="__u64" , - .get = get_u64, - .put = put_u64, -}; -#endif /* __linux__ */ -/* 8 bit int. See that the received value is the same than the one in the field */
Signature · 1 line
1.7.1
PATCH 7/19 qemu-kvm: Start using qemu-thread services
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Convert VCPU thread creation to qemu_thread_create. This allows to drop the thread field from KVMCPUState. It requires us to rename qemu-kvm's qemu_cond_wait as a temporary solution until we find a common version.
--- configure | 1 + cpu-defs.h | 1 - qemu-kvm-x86.c | 4 ++-- qemu-kvm.c | 29 ++++++++++++++--------------- 4 files changed, 17 insertions(+), 18 deletions(-)
configure +1 -0
@@ -3382,6 +3382,7 @@ case "$target_arch2" in \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \ \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then echo "CONFIG_KVM=y" >> $config_target_mak + echo "CONFIG_THREAD=y" >> $config_host_mak echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak if test "$kvm_para" = "yes"; then echo "CONFIG_KVM_PARA=y" >> $config_target_mak
cpu-defs.h +0 -1
@@ -158,7 +158,6 @@ typedef struct CPUWatchpoint {struct qemu_work_item ;struct KVMCPUState { -pthread_t thread;int signalled;struct qemu_work_item *queued_work_first, *queued_work_last; };
qemu-kvm-x86.c +2 -2
@@ -486,7 +486,7 @@ void kvm_arch_load_regs(CPUState *env, int level) {int rc; -assert (kvm_cpu_is_stopped (env) || env->thread_id ==kvm_get_thread_id ()); +assert (kvm_cpu_is_stopped (env) ||qemu_cpu_is_self (env));kvm_getput_regs (env,1 );
@@ -521,7 +521,7 @@ void kvm_arch_save_regs(CPUState *env) {int rc; -assert (kvm_cpu_is_stopped (env) || env->thread_id ==kvm_get_thread_id ()); +assert (kvm_cpu_is_stopped (env) ||qemu_cpu_is_self (env));kvm_getput_regs (env,0 );
qemu-kvm.c +14 -15
@@ -19,6 +19,7 @@#include "gdbstub.h" #include "monitor.h" #include "cpus.h" +#include "qemu-thread.h" #include "qemu-kvm.h" #include "libkvm.h"
@@ -498,7 +499,7 @@ int kvm_run(CPUState *env) }if (env->exit_request) { env->exit_request =0 ; -pthread_kill (env->kvm_cpu_state.thread,SIG_IPI ); +pthread_kill (env->thread->thread,SIG_IPI ); } r =ioctl (fd,KVM_RUN ,0 );
@@ -1034,7 +1035,7 @@ unsigned long kvm_get_thread_id(void)return syscall (SYS_gettid); } -static void qemu_cond_wait (pthread_cond_t *cond) +static void kvm_cond_wait (pthread_cond_t *cond) {CPUState *env = cpu_single_env;
@@ -1090,9 +1091,9 @@ void on_vcpu(CPUState *env, void (*func)(void *data), void *data) wi.next =NULL ; wi.done = false; -pthread_kill (env->kvm_cpu_state.thread,SIG_IPI ); +pthread_kill (env->thread->thread,SIG_IPI );while (!wi.done) { -qemu_cond_wait (&qemu_work_cond); +kvm_cond_wait (&qemu_work_cond); } }
@@ -1153,8 +1154,8 @@ void kvm_update_interrupt_request(CPUState *env)if (signal) { env->kvm_cpu_state.signalled =1 ; -if (env->kvm_cpu_state.thread) { -pthread_kill (env->kvm_cpu_state.thread,SIG_IPI ); +if (env->thread) { +pthread_kill (env->thread->thread,SIG_IPI ); } } }
@@ -1272,7 +1273,7 @@ static void pause_all_threads(void)while (penv) {if (penv != cpu_single_env) { penv->stop =1 ; -pthread_kill (penv->kvm_cpu_state.thread,SIG_IPI ); +pthread_kill (penv->thread->thread,SIG_IPI ); }else { penv->stop =0 ; penv->stopped =1 ;
@@ -1282,7 +1283,7 @@ static void pause_all_threads(void) }while (!all_threads_paused ()) { -qemu_cond_wait (&qemu_pause_cond); +kvm_cond_wait (&qemu_pause_cond); } }
@@ -1295,7 +1296,7 @@ static void resume_all_threads(void)while (penv) { penv->stop =0 ; penv->stopped =0 ; -pthread_kill (penv->kvm_cpu_state.thread,SIG_IPI ); +pthread_kill (penv->thread->thread,SIG_IPI ); penv = (CPUState *) penv->next_cpu; } }
@@ -1368,15 +1369,12 @@ static int kvm_main_loop_cpu(CPUState *env)static void *ap_main_loop (void *_env) {CPUState *env = _env; -sigset_t signals;#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT struct ioperm_data *data =NULL ;#endif current_env = env; env->thread_id =kvm_get_thread_id (); -sigfillset (&signals); -sigprocmask (SIG_BLOCK , &signals,NULL );#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT /* do ioperm for io ports of assigned devices */
@@ -1398,7 +1396,7 @@ static void *ap_main_loop(void *_env)/* and wait for machine initialization */ while (!qemu_system_ready) { -qemu_cond_wait (&qemu_system_cond); +kvm_cond_wait (&qemu_system_cond); }/* re-initialize cpu_single_env after re-acquiring qemu_mutex */
@@ -1410,10 +1408,11 @@ static void *ap_main_loop(void *_env)int kvm_init_vcpu (CPUState *env) { -pthread_create (&env->kvm_cpu_state.thread,NULL , ap_main_loop, env); + env->thread =qemu_mallocz (sizeof (QemuThread)); +qemu_thread_create (env->thread, ap_main_loop, env);while (env->created ==0 ) { -qemu_cond_wait (&qemu_vcpu_cond); +kvm_cond_wait (&qemu_vcpu_cond); }return 0 ;
Signature · 1 line
1.7.1
PATCH 10/19 qemu-kvm: Drop remaining libkvm fragments
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
The bits under kvm/ are kept for now, not sure if they still serve any purpose. Same for anything in target-ia64. That arch is now definitely broken, but I bet it was already.
--- qemu-kvm-x86.c | 3 +- qemu-kvm.c | 6 --- qemu-kvm.h | 11 ----- target-i386/libkvm.h | 28 -------------- target-ppc/libkvm.c | 102 -------------------------------------------------- target-ppc/libkvm.h | 36 ----------------- 6 files changed, 1 insertions(+), 185 deletions(-) delete mode 100644 target-i386/libkvm.h delete mode 100644 target-ppc/libkvm.c delete mode 100644 target-ppc/libkvm.h
qemu-kvm-x86.c +1 -2
@@ -15,7 +15,6 @@#include <sys/io.h> #include "qemu-kvm.h" -#include "libkvm.h" #include <pthread.h> #include <sys/utsname.h> #include <linux/kvm_para.h>
@@ -28,7 +27,7 @@extern unsigned int kvm_shadow_memory; -int kvm_set_tss_addr (kvm_context_t kvm,unsigned long addr) +static int kvm_set_tss_addr (kvm_context_t kvm,unsigned long addr) {int r;
qemu-kvm.c +0 -6
@@ -22,7 +22,6 @@#include "qemu-thread.h" #include "qemu-kvm.h" -#include "libkvm.h" #include <pthread.h> #include <sys/utsname.h>
@@ -84,9 +83,6 @@ static QLIST_HEAD(, ioperm_data) ioperm_head;#define ALIGN (x, y) (((x)+(y)-1) & ~((y)-1)) -int kvm_abi =EXPECTED_KVM_API_VERSION ; -int kvm_page_size; -static int handle_unhandled (uint64_t reason) {fprintf (stderr,"kvm: unhandled exit %" PRIx64"\n" , reason);
@@ -162,8 +158,6 @@ int kvm_init(void)fprintf (stderr,"kvm userspace version too old\n" ); goto out_close; } - kvm_abi = r; - kvm_page_size =getpagesize (); kvm_state =qemu_mallocz (sizeof (*kvm_state)); kvm_context = &kvm_state->kvm_context;
qemu-kvm.h +0 -11
@@ -43,9 +43,6 @@#define MAX_VCPUS 16#endif -/* kvm abi verison variable */ -extern int kvm_abi; -/** * \brief The KVM context *
@@ -457,14 +454,6 @@ int kvm_enable_vapic(CPUState *env, uint64_t vapic);#endif -#if defined(__s390__) -int kvm_s390_initial_reset (kvm_context_t kvm,int slot); -int kvm_s390_interrupt (kvm_context_t kvm,int slot, -struct kvm_s390_interrupt *kvmint); -int kvm_s390_set_initial_psw (kvm_context_t kvm,int slot,psw_t psw); -int kvm_s390_store_status (kvm_context_t kvm,int slot,unsigned long addr); -#endif -#ifdef KVM_CAP_DEVICE_ASSIGNMENT /*! * \brief Notifies host kernel about a PCI device to be assigned to a guest
target-i386/libkvm.h deleted +0 -28
@@ -1,28 +0,0 @@ -/* -* This header is for functions & variables that will ONLY be -* used inside libkvm for x86. -* THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE -* WITHIN LIBKVM. -* -* derived from libkvm.c -* -* Copyright (C) 2006 Qumranet, Inc. -* -* Authors: -* Avi Kivity <[email protected]> -* Yaniv Kamay <[email protected]> -* -* This work is licensed under the GNU LGPL license, version 2. -*/ - -#ifndef KVM_X86_H -#define KVM_X86_H - -#define PAGE_SIZE 4096ul -#define PAGE_MASK (~(PAGE_SIZE - 1)) - -int kvm_set_tss_addr (kvm_context_t kvm,unsigned long addr); - -#define smp_wmb () asm volatile("" ::: "memory") - -#endif
target-ppc/libkvm.c deleted +0 -102
102 lines not on this page · raw message
target-ppc/libkvm.h deleted +0 -36
@@ -1,36 +0,0 @@ -/* -* This header is for functions & variables that will ONLY be -* used inside libkvm for powerpc. -* THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE -* WITHIN LIBKVM. -* -* Copyright (C) 2006 Qumranet, Inc. -* -* Authors: -* Avi Kivity <[email protected]> -* Yaniv Kamay <[email protected]> -* -* Copyright 2007 IBM Corporation. -* Added by: Jerone Young <[email protected]> -* -* This work is licensed under the GNU LGPL license, version 2. -*/ - -#ifndef KVM_POWERPC_H -#define KVM_POWERPC_H - -#include "libkvm-all.h" - -extern int kvm_page_size; - -#define PAGE_SIZE kvm_page_size -#define PAGE_MASK (~(PAGE_SIZE - 1)) - -static inline void eieio (void ) -{ - asmvolatile ("eieio" : : :"memory" ); -} - -#define smp_wmb () eieio() - -#endif
Signature · 1 line
1.7.1
PATCH 11/19 qemu-kvm: Drop some more unused code
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
No more users (except broken ia64), so remove this dead code.
--- qemu-kvm-x86.c | 15 ----- qemu-kvm.c | 92 -------------------------------- qemu-kvm.h | 161 -------------------------------------------------------- 3 files changed, 0 insertions(+), 268 deletions(-)
qemu-kvm-x86.c +0 -15
@@ -418,21 +418,6 @@ int kvm_set_shadow_pages(kvm_context_t kvm, unsigned int nrshadow_pages)return -1 ; } -int kvm_get_shadow_pages (kvm_context_t kvm,unsigned int *nrshadow_pages) -{ -#ifdef KVM_CAP_MMU_SHADOW_CACHE_CONTROL -int r; - - r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION , -KVM_CAP_MMU_SHADOW_CACHE_CONTROL ); -if (r >0 ) { - *nrshadow_pages =kvm_vm_ioctl (kvm_state,KVM_GET_NR_MMU_PAGES ); -return 0 ; - } -#endif -return -1 ; -} -#ifdef KVM_CAP_VAPIC static int kvm_enable_tpr_access_reporting (CPUState *env) {
qemu-kvm.c +0 -92
134 lines not on this page · raw message
qemu-kvm.h +0 -161
248 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 12/19 qemu-kvm: Drop some obsolete/unused fields from kvm_context
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
irqchip_in_kernel cam be migrated to the field in KVMState, and opaque as well as dirty_pages_log_all were write-only.
--- qemu-kvm-x86.c | 2 +- qemu-kvm.c | 18 ++++++------------ qemu-kvm.h | 7 +------ 3 files changed, 8 insertions(+), 19 deletions(-)
qemu-kvm-x86.c +1 -1
@@ -518,7 +518,7 @@ int kvm_arch_try_push_interrupts(void *opaque) }#ifdef KVM_CAP_USER_NMI -void kvm_arch_push_nmi (void *opaque) +void kvm_arch_push_nmi (void ) {CPUState *env = cpu_single_env;int r;
qemu-kvm.c +6 -12
@@ -157,10 +157,6 @@ int kvm_init(void) kvm_state->fd = fd; kvm_state->vmfd =-1 ; - kvm_context->opaque = cpu_single_env; - kvm_context->dirty_pages_log_all =0 ; - kvm_context->no_irqchip_creation =0 ; - kvm_context->no_pit_creation =0 ;#ifdef KVM_CAP_SET_GUEST_DEBUG QTAILQ_INIT (&kvm_state->kvm_sw_breakpoints);
@@ -263,7 +259,6 @@ void kvm_create_irqchip(kvm_context_t kvm) {int r; - kvm->irqchip_in_kernel =0 ;#ifdef KVM_CAP_IRQCHIP if (!kvm->no_irqchip_creation) { r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION ,KVM_CAP_IRQCHIP );
@@ -278,13 +273,12 @@ void kvm_create_irqchip(kvm_context_t kvm) kvm->irqchip_inject_ioctl =KVM_IRQ_LINE_STATUS ; }#endif - kvm->irqchip_in_kernel = 1; + kvm_state->irqchip_in_kernel = 1; }else fprintf (stderr,"Create kernel PIC irqchip failed\n" ); } }#endif - kvm_state->irqchip_in_kernel = kvm->irqchip_in_kernel; }int kvm_create (kvm_context_t kvm,unsigned long phys_mem_bytes,void **vm_mem)
@@ -320,7 +314,7 @@ int kvm_set_irq_level(kvm_context_t kvm, int irq, int level, int *status)struct kvm_irq_level event;int r; -if (!kvm->irqchip_in_kernel) { +if (!kvm_state->irqchip_in_kernel) {return 0 ; } event.level = level;
@@ -346,7 +340,7 @@ int kvm_get_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip) {int r; -if (!kvm->irqchip_in_kernel) { +if (!kvm_state->irqchip_in_kernel) {return 0 ; } r =kvm_vm_ioctl (kvm_state,KVM_GET_IRQCHIP , chip);
@@ -360,7 +354,7 @@ int kvm_set_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip) {int r; -if (!kvm->irqchip_in_kernel) { +if (!kvm_state->irqchip_in_kernel) {return 0 ; } r =kvm_vm_ioctl (kvm_state,KVM_SET_IRQCHIP , chip);
@@ -404,7 +398,7 @@ int handle_shutdown(kvm_context_t kvm, CPUState *env)static inline void push_nmi (kvm_context_t kvm) {#ifdef KVM_CAP_USER_NMI -kvm_arch_push_nmi (kvm->opaque); +kvm_arch_push_nmi ();#endif /* KVM_CAP_USER_NMI */ }
@@ -442,7 +436,7 @@ int kvm_run(CPUState *env) }push_nmi (kvm);#if !defined(__s390__) -if (!kvm->irqchip_in_kernel) { +if (!kvm_state->irqchip_in_kernel) { run->request_interrupt_window =kvm_arch_try_push_interrupts (env); }#endif
qemu-kvm.h +1 -6
@@ -50,13 +50,8 @@*/ struct kvm_context { -void *opaque; -/// is dirty pages logging enabled for all regions or not -int dirty_pages_log_all;/// do not create in-kernel irqchip if set int no_irqchip_creation; -/// in-kernel irqchip status -int irqchip_in_kernel;/// ioctl to use to inject interrupts int irqchip_inject_ioctl;/// do not create in-kernel pit if set
@@ -500,7 +495,7 @@ int kvm_arch_qemu_create_context(void);int kvm_arch_has_work (CPUState *env);void kvm_arch_process_irqchip_events (CPUState *env);int kvm_arch_try_push_interrupts (void *opaque); -void kvm_arch_push_nmi (void *opaque); +void kvm_arch_push_nmi (void );int kvm_set_boot_cpu_id (uint32_t id);void kvm_tpr_access_report (CPUState *env,uint64_t rip,int is_write);
Signature · 1 line
1.7.1
PATCH 13/19 qemu-kvm: Refactor in-kernel irqchip and pit control
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Simplify the logic for detecting and querying if in-kernel irqchip and pit should be created. This also allows to drop two further fields from kvm_context.
--- qemu-kvm-x86.c | 16 +++++----------- qemu-kvm.c | 20 +++----------------- qemu-kvm.h | 24 ------------------------ 3 files changed, 8 insertions(+), 52 deletions(-)
qemu-kvm-x86.c +5 -11
@@ -105,17 +105,11 @@ static int kvm_create_pit(kvm_context_t kvm)#ifdef KVM_CAP_PIT int r; - kvm_state->pit_in_kernel =0 ; -if (!kvm->no_pit_creation) { - r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION ,KVM_CAP_PIT ); -if (r >0 ) { - r =kvm_vm_ioctl (kvm_state,KVM_CREATE_PIT ); -if (r >=0 ) { - kvm_state->pit_in_kernel =1 ; - }else { -fprintf (stderr,"Create kernel PIC irqchip failed\n" ); -return r; - } +if (kvm_pit_in_kernel ()) { + r =kvm_vm_ioctl (kvm_state,KVM_CREATE_PIT ); +if (r <0 ) { +fprintf (stderr,"Create kernel PIC irqchip failed\n" ); +return r; } }#endif
qemu-kvm.c +3 -17
@@ -199,16 +199,6 @@ static void kvm_finalize(KVMState *s)free (s); } -void kvm_disable_irqchip_creation (kvm_context_t kvm) -{ - kvm->no_irqchip_creation =1 ; -} - -void kvm_disable_pit_creation (kvm_context_t kvm) -{ - kvm->no_pit_creation =1 ; -} -static int kvm_set_boot_vcpu_id (kvm_context_t kvm,uint32_t id) {#ifdef KVM_CAP_SET_BOOT_CPU_ID
@@ -260,7 +250,7 @@ void kvm_create_irqchip(kvm_context_t kvm)int r;#ifdef KVM_CAP_IRQCHIP -if (!kvm->no_irqchip_creation) { +if (kvm_irqchip) { r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION ,KVM_CAP_IRQCHIP );if (r >0 ) {/* kernel irqchip supported */ r =kvm_vm_ioctl (kvm_state,KVM_CREATE_IRQCHIP );
@@ -1437,12 +1427,8 @@ static int kvm_create_context(void)int r; -if (!kvm_irqchip) { -kvm_disable_irqchip_creation (kvm_context); - } -if (!kvm_pit) { -kvm_disable_pit_creation (kvm_context); - } + kvm_state->pit_in_kernel = kvm_pit; +if (kvm_create (kvm_context,0 ,NULL ) <0 ) {kvm_finalize (kvm_state);return -1 ;
qemu-kvm.h +0 -24
@@ -50,12 +50,8 @@*/ struct kvm_context { -/// do not create in-kernel irqchip if set -int no_irqchip_creation;/// ioctl to use to inject interrupts int irqchip_inject_ioctl; -/// do not create in-kernel pit if set -int no_pit_creation;#ifdef KVM_CAP_IRQ_ROUTING struct kvm_irq_routing *irq_routes;int nr_allocated_irq_routes;
@@ -85,26 +81,6 @@ int handle_io_window(kvm_context_t kvm);int try_push_interrupts (kvm_context_t kvm);/*! -* \brief Disable the in-kernel IRQCHIP creation -* -* In-kernel irqchip is enabled by default. If userspace irqchip is to be used, -* this should be called prior to kvm_create(). -* -* \param kvm Pointer to the kvm_context -*/ -void kvm_disable_irqchip_creation (kvm_context_t kvm); - -/*! -* \brief Disable the in-kernel PIT creation -* -* In-kernel pit is enabled by default. If userspace pit is to be used, -* this should be called prior to kvm_create(). -* -* \param kvm Pointer to the kvm_context -*/ -void kvm_disable_pit_creation (kvm_context_t kvm); - -/*! * \brief Create new virtual machine * * This creates a new virtual machine, maps physical RAM to it, and creates a
Signature · 1 line
1.7.1
PATCH 14/19 qemu-kvm: Fold kvm_create into kvm_create_context
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
A small step towards switching to upstream code: reduce the init function maze.
--- qemu-kvm.c | 94 +++++++++++++++++++++--------------------------------------- qemu-kvm.h | 17 ----------- 2 files changed, 33 insertions(+), 78 deletions(-)
qemu-kvm.c +33 -61
@@ -127,7 +127,7 @@ static int kvm_create_context(void);int kvm_init (void ) {int fd; -int r, gsi_count; +int r, gsi_count, i; fd =open ("/dev/kvm" ,O_RDWR );
@@ -162,6 +162,21 @@ int kvm_init(void)QTAILQ_INIT (&kvm_state->kvm_sw_breakpoints);#endif +for (i =0 ; i <ARRAY_SIZE (kvm_state->slots); i++) { + kvm_state->slots[i].slot = i; + } + +#ifdef KVM_CAP_USER_MEMORY + r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION ,KVM_CAP_USER_MEMORY ); +if (r <=0 ) { +fprintf (stderr, +"Hypervisor too old: KVM_CAP_USER_MEMORY extension not supported\n" ); + goto out_close; + } +#else +#error Hypervisor too old: KVM_CAP_USER_MEMORY extension not supported +#endif + gsi_count =kvm_get_gsi_count (kvm_context);if (gsi_count >0 ) {int gsi_bits, i;
@@ -212,39 +227,6 @@ static int kvm_set_boot_vcpu_id(kvm_context_t kvm, uint32_t id)#endif } -int kvm_create_vm (kvm_context_t kvm) -{ -int fd; -#ifdef KVM_CAP_IRQ_ROUTING - kvm->irq_routes =qemu_mallocz (sizeof (*kvm->irq_routes)); - kvm->nr_allocated_irq_routes =0 ; -#endif - - fd =kvm_ioctl (kvm_state,KVM_CREATE_VM ,0 ); -if (fd <0 ) { -fprintf (stderr,"kvm_create_vm: %m\n" ); -return -1 ; - } - kvm_state->vmfd = fd; -return 0 ; -} - -static int kvm_create_default_phys_mem (kvm_context_t kvm, -unsigned long phys_mem_bytes, -void **vm_mem) -{ -#ifdef KVM_CAP_USER_MEMORY -int r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION ,KVM_CAP_USER_MEMORY ); -if (r >0 ) -return 0 ; -fprintf (stderr, -"Hypervisor too old: KVM_CAP_USER_MEMORY extension not supported\n" ); -#else -#error Hypervisor too old: KVM_CAP_USER_MEMORY extension not supported -#endif -return -1 ; -} -void kvm_create_irqchip (kvm_context_t kvm) {int r;
@@ -271,32 +253,6 @@ void kvm_create_irqchip(kvm_context_t kvm)#endif } -int kvm_create (kvm_context_t kvm,unsigned long phys_mem_bytes,void **vm_mem) -{ -int r, i; - - r =kvm_create_vm (kvm); -if (r <0 ) { -return r; - } - r =kvm_arch_create (kvm, phys_mem_bytes, vm_mem); -if (r <0 ) { -return r; - } -for (i =0 ; i <ARRAY_SIZE (kvm_state->slots); i++) { - kvm_state->slots[i].slot = i; - } - - r =kvm_create_default_phys_mem (kvm, phys_mem_bytes, vm_mem); -if (r <0 ) { -return r; - } - -kvm_create_irqchip (kvm); - -return 0 ; -} -#ifdef KVM_CAP_IRQCHIP int kvm_set_irq_level (kvm_context_t kvm,int irq,int level,int *status)
@@ -1429,10 +1385,26 @@ static int kvm_create_context(void) kvm_state->pit_in_kernel = kvm_pit; -if (kvm_create (kvm_context,0 ,NULL ) <0 ) { +#ifdef KVM_CAP_IRQ_ROUTING + kvm_context->irq_routes =qemu_mallocz (sizeof (*kvm_context->irq_routes)); + kvm_context->nr_allocated_irq_routes =0 ; +#endif + + kvm_state->vmfd =kvm_ioctl (kvm_state,KVM_CREATE_VM ,0 ); +if (kvm_state->vmfd <0 ) { +fprintf (stderr,"kvm_create_vm: %m\n" );kvm_finalize (kvm_state);return -1 ; } + + r =kvm_arch_create (kvm_context,0 ,NULL ); +if (r <0 ) { +kvm_finalize (kvm_state); +return r; + } + +kvm_create_irqchip (kvm_context); + r =kvm_arch_qemu_create_context ();if (r <0 ) {kvm_finalize (kvm_state);
qemu-kvm.h +0 -17
@@ -80,23 +80,6 @@ int pre_kvm_run(kvm_context_t kvm, CPUState *env);int handle_io_window (kvm_context_t kvm);int try_push_interrupts (kvm_context_t kvm); -/*! -* \brief Create new virtual machine -* -* This creates a new virtual machine, maps physical RAM to it, and creates a -* virtual CPU for it.\n -* \n -* Memory gets mapped for addresses 0->0xA0000, 0xC0000->phys_mem_bytes -* -* \param kvm Pointer to the current kvm_context -* \param phys_mem_bytes The amount of physical ram you want the VM to have -* \param phys_mem This pointer will be set to point to the memory that -* kvm_create allocates for physical RAM -* \return 0 on success -*/ -int kvm_create (kvm_context_t kvm,unsigned long phys_mem_bytes, -void **phys_mem); -int kvm_create_vm (kvm_context_t kvm);void kvm_create_irqchip (kvm_context_t kvm);/*!
Signature · 1 line
1.7.1
PATCH 4/19 qemu-kvm: x86: Drop MSR reset
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Paravirtual MSRs are properly cleared on reset now, and blindly clearing the rest is questionable anyway (better address those one by one, re-initializing their backing CPU state fields).
--- qemu-kvm-x86.c | 69 -------------------------------------------------------- 1 files changed, 0 insertions(+), 69 deletions(-)
qemu-kvm-x86.c +0 -69
@@ -26,7 +26,6 @@#define MSR_IA32_TSC 0x10 -static struct kvm_msr_list *kvm_msr_list;extern unsigned int kvm_shadow_memory;int kvm_set_tss_addr (kvm_context_t kvm,unsigned long addr)
@@ -338,35 +337,6 @@ void kvm_show_code(CPUState *env)fprintf (stderr,"code:%s\n" , code_str); } - -/* -* Returns available msr list. User must free. -*/ -static struct kvm_msr_list *kvm_get_msr_list (void ) -{ -struct kvm_msr_list sizer, *msrs; -int r; - - sizer.nmsrs =0 ; - r =kvm_ioctl (kvm_state,KVM_GET_MSR_INDEX_LIST , &sizer); -if (r <0 && r != -E2BIG ) { -return NULL ; - } -/* Old kernel modules had a bug and could write beyond the provided -memory. Allocate at least a safe amount of 1K. */ - msrs =qemu_malloc (MAX (1024 ,sizeof (*msrs) + - sizer.nmsrs *sizeof (*msrs->indices))); - - msrs->nmsrs = sizer.nmsrs; - r =kvm_ioctl (kvm_state,KVM_GET_MSR_INDEX_LIST , msrs); -if (r <0 ) { -free (msrs); - errno = r; -return NULL ; - } -return msrs; -} -static void print_seg (FILE *file,const char *name,struct kvm_segment *seg) { fprintf(stderr,
@@ -496,11 +466,6 @@ int kvm_arch_qemu_create_context(void)return r; } - kvm_msr_list =kvm_get_msr_list (); -if (!kvm_msr_list) { -return -1 ; - } - r =kvm_set_boot_cpu_id (0 );if (r <0 && r != -ENOSYS ) {return r;
@@ -653,42 +618,8 @@ void kvm_arch_push_nmi(void *opaque) }#endif /* KVM_CAP_USER_NMI */ -static int kvm_reset_msrs (CPUState *env) -{ -struct { -struct kvm_msrs info; -struct kvm_msr_entry entries[100 ]; - } msr_data; -int n; -struct kvm_msr_entry *msrs = msr_data.entries; -uint32_t index; -uint64_t data; - -if (!kvm_msr_list) { -return -1 ; - } - -for (n =0 ; n < kvm_msr_list->nmsrs; n++) { - index = kvm_msr_list->indices[n]; -switch (index) { -case MSR_PAT : - data =0x0007040600070406ULL ; -break ; -default : - data =0 ; - } -kvm_msr_entry_set (&msrs[n], kvm_msr_list->indices[n], data); - } - - msr_data.info.nmsrs = n; - -return kvm_vcpu_ioctl (env,KVM_SET_MSRS , &msr_data); -} - -void kvm_arch_cpu_reset (CPUState *env) { -kvm_reset_msrs (env);kvm_arch_reset_vcpu (env); }
Signature · 1 line
1.7.1
PATCH 5/19 qemu-kvm: Use upstream VCPU reset services
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
--- kvm-all.c | 2 -- qemu-kvm-ia64.c | 2 +- qemu-kvm-x86.c | 5 ----- qemu-kvm.c | 7 ------- qemu-kvm.h | 1 - 5 files changed, 1 insertions(+), 16 deletions(-)
kvm-all.c +0 -2
@@ -183,14 +183,12 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot)return kvm_vm_ioctl (s,KVM_SET_USER_MEMORY_REGION , &mem); } -#ifdef OBSOLETE_KVM_IMPL static void kvm_reset_vcpu (void *opaque) {CPUState *env = opaque;kvm_arch_reset_vcpu (env); } -#endif int kvm_irqchip_in_kernel (void ) {
qemu-kvm-ia64.c +1 -1
@@ -120,7 +120,7 @@ void kvm_arch_load_mpstate(CPUState *env)#endif } -void kvm_arch_cpu_reset (CPUState *env) +void kvm_arch_reset_vcpu (CPUState *env) {if (kvm_irqchip_in_kernel (kvm_context)) {#ifdef KVM_CAP_MP_STATE
qemu-kvm-x86.c +0 -5
@@ -618,11 +618,6 @@ void kvm_arch_push_nmi(void *opaque) }#endif /* KVM_CAP_USER_NMI */ -void kvm_arch_cpu_reset (CPUState *env) -{ -kvm_arch_reset_vcpu (env); -} -#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT void kvm_arch_do_ioperm (void *_data) {
qemu-kvm.c +0 -7
@@ -224,13 +224,6 @@ void kvm_disable_pit_creation(kvm_context_t kvm) kvm->no_pit_creation =1 ; } -static void kvm_reset_vcpu (void *opaque) -{ -CPUState *env = opaque; - -kvm_arch_cpu_reset (env); -} -static void kvm_create_vcpu (CPUState *env,int id) {long mmap_size;
qemu-kvm.h +0 -1
@@ -663,7 +663,6 @@ int kvm_arch_has_work(CPUState *env);void kvm_arch_process_irqchip_events (CPUState *env);int kvm_arch_try_push_interrupts (void *opaque);void kvm_arch_push_nmi (void *opaque); -void kvm_arch_cpu_reset (CPUState *env);int kvm_set_boot_cpu_id (uint32_t id);void qemu_kvm_aio_wait_start (void );
Signature · 1 line
1.7.1
PATCH 6/19 qemu-kvm: Use upstream vcpu initialization
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This is a bit ugly, but as we overload kvm_init_vcpu with a wrapper, we need to rename upstream's core implementation for now. Better than keeping two identical versions of this non-trivial function around.
--- kvm-all.c | 4 +--- qemu-kvm.c | 53 +++-------------------------------------------------- 2 files changed, 4 insertions(+), 53 deletions(-)
kvm-all.c +1 -3
@@ -200,8 +200,7 @@ int kvm_pit_in_kernel(void)return kvm_state->pit_in_kernel; } -#ifdef OBSOLETE_KVM_IMPL -int kvm_init_vcpu (CPUState *env) +static int kvm_create_vcpu (CPUState *env) {KVMState *s = kvm_state;long mmap_size;
@@ -247,7 +246,6 @@ int kvm_init_vcpu(CPUState *env) err:return ret; } -#endif /* * dirty pages logging control
qemu-kvm.c +3 -50
65 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 8/19 qemu-kvm: Use upstream kvm_arch_get/put_registers
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Having two implementations of these services used to be a source of constant pain in the past. Now they are almost equivalent, and we can switch to upstream's versions. We just need to import the APIC bits into the upstream code until they are merge as well.
--- qemu-kvm-ia64.c | 4 +- qemu-kvm-x86.c | 67 ----------------------------------------------------- qemu-kvm.c | 8 +++--- qemu-kvm.h | 2 - target-i386/kvm.c | 12 +++++++-- 5 files changed, 15 insertions(+), 78 deletions(-)
qemu-kvm-ia64.c +2 -2
@@ -16,12 +16,12 @@ int kvm_arch_qemu_create_context(void)return 0 ; } -void kvm_arch_load_regs (CPUState *env,int level) +void kvm_arch_put_registers (CPUState *env,int level) { } -void kvm_arch_save_regs (CPUState *env) +void kvm_arch_get_registers (CPUState *env) { }
qemu-kvm-x86.c +0 -67
73 lines not on this page · raw message
qemu-kvm.c +4 -4
@@ -483,7 +483,7 @@ int kvm_run(CPUState *env) again:if (env->kvm_vcpu_dirty) { -kvm_arch_load_regs (env,KVM_PUT_RUNTIME_STATE ); +kvm_arch_put_registers (env,KVM_PUT_RUNTIME_STATE ); env->kvm_vcpu_dirty =0 ; }push_nmi (kvm);
@@ -1102,7 +1102,7 @@ static void do_kvm_cpu_synchronize_state(void *_env)CPUState *env = _env;if (!env->kvm_vcpu_dirty) { -kvm_arch_save_regs (env); +kvm_arch_get_registers (env); env->kvm_vcpu_dirty =1 ; } }
@@ -1116,13 +1116,13 @@ void kvm_cpu_synchronize_state(CPUState *env)void kvm_cpu_synchronize_post_reset (CPUState *env) { -kvm_arch_load_regs (env,KVM_PUT_RESET_STATE ); +kvm_arch_put_registers (env,KVM_PUT_RESET_STATE ); env->kvm_vcpu_dirty =0 ; }void kvm_cpu_synchronize_post_init (CPUState *env) { -kvm_arch_load_regs (env,KVM_PUT_FULL_STATE ); +kvm_arch_put_registers (env,KVM_PUT_FULL_STATE ); env->kvm_vcpu_dirty =0 ; }
qemu-kvm.h +0 -2
@@ -657,8 +657,6 @@ int kvm_qemu_destroy_memory_alias(uint64_t phys_start);int kvm_arch_qemu_create_context (void ); -void kvm_arch_save_regs (CPUState *env); -void kvm_arch_load_regs (CPUState *env,int level);int kvm_arch_has_work (CPUState *env);void kvm_arch_process_irqchip_events (CPUState *env);int kvm_arch_try_push_interrupts (void *opaque);
target-i386/kvm.c +9 -3
@@ -331,7 +331,6 @@ int kvm_arch_on_sigbus(int code, void *addr)return 0 ; } -#ifdef OBSOLETE_KVM_IMPL static int kvm_inject_mce_oldstyle (CPUState *env) {#ifdef KVM_CAP_MCE
@@ -363,7 +362,6 @@ static int kvm_inject_mce_oldstyle(CPUState *env)#endif /* KVM_CAP_MCE */ return 0 ; } -#endif static void cpu_update_state (void *opaque,int running,int reason) {
@@ -1454,7 +1452,6 @@ static int kvm_get_debugregs(CPUState *env)return 0 ; } -#ifdef OBSOLETE_KVM_IMPL int kvm_arch_put_registers (CPUState *env,int level) {int ret;
@@ -1491,6 +1488,8 @@ int kvm_arch_put_registers(CPUState *env, int level)if (ret <0 ) {return ret; } + +kvm_load_lapic (env); } ret =kvm_put_vcpu_events (env, level);if (ret <0 ) {
@@ -1500,6 +1499,11 @@ int kvm_arch_put_registers(CPUState *env, int level)if (ret <0 ) {return ret; } +if (level ==KVM_PUT_FULL_STATE ) { +if (env->kvm_vcpu_update_vapic) { +kvm_tpr_enable_vapic (env); + } + }/* must be last */ ret =kvm_guest_debug_workarounds (env);if (ret <0 ) {
@@ -1538,6 +1542,7 @@ int kvm_arch_get_registers(CPUState *env)if (ret <0 ) {return ret; } +kvm_save_lapic (env); ret =kvm_get_vcpu_events (env);if (ret <0 ) {return ret;
@@ -1549,6 +1554,7 @@ int kvm_arch_get_registers(CPUState *env)return 0 ; } +#ifdef OBSOLETE_KVM_IMPL void kvm_arch_pre_run (CPUState *env,struct kvm_run *run) {int ret;
Signature · 1 line
1.7.1
PATCH 15/19 qemu-kvm: Fold kvm_arch_qemu_create_context into kvm_arch_create
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This reorders kvm_create_irqchip and the content of kvm_arch_qemu_create_context, but this should not cause any problems.
--- qemu-kvm-x86.c | 48 ++++++++++++++++++++---------------------------- qemu-kvm.c | 7 +------ qemu-kvm.h | 5 +---- 3 files changed, 22 insertions(+), 38 deletions(-)
qemu-kvm-x86.c +20 -28
@@ -116,9 +116,9 @@ static int kvm_create_pit(kvm_context_t kvm)return 0 ; } -int kvm_arch_create (kvm_context_t kvm,unsigned long phys_mem_bytes, -void **vm_mem) +int kvm_arch_create (kvm_context_t kvm) { +struct utsname utsname;int r =0 ; r =kvm_init_tss (kvm);
@@ -149,6 +149,24 @@ int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,return r; } +uname (&utsname); + lm_capable_kernel =strcmp (utsname.machine,"x86_64" ) ==0 ; + +if (kvm_shadow_memory) { +kvm_set_shadow_pages (kvm_context, kvm_shadow_memory); + } + +/* initialize has_msr_star/has_msr_hsave_pa */ + r =kvm_get_supported_msrs (kvm_state); +if (r <0 ) { +return r; + } + + r =kvm_set_boot_cpu_id (0 ); +if (r <0 && r != -ENOSYS ) { +return r; + } +return 0 ; }
@@ -426,32 +444,6 @@ static int kvm_enable_tpr_access_reporting(CPUState *env) }#endif -int kvm_arch_qemu_create_context (void ) -{ -int r; -struct utsname utsname; - -uname (&utsname); - lm_capable_kernel =strcmp (utsname.machine,"x86_64" ) ==0 ; - -if (kvm_shadow_memory) { -kvm_set_shadow_pages (kvm_context, kvm_shadow_memory); - } - -/* initialize has_msr_star/has_msr_hsave_pa */ - r =kvm_get_supported_msrs (kvm_state); -if (r <0 ) { -return r; - } - - r =kvm_set_boot_cpu_id (0 ); -if (r <0 && r != -ENOSYS ) { -return r; - } - -return 0 ; -} -static int _kvm_arch_init_vcpu (CPUState *env) {kvm_arch_reset_vcpu (env);
qemu-kvm.c +1 -6
@@ -1397,7 +1397,7 @@ static int kvm_create_context(void)return -1 ; } - r =kvm_arch_create (kvm_context,0 ,NULL ); + r =kvm_arch_create (kvm_context);if (r <0 ) {kvm_finalize (kvm_state);return r;
@@ -1405,11 +1405,6 @@ static int kvm_create_context(void)kvm_create_irqchip (kvm_context); - r =kvm_arch_qemu_create_context (); -if (r <0 ) { -kvm_finalize (kvm_state); -return -1 ; - }if (kvm_pit && !kvm_pit_reinject) {if (kvm_reinject_control (kvm_context,0 )) {fprintf (stderr,"failure to disable in-kernel PIT reinjection\n" );
qemu-kvm.h +1 -4
@@ -64,8 +64,7 @@ typedef struct kvm_context *kvm_context_t;#include "kvm.h" -int kvm_arch_create (kvm_context_t kvm,unsigned long phys_mem_bytes, -void **vm_mem); +int kvm_arch_create (kvm_context_t kvm);int kvm_arch_run (CPUState *env);
@@ -449,8 +448,6 @@ void on_vcpu(CPUState *env, void (*func)(void *data), void *data);void kvm_inject_interrupt (CPUState *env,int mask);void kvm_update_interrupt_request (CPUState *env); -int kvm_arch_qemu_create_context (void ); -int kvm_arch_has_work (CPUState *env);void kvm_arch_process_irqchip_events (CPUState *env);int kvm_arch_try_push_interrupts (void *opaque);
Signature · 1 line
1.7.1
PATCH 16/19 qemu-kvm: Push PIT reinjection control into x86 code
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This belongs where the in-kernel PIT is created.
--- qemu-kvm-x86.c | 8 ++++++++ qemu-kvm.c | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-)
qemu-kvm-x86.c +8 -0
@@ -111,6 +111,14 @@ static int kvm_create_pit(kvm_context_t kvm)fprintf (stderr,"Create kernel PIC irqchip failed\n" ); return r; } +if (!kvm_pit_reinject) { + r =kvm_reinject_control (kvm_context,0 ); +if (r <0 ) { +fprintf (stderr, +"failure to disable in-kernel PIT reinjection\n" ); +return r; + } + } }#endif return 0 ;
qemu-kvm.c +0 -7
@@ -1405,13 +1405,6 @@ static int kvm_create_context(void)kvm_create_irqchip (kvm_context); -if (kvm_pit && !kvm_pit_reinject) { -if (kvm_reinject_control (kvm_context,0 )) { -fprintf (stderr,"failure to disable in-kernel PIT reinjection\n" ); -return -1 ; - } - } -/* There was a nasty bug in < kvm-80 that prevents memory slots from being * destroyed properly. Since we rely on this capability, refuse to work * with any kernel without this capability. */
Signature · 1 line
1.7.1
PATCH 17/19 qemu-kvm: Replace kvm_show_regs/code with cpu_dump_state
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
The latter provides even more information.
--- qemu-kvm-x86.c | 95 -------------------------------------------------------- qemu-kvm.c | 7 ++-- qemu-kvm.h | 17 ---------- 3 files changed, 3 insertions(+), 116 deletions(-)
qemu-kvm-x86.c +0 -95
@@ -319,101 +319,6 @@ int kvm_has_pit_state2(kvm_context_t kvm)return r; } -void kvm_show_code (CPUState *env) -{ -#define SHOW_CODE_LEN 50 -struct kvm_regs regs; -struct kvm_sregs sregs; -int r, n; -int back_offset; -unsigned char code; -char code_str[SHOW_CODE_LEN *3 +1 ]; -unsigned long rip; - - r =kvm_vcpu_ioctl (env,KVM_GET_SREGS , &sregs); -if (r <0 ) { -perror ("KVM_GET_SREGS" ); -return ; - } - r =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); -if (r <0 ) { -perror ("KVM_GET_REGS" ); -return ; - } - rip = sregs.cs.base + regs.rip; - back_offset = regs.rip; -if (back_offset >20 ) { - back_offset =20 ; - } - *code_str =0 ; -for (n = -back_offset; n <SHOW_CODE_LEN -back_offset; ++n) { -if (n ==0 ) { -strcat (code_str," -->" ); - } -cpu_physical_memory_rw (rip + n, &code,1 ,1 ); -sprintf (code_str +strlen (code_str)," %02x" , code); - } -fprintf (stderr,"code:%s\n" , code_str); -} - -static void print_seg (FILE *file,const char *name,struct kvm_segment *seg) -{ -fprintf (stderr, -"%s %04x (%08llx/%08x p %d dpl %d db %d s %d type %x l %d" -" g %d avl %d)\n" , - name, seg->selector, seg->base, seg->limit, seg->present, - seg->dpl, seg->db, seg->s, seg->type, seg->l, seg->g, - seg->avl); -} - -static void print_dt (FILE *file,const char *name,struct kvm_dtable *dt) -{ -fprintf (stderr,"%s %llx/%x\n" , name, dt->base, dt->limit); -} - -void kvm_show_regs (CPUState *env) -{ -struct kvm_regs regs; -struct kvm_sregs sregs; -int r; - - r =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); -if (r <0 ) { -perror ("KVM_GET_REGS" ); -return ; - } -fprintf (stderr, -"rax %016llx rbx %016llx rcx %016llx rdx %016llx\n" -"rsi %016llx rdi %016llx rsp %016llx rbp %016llx\n" -"r8 %016llx r9 %016llx r10 %016llx r11 %016llx\n" -"r12 %016llx r13 %016llx r14 %016llx r15 %016llx\n" -"rip %016llx rflags %08llx\n" , - regs.rax, regs.rbx, regs.rcx, regs.rdx, - regs.rsi, regs.rdi, regs.rsp, regs.rbp, - regs.r8, regs.r9, regs.r10, regs.r11, - regs.r12, regs.r13, regs.r14, regs.r15, - regs.rip, regs.rflags); - r =kvm_vcpu_ioctl (env,KVM_GET_SREGS , &sregs); -if (r <0 ) { -perror ("KVM_GET_SREGS" ); -return ; - } -print_seg (stderr,"cs" , &sregs.cs); -print_seg (stderr,"ds" , &sregs.ds); -print_seg (stderr,"es" , &sregs.es); -print_seg (stderr,"ss" , &sregs.ss); -print_seg (stderr,"fs" , &sregs.fs); -print_seg (stderr,"gs" , &sregs.gs); -print_seg (stderr,"tr" , &sregs.tr); -print_seg (stderr,"ldt" , &sregs.ldt); -print_dt (stderr,"gdt" , &sregs.gdt); -print_dt (stderr,"idt" , &sregs.idt); -fprintf (stderr,"cr0 %llx cr2 %llx cr3 %llx cr4 %llx cr8 %llx" -" efer %llx\n" , - sregs.cr0, sregs.cr2, sregs.cr3, sregs.cr4, sregs.cr8, - sregs.efer); -} -static void kvm_set_cr8 (CPUState *env,uint64_t cr8) { env->kvm_run->cr8 = cr8;
qemu-kvm.c +3 -4
@@ -425,8 +425,7 @@ int kvm_run(CPUState *env)case KVM_EXIT_EXCEPTION :fprintf (stderr,"exception %d (%x)\n" , run->ex.exception, run->ex.error_code); -kvm_show_regs (env); -kvm_show_code (env); +cpu_dump_state (env, stderr, fprintf,CPU_DUMP_CODE );abort ();break ;case KVM_EXIT_IO :
@@ -463,7 +462,7 @@ int kvm_run(CPUState *env) r =kvm_arch_run (env);if (r <0 ) {fprintf (stderr,"unhandled vm exit: 0x%x\n" , run->exit_reason); -kvm_show_regs (env); +cpu_dump_state (env, stderr, fprintf,CPU_DUMP_CODE );abort (); }if (r >0 ) {
@@ -988,7 +987,7 @@ int kvm_cpu_exec(CPUState *env) r =kvm_run (env);if (r <0 ) {printf ("kvm_run returned %d\n" , r); -kvm_show_regs (env); +cpu_dump_state (env, stderr, fprintf,CPU_DUMP_CODE );vm_stop (VMSTOP_PANIC ); }
qemu-kvm.h +0 -17
@@ -68,9 +68,6 @@ int kvm_arch_create(kvm_context_t kvm);int kvm_arch_run (CPUState *env); - -void kvm_show_code (CPUState *env); -int handle_halt (CPUState *env);int handle_shutdown (kvm_context_t kvm,CPUState *env);
@@ -139,20 +136,6 @@ int kvm_set_shadow_pages(kvm_context_t kvm, unsigned int nrshadow_pages);#endif -/*! -* \brief Dump VCPU registers -* -* This dumps some of the information that KVM has about a virtual CPU, namely: -* - GP Registers -* -* A much more verbose version of this is available as kvm_dump_vcpu() -* -* \param kvm Pointer to the current kvm_context -* \param vcpu Which virtual CPU should get dumped -* \return 0 on success -*/ -void kvm_show_regs (CPUState *env); -int kvm_set_irq_level (kvm_context_t kvm,int irq,int level,int *status);#ifdef KVM_CAP_IRQCHIP
Signature · 1 line
1.7.1
PATCH 18/19 qemu-kvm: Fold kvm_init_coalesced_mmio into kvm_create_context
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Aligns the initialization to upstream.
--- qemu-kvm-x86.c | 5 ----- qemu-kvm.c | 20 ++++++-------------- qemu-kvm.h | 9 --------- 3 files changed, 6 insertions(+), 28 deletions(-)
qemu-kvm-x86.c +0 -5
@@ -152,11 +152,6 @@ int kvm_arch_create(kvm_context_t kvm)return r; } - r =kvm_init_coalesced_mmio (kvm); -if (r <0 ) { -return r; - } -uname (&utsname); lm_capable_kernel =strcmp (utsname.machine,"x86_64" ) ==0 ;
qemu-kvm.c +6 -14
@@ -495,20 +495,6 @@ int kvm_inject_nmi(CPUState *env)#endif } -int kvm_init_coalesced_mmio (kvm_context_t kvm) -{ -int r =0 ; - kvm_state->coalesced_mmio =0 ; -#ifdef KVM_CAP_COALESCED_MMIO - r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION ,KVM_CAP_COALESCED_MMIO ); -if (r >0 ) { - kvm_state->coalesced_mmio = r; -return 0 ; - } -#endif -return r; -} -#ifdef KVM_CAP_DEVICE_ASSIGNMENT int kvm_assign_pci_device (kvm_context_t kvm,struct kvm_assigned_pci_dev *assigned_dev)
@@ -1419,6 +1405,12 @@ static int kvm_create_context(void)return r; } + kvm_state->coalesced_mmio =0 ; +#ifdef KVM_CAP_COALESCED_MMIO + kvm_state->coalesced_mmio = +kvm_check_extension (kvm_state,KVM_CAP_COALESCED_MMIO ); +#endif + kvm_state->vcpu_events =0 ;#ifdef KVM_CAP_VCPU_EVENTS kvm_state->vcpu_events =kvm_check_extension (kvm_state,KVM_CAP_VCPU_EVENTS );
qemu-kvm.h +0 -9
@@ -200,15 +200,6 @@ int kvm_inject_nmi(CPUState *env);#endif -/*! -* \brief Initialize coalesced MMIO -* -* Check for coalesced MMIO capability and store in context -* -* \param kvm Pointer to the current kvm_context -*/ -int kvm_init_coalesced_mmio (kvm_context_t kvm); -#ifdef KVM_CAP_PIT #if defined(__i386__) || defined(__x86_64__)
Signature · 1 line
1.7.1
PATCH 9/19 qemu-kvm: Use upstream state synchronization services
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Both implementations are identical if we map run_on_cpu on qemu-kvm's on_vcpu.
--- kvm-all.c | 12 ++++++------ qemu-kvm.c | 29 ----------------------------- 2 files changed, 6 insertions(+), 35 deletions(-)
kvm-all.c +6 -6
@@ -33,6 +33,10 @@#include <sys/eventfd.h> #endif +#ifndef OBSOLETE_KVM_IMPL +#define run_on_cpu on_vcpu +#endif /* !OBSOLETE_KVM_IMPL */ +/* KVM uses PAGE_SIZE in it's definition of COALESCED_MMIO_MAX */ #define PAGE_SIZE TARGET_PAGE_SIZE
@@ -896,8 +900,6 @@ void kvm_flush_coalesced_mmio_buffer(void) } } -#ifdef OBSOLETE_KVM_IMPL -static void do_kvm_cpu_synchronize_state (void *_env) {CPUState *env = _env;
@@ -927,6 +929,8 @@ void kvm_cpu_synchronize_post_init(CPUState *env) env->kvm_vcpu_dirty =0 ; } +#ifdef OBSOLETE_KVM_IMPL +int kvm_cpu_exec (CPUState *env) {struct kvm_run *run = env->kvm_run;
@@ -1137,10 +1141,6 @@ void kvm_setup_guest_memory(void *start, size_t size) }#ifdef KVM_CAP_SET_GUEST_DEBUG -#ifndef OBSOLETE_KVM_IMPL -#define run_on_cpu on_vcpu -#endif /* !OBSOLETE_KVM_IMPL */ -struct kvm_sw_breakpoint *kvm_find_sw_breakpoint (CPUState *env,target_ulong pc) {
qemu-kvm.c +0 -29
@@ -1097,35 +1097,6 @@ void on_vcpu(CPUState *env, void (*func)(void *data), void *data) } } -static void do_kvm_cpu_synchronize_state (void *_env) -{ -CPUState *env = _env; - -if (!env->kvm_vcpu_dirty) { -kvm_arch_get_registers (env); - env->kvm_vcpu_dirty =1 ; - } -} - -void kvm_cpu_synchronize_state (CPUState *env) -{ -if (!env->kvm_vcpu_dirty) { -on_vcpu (env, do_kvm_cpu_synchronize_state, env); - } -} - -void kvm_cpu_synchronize_post_reset (CPUState *env) -{ -kvm_arch_put_registers (env,KVM_PUT_RESET_STATE ); - env->kvm_vcpu_dirty =0 ; -} - -void kvm_cpu_synchronize_post_init (CPUState *env) -{ -kvm_arch_put_registers (env,KVM_PUT_FULL_STATE ); - env->kvm_vcpu_dirty =0 ; -} -static void inject_interrupt (void *data) {cpu_interrupt (current_env, (long ) data);
Signature · 1 line
1.7.1
PATCH 19/19 qemu-kvm: x86: Use kvm_arch_init
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Fold the qemu-kvm specific bits of kvm_arch_create into upstream's kvm_arch_init and call that service directly. This nicely obsolete quite a few more functions.
--- qemu-kvm-x86.c | 145 ----------------------------------------------------- qemu-kvm.c | 2 +- qemu-kvm.h | 13 +---- target-i386/kvm.c | 23 +++++++-- 4 files changed, 20 insertions(+), 163 deletions(-)
qemu-kvm-x86.c +0 -145
@@ -23,83 +23,6 @@#include "kvm.h" #include "hw/apic.h" -#define MSR_IA32_TSC 0x10 - -extern unsigned int kvm_shadow_memory; - -static int kvm_set_tss_addr (kvm_context_t kvm,unsigned long addr) -{ -int r; - - r =kvm_vm_ioctl (kvm_state,KVM_SET_TSS_ADDR , addr); -if (r <0 ) { -fprintf (stderr,"kvm_set_tss_addr: %m\n" ); -return r; - } -return 0 ; -} - -static int kvm_init_tss (kvm_context_t kvm) -{ -int r; - - r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION ,KVM_CAP_SET_TSS_ADDR ); -if (r >0 ) { -/* -* this address is 3 pages before the bios, and the bios should present -* as unavaible memory -*/ - r =kvm_set_tss_addr (kvm,0xfeffd000 ); -if (r <0 ) { -fprintf (stderr,"kvm_init_tss: unable to set tss addr\n" ); -return r; - } - }else { -fprintf (stderr,"kvm does not support KVM_CAP_SET_TSS_ADDR\n" ); - } -return 0 ; -} - -static int kvm_set_identity_map_addr (kvm_context_t kvm,uint64_t addr) -{ -#ifdef KVM_CAP_SET_IDENTITY_MAP_ADDR -int r; - - r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION ,KVM_CAP_SET_IDENTITY_MAP_ADDR ); -if (r >0 ) { - r =kvm_vm_ioctl (kvm_state,KVM_SET_IDENTITY_MAP_ADDR , &addr); -if (r ==-1 ) { -fprintf (stderr,"kvm_set_identity_map_addr: %m\n" ); -return -errno; - } -return 0 ; - } -#endif -return -ENOSYS ; -} - -static int kvm_init_identity_map_page (kvm_context_t kvm) -{ -#ifdef KVM_CAP_SET_IDENTITY_MAP_ADDR -int r; - - r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION ,KVM_CAP_SET_IDENTITY_MAP_ADDR ); -if (r >0 ) { -/* -* this address is 4 pages before the bios, and the bios should present -* as unavaible memory -*/ - r =kvm_set_identity_map_addr (kvm,0xfeffc000 ); -if (r <0 ) { -fprintf (stderr,"kvm_init_identity_map_page: " -"unable to set identity mapping addr\n" ); -return r; - } - } -#endif -return 0 ; -} -static int kvm_create_pit (kvm_context_t kvm) {#ifdef KVM_CAP_PIT
@@ -124,55 +47,6 @@ static int kvm_create_pit(kvm_context_t kvm)return 0 ; } -int kvm_arch_create (kvm_context_t kvm) -{ -struct utsname utsname; -int r =0 ; - - r =kvm_init_tss (kvm); -if (r <0 ) { -return r; - } - - r =kvm_init_identity_map_page (kvm); -if (r <0 ) { -return r; - } - -/* -* Tell fw_cfg to notify the BIOS to reserve the range. -*/ -if (e820_add_entry (0xfeffc000 ,0x4000 ,E820_RESERVED ) <0 ) { -perror ("e820_add_entry() table is full" ); -exit (1 ); - } - - r =kvm_create_pit (kvm); -if (r <0 ) { -return r; - } - -uname (&utsname); - lm_capable_kernel =strcmp (utsname.machine,"x86_64" ) ==0 ; - -if (kvm_shadow_memory) { -kvm_set_shadow_pages (kvm_context, kvm_shadow_memory); - } - -/* initialize has_msr_star/has_msr_hsave_pa */ - r =kvm_get_supported_msrs (kvm_state); -if (r <0 ) { -return r; - } - - r =kvm_set_boot_cpu_id (0 ); -if (r <0 && r != -ENOSYS ) { -return r; - } - -return 0 ; -} -#ifdef KVM_EXIT_TPR_ACCESS static int kvm_handle_tpr_access (CPUState *env)
@@ -319,25 +193,6 @@ static void kvm_set_cr8(CPUState *env, uint64_t cr8) env->kvm_run->cr8 = cr8; } -int kvm_set_shadow_pages (kvm_context_t kvm,unsigned int nrshadow_pages) -{ -#ifdef KVM_CAP_MMU_SHADOW_CACHE_CONTROL -int r; - - r =kvm_ioctl (kvm_state,KVM_CHECK_EXTENSION , -KVM_CAP_MMU_SHADOW_CACHE_CONTROL ); -if (r >0 ) { - r =kvm_vm_ioctl (kvm_state,KVM_SET_NR_MMU_PAGES , nrshadow_pages); -if (r <0 ) { -fprintf (stderr,"kvm_set_shadow_pages: %m\n" ); -return r; - } -return 0 ; - } -#endif -return -1 ; -} -#ifdef KVM_CAP_VAPIC static int kvm_enable_tpr_access_reporting (CPUState *env) {
qemu-kvm.c +1 -1
@@ -1382,7 +1382,7 @@ static int kvm_create_context(void)return -1 ; } - r =kvm_arch_create (kvm_context); + r =kvm_arch_init (kvm_state);if (r <0 ) {kvm_finalize (kvm_state);return r;
qemu-kvm.h +1 -12
@@ -64,8 +64,6 @@ typedef struct kvm_context *kvm_context_t;#include "kvm.h" -int kvm_arch_create (kvm_context_t kvm); -int kvm_arch_run (CPUState *env);int handle_halt (CPUState *env);
@@ -124,16 +122,6 @@ int kvm_is_ready_for_interrupt_injection(CPUState *env);* \return 0 on success */ int kvm_inject_irq (CPUState *env,unsigned irq); - - -/*! -* \brief Setting the number of shadow pages to be allocated to the vm -* -* \param kvm pointer to kvm_context -* \param nrshadow_pages number of pages to be allocated -*/ -int kvm_set_shadow_pages (kvm_context_t kvm,unsigned int nrshadow_pages); -#endif int kvm_set_irq_level (kvm_context_t kvm,int irq,int level,int *status);
@@ -449,6 +437,7 @@ extern int kvm_pit;extern int kvm_pit_reinject;extern int kvm_nested;extern kvm_context_t kvm_context; +extern unsigned int kvm_shadow_memory;struct ioperm_data {unsigned long start_port;
target-i386/kvm.c +18 -5
@@ -197,7 +197,6 @@ typedef struct HWPoisonPage { static QLIST_HEAD(, HWPoisonPage) hwpoison_page_list =QLIST_HEAD_INITIALIZER (hwpoison_page_list); -#ifdef OBSOLETE_KVM_IMPL static void kvm_unpoison_all (void *param) {HWPoisonPage *page, *next_page;
@@ -208,7 +207,6 @@ static void kvm_unpoison_all(void *param)qemu_free (page); } } -#endif #ifdef KVM_CAP_MCE static void kvm_hwpoison_page_add (ram_addr_t ram_addr)
@@ -603,7 +601,7 @@ static int kvm_get_supported_msrs(KVMState *s)return ret; } -#ifdef OBSOLETE_KVM_IMPL +static int kvm_create_pit (kvm_context_t kvm);int kvm_arch_init (KVMState *s) {
@@ -655,11 +653,26 @@ int kvm_arch_init(KVMState *s) }qemu_register_reset (kvm_unpoison_all,NULL ); + ret =kvm_create_pit (&s->kvm_context); +if (ret <0 ) { +return ret; + } + +if (kvm_shadow_memory) { + ret =kvm_vm_ioctl (s,KVM_SET_NR_MMU_PAGES , kvm_shadow_memory); +if (ret <0 ) { +return ret; + } + } + + ret =kvm_set_boot_cpu_id (0 ); +if (ret <0 && ret != -ENOSYS ) { +return ret; + } +return 0 ; } -#endif -static void set_v8086_seg (struct kvm_segment *lhs,const SegmentCache *rhs) { lhs->selector = rhs->selector;
Signature · 1 line
1.7.1
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
In reply to Jan KiszkaQuoted 6 lines · Jan Kiszka
From: Jan Kiszka<[email protected]>
Paravirtual MSRs are properly cleared on reset now, and blindly clearing the rest is questionable anyway (better address those one by one, re-initializing their backing CPU state fields).
This can introduce a regression when new paravirtual MSRs are added. So we either need to port this, or query the reset state from the kernel immediately after creating the vcpu and saving it.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
Quoted 9 lines · Avi Kivity
Quoted 6 lines · Jan Kiszka
From: Jan Kiszka<[email protected]>
Paravirtual MSRs are properly cleared on reset now, and blindly clearing the rest is questionable anyway (better address those one by one, re-initializing their backing CPU state fields).
This can introduce a regression when new paravirtual MSRs are added.
You mean MSRs already included or future ones?
Quoted 3 lines
So
we either need to port this, or query the reset state from the kernel immediately after creating the vcpu and saving it.
Can't completely follow what you mean.
My general point remains: Every MSR requires individual care, not blind overwriting like qemu-kvm does. So the person contributing a new MSR, real or pv, has to tackle this aspect, and we need to review the code in this regard.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
Quoted 4 lines · Jan Kiszka
Quoted 3 lines · Avi Kivity
Quoted 2 lines · Jan Kiszka
From: Jan Kiszka<[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Paravirtual MSRs are properly cleared on reset now, and blindly clearing the rest is questionable anyway (better address those one by one, re-initializing their backing CPU state fields).
This can introduce a regression when new paravirtual MSRs are added.
You mean MSRs already included or future ones?
Future ones.
Quoted 10 lines
Quoted 3 lines
So
we either need to port this, or query the reset state from the kernel immediately after creating the vcpu and saving it.Can't completely follow what you mean.
My general point remains: Every MSR requires individual care, not blind overwriting like qemu-kvm does. So the person contributing a new MSR, real or pv, has to tackle this aspect, and we need to review the code in this regard.
It's a trick to avoid needing individual care.
1. Call KVM_CREATE_VCPU. This causes all MSRs to be initialized to their power-on reset values.
2. Issue KVM_GET_MSR_LIST, and then KVM_GET_MSRS to read all MSRs. Stash them all in safe places - the ones known to qemu but also the unknown ones. Qemu may use its own values for the MSRs it knows about (for example if different cpu models have different power-on values)
3. On reset, issue KVM_SET_MSRS with the MSR values obtained in step 2.
The result is forward and backwards compatibility without lockstepping qemu and kvm.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 4 lines · Jan Kiszka
All required bits for this cleanup of qemu-kvm are now upstream and merged back - it's time to start the show. There are now 65 patches in my queue, and I'm planning for at least 4 rounds.
Quoted 8 lines
This first part primarily aims at using upstream
kvm_arch_init. Further highlights are:
- switch to upstream CPU register get/put
- switch to upstream kvmclock
- sustainable breakage of IA64Please review/merge.
I didn't do a line-by-line review, just a general look around, and it all looks good except for the MSR behavioural change.
How did you test it? I suggest testing at least vmport in addition to an autotest run (if you don't have a setup ready, we can do it, but it would be really helpful to test pre-merge). I guess we can expect a few regressions but if we're too careful this mess will continue forever.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
In reply to Avi KivityQuoted 27 lines · Avi Kivity
Quoted 4 lines · Jan Kiszka
Quoted 3 lines · Avi Kivity
Quoted 2 lines · Jan Kiszka
From: Jan Kiszka<[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Paravirtual MSRs are properly cleared on reset now, and blindly clearing the rest is questionable anyway (better address those one by one, re-initializing their backing CPU state fields).
This can introduce a regression when new paravirtual MSRs are added.
You mean MSRs already included or future ones?
Future ones.
Quoted 10 lines
Quoted 3 lines
So
we either need to port this, or query the reset state from the kernel immediately after creating the vcpu and saving it.Can't completely follow what you mean.
My general point remains: Every MSR requires individual care, not blind overwriting like qemu-kvm does. So the person contributing a new MSR, real or pv, has to tackle this aspect, and we need to review the code in this regard.
Quoted 4 lines
It's a trick to avoid needing individual care.
1. Call
KVM_CREATE_VCPU. This causes all MSRs to be initialized to their power-on reset values.
Almost all: Which ones are CPU specific like the APIC_BASE?
Quoted 8 lines
2. Issue
KVM_GET_MSR_LIST, and thenKVM_GET_MSRSto read all MSRs. Stash them all in safe places - the ones known to qemu but also the unknown ones. Qemu may use its own values for the MSRs it knows about (for example if different cpu models have different power-on values)
3. On reset, issueKVM_SET_MSRSwith the MSR values obtained in step 2.The result is forward and backwards compatibility without lockstepping qemu and kvm.
OK, sounds good. I will work out a patch for uq/master.
Nevertheless, the qemu-kvm code is already unneeded today and can safely be removed IMHO.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 11 lines · Avi Kivity
Quoted 10 lines · Jan Kiszka
All required bits for this cleanup of qemu-kvm are now upstream and merged back - it's time to start the show. There are now 65 patches in my queue, and I'm planning for at least 4 rounds.
This first part primarily aims at using upstream
kvm_arch_init. Further highlights are:
- switch to upstream CPU register get/put
- switch to upstream kvmclock
- sustainable breakage of IA64
Quoted 7 lines
Quoted 2 lines
Please review/merge.
I didn't do a line-by-line review, just a general look around, and it all looks good except for the MSR behavioural change.
How did you test it?
Running various VMs, mostly Linux (including vmmouse support) but also some XP guests. I'm using the whole series for internal purposes for a few months now (frequently rebased). So I have a quite good feeling about it, except for the unknown corner cases. :)
Quoted 4 lines
I suggest testing at least vmport in addition to
an autotest run (if you don't have a setup ready, we can do it, but it would be really helpful to test pre-merge). I guess we can expect a few regressions but if we're too careful this mess will continue forever.
I would be happy to off-load the full autotest run to $someone_else. Will jump in again if it fails.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
In reply to Jan KiszkaQuoted 5 lines · Jan Kiszka
Quoted 3 lines
1. Call
KVM_CREATE_VCPU. This causes all MSRs to be initialized to their power-on reset values.Almost all: Which ones are CPU specific like the
APIC_BASE?
Do you mean cpu specific as in smp or cpu specific as in cpu model?
If the former, we simply do the reset operation per-cpu. It's the natural thing anyway.
Quoted 10 lines
Quoted 8 lines
2. Issue
KVM_GET_MSR_LIST, and thenKVM_GET_MSRSto read all MSRs. Stash them all in safe places - the ones known to qemu but also the unknown ones. Qemu may use its own values for the MSRs it knows about (for example if different cpu models have different power-on values)
3. On reset, issueKVM_SET_MSRSwith the MSR values obtained in step 2.The result is forward and backwards compatibility without lockstepping qemu and kvm.
OK, sounds good. I will work out a patch for uq/master.
Great, thanks.
Quoted 2 lines
Nevertheless, the qemu-kvm code is already unneeded today and can safely be removed IMHO.
I don't follow? Won't it cause a regression?
Of course, if we get a patch soon no one will ever see the regression so we can apply the series.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
Quoted 8 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
Quoted 3 lines
1. Call
KVM_CREATE_VCPU. This causes all MSRs to be initialized to their power-on reset values.Almost all: Which ones are CPU specific like the
APIC_BASE?Do you mean cpu specific as in smp or cpu specific as in cpu model?
Yep.
Quoted 3 lines
If the former, we simply do the reset operation per-cpu. It's the natural thing anyway.
Quite wasteful /wrt to memory given that the majority will be identical.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
2. Issue
KVM_GET_MSR_LIST, and thenKVM_GET_MSRSto read all MSRs. Stash them all in safe places - the ones known to qemu but also the unknown ones. Qemu may use its own values for the MSRs it knows about (for example if different cpu models have different power-on values)
3. On reset, issueKVM_SET_MSRSwith the MSR values obtained in step 2.The result is forward and backwards compatibility without lockstepping qemu and kvm.
Quoted 8 lines
Quoted 1 line
OK, sounds good. I will work out a patch for uq/master.
Great, thanks.
Quoted 2 lines
Nevertheless, the qemu-kvm code is already unneeded today and can safely be removed IMHO.
I don't follow? Won't it cause a regression?
Not at all. We use the "individual care" pattern upstream now, specifically for those MSRs (kvmclock) for which the qemu-kvm code was introduced.
Quoted 3 lines
Of course, if we get a patch soon no one will ever see the regression so we can apply the series.
I will still require the usual testing and merging round via upstream and back. Not sure when I'll be able to work on it, probably not the next days.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
Quoted 11 lines · Jan Kiszka
Quoted 8 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
Quoted 3 lines
1. Call
KVM_CREATE_VCPU. This causes all MSRs to be initialized to their power-on reset values.Almost all: Which ones are CPU specific like the
APIC_BASE?Do you mean cpu specific as in smp or cpu specific as in cpu model?
Yep.
Doh.
Quoted 5 lines
Quoted 3 lines
If the former, we simply do the reset operation per-cpu. It's the natural thing anyway.
Quite wasteful /wrt to memory given that the majority will be identical.
We're talking a few hundred bytes per cpu. If you want to save memory, look at the PhysPageDesc array, it takes up 0.4% of guest memory, so 4MB for a 1GB guest.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Nevertheless, the qemu-kvm code is already unneeded today and can safely be removed IMHO.
I don't follow? Won't it cause a regression?
Not at all. We use the "individual care" pattern upstream now, specifically for those MSRs (kvmclock) for which the qemu-kvm code was introduced.
I mean a future regression with current+patch qemu and a new kernel.
Quoted 7 lines
Quoted 3 lines
Of course, if we get a patch soon no one will ever see the regression so we can apply the series.
I will still require the usual testing and merging round via upstream and back. Not sure when I'll be able to work on it, probably not the next days.
If you can do it within a couple of weeks or so that should be fine.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
Quoted 16 lines · Avi Kivity
Quoted 11 lines · Jan Kiszka
Quoted 8 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
Quoted 3 lines
1. Call
KVM_CREATE_VCPU. This causes all MSRs to be initialized to their power-on reset values.Almost all: Which ones are CPU specific like the
APIC_BASE?Do you mean cpu specific as in smp or cpu specific as in cpu model?
Yep.
Doh.
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If the former, we simply do the reset operation per-cpu. It's the natural thing anyway.
Quite wasteful /wrt to memory given that the majority will be identical.
We're talking a few hundred bytes per cpu. If you want to save memory, look at the PhysPageDesc array, it takes up 0.4% of guest memory, so 4MB for a 1GB guest.
I know (that's fixable, BTW). But that should not excuse needless memory wasting elsewhere.
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Nevertheless, the qemu-kvm code is already unneeded today and can
safely
Quoted 2 lines
Quoted 1 line
be removed IMHO.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I don't follow? Won't it cause a regression?
Not at all. We use the "individual care" pattern upstream now, specifically for those MSRs (kvmclock) for which the qemu-kvm code was introduced.
I mean a future regression with current+patch qemu and a new kernel.
For sane scenarios, such a combination should never expose new (ie. unknown from qemu's POV) MSRs to the guest. Thus not clearing them cannot cause any harm.
BTW, you also do not know if 0 will be the right reset value for these to-be-invented MSRs. That could cause regression as well.
Quoted 12 lines
Quoted 9 lines
Quoted 3 lines
Of course, if we get a patch soon no one will ever see the
regression so
Quoted 1 line
we can apply the series.
I will still require the usual testing and merging round via upstream and back. Not sure when I'll be able to work on it, probably not the next days.
If you can do it within a couple of weeks or so that should be fine.
We'll see, but I still do not share your concern regarding future regressions when removing the fragile reset code.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
Quoted 4 lines · Jan Kiszka
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
If the former, we simply do the reset operation per-cpu. It's the natural thing anyway.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quite wasteful /wrt to memory given that the majority will be identical.
We're talking a few hundred bytes per cpu. If you want to save memory, look at the PhysPageDesc array, it takes up 0.4% of guest memory, so 4MB for a 1GB guest.
I know (that's fixable, BTW). But that should not excuse needless memory wasting elsewhere.
IMO a few hundred bytes is worth the correctness here.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
Nevertheless, the qemu-kvm code is already unneeded today and can
safely
Quoted 3 lines
Quoted 1 line
be removed IMHO.
I don't follow? Won't it cause a regression?
Not at all. We use the "individual care" pattern upstream now, specifically for those MSRs (kvmclock) for which the qemu-kvm code was introduced.
Quoted 5 lines
Quoted 1 line
I mean a future regression with current+patch qemu and a new kernel.
For sane scenarios, such a combination should never expose new (ie. unknown from qemu's POV) MSRs to the guest. Thus not clearing them cannot cause any harm.
The problem is with hardware MSRs (PV MSRs are protected by cpuid, and always disable themselves when zeroed).
Quoted 2 lines
BTW, you also do not know if 0 will be the right reset value for these to-be-invented MSRs. That could cause regression as well.
What I suggested wasn't zeroing them, but writing the value we read just after vcpu creation.
We had a regression when we started supporting PAT. Zeroing it causes the cache to be disabled, making everything ridiculously slow. We now special case it; my proposed solution would have taken care of it.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
Quoted 33 lines · Avi Kivity
Quoted 8 lines · Jan Kiszka
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
If the former, we simply do the reset operation per-cpu. It's
the
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
natural thing anyway.
Quite wasteful /wrt to memory given that the majority will be
identical.
Quoted 1 line
Quoted 8 lines
Quoted 1 line
We're talking a few hundred bytes per cpu. If you want to save
memory,
Quoted 1 line
look at the PhysPageDesc array, it takes up 0.4% of guest memory,
so 4MB
Quoted 1 line
for a 1GB guest.
I know (that's fixable, BTW). But that should not excuse needless memory wasting elsewhere.
IMO a few hundred bytes is worth the correctness here.
Quoted 13 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Nevertheless, the qemu-kvm code is already unneeded today and
can
Quoted 7 lines
Quoted 7 lines
safely
Quoted 3 lines
Quoted 1 line
be removed IMHO.
I don't follow? Won't it cause a regression?
Not at all. We use the "individual care" pattern upstream now, specifically for those MSRs (kvmclock) for which the qemu-kvm code
was
Quoted 2 lines
Quoted 1 line
introduced.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
I mean a future regression with current+patch qemu and a new kernel.
For sane scenarios, such a combination should never expose new (ie. unknown from qemu's POV) MSRs to the guest. Thus not clearing them cannot cause any harm.
The problem is with hardware MSRs (PV MSRs are protected by cpuid, and always disable themselves when zeroed).
Well, this doesn't change the problem of the existing code.
Quoted 10 lines
Quoted 3 lines
BTW, you also do not know if 0 will be the right reset value for these to-be-invented MSRs. That could cause regression as well.
What I suggested wasn't zeroing them, but writing the value we read just after vcpu creation.
We had a regression when we started supporting PAT. Zeroing it causes the cache to be disabled, making everything ridiculously slow. We now special case it; my proposed solution would have taken care of it.
I'm talking about the current code, not the proper way to do it in the future. PAT demonstrates why regressions can happen as long as we zero and it's better to stop this now even without the new code in place.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
In reply to Jan KiszkaQuoted 9 lines · Jan Kiszka
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
Of course, if we get a patch soon no one will ever see the
regression so
Quoted 1 line
we can apply the series.
I will still require the usual testing and merging round via upstream and back. Not sure when I'll be able to work on it, probably not the next days.
Quoted 6 lines
Quoted 2 lines
If you can do it within a couple of weeks or so that should be fine.
We'll see, but I still do not share your concern regarding future regressions when removing the fragile reset code.
Why do we rely on userspace to properly reset kernel component anyway? We should introduce cpu/lapic/ioapic/pit/pic resets ASAP.
--
Gleb.
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
In reply to Jan KiszkaQuoted 5 lines · Jan Kiszka
Quoted 3 lines
The problem is with hardware MSRs (PV MSRs are protected by cpuid, and always disable themselves when zeroed).
Well, this doesn't change the problem of the existing code.
Right.
Quoted 11 lines
Quoted 7 lines
What I suggested wasn't zeroing them, but writing the value we read just after vcpu creation.
We had a regression when we started supporting PAT. Zeroing it causes the cache to be disabled, making everything ridiculously slow. We now special case it; my proposed solution would have taken care of it.
I'm talking about the current code, not the proper way to do it in the future. PAT demonstrates why regressions can happen as long as we zero and it's better to stop this now even without the new code in place.
I'm not sure, but if we do adopt the new reset mechanism, it doesn't matter.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
In reply to Gleb NatapovQuoted 6 lines · Gleb Natapov
Quoted 4 lines
We'll see, but I still do not share your concern regarding future regressions when removing the fragile reset code.
Why do we rely on userspace to properly reset kernel component anyway? We should introduce cpu/lapic/ioapic/pit/pic resets ASAP.
We should, but we'll always have to deal with kernels that don't have reset ioctls.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
Quoted 11 lines · Avi Kivity
Quoted 6 lines · Gleb Natapov
Quoted 4 lines
We'll see, but I still do not share your concern regarding future regressions when removing the fragile reset code.
Why do we rely on userspace to properly reset kernel component anyway? We should introduce cpu/lapic/ioapic/pit/pic resets ASAP.
We should, but we'll always have to deal with kernels that don't have reset ioctls.
s/always/for quite a while/. Unfortunately yes. Unless we put qemu in the kernel tree and will release them in lock steps of course :)
--
Gleb.
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
Quoted 6 lines · Gleb Natapov
Quoted 5 lines · Avi Kivity
Quoted 4 lines · Gleb Natapov
Quoted 4 lines
We'll see, but I still do not share your concern regarding future regressions when removing the fragile reset code.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Why do we rely on userspace to properly reset kernel component anyway? We should introduce cpu/lapic/ioapic/pit/pic resets ASAP.
We should, but we'll always have to deal with kernels that don't have reset ioctls.
s/always/for quite a while/. Unfortunately yes. Unless we put qemu in the kernel tree and will release them in lock steps of course :)
Seriously, I do not see much added-value of a reset service. The pattern we will use for MSRs could just be applied to other in-kernel resources as well - unless they are already architecturally defined in a way that leaves no questions regarding the proper future reset state. Except for the CPU, all other in-kernel devices are not extensible in their current form.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
In reply to Gleb NatapovQuoted 10 lines · Gleb Natapov
Quoted 9 lines · Jan Kiszka
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
Of course, if we get a patch soon no one will ever see the
regression so
Quoted 1 line
we can apply the series.
I will still require the usual testing and merging round via upstream and back. Not sure when I'll be able to work on it, probably not the next days.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
If you can do it within a couple of weeks or so that should be fine.
We'll see, but I still do not share your concern regarding future regressions when removing the fragile reset code.
Why do we rely on userspace to properly reset kernel component anyway?
In general its required that userspace properly sets (some of) the parameters of emulated hardware, including on reset.
Quoted 1 line
We should introduce cpu/lapic/ioapic/pit/pic resets ASAP.
Thats done through userspace via ioctls, don't get your point?
Re: [PATCH 04/19] qemu-kvm: x86: Drop MSR reset
Quoted 14 lines · Marcelo Tosatti
Quoted 13 lines · Gleb Natapov
Quoted 12 lines · Jan Kiszka
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines
Of course, if we get a patch soon no one will ever see the
regression so
Quoted 1 line
we can apply the series.
I will still require the usual testing and merging round via upstream and back. Not sure when I'll be able to work on it, probably not the next days.
If you can do it within a couple of weeks or so that should be fine.
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
We'll see, but I still do not share your concern regarding future regressions when removing the fragile reset code.
Why do we rely on userspace to properly reset kernel component anyway?
In general its required that userspace properly sets (some of) the parameters of emulated hardware, including on reset.
That's just how things work now. It doesn't have to be this way.
Quoted 4 lines
Quoted 2 lines
We should introduce cpu/lapic/ioapic/pit/pic resets ASAP.
Thats done through userspace via ioctls, don't get your point?
Why userspace shouldn't know such low level details about in kernel device? We had same devices emulated in qemu so it was easy to reuse that for reset, but think about writing device model from the start. With current interfaces you either need to have very low level knowledge about in kernel device in userspace just to reset it properly, or you need to save device state just after creation and reload the saved state on reset (kind of what Avi proposed for MSR). Both solutions are not optional IMO.
--
Gleb.
Marcelo Tosatti
AppliedQuoted 11 lines · Jan Kiszka
All required bits for this cleanup of qemu-kvm are now upstream and merged back - it's time to start the show. There are now 65 patches in my queue, and I'm planning for at least 4 rounds.
This first part primarily aims at using upstream
kvm_arch_init. Further highlights are:
- switch to upstream CPU register get/put
- switch to upstream kvmclock
- sustainable breakage of IA64Please review/merge.
Applied, thanks.