From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH 7/8] KVM: Optimize kvm_read_cr[04]_bits() Date: Fri, 05 Feb 2010 09:26:39 +0100 Message-ID: <4B6BD63F.1000009@web.de> References: <1264080712-3981-1-git-send-email-avi@redhat.com> <1264080712-3981-8-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigDC279F2FF6140EB9F5090686" Cc: Marcelo Tosatti , kvm@vger.kernel.org, Gleb Natapov To: Avi Kivity Return-path: Received: from fmmailgate03.web.de ([217.72.192.234]:41837 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752620Ab0BEI0t (ORCPT ); Fri, 5 Feb 2010 03:26:49 -0500 In-Reply-To: <1264080712-3981-8-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigDC279F2FF6140EB9F5090686 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Avi Kivity wrote: > 'mask' is always a constant, so we can check whether it includes a bit = that > might be owned by the guest very cheaply, and avoid the decache call. = Saves > a few hundred bytes of module text. -no-kvm-irqchip -smp 2 is broken for my Linux guests since this commit. Their user space applications receive #UD and things fall apart. Jan >=20 > Signed-off-by: Avi Kivity > --- > arch/x86/kvm/kvm_cache_regs.h | 9 +++++++-- > 1 files changed, 7 insertions(+), 2 deletions(-) >=20 > diff --git a/arch/x86/kvm/kvm_cache_regs.h b/arch/x86/kvm/kvm_cache_reg= s.h > index 6b419a3..5a109c6 100644 > --- a/arch/x86/kvm/kvm_cache_regs.h > +++ b/arch/x86/kvm/kvm_cache_regs.h > @@ -1,6 +1,9 @@ > #ifndef ASM_KVM_CACHE_REGS_H > #define ASM_KVM_CACHE_REGS_H > =20 > +#define KVM_POSSIBLE_CR0_GUEST_BITS X86_CR0_TS > +#define KVM_POSSIBLE_CR4_GUEST_BITS X86_CR4_PGE > + > static inline unsigned long kvm_register_read(struct kvm_vcpu *vcpu, > enum kvm_reg reg) > { > @@ -40,7 +43,8 @@ static inline u64 kvm_pdptr_read(struct kvm_vcpu *vcp= u, int index) > =20 > static inline ulong kvm_read_cr0_bits(struct kvm_vcpu *vcpu, ulong mas= k) > { > - if (mask & vcpu->arch.cr0_guest_owned_bits) > + ulong tmask =3D mask & KVM_POSSIBLE_CR0_GUEST_BITS; > + if (tmask & vcpu->arch.cr0_guest_owned_bits) > kvm_x86_ops->decache_cr0_guest_bits(vcpu); > return vcpu->arch.cr0 & mask; > } > @@ -52,7 +56,8 @@ static inline ulong kvm_read_cr0(struct kvm_vcpu *vcp= u) > =20 > static inline ulong kvm_read_cr4_bits(struct kvm_vcpu *vcpu, ulong mas= k) > { > - if (mask & vcpu->arch.cr4_guest_owned_bits) > + ulong tmask =3D mask & KVM_POSSIBLE_CR4_GUEST_BITS; > + if (tmask & vcpu->arch.cr4_guest_owned_bits) > kvm_x86_ops->decache_cr4_guest_bits(vcpu); > return vcpu->arch.cr4 & mask; > } --------------enigDC279F2FF6140EB9F5090686 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAktr1kYACgkQitSsb3rl5xTJTgCfbfdJiUd44tzAuHSP05kBRy+G gAoAoM46nVTiL69/F+/NZVZKBt6qpKaI =U6YD -----END PGP SIGNATURE----- --------------enigDC279F2FF6140EB9F5090686--