From patchwork Tue Feb 2 08:18:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 44245 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7140AB7D58 for ; Tue, 2 Feb 2010 19:35:21 +1100 (EST) Received: from localhost ([127.0.0.1]:51796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcEAZ-0003CY-4v for incoming@patchwork.ozlabs.org; Tue, 02 Feb 2010 03:31:35 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NcDyj-0001TV-KT for qemu-devel@nongnu.org; Tue, 02 Feb 2010 03:19:21 -0500 Received: from [199.232.76.173] (port=39157 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcDyi-0001T0-Js for qemu-devel@nongnu.org; Tue, 02 Feb 2010 03:19:20 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NcDye-0000FN-BV for qemu-devel@nongnu.org; Tue, 02 Feb 2010 03:19:19 -0500 Received: from mx20.gnu.org ([199.232.41.8]:27281) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NcDyd-0000Ee-Ep for qemu-devel@nongnu.org; Tue, 02 Feb 2010 03:19:15 -0500 Received: from thoth.sbs.de ([192.35.17.2]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NcDyb-0005ez-CW for qemu-devel@nongnu.org; Tue, 02 Feb 2010 03:19:13 -0500 Received: from mail2.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id o128J9ce010251; Tue, 2 Feb 2010 09:19:10 +0100 Received: from localhost.localdomain ([139.25.173.39]) by mail2.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o128J7sJ008551; Tue, 2 Feb 2010 09:19:09 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Tue, 2 Feb 2010 09:18:49 +0100 Message-Id: <3d834dc34d1566a2409115f6afe3f43f49cbe2cd.1265098706.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.4-2.6 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Anthony Liguori , Glauber Costa , Alexander Graf , kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 03/21] qemu-kvm: Clean up register access API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org qemu-kvm's functios for accessing the VCPU registers are kvm_arch_load/save_regs. Use them directly instead of going through various wrappers. Specifically, we do not need on_vcpu wrapping as all users either already run in the related thread or call while the vm is stopped. Signed-off-by: Jan Kiszka --- qemu-kvm.c | 37 +++---------------------------------- qemu-kvm.h | 11 ----------- target-ia64/machine.c | 4 ++-- 3 files changed, 5 insertions(+), 47 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index a305907..97c098c 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -862,7 +862,7 @@ int pre_kvm_run(kvm_context_t kvm, CPUState *env) kvm_arch_pre_run(env, env->kvm_run); if (env->kvm_cpu_state.regs_modified) { - kvm_arch_put_registers(env); + kvm_arch_load_regs(env); env->kvm_cpu_state.regs_modified = 0; } @@ -1532,16 +1532,11 @@ static void on_vcpu(CPUState *env, void (*func)(void *data), void *data) qemu_cond_wait(&qemu_work_cond); } -void kvm_arch_get_registers(CPUState *env) -{ - kvm_arch_save_regs(env); -} - static void do_kvm_cpu_synchronize_state(void *_env) { CPUState *env = _env; if (!env->kvm_cpu_state.regs_modified) { - kvm_arch_get_registers(env); + kvm_arch_save_regs(env); env->kvm_cpu_state.regs_modified = 1; } } @@ -1584,32 +1579,6 @@ void kvm_update_interrupt_request(CPUState *env) } } -static void kvm_do_load_registers(void *_env) -{ - CPUState *env = _env; - - kvm_arch_load_regs(env); -} - -void kvm_load_registers(CPUState *env) -{ - if (kvm_enabled() && qemu_system_ready) - on_vcpu(env, kvm_do_load_registers, env); -} - -static void kvm_do_save_registers(void *_env) -{ - CPUState *env = _env; - - kvm_arch_save_regs(env); -} - -void kvm_save_registers(CPUState *env) -{ - if (kvm_enabled()) - on_vcpu(env, kvm_do_save_registers, env); -} - static void kvm_do_load_mpstate(void *_env) { CPUState *env = _env; @@ -2379,7 +2348,7 @@ static void kvm_invoke_set_guest_debug(void *data) struct kvm_set_guest_debug_data *dbg_data = data; if (cpu_single_env->kvm_cpu_state.regs_modified) { - kvm_arch_put_registers(cpu_single_env); + kvm_arch_save_regs(cpu_single_env); cpu_single_env->kvm_cpu_state.regs_modified = 0; } dbg_data->err = diff --git a/qemu-kvm.h b/qemu-kvm.h index 6b3e5a1..1354227 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -902,8 +902,6 @@ int kvm_main_loop(void); int kvm_init_ap(void); #ifndef QEMU_KVM_NO_CPU int kvm_vcpu_inited(CPUState *env); -void kvm_load_registers(CPUState *env); -void kvm_save_registers(CPUState *env); void kvm_load_mpstate(CPUState *env); void kvm_save_mpstate(CPUState *env); int kvm_cpu_exec(CPUState *env); @@ -1068,8 +1066,6 @@ void kvm_load_tsc(CPUState *env); #ifdef TARGET_I386 #define qemu_kvm_has_pit_state2() (0) #endif -#define kvm_load_registers(env) do {} while(0) -#define kvm_save_registers(env) do {} while(0) #define kvm_save_mpstate(env) do {} while(0) #define qemu_kvm_cpu_stop(env) do {} while(0) static inline void kvm_init_vcpu(CPUState *env) @@ -1098,13 +1094,6 @@ static inline int kvm_sync_vcpus(void) } #ifndef QEMU_KVM_NO_CPU -void kvm_arch_get_registers(CPUState *env); - -static inline void kvm_arch_put_registers(CPUState *env) -{ - kvm_load_registers(env); -} - void kvm_cpu_synchronize_state(CPUState *env); static inline void cpu_synchronize_state(CPUState *env) diff --git a/target-ia64/machine.c b/target-ia64/machine.c index 70ef379..7d29575 100644 --- a/target-ia64/machine.c +++ b/target-ia64/machine.c @@ -9,7 +9,7 @@ void cpu_save(QEMUFile *f, void *opaque) CPUState *env = opaque; if (kvm_enabled()) { - kvm_save_registers(env); + kvm_arch_save_regs(env); kvm_arch_save_mpstate(env); } } @@ -19,7 +19,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) CPUState *env = opaque; if (kvm_enabled()) { - kvm_load_registers(env); + kvm_arch_load_regs(env); kvm_arch_load_mpstate(env); } return 0;