From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LgmZO-0005YA-Uj for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:59:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LgmZN-0005Wn-22 for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:59:30 -0400 Received: from [199.232.76.173] (port=37555 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LgmZM-0005Wi-NR for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:59:28 -0400 Received: from mx20.gnu.org ([199.232.41.8]:2705) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lgloi-0007Gl-Tm for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:11:17 -0400 Received: from mx2.redhat.com ([66.187.237.31]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lgc22-0002Ov-Om for qemu-devel@nongnu.org; Mon, 09 Mar 2009 05:44:23 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n299fLu2026148 for ; Mon, 9 Mar 2009 05:41:22 -0400 Message-ID: <49B4E440.1090307@redhat.com> Date: Mon, 09 Mar 2009 11:41:20 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [6684] Fix "info registers" under kvm. References: <49B3EAA8.6050900@web.de> <49B3EFDC.8050205@redhat.com> <49B3F0F5.8020202@redhat.com> <49B3F418.4090805@codemonkey.ws> In-Reply-To: <49B3F418.4090805@codemonkey.ws> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Anthony Liguori wrote: > > In the case of save/load registers, I'd prefer wrapper functions like: > > cpu_state_update(CPUState *env, int is_dirty) > > That could be hooked by something like Xen. The implementation would be: > > static void cpu_state_update(CPUState *env, int is_dirty) > { > if (kvm_enabled()) { > if (is_dirty) > kvm_arch_save_registers(env); > else > kvm_arch_load_registers(env); > } > } That reduces readability IMO (boolean parameters do that, as well as a function where the direction of data movement isn't clear). But we could keep dirty in the environment, and do everything automatically. random qemu code: cpu_state_sync(env); // read registers // write registers cpu_state_dirty(env); kvm arch code: if (env->registers_dirty) { copy registers to kernel env->registers_dirty = 0; } The kernel code does similar things for registers which can be either in memory or in the vmcs; it uses accessors so cpu_state_sync() and cpu_state_dirty() aren't needed; -- error compiling committee.c: too many arguments to function