From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Graf Subject: Re: [PATCH 01/15] KVM: PPC: Make register read/write wrappers always work Date: Mon, 08 Mar 2010 14:53:56 +0100 Message-ID: <4B950174.7010709@suse.de> References: <1267807842-3751-1-git-send-email-agraf@suse.de> <1267807842-3751-2-git-send-email-agraf@suse.de> <4B94FE41.1040904@redhat.com> <4B94FF56.9060200@suse.de> <4B9500B2.7030708@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from cantor.suse.de ([195.135.220.2]:54475 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754022Ab0CHNx5 (ORCPT ); Mon, 8 Mar 2010 08:53:57 -0500 In-Reply-To: <4B9500B2.7030708@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Avi Kivity wrote: > On 03/08/2010 03:44 PM, Alexander Graf wrote: >> Avi Kivity wrote: >> >>> On 03/05/2010 06:50 PM, Alexander Graf wrote: >>> >>>> We have wrappers to do for example gpr read/write accesses with, >>>> because the contents of registers could be either in the PACA >>>> or in the VCPU struct. >>>> >>>> There's nothing that says we have to have the guest vcpu loaded >>>> when using these wrappers though, so let's introduce a flag that >>>> tells us whether we're inside a vcpu_load context. >>>> >>>> >>>> >>> On x86 we always access registers within vcpu_load() context. That >>> simplifies things. Does this not apply here? >>> >>> Even so, sometimes guest registers are present on the cpu, and >>> sometimes in shadow variables (for example, msrs might be loaded or >>> not). The approach here is to always unload and access the variable >>> data. See for example vmx_set_msr() calling vmx_load_host_state() >>> before accessing msrs. >>> >>> Seems like this could reduce the if () tree? >>> >> Well - it would probably render this particular patch void. In fact, I >> think it is already useless thanks to the other "always do vcpu_load" >> patch. >> >> As far as the already existing if goes, we can't really get rid of that. >> I want to be fast in the instruction emulation. Copying around the >> registers won't help there. >> > > So do it the other way around. Always load the registers (of course, > do nothing if already loaded) and then access them in just one way. I > assume during emulation the registers will always be loaded? During emulation we're always in VCPU_RUN, so the vcpu is loaded. Do you mean something like: read_register(num) { vcpu_load(); read register from PACA(num); vcpu_put(); } ? Does vcpu_load incur overhead when it doesnt' need to do anything? Alex